com.bbn.openmap.layer.daynight
Class DayNightLayer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.bbn.openmap.Layer
                  extended by com.bbn.openmap.layer.OMGraphicHandlerLayer
                      extended by com.bbn.openmap.layer.daynight.DayNightLayer
All Implemented Interfaces:
ProjectionListener, GestureResponsePolicy, OMGraphicHandler, ProjectionPainter, PropertyConsumer, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.io.Serializable, java.util.EventListener

public class DayNightLayer
extends OMGraphicHandlerLayer
implements ProjectionListener, java.awt.event.ActionListener

The DayNightLayer is a layer that draws the day/Night terminator on the map. When the layer is re-projected, it figures out the brightest point on the earth (closest to the sun), and creates an image that has daytime pixels clear and the nighttime pixels shaded. There are a couple of options available for the layer. The terminator can be faded from light to dark, and the width of the fading can be adjusted. The color of the shading can be changed. The shading can reflect the current time, or be set to display the shading of a specified time. A time interval can be set to have the layer automatically update at regular intervals.

The openmap.properties file can control the layer with the following settings:

 
  # These are all optional, and can be omitted if you want to use the defaults.
  # draw terminator as poly (faster calculation than image,
  # defaults to true).
  daynight.doPolyTerminator=true
  # number of vertices for polygon terminator line.  this is only valid
  # if doPolyTerminator is true...
  daynight.terminatorVerts=360
  # termFade - the distance of the transition of fade, as a percentage of PI.
  daynight.termFade=.1
  # currentTime - true to display the shading at the computer's current time.
  daynight.currentTime=true
  # overlayTime - time, in milliseconds from java/unix epoch, to set the layer
  # time being displayed.  currentTime has to be false for this to be used.
  daynight.overlayTime=919453689000
  # updateInterval - time in milliseconds between updates.  currentTime has to be
  # true for this to be used.
  daynight.updateInterval=300000
  # Color of the shading (32bit Hex ARGB)
  daynight.nighttimeColor=64000000
  
 

In addition, you can get this layer to work with the OpenMap viewer by editing your openmap.properties file:

 
  # layers
  openmap.layers=daynight ...
  # class
  daynight.class=com.bbn.openmap.layer.daynight.DayNightLayer
  # name
  daynight.prettyName=Day/Night Shading
  
 

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  boolean currentTime
          If true, the layer will set the darkness according to the current time.
static java.lang.String CurrentTimeProperty
           
protected  java.awt.Color daytimeColor
          The color of daytime - default is white and clear.
static java.lang.String DaytimeColorProperty
           
static float DEFAULT_TERM_FADE
          Default value of fade to the terminator line, set to .10f.
static int DO_NOT_UPDATE
          Default update interval, which is never - updates occur on re-projections.
protected  boolean doPolyTerminator
          Create the terminator line as a polygon.
static java.lang.String DoPolyTerminatorProperty
           
protected  java.awt.Color nighttimeColor
          the color of darkness - default is black.
static java.lang.String NighttimeColorProperty
           
protected  long overlayTime
          The time used to create the layer, in milliseconds from java/unix epoch.
static java.lang.String OverlayTimeProperty
           
protected  float termFade
          Percentage of the distance from the horizon to the brightest point to start fading to darkness.
static java.lang.String TermFadeProperty
           
protected  int terminatorVerts
          The number of vertices of the polygon terminator line.
static java.lang.String TerminatorVertsProperty
           
protected  javax.swing.Timer timer
          Update timer.
protected  int updateInterval
          Update interval to automatically update the layer, in milli-seconds
static java.lang.String UpdateIntervalProperty
           
 
Fields inherited from class com.bbn.openmap.layer.OMGraphicHandlerLayer
consumeEvents, ConsumeEventsProperty, filter, interruptable, InterruptableProperty, layerWorker, LAYERWORKER_LOCK, layerWorkerQueue, logger, mouseEventInterpreter, mouseModeIDs, MouseModesProperty, projectionChangePolicy, ProjectionChangePolicyProperty, renderPolicy, RenderPolicyProperty, selectedList, TransparencyProperty
 
Fields inherited from class com.bbn.openmap.Layer
addAsBackground, AddAsBackgroundProperty, addToBeanContext, AddToBeanContextProperty, attributes, autoPalette, AutoPaletteProperty, beanContextChildSupport, coordTransform, DataPathPrefixProperty, DisplayPaletteCmd, DisplayPropertiesCmd, doHack, HidePaletteCmd, i18n, localHackList, maxScale, MaxScaleProperty, minScale, MinScaleProperty, palette, paletteListener, PrettyNameProperty, propertyPrefix, readyToPaint, RedrawCmd, removable, RemovableProperty, SWING_PACKAGE, TransformProperty, windowSupport
 
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 com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DayNightLayer()
          The default constructor for the Layer.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          Handle an ActionEvent from the Timer.
protected  OMGraphic createImage(Projection projection)
          Create the OMGraphic that acts as an overlay showing the day/night terminator.
 boolean getCurrentTime()
          Returns whether the layer will set the overlayTime to the time the image is created.
 long getOverlayTime()
          Get the time of the overlay.
 java.util.Properties getProperties(java.util.Properties props)
          Overrides Layer getProperties method., also calls that method on Layer.
 java.util.Properties getPropertyInfo(java.util.Properties props)
          Overrides Layer getProperties method., also calls that method on Layer.
 javax.swing.Timer getTimer()
          Get the timer being used for automatic updates.
 OMGraphicList prepare()
          Prepares the graphics for the layer.
 void setCurrentTime(boolean ct)
          Set whether the layer should set the overlayTime to the time the image is created.
 void setOverlayTime(long ot)
          Set the time for the overlay.
 void setProperties(java.lang.String prefix, java.util.Properties properties)
          The properties and prefix are managed and decoded here, for the standard uses of the DayNightLayer.
 void setTimer(javax.swing.Timer t)
          If you want the layer to update itself at certain intervals, you can set the timer to do that.
 
Methods inherited from class com.bbn.openmap.layer.OMGraphicHandlerLayer
canSetList, copy, createLayerWorker, cut, deselect, dispose, doAction, doPrepare, filter, filter, filter, getConsumeEvents, getDefaultSettingsPanel, getFilter, getInfoText, getItemsForMapMenu, getItemsForOMGraphicMenu, getLayerWorker, getList, getMapMouseListener, getMouseEventInterpreter, getMouseModeIDsForEvents, getProjectionChangePolicy, getRedrawButton, getRenderPolicy, getSelected, getSettingsButton, getToolTipTextFor, getTransparency, getTransparencyAdjustmentPanel, highlight, isCancelled, isHighlightable, isInterruptable, isSelectable, isWorking, leftClick, mouseOver, paint, paste, projectionChanged, receivesMapEvents, renderDataForProjection, resetFiltering, select, setConsumeEvents, setFilter, setInterruptable, setLayerWorker, setList, setMouseEventInterpreter, setMouseModeIDsForEvents, setProjectionChangePolicy, setRenderPolicy, setTransparency, supportsSQL, unhighlight, workerComplete
 
Methods inherited from class com.bbn.openmap.Layer
addComponentListener, added, addInfoDisplayListener, addLayerStatusListener, addMouseListener, addVetoableChangeListener, childrenAdded, childrenRemoved, clearListeners, connectToBeanContext, createWindowSupport, disconnectFromBeanContext, finalize, findAndInit, findAndInit, findAndUndo, fireHideToolTip, firePaletteEvent, fireRequestBrowserContent, fireRequestBrowserContent, fireRequestCursor, fireRequestInfoLine, fireRequestInfoLine, fireRequestInfoLine, fireRequestMessage, fireRequestMessage, fireRequestToolTip, fireRequestToolTip, fireRequestURL, fireRequestURL, fireStatusUpdate, fireStatusUpdate, fireVetoableChange, getAddAsBackground, getAddToBeanContext, getAttribute, getBeanContext, getCoordTransform, getGUI, getIcon, getMaxScale, getMinScale, getPackage, getPalette, getProjection, getPropertyPrefix, getWindowSupport, hasGUI, hidePalette, isAutoPalette, isProjectionOK, isReadyToPaint, isRemovable, notifyHideHack, prependDataPathPrefix, putAttribute, removeComponentListener, removeConfirmed, removed, removeInfoDisplayListener, removeLayerStatusListener, removeVetoableChangeListener, repaint, resetPalette, setAddAsBackground, setAddToBeanContext, setAutoPalette, setBeanContext, setCoordTransform, setIcon, setLayerProperties, setMaxScale, setMinScale, setName, setPaletteVisible, setProjection, setProjection, setProperties, setPropertyPrefix, setReadyToPaint, setRemovable, setVisible, setWindowSupport, showPalette
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, 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, getPreferredSize, 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, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, 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, 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, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, 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, 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, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.bbn.openmap.event.ProjectionListener
projectionChanged
 
Methods inherited from interface java.beans.beancontext.BeanContextChild
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

DEFAULT_TERM_FADE

public static final float DEFAULT_TERM_FADE
Default value of fade to the terminator line, set to .10f. This means that the last 10% of the horizon will be faded out.

See Also:
Constant Field Values

DO_NOT_UPDATE

public static final int DO_NOT_UPDATE
Default update interval, which is never - updates occur on re-projections.

See Also:
Constant Field Values

daytimeColor

protected java.awt.Color daytimeColor
The color of daytime - default is white and clear.


nighttimeColor

protected java.awt.Color nighttimeColor
the color of darkness - default is black.


termFade

protected float termFade
Percentage of the distance from the horizon to the brightest point to start fading to darkness. Expected to be between 0.0 and 0.5.


currentTime

protected boolean currentTime
If true, the layer will set the darkness according to the current time.


overlayTime

protected long overlayTime
The time used to create the layer, in milliseconds from java/unix epoch.


updateInterval

protected int updateInterval
Update interval to automatically update the layer, in milli-seconds


timer

protected javax.swing.Timer timer
Update timer.


doPolyTerminator

protected boolean doPolyTerminator
Create the terminator line as a polygon.


terminatorVerts

protected int terminatorVerts
The number of vertices of the polygon terminator line.


DaytimeColorProperty

public static final java.lang.String DaytimeColorProperty
See Also:
Constant Field Values

NighttimeColorProperty

public static final java.lang.String NighttimeColorProperty
See Also:
Constant Field Values

TermFadeProperty

public static final java.lang.String TermFadeProperty
See Also:
Constant Field Values

CurrentTimeProperty

public static final java.lang.String CurrentTimeProperty
See Also:
Constant Field Values

OverlayTimeProperty

public static final java.lang.String OverlayTimeProperty
See Also:
Constant Field Values

UpdateIntervalProperty

public static final java.lang.String UpdateIntervalProperty
See Also:
Constant Field Values

DoPolyTerminatorProperty

public static final java.lang.String DoPolyTerminatorProperty
See Also:
Constant Field Values

TerminatorVertsProperty

public static final java.lang.String TerminatorVertsProperty
See Also:
Constant Field Values
Constructor Detail

DayNightLayer

public DayNightLayer()
The default constructor for the Layer. All of the attributes are set to their default values.

Method Detail

setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties properties)
The properties and prefix are managed and decoded here, for the standard uses of the DayNightLayer.

Specified by:
setProperties in interface PropertyConsumer
Overrides:
setProperties in class OMGraphicHandlerLayer
Parameters:
prefix - string prefix used in the properties file for this layer.
properties - the properties set in the properties file.

getProperties

public java.util.Properties getProperties(java.util.Properties props)
Description copied from class: OMGraphicHandlerLayer
Overrides Layer getProperties method., also calls that method on Layer. Sets the properties from the policy objects used by this OMGraphicHandler layer.

Specified by:
getProperties in interface PropertyConsumer
Overrides:
getProperties in class OMGraphicHandlerLayer
Parameters:
props - a Properties object to load the PropertyConsumer properties into. If props equals null, then a new Properties object should be created.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

getPropertyInfo

public java.util.Properties getPropertyInfo(java.util.Properties props)
Description copied from class: OMGraphicHandlerLayer
Overrides Layer getProperties method., also calls that method on Layer. Sets the properties from the policy objects used by this OMGraphicHandler layer.

Specified by:
getPropertyInfo in interface PropertyConsumer
Overrides:
getPropertyInfo in class OMGraphicHandlerLayer
Parameters:
props - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
Handle an ActionEvent from the Timer.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Overrides:
actionPerformed in class OMGraphicHandlerLayer
Parameters:
ae - action event from the timer.

createImage

protected OMGraphic createImage(Projection projection)
Create the OMGraphic that acts as an overlay showing the day/night terminator. The brightest spot on the earth is calculated, and then each pixel is inverse projected to find out its coordinates. Then the great circle distance is calculated. The terminator is assumed to be the great circle where all the points are PI/2 away from the bright point. If the termFade variable is set, then the difference in color over the terminator is feathered, on equal amount of the terminator.

Parameters:
projection - the projection of the screen,
Returns:
OMGraphic containing image to use for the layer. The image has been projected.

prepare

public OMGraphicList prepare()
Prepares the graphics for the layer. This is where the getRectangle() method call is made on the location.

Occasionally it is necessary to abort a prepare call. When this happens, the map will set the cancel bit in the LayerThread, (the thread that is running the prepare). If this Layer needs to do any cleanups during the abort, it should do so, but return out of the prepare asap.

Overrides:
prepare in class OMGraphicHandlerLayer

getOverlayTime

public long getOverlayTime()
Get the time of the overlay.


setOverlayTime

public void setOverlayTime(long ot)
Set the time for the overlay.


getCurrentTime

public boolean getCurrentTime()
Returns whether the layer will set the overlayTime to the time the image is created.


setCurrentTime

public void setCurrentTime(boolean ct)
Set whether the layer should set the overlayTime to the time the image is created. If the time is being set to reflect a time other than the current time, this needs to be set to false. It actually is, if you manually set the overlay time.


getTimer

public javax.swing.Timer getTimer()
Get the timer being used for automatic updates. May be null if a timer is not set.


setTimer

public void setTimer(javax.swing.Timer t)
If you want the layer to update itself at certain intervals, you can set the timer to do that. Set it to null to disable it.



Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details