stella.jview
Class JNight

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by jview.JNormalizedCanvas
                  extended by jview.JViewportCanvas
                      extended by stella.jview.JNight
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, NormalizedCoordinates, NormalizedShapes, UserCoordinates, Zoomable, ConditionalRefreshing, Initializable, PriorityCaster, PropertyAware, PropertyComposed, Refreshing, Savable

public class JNight
extends JViewportCanvas
implements ConditionalRefreshing, UserCoordinates, PriorityCaster

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

See Also:
Serialized Form

Nested Class Summary
static class JNight.Show
          Shows the earth in a mercator projection with the current day/night terminator.
 
Nested classes/interfaces inherited from class jview.JViewportCanvas
JViewportCanvas.Test, JViewportCanvas.ViewportKey
 
Nested classes/interfaces inherited from class jview.JNormalizedCanvas
JNormalizedCanvas.ShowImage
 
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  int curprior
          My current importance.
private static String DEFBORDERS
          The default map.
private static double DEFDAYTWILIGHT
          The default twilight border for pitch black.
private static String DEFMERIDIAN
          On zero meridian.
private static double DEFMOONDIM
          The default k of the atmosphere.
private static double DEFMOONHEIGHT
          The default minimum moon height.
private static double DEFMOONLIGHT
          The default white for full moonlight.
private static double DEFMOONSTEEP
          The default white for full moonlight.
private static double DEFNIGHTTWILIGHT
          The default twilight border for pitch black.
private static int DEFPRIORITY
          Default maximum priority.
private static String DEFPROJECTION
          The default is a plate caree projection.
private static long DEFREFRESH
          The default refresh interval in ms.
private static boolean DEFSHOWCOORDINATE
          The cursor behaviour.
private static boolean DEFSHOWTIME
          Show current time.
private static String DEFWORLD
          The default map.
private  List<PriorityListener> ear
          My importance may change.
static String KEY_ACCELERATE
          If artificial advances desired, use this multiplier.
static String KEY_BORDERS
          The image to overlay the dawn on, should be mostly transparent.
static String KEY_DAYTWILIGHT
          The sol-height border between day and foggytwilight.
static String KEY_FORDATE
          If not for current time, but for specific.
static String KEY_MERIDIAN
          If the central meridian is different than zero.
static String KEY_MOONDIM
          The atmospheric constant for moon-light dimming per airmass.
static String KEY_MOONHEIGHT
          The minimum height of the moon for giving light.
static String KEY_MOONLIGHT
          The value for maximum moon brightness in white-color.
static String KEY_MOONSTEEP
          The multiplicator for dimming moon light to horizon.
static String KEY_NIGHTTWILIGHT
          The sol-height border between night and twilight.
static String KEY_PRIORITY
          The maximum priority I can acheive.
static String KEY_PROJECTION
          The cylindrical projection of the map, class name.
static String KEY_REFRESH
          The refresh interval in ms.
static String KEY_SHOWTIME
          If true, the current UT is shown in the lower right corner.
static String KEY_WORLD
          The map resource to display, an image of the earth.
static String KEY_XSTEPWIDTH
          A different stepwidth than one pixel.
static String KEY_YSTEPWIDTH
          A different stepwidth than one pixel.
private  CoordinateTransforming map
          Coordinate transformation that translates long/lat into normalized.
private  MoonDec moonde
          Moon position.
private static double MOONMAG
          Moon brighness span in magnitudes.
private  MoonAngle moonphi
          Moon phase.
private  MoonRa moonra
          Moon position.
private  BufferedImage night
          The overlay on the Earth to show current twilight/night.
private  AcceleratedTime now
          The current time.
private  SolDec solde
          Solar position.
private  SolRa solra
          Solar position.
private  SiderealGreenwichApparent theta
          Sidereal time.
 
Fields inherited from class jview.JViewportCanvas
MAXVIEW, VIEWPORTIMAGEPROPERTY, VIEWPORTPROPERTY
 
Fields inherited from class jview.JNormalizedCanvas
BACKGROUNDIMAGEPROPERTY, EXPORTACTION, GENERIC, inverse, KEY_BACKGROUND, KEY_CANVASNAME, KEY_CANVASTIP, KEY_CURSORCLASSES, KEY_CURSORPROPS, KEY_DRAWINGSETS, KEY_FOREGROUND, KEY_MAXIMUMHEIGHT, KEY_MAXIMUMWIDTH, KEY_MINIMUMHEIGHT, KEY_MINIMUMWIDTH, KEY_PREFERREDHEIGHT, KEY_PREFERREDWIDTH, KEY_PRINTFONT, KEY_PRINTFONTSCALE, KEY_PRINTSHAPESCALE, KEY_RESTORESHAPES, KEY_XFLIPIMAGE, KEY_YFLIPIMAGE, PRINTACTION, SAVEACTION, transform
 
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
JNight(Map<String,String> info)
          Constructs a new night earth giving its properties.
JNight(PropertyBearing info)
          Constructs a new night earth giving its properties.
 
Method Summary
 void addPriorityListener(PriorityListener to)
          Adds a priority listener.
 int currentPriority(String id)
          Last priority calculated.
protected  void drawNight(BufferedImage into, Point2D grid, Dimension s0, double noon)
          If we know nothing about the tranformation, we can only point-by-point step.
private  BufferedImage getOverlay()
          Return the buffered image we draw the twilight and night in.
 long getRefreshInterval()
          The refresh interval is a property.
 CoordinateTransforming getUserTransformation()
          Returns the user transfromation.
 void init()
          Initializes additionally the parameters needed.
 boolean isFixedRate()
          We do not want fixed rate, merely act like a cursor.
 boolean isRefreshNeeded()
          We only want updates if we are visible.
private  void notifyListeners(int np)
          Notifies all listeners with my component name.
 void paintComponent(Graphics g)
          Paints the individual bars of twilight and night onto the component using x-or mode.
 void refresh()
          On refresh, we create the overlay buffer.
 void removePriorityListener(PriorityListener to)
          Removes a priority listener.
 void setComposedProperties(PropertyBearing prop)
          Sets the proberties of the earth and defailts colors.
 void setUserTransformation(CoordinateTransforming user)
          Sets the tranformation from user coordinates to normalized cooridnates.
 
Methods inherited from class jview.JViewportCanvas
addAttachedViewport, addZoom, calculateShapeTransform, getViewport, getViewportImage, isMaximalViewport, isNormalizedOnScreen, prepareCanvas, removeAttachedViewport, resetViewport, selectArea, selectViewport, setViewportImage, silentlySelectViewport, transferView
 
Methods inherited from class jview.JNormalizedCanvas
addCrossCursor, addDrawable, addDrawable, addDrawable, addDrawingInfo, addLink, addLink, addPoint, addPoint, addText, addText, allInside, applyDrawingInfo, assignCursorLabel, clearAllDrawable, clearAllText, clearDrawable, clearText, createCanvasCursor, disabledCanvas, drawPoints, drawPointsMap, drawShapes, drawShapesMap, drawText, drawTextMap, firePropertyChange, getActions, getAnimationInfo, getArea, getBackground, getBackgroundImage, getCanvasCursor, getClosest, getClosest, getClosest, getClosestShape, getComposedProperties, getFromName, getImageOperation, getInside, getInsideShapes, getInverseTransform, getLink, getLinkedTo, getMaximumSize, getMinimumSize, getNormalized, getNormalizedRect, getPreferredSize, getSaveBuffer, getScreen, getScreenRect, getShapeTransform, isEmpty, isFlipX, isFlipY, isScreenInNormalized, paintObjects, paintPointsList, paintShapesList, paintTextList, printComponent, removeDrawable, removeDrawable, removeLink, removeText, removeText, repaintLater, repaintNow, setBackgroundImage, setBounds, setComplete, setCursor, setCursor, setDrawable, setImageOperation, setLink, setPrepare, startAnimation, stopAnimation, wasReshaped
 
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, 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, 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, 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, setComponentOrientation, 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
 
Methods inherited from interface jview.NormalizedCoordinates
getArea, getNormalized, getNormalizedRect, getScreen, getScreenRect, getViewport, isNormalizedOnScreen, isScreenInNormalized
 

Field Detail

KEY_WORLD

public static final String KEY_WORLD
The map resource to display, an image of the earth.

See Also:
Constant Field Values

KEY_BORDERS

public static final String KEY_BORDERS
The image to overlay the dawn on, should be mostly transparent.

See Also:
Constant Field Values

KEY_PROJECTION

public static final String KEY_PROJECTION
The cylindrical projection of the map, class name.

See Also:
Constant Field Values

KEY_MERIDIAN

public static final String KEY_MERIDIAN
If the central meridian is different than zero.

See Also:
Constant Field Values

KEY_NIGHTTWILIGHT

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

See Also:
Constant Field Values

KEY_DAYTWILIGHT

public static final String KEY_DAYTWILIGHT
The sol-height border between day and foggytwilight.

See Also:
Constant Field Values

KEY_MOONHEIGHT

public static final String KEY_MOONHEIGHT
The minimum height of the moon for giving light.

See Also:
Constant Field Values

KEY_MOONLIGHT

public static final String KEY_MOONLIGHT
The value for maximum moon brightness in white-color.

See Also:
Constant Field Values

KEY_MOONSTEEP

public static final String KEY_MOONSTEEP
The multiplicator for dimming moon light to horizon.

See Also:
Constant Field Values

KEY_MOONDIM

public static final String KEY_MOONDIM
The atmospheric constant for moon-light dimming per airmass.

See Also:
Constant Field Values

KEY_REFRESH

public static final String KEY_REFRESH
The refresh interval in ms.

See Also:
Constant Field Values

KEY_FORDATE

public static final String KEY_FORDATE
If not for current time, but for specific.

See Also:
Constant Field Values

KEY_ACCELERATE

public static final String KEY_ACCELERATE
If artificial advances desired, use this multiplier.

See Also:
Constant Field Values

KEY_SHOWTIME

public static final String KEY_SHOWTIME
If true, the current UT is shown in the lower right corner.

See Also:
Constant Field Values

KEY_PRIORITY

public static final String KEY_PRIORITY
The maximum priority I can acheive.

See Also:
Constant Field Values

KEY_XSTEPWIDTH

public static final String KEY_XSTEPWIDTH
A different stepwidth than one pixel.

See Also:
Constant Field Values

KEY_YSTEPWIDTH

public static final String KEY_YSTEPWIDTH
A different stepwidth than one pixel.

See Also:
Constant Field Values

DEFWORLD

private static final String DEFWORLD
The default map.

See Also:
Constant Field Values

DEFBORDERS

private static final String DEFBORDERS
The default map.

See Also:
Constant Field Values

DEFPROJECTION

private static final String DEFPROJECTION
The default is a plate caree projection.

See Also:
Constant Field Values

DEFMERIDIAN

private static final String DEFMERIDIAN
On zero meridian.

See Also:
Constant Field Values

DEFNIGHTTWILIGHT

private static final double DEFNIGHTTWILIGHT
The default twilight border for pitch black.

See Also:
Constant Field Values

DEFDAYTWILIGHT

private static final double DEFDAYTWILIGHT
The default twilight border for pitch black.

See Also:
Constant Field Values

DEFMOONHEIGHT

private static final double DEFMOONHEIGHT
The default minimum moon height.

See Also:
Constant Field Values

DEFMOONLIGHT

private static final double DEFMOONLIGHT
The default white for full moonlight.

See Also:
Constant Field Values

DEFMOONSTEEP

private static final double DEFMOONSTEEP
The default white for full moonlight.

See Also:
Constant Field Values

DEFMOONDIM

private static final double DEFMOONDIM
The default k of the atmosphere.

See Also:
Constant Field Values

DEFREFRESH

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

See Also:
Constant Field Values

DEFSHOWCOORDINATE

private static final boolean DEFSHOWCOORDINATE
The cursor behaviour.

See Also:
Constant Field Values

DEFSHOWTIME

private static final boolean DEFSHOWTIME
Show current time.

See Also:
Constant Field Values

DEFPRIORITY

private static final int DEFPRIORITY
Default maximum priority.

See Also:
Constant Field Values

MOONMAG

private static final double MOONMAG
Moon brighness span in magnitudes.

See Also:
Constant Field Values

now

private AcceleratedTime now
The current time.


solra

private SolRa solra
Solar position.


solde

private SolDec solde
Solar position.


moonra

private MoonRa moonra
Moon position.


moonde

private MoonDec moonde
Moon position.


moonphi

private MoonAngle moonphi
Moon phase.


theta

private SiderealGreenwichApparent theta
Sidereal time.


night

private BufferedImage night
The overlay on the Earth to show current twilight/night.


map

private CoordinateTransforming map
Coordinate transformation that translates long/lat into normalized.


ear

private List<PriorityListener> ear
My importance may change.


curprior

private int curprior
My current importance.

Constructor Detail

JNight

public JNight(Map<String,String> info)
Constructs a new night earth giving its properties.


JNight

public JNight(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 JNormalizedCanvas

init

public void init()
Initializes additionally the parameters needed.

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

getOverlay

private BufferedImage getOverlay()
Return the buffered image we draw the twilight and night in. This is either an empty buffered sized as the background image or a mostly translucent image define by #KEY_OVERLAY.


setUserTransformation

public void setUserTransformation(CoordinateTransforming user)
Sets the tranformation from user coordinates to normalized cooridnates. User coordinates are longitude and latitude in degrees, the longitude in the first index, east is positive.

Specified by:
setUserTransformation in interface UserCoordinates

getUserTransformation

public CoordinateTransforming getUserTransformation()
Returns the user transfromation. User coordinates are longitude and latitude in degrees, the longitude in the first index, east is positive.

Specified by:
getUserTransformation in interface UserCoordinates

addPriorityListener

public void addPriorityListener(PriorityListener to)
Adds a priority listener.

Specified by:
addPriorityListener in interface PriorityCaster

removePriorityListener

public void removePriorityListener(PriorityListener to)
Removes a priority listener.

Specified by:
removePriorityListener in interface PriorityCaster

currentPriority

public int currentPriority(String id)
Last priority calculated. We only know our name as a priority item.

Specified by:
currentPriority in interface PriorityCaster

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 create the overlay buffer.

Specified by:
refresh in interface Refreshing

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 JNormalizedCanvas

drawNight

protected void drawNight(BufferedImage into,
                         Point2D grid,
                         Dimension s0,
                         double noon)
If we know nothing about the tranformation, we can only point-by-point step.


isFixedRate

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

Specified by:
isFixedRate in interface Refreshing
See Also:
Timer

notifyListeners

private void notifyListeners(int np)
Notifies all listeners with my component name.