stella.jview
Class JEarthNight

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by jview.JImageComponent
                  extended by jview.JEarth
                      extended by stella.jview.JEarthNight
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, ConditionalRefreshing, Initializable, PropertyAware, PropertyComposed, Refreshing

public class JEarthNight
extends JEarth
implements ConditionalRefreshing

We display an image of the earth with the current day-night boundary overlayed.

See Also:
Serialized Form

Nested Class Summary
static class JEarthNight.Show
          Shows the earth in a mercator projection with the current day/night terminator.
 
Nested classes/interfaces inherited from class jview.JImageComponent
JImageComponent.Display
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private static Color DEFNIGHTCOLOR
          The default night color.
private static long DEFREFRESH
          The default refresh interval in ms.
private static double DEFTWILIGHT
          The default twilight border.
private static Color DEFTWILIGHTCOLOR
          The default twilight color.
static String KEY_NIGHTCOLOR
          The key to the color for night.
static String KEY_REFRESH
          The refresh interval in ms.
static String KEY_TWILIGHT
          The sol-height border between night and twilight.
static String KEY_TWILIGHTCOLOR
          The key to the color for twilight.
private  SiderealTime sid
          Greenwich sidereal time.
private  SolDec solde
          Solar position.
private  SolRa solra
          Solar position.
 
Fields inherited from class jview.JEarth
KEY_LAMBDA0, KEY_MERCATOR, KEY_XORIGIN, KEY_XSCALE, KEY_YORIGIN, KEY_YSCALE
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JEarthNight(PropertyBearing info)
          Constructs a new night earth giving its properties.
 
Method Summary
 long getRefreshInterval()
          The refresh interval is a property.
private  Vector2D getRiseSet(double phi, double h)
          For a given latitude and a twilight calculate the two geographical longitudes for which this is the case.
private  VectorG getSolar(double phi, double h)
          Returns a four-dimensional vector with four geographical longitudes.
 void init()
          Initializes additionally the parameters needed.
private  boolean isAlwaysBelow(double phi, double h)
          Checks if the sun is currently below the given height for all possible longitudes at the given latitude.
 boolean isFixedRate()
          We do not want fixed rate, merely act like a cursor.
 boolean isRefreshNeeded()
          We only want updates if we are visible.
 void paintComponent(Graphics g)
          Paints the individual bars of twilight and night onto the component using x-or mode.
 void refresh()
          On refresh, we repaint.
 void setComposedProperties(PropertyBearing prop)
          Sets the proberties of the earth and defailts colors.
 
Methods inherited from class jview.JEarth
getComposedProperties, getGeography, getPixel
 
Methods inherited from class jview.JImageComponent
createBufferedImage, getImage, getPreferredSize, setImage
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_NIGHTCOLOR

public static final String KEY_NIGHTCOLOR
The key to the color for night.

See Also:
Constant Field Values

KEY_TWILIGHTCOLOR

public static final String KEY_TWILIGHTCOLOR
The key to the color for twilight.

See Also:
Constant Field Values

KEY_TWILIGHT

public static final String KEY_TWILIGHT
The sol-height border between night and twilight.

See Also:
Constant Field Values

KEY_REFRESH

public static final String KEY_REFRESH
The refresh interval in ms.

See Also:
Constant Field Values

DEFNIGHTCOLOR

private static final Color DEFNIGHTCOLOR
The default night color.


DEFTWILIGHTCOLOR

private static final Color DEFTWILIGHTCOLOR
The default twilight color.


DEFTWILIGHT

private static final double DEFTWILIGHT
The default twilight border.

See Also:
Constant Field Values

DEFREFRESH

private static final long DEFREFRESH
The default refresh interval in ms.

See Also:
Constant Field Values

solra

private SolRa solra
Solar position.


solde

private SolDec solde
Solar position.


sid

private SiderealTime sid
Greenwich sidereal time.

Constructor Detail

JEarthNight

public JEarthNight(PropertyBearing info)
Constructs a new night earth giving its properties.

Method Detail

setComposedProperties

public void setComposedProperties(PropertyBearing prop)
Sets the proberties of the earth and defailts colors.

Specified by:
setComposedProperties in interface PropertyAware
Overrides:
setComposedProperties in class JEarth

init

public void init()
Initializes additionally the parameters needed.

Specified by:
init in interface Initializable
Overrides:
init in class JEarth

paintComponent

public void paintComponent(Graphics g)
Paints the individual bars of twilight and night onto the component using x-or mode.

Overrides:
paintComponent in class JImageComponent

isRefreshNeeded

public boolean isRefreshNeeded()
We only want updates if we are visible.

Specified by:
isRefreshNeeded in interface ConditionalRefreshing

getRefreshInterval

public long getRefreshInterval()
The refresh interval is a property.

Specified by:
getRefreshInterval in interface Refreshing

refresh

public void refresh()
On refresh, we repaint.

Specified by:
refresh in interface Refreshing

isFixedRate

public boolean isFixedRate()
We do not want fixed rate, merely act like a cursor.

Specified by:
isFixedRate in interface Refreshing
See Also:
Timer

isAlwaysBelow

private boolean isAlwaysBelow(double phi,
                              double h)
Checks if the sun is currently below the given height for all possible longitudes at the given latitude.


getSolar

private VectorG getSolar(double phi,
                         double h)
Returns a four-dimensional vector with four geographical longitudes.


getRiseSet

private Vector2D getRiseSet(double phi,
                            double h)
For a given latitude and a twilight calculate the two geographical longitudes for which this is the case. The first longitude is sun rise, second one sun set.