com.bbn.openmap
Class Layer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.bbn.openmap.Layer
All Implemented Interfaces:
ProjectionListener, 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
Direct Known Subclasses:
CacheLayer, HelloWorldLayer, OMGraphicHandlerLayer, OverviewMapAreaLayer, ScaleFilterLayer, SimpleBeanLayer, SinkLayer

public abstract class Layer
extends javax.swing.JComponent
implements ProjectionListener, ProjectionPainter, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, PropertyConsumer, java.awt.event.ActionListener

Layer objects are components which can be added to the MapBean to make a map.

Layers implement the ProjectionListener interface to listen for ProjectionEvents. When the projection changes, they may need to refetch, regenerate their graphics, and then repaint themselves into the new view.

When the Layer is added to the MapBean, it will start receiving ProjectionEvents via the ProjectionListener.projectionChanged() method it has to implement. There is a setProjection(ProjectionEvent) methods that should be called from there if you want to save the projection for later use (handling MouseEvents, etc). If you call getProjection() before calling setProjection(), getProjection() will return null, and your OMGraphics will complain and probably freak out at some point.

 // // SAMPLE handling of the ProjectionListener interface.
 
 public void projectionChanged(com.bbn.openmap.event.ProjectionEvent pe) {
     Projection proj = setProjection(pe);
     if (proj != null) {
         // Use the projection to gather OMGraphics in the layer,
         // and prepare the layer so that in the paint() method,
         // the OMGraphics get rendered.
 
         // Call any methods that kick off work to build graphics
         // here...
 
         // You get the paint() methods called by calling
         // repaint():
         repaint();
     }
 
     fireStatusUpdate(LayerStatusEvent.FINISH_WORKING);
 }
 

See Also:
ProjectionListener, ProjectionEvent, PropertyConsumer, 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 addAsBackground
          Flag used by the layer to indicate that it should be treated as a background layer, indicating that any cache mechanism available can enable extra buffering.
static java.lang.String AddAsBackgroundProperty
          Property 'background' to designate this layer as a background layer, which will cause extra buffering to occur if the application can handle it.
protected  boolean addToBeanContext
          Used by the LayerHandler to check if the layer should be added to the MapHandler BeanContext.
static java.lang.String AddToBeanContextProperty
          The property to set to add the layer to the BeanContext "addToBeanContext".
protected  java.util.Hashtable attributes
          Hashtable containing attribute information for the layer.
protected  boolean autoPalette
          A flag to have the layer display it's palette when the properties are set.
static java.lang.String AutoPaletteProperty
          The property to show the palette when the layer is created - or, more accurately, when the properties are set.
protected  java.beans.beancontext.BeanContextChildSupport beanContextChildSupport
          The BeanContext allows Layers to find other components, and other components to find the layer, if the layer is added to it.
protected  GeoCoordTransformation coordTransform
          A translator that can be set to convert pre-projected coordinates from the file into decimal degree lat/lon, and for saving data to a file in pre-projected coordinates.
static java.lang.String DataPathPrefixProperty
          Generic property that may be set for a layer to let it know at runtime that a path prefix needs to be added to a relative data path.
static java.lang.String DisplayPaletteCmd
          Layer-defined action event command to display the palette.
static java.lang.String DisplayPropertiesCmd
          Layer-defined action event command to display the properties using an Inspector.
protected  boolean doHack
          Part of a layer hack to notify the component listener when the component is hidden.
static java.lang.String HidePaletteCmd
          Layer-defined action event command to hide the palette.
protected  I18n i18n
          All layers have access to an I18n object, which is provided by the Environment.
protected  ListenerSupport<java.awt.event.ComponentListener> localHackList
          Part of a layer hack to notify the component listener when the component is hidden.
protected  float maxScale
          A maximum projection scale value that the layer will respond to.
static java.lang.String MaxScaleProperty
          The property for designating the maximum projection scale value that the layer will respond to.
protected  float minScale
          A minimum projection scale value that the layer will respond to.
static java.lang.String MinScaleProperty
          The property for designating the minimum projection scale value that the layer will respond to.
protected  java.awt.Container palette
          A pointer to the JDialog or JInternalFrame.
protected  java.awt.event.ComponentListener paletteListener
          A helper component listener that is paying attention to the visibility of the palette.
static java.lang.String PrettyNameProperty
          The String to use for a key lookup in a Properties object to find the name to use in a GUI relating to this layer.
protected  java.lang.String propertyPrefix
          Token uniquely identifying this layer in the application properties.
protected  java.util.concurrent.atomic.AtomicBoolean readyToPaint
          New variable to describe when a layer has responded to a projection change and is ready to be painted.
static java.lang.String RedrawCmd
          Layer-defined action event command to force a redraw on the layer.
protected  boolean removable
          Flag to designate the layer as removable or not.
static java.lang.String RemovableProperty
          Property 'removable' to designate this layer as removable from the application, or able to be deleted.
protected static java.lang.String SWING_PACKAGE
          Pre-caches the swing package.
static java.lang.String TransformProperty
          The property used to name a class providing translation services (optional, depends on input data).
protected  WindowSupport windowSupport
          Support class that now handles palette windows.
 
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
Layer()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          The default actionPerformed method for Layer.
 void addComponentListener(java.awt.event.ComponentListener cl)
          Part of a layer hack to notify the component listener when the component is hidden.
 void added(java.awt.Container cont)
          This method is called when the layer is added to the MapBean
 void addInfoDisplayListener(InfoDisplayListener aInfoDisplayListener)
          Adds a listener for InfoDisplayEvents.
 void addLayerStatusListener(LayerStatusListener aLayerStatusListener)
          Adds a listener for LayerStatusEvents.
 void addMouseListener(java.awt.event.MouseListener l)
          Override to only allow swing package listeners.
 void addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener in_vcl)
          Method for BeanContextChild interface.
 void childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)
          BeanContextMembershipListener method.
 void childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)
          BeanContextMembershipListener method.
 void clearListeners()
           
 void connectToBeanContext(java.beans.beancontext.BeanContext in_bc)
          Layer method to just connect to the BeanContext, without grabbing the iterator as in setBeanContext().
protected  WindowSupport createWindowSupport()
          Callback method to override how window support is created.
 void disconnectFromBeanContext()
          Layer method to just disconnect from the BeanContext, without grabbing the iterator as in setBeanContext().
 void dispose()
          Method called when layer detects that it has been removed from MapHandler, assumes it's being thrown away.
protected  void finalize()
           
 void findAndInit(java.util.Iterator<?> it)
          This is the method that your layer can use to find other objects within the MapHandler (BeanContext).
 void findAndInit(java.lang.Object obj)
          This method is called by the findAndInit(Iterator) method, once for every object inside the iterator.
 void findAndUndo(java.lang.Object obj)
          This is the method that does the opposite as the findAndInit(Object).
 void fireHideToolTip()
          Request to hide the tool tips on the map.
 void firePaletteEvent(java.awt.event.ComponentEvent event)
          Fire a component event to the Layer component listeners, with the palette as the component, letting them know if it's visible or not.
 void fireRequestBrowserContent(InfoDisplayEvent evt)
          Sends a request to the InfoDisplay listener to display the information in the InfoDisplay event in a Browser.
 void fireRequestBrowserContent(java.lang.String browserContent)
          Sends a request to the InfoDisplayListener to display the information in a Browser.
 void fireRequestCursor(java.awt.Cursor cursor)
          Sends a request to the InfoDisplayListener to show a specific cursor over its component area.
 void fireRequestInfoLine(InfoDisplayEvent evt)
          Sends a request to the InfoDisplayListener to show the information in the InfoDisplay event on an single line display facility.
 void fireRequestInfoLine(java.lang.String infoLine)
          Sends a request to the InfoDisplay listener to display the information on an single line display facility.
 void fireRequestInfoLine(java.lang.String infoLine, int loc)
          Sends a request to the InfoDisplay listener to display the information on an single line display facility at preferred location.
 void fireRequestMessage(InfoDisplayEvent evt)
          Sends a request to the InfoDisplayListener to put the information in the InfoDisplay event in a dialog window.
 void fireRequestMessage(java.lang.String message)
          Sends a request to the InfoDisplayListener to display the information in a dialog window.
 void fireRequestToolTip(InfoDisplayEvent event)
          Fire off a Tool Tip request to the InfoDisplayListeners.
 void fireRequestToolTip(java.lang.String tip)
          Request to show the tool tips on the map.
 void fireRequestURL(InfoDisplayEvent evt)
          Sends a request to the InfoDisplayListener to display a URL given in the InfoDisplay event in a Browser.
 void fireRequestURL(java.lang.String url)
          Sends a request to the InfoDisplayListener to display a URL in a browser.
 void fireStatusUpdate(int status)
          Sends a status update to the LayerStatusListener.
 void fireStatusUpdate(LayerStatusEvent evt)
          Sends a status update to the LayerStatusListener.
 void fireVetoableChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
          Report a vetoable property update to any registered listeners.
 boolean getAddAsBackground()
          Check to see if the layer is marked as one that should be considered a background layer.
 boolean getAddToBeanContext()
          Set whether the Layer should be added to the BeanContext.
 java.lang.Object getAttribute(java.lang.Object key)
           
 java.beans.beancontext.BeanContext getBeanContext()
          Method for BeanContextChild interface.
 GeoCoordTransformation getCoordTransform()
           
 java.awt.Component getGUI()
          Gets the gui controls associated with the layer.
 javax.swing.Icon getIcon()
           
 MapMouseListener getMapMouseListener()
          Returns the MapMouseListener object that handles the mouse events.
 float getMaxScale()
           
 float getMinScale()
           
protected static java.lang.String getPackage(java.lang.Class c)
          Returns the package of the given class as a string.
 java.awt.Container getPalette()
          Return the JDialog, or JInternalFrame, that serves as the palette for the layer.
 Projection getProjection()
          Get the latest projection.
 java.util.Properties getProperties(java.util.Properties props)
          PropertyConsumer method, to fill in a Properties object, reflecting the current values of the layer.
 java.util.Properties getPropertyInfo(java.util.Properties list)
          Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer.
 java.lang.String getPropertyPrefix()
          Get the property key prefix that is being used to prepend to the property keys for Properties lookups.
 WindowSupport getWindowSupport()
          Get the WindowSupport object handling the palette.
 boolean hasGUI()
          A GUI query method for other components to use to display whether gui controls are available for this layer.
 void hidePalette()
          Hide the layer's palette.
 boolean isAutoPalette()
           
 boolean isProjectionOK(Projection proj)
          Method that responds whether the Layer should render on the map, given a particular projection.
 boolean isReadyToPaint()
           
 boolean isRemovable()
          Check to see if the layer is marked as one that can be removed from an application.
 void notifyHideHack()
          Part of a layer hack to notify the component listener when the component is hidden.
protected  java.lang.String prependDataPathPrefix(java.lang.String fileName)
          The dataPathPrefix layer attribute lets you append a path to a relative path at runtime.
 void putAttribute(java.lang.Object key, java.lang.Object value)
           
 void removeComponentListener(java.awt.event.ComponentListener cl)
          Part of a layer hack to notify the component listener when the component is hidden.
 boolean removeConfirmed()
          Check to see if the removable layer can be removed now.
 void removed(java.awt.Container cont)
          This method is called after the layer is removed from the MapBean and when the projection changes.
 void removeInfoDisplayListener(InfoDisplayListener aInfoDisplayListener)
          Removes an InfoDisplayListener from this Layer.
 void removeLayerStatusListener(LayerStatusListener aLayerStatusListener)
          Removes a LayerStatusListene from this Layer.
 void removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener in_vcl)
          Method for BeanContextChild interface.
 void renderDataForProjection(Projection proj, java.awt.Graphics g)
          This method is here to provide a default action for Layers as they act as a ProjectionPainter.
 void repaint(long tm, int x, int y, int width, int height)
          Repaint the layer.
protected  void resetPalette()
          Called when something about the layer has changed that would require the palette to be reconfigured.
 void setAddAsBackground(boolean set)
          Mark the layer as one that should be considered a background layer.
 void setAddToBeanContext(boolean set)
          Set whether the Layer should be added to the BeanContext.
 void setAutoPalette(boolean autoPalette)
           
 void setBeanContext(java.beans.beancontext.BeanContext in_bc)
          Method for BeanContextChild interface.
 void setCoordTransform(GeoCoordTransformation coordTranslator)
           
 void setIcon(javax.swing.Icon icon)
           
protected  void setLayerProperties(java.lang.String prefix, java.util.Properties props)
          Called by setProperties.
 void setMaxScale(float maxScale)
           
 void setMinScale(float minScale)
           
 void setName(java.lang.String name)
           
 void setPaletteVisible(boolean visible)
          Make the palette visible or not, destroy if invisible.
 void setProjection(Projection proj)
          Set the projection the layer should use for calculations.
 Projection setProjection(ProjectionEvent projEvent)
          This method lets you take the ProjectionEvent received from the MapBean, and lets you know if you should do something with it.
 void setProperties(java.util.Properties props)
          Sets the properties for the Layer.
 void setProperties(java.lang.String prefix, java.util.Properties props)
          Sets the properties for the Layer.
 void setPropertyPrefix(java.lang.String prefix)
          Set the property key prefix that should be used by the PropertyConsumer.
 void setReadyToPaint(boolean readyToPaint)
           
 void setRemovable(boolean set)
          Mark the layer as removable, or one that can be deleted from the application.
 void setVisible(boolean show)
          Part of a layer hack to notify the component listener when the component is hidden.
 void setWindowSupport(WindowSupport ws)
          Set the WindowSupport object handling the palette.
 void showPalette()
          Make the palette visible.
 
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, paint, 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

SWING_PACKAGE

protected static final java.lang.String SWING_PACKAGE
Pre-caches the swing package. Computed based on the package of JComponent.


PrettyNameProperty

public static final java.lang.String PrettyNameProperty
The String to use for a key lookup in a Properties object to find the name to use in a GUI relating to this layer.

See Also:
Constant Field Values

AddToBeanContextProperty

public static final java.lang.String AddToBeanContextProperty
The property to set to add the layer to the BeanContext "addToBeanContext". This probably needs be set by the layer itself, because it knows whether it needs other components or not. However, this property is defined in case an option can be given to the user. If a Layer doesn't want this option given, it should reset the addToBeanContext variable after setProperties() is called. The Layer.setProperties() methods maintain the current state of the variable if undefined, which is true by default.

See Also:
Constant Field Values

AddAsBackgroundProperty

public static final java.lang.String AddAsBackgroundProperty
Property 'background' to designate this layer as a background layer, which will cause extra buffering to occur if the application can handle it. False by default.

See Also:
Constant Field Values

RemovableProperty

public static final java.lang.String RemovableProperty
Property 'removable' to designate this layer as removable from the application, or able to be deleted. True by default.

See Also:
Constant Field Values

MinScaleProperty

public static final java.lang.String MinScaleProperty
The property for designating the minimum projection scale value that the layer will respond to. This Layer class doesn't limit how subclasses will react to projections with scale values smaller than the specified value.

See Also:
Constant Field Values

MaxScaleProperty

public static final java.lang.String MaxScaleProperty
The property for designating the maximum projection scale value that the layer will respond to. This Layer class doesn't limit how subclasses will react to projections with scale values greater than the specified value.

See Also:
Constant Field Values

AutoPaletteProperty

public static final java.lang.String AutoPaletteProperty
The property to show the palette when the layer is created - or, more accurately, when the properties are set.

See Also:
Constant Field Values

DisplayPaletteCmd

public static final java.lang.String DisplayPaletteCmd
Layer-defined action event command to display the palette.

See Also:
Constant Field Values

HidePaletteCmd

public static final java.lang.String HidePaletteCmd
Layer-defined action event command to hide the palette.

See Also:
Constant Field Values

DisplayPropertiesCmd

public static final java.lang.String DisplayPropertiesCmd
Layer-defined action event command to display the properties using an Inspector.

See Also:
Constant Field Values

RedrawCmd

public static final java.lang.String RedrawCmd
Layer-defined action event command to force a redraw on the layer. The Layer class does not respond to this command, it's provided as a convenience.

See Also:
Constant Field Values

DataPathPrefixProperty

public static final java.lang.String DataPathPrefixProperty
Generic property that may be set for a layer to let it know at runtime that a path prefix needs to be added to a relative data path. This property should be set in the attributes of a layer after being read from properties.

See Also:
Constant Field Values

TransformProperty

public static final java.lang.String TransformProperty
The property used to name a class providing translation services (optional, depends on input data).

See Also:
Constant Field Values

propertyPrefix

protected java.lang.String propertyPrefix
Token uniquely identifying this layer in the application properties.


addToBeanContext

protected boolean addToBeanContext
Used by the LayerHandler to check if the layer should be added to the MapHandler BeanContext. See the comments under the AddToBeanContextProperty. True by default.


addAsBackground

protected boolean addAsBackground
Flag used by the layer to indicate that it should be treated as a background layer, indicating that any cache mechanism available can enable extra buffering. This may prevent mouse events from being received by the layer.


removable

protected boolean removable
Flag to designate the layer as removable or not.


autoPalette

protected boolean autoPalette
A flag to have the layer display it's palette when the properties are set. If you are creating a layer manually, just call showPalette() instead.


minScale

protected float minScale
A minimum projection scale value that the layer will respond to. Using this value for reacting to the projection depends on the Layer implementation, the Layer class doesn't limit subclasses from doing their own thing in response to the scale setting on a projection.


maxScale

protected float maxScale
A maximum projection scale value that the layer will respond to. Using this value for reacting to the projection depends on the Layer implementation, the Layer class doesn't limit subclasses from doing their own thing in response to the scale setting on a projection.


windowSupport

protected transient WindowSupport windowSupport
Support class that now handles palette windows.


paletteListener

protected transient java.awt.event.ComponentListener paletteListener
A helper component listener that is paying attention to the visibility of the palette.


palette

protected transient java.awt.Container palette
A pointer to the JDialog or JInternalFrame. May be used by the layer's ComponentListeners to figure out if a component event is for the layer or for the palette.


beanContextChildSupport

protected transient java.beans.beancontext.BeanContextChildSupport beanContextChildSupport
The BeanContext allows Layers to find other components, and other components to find the layer, if the layer is added to it.


i18n

protected transient I18n i18n
All layers have access to an I18n object, which is provided by the Environment.


attributes

protected java.util.Hashtable attributes
Hashtable containing attribute information for the layer. For serialized layers, we're not really going out of our way to make sure that keys and values are serializable.


coordTransform

protected GeoCoordTransformation coordTransform
A translator that can be set to convert pre-projected coordinates from the file into decimal degree lat/lon, and for saving data to a file in pre-projected coordinates.


readyToPaint

protected java.util.concurrent.atomic.AtomicBoolean readyToPaint
New variable to describe when a layer has responded to a projection change and is ready to be painted. Used by the BufferedLayerMapBean, which limits repaint calls to only be passed on when all background layers are ready to be painted. This eliminates the flashing effect caused when some layers call for a repaint before background layers do, causing the map background to be displayed for a second.


localHackList

protected ListenerSupport<java.awt.event.ComponentListener> localHackList
Part of a layer hack to notify the component listener when the component is hidden. These components don't receive the ComponentHidden notification. Remove when it works.


doHack

protected boolean doHack
Part of a layer hack to notify the component listener when the component is hidden. These components don't receive the ComponentHidden notification. Remove when it works. Set to false to test.

Constructor Detail

Layer

public Layer()
Method Detail

getPackage

protected static java.lang.String getPackage(java.lang.Class c)
Returns the package of the given class as a string.

Parameters:
c - a class

addMouseListener

public final void addMouseListener(java.awt.event.MouseListener l)
Override to only allow swing package listeners. If Listeners get added to the Layers, the mouse events don't make it to the map. Ever.

Swing popup menus, like JPopupMenu grab the JComponent by adding themselves as MouseListener s. So this method allows instances of classes in the xxx.swing package to be added as MouseListeners, and no one else.

Overrides:
addMouseListener in class java.awt.Component
Parameters:
l - a mouse listener.

setProperties

public void setProperties(java.util.Properties props)
Sets the properties for the Layer. This particular method assumes that the marker name is not needed, because all of the contents of this Properties object are to be used for this layer, and scoping the properties with a prefix is unnecessary.

Specified by:
setProperties in interface PropertyConsumer
Parameters:
props - the Properties object.

setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties props)
Sets the properties for the Layer. Part of the PropertyConsumer interface. Layers which override this method should do something like:
 public void setProperties(String prefix, Properties props) {
     super.setProperties(prefix, props);
     // do local stuff
 }
 
If the addToBeanContext property is not defined, it maintains the same state.

Specified by:
setProperties in interface PropertyConsumer
Parameters:
prefix - the token to prefix the property names
props - the Properties object

setLayerProperties

protected void setLayerProperties(java.lang.String prefix,
                                  java.util.Properties props)
Called by setProperties. Allows subclasses to avoid super.setProperties() while still having basic Layer settings taken care of.

Parameters:
prefix - the token to prefix the property names
props - the Properties object

setName

public void setName(java.lang.String name)
Overrides:
setName in class java.awt.Component

getProperties

public java.util.Properties getProperties(java.util.Properties props)
PropertyConsumer method, to fill in a Properties object, reflecting the current values of the layer. If the layer has a propertyPrefix set, the property keys should have that prefix plus a separating '.' prepended to each property key it uses for configuration.

Specified by:
getProperties in interface PropertyConsumer
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 list)
Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer. The key for each property should be the raw property name (without a prefix) with a value that is a String that describes what the property key represents, along with any other information about the property that would be helpful (range, default value, etc.). For Layer, this method should at least return the 'prettyName' property.

Specified by:
getPropertyInfo in interface PropertyConsumer
Parameters:
list - 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.

setPropertyPrefix

public void setPropertyPrefix(java.lang.String prefix)
Set the property key prefix that should be used by the PropertyConsumer. The prefix, along with a '.', should be prepended to the property keys known by the PropertyConsumer.

Specified by:
setPropertyPrefix in interface PropertyConsumer
Parameters:
prefix - the prefix String.

getPropertyPrefix

public java.lang.String getPropertyPrefix()
Get the property key prefix that is being used to prepend to the property keys for Properties lookups.

Specified by:
getPropertyPrefix in interface PropertyConsumer
Returns:
the property prefix for the layer

setProjection

public void setProjection(Projection proj)
Set the projection the layer should use for calculations. You probably don't need this if you are wondering if you do. Call setProjection(projEvent) instead.


setProjection

public Projection setProjection(ProjectionEvent projEvent)
This method lets you take the ProjectionEvent received from the MapBean, and lets you know if you should do something with it. MUST to be called in the projectionChanged() method of your layer, if you want to refer to the projection later. If this methods returns null, you probably just want to call repaint() if your layer.paint() method is ready to paint what it should.

Parameters:
projEvent - the ProjectionEvent from the ProjectionListener method.
Returns:
The new Projection if it is different from the one we already have, null if is the same as the current one.

getProjection

public Projection getProjection()
Get the latest projection.


getMapMouseListener

public MapMouseListener getMapMouseListener()
Returns the MapMouseListener object that handles the mouse events. This method is IGNORED in this class: it returns null. Derived Layers should return the appropriate object if they desire to receive MouseEvents. The easiest thing for a Layer to do in order to receive MouseEvents is to implement the MapMouseListener interface and return itself. A code snippet:

 public MapMouseListener getMapMouseListener() {
     return this;
 }
 
 public String[] getMouseModeServiceList() {
     return new String[] { SelectMouseMode.modeID };
 }
 

Returns:
null for the default, method can be overridden to return something interested in mouse events.

hasGUI

public boolean hasGUI()
A GUI query method for other components to use to display whether gui controls are available for this layer. If your layer provides gui controls and the LayersPanel is being used in your application, you should override this method in your layer to return true. This will allow the other gui components to know that your layer has controls, while still not actually building those controls until they are needed by the user.

Returns:
true if there is a GUI for controlling the layer settings, false if not or if the getGUI() method hasn't been overridden.

getGUI

public java.awt.Component getGUI()
Gets the gui controls associated with the layer. This default implementation returns null indicating that the layer has no gui controls.

Returns:
java.awt.Component or null, null by default.

addInfoDisplayListener

public void addInfoDisplayListener(InfoDisplayListener aInfoDisplayListener)
Adds a listener for InfoDisplayEvents.

Parameters:
aInfoDisplayListener - the listener to add

removeInfoDisplayListener

public void removeInfoDisplayListener(InfoDisplayListener aInfoDisplayListener)
Removes an InfoDisplayListener from this Layer.

Parameters:
aInfoDisplayListener - the listener to remove

fireRequestInfoLine

public void fireRequestInfoLine(InfoDisplayEvent evt)
Sends a request to the InfoDisplayListener to show the information in the InfoDisplay event on an single line display facility.

Parameters:
evt - the InfoDisplay event carrying the string.

fireRequestInfoLine

public void fireRequestInfoLine(java.lang.String infoLine)
Sends a request to the InfoDisplay listener to display the information on an single line display facility. The InfoDisplayEvent is created inside this function.

Parameters:
infoLine - the string to put in the InfoDisplayEvent.

fireRequestInfoLine

public void fireRequestInfoLine(java.lang.String infoLine,
                                int loc)
Sends a request to the InfoDisplay listener to display the information on an single line display facility at preferred location. The InfoDisplayEvent is created inside this function.

Parameters:
infoLine - the string to put in the InfoDisplayEvent.
loc - the index of a preferred location, starting at 0.

fireRequestBrowserContent

public void fireRequestBrowserContent(InfoDisplayEvent evt)
Sends a request to the InfoDisplay listener to display the information in the InfoDisplay event in a Browser.

Parameters:
evt - the InfoDisplayEvent holding the contents to put in the Browser.

fireRequestBrowserContent

public void fireRequestBrowserContent(java.lang.String browserContent)
Sends a request to the InfoDisplayListener to display the information in a Browser. The InfoDisplayEvent is created here holding the browserContent

Parameters:
browserContent - the contents to put in the Browser.

fireRequestURL

public void fireRequestURL(InfoDisplayEvent evt)
Sends a request to the InfoDisplayListener to display a URL given in the InfoDisplay event in a Browser.

Parameters:
evt - the InfoDisplayEvent holding the url location to give to the Browser.

fireRequestURL

public void fireRequestURL(java.lang.String url)
Sends a request to the InfoDisplayListener to display a URL in a browser. The InfoDisplayEvent is created here, and the URL location is put inside it.

Parameters:
url - the url location to give to the Browser.

fireRequestCursor

public void fireRequestCursor(java.awt.Cursor cursor)
Sends a request to the InfoDisplayListener to show a specific cursor over its component area.

Parameters:
cursor - the cursor to use.

fireRequestMessage

public void fireRequestMessage(InfoDisplayEvent evt)
Sends a request to the InfoDisplayListener to put the information in the InfoDisplay event in a dialog window.

Parameters:
evt - the InfoDisplayEvent holding the message to put into the dialog window.

fireRequestMessage

public void fireRequestMessage(java.lang.String message)
Sends a request to the InfoDisplayListener to display the information in a dialog window. The InfoDisplayEvent is created here, and the URL location is put inside it.

Parameters:
message - the message to put in the dialog window.

fireRequestToolTip

public void fireRequestToolTip(java.lang.String tip)
Request to show the tool tips on the map.

Parameters:
tip - string to display.

fireHideToolTip

public void fireHideToolTip()
Request to hide the tool tips on the map.


fireRequestToolTip

public void fireRequestToolTip(InfoDisplayEvent event)
Fire off a Tool Tip request to the InfoDisplayListeners. If the InfoDisplayEvent is null, then a requestHideToolTip will be fired.


addLayerStatusListener

public void addLayerStatusListener(LayerStatusListener aLayerStatusListener)
Adds a listener for LayerStatusEvents.

Parameters:
aLayerStatusListener - LayerStatusListener

removeLayerStatusListener

public void removeLayerStatusListener(LayerStatusListener aLayerStatusListener)
Removes a LayerStatusListene from this Layer.

Parameters:
aLayerStatusListener - the listener to remove

fireStatusUpdate

public void fireStatusUpdate(LayerStatusEvent evt)
Sends a status update to the LayerStatusListener.

Parameters:
evt - LayerStatusEvent

fireStatusUpdate

public void fireStatusUpdate(int status)
Sends a status update to the LayerStatusListener.

Parameters:
status - the new status

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Repaint the layer. If you are using BufferedMapBean for your application, WE STRONGLY RECOMMEND THAT YOU DO NOT OVERRIDE THIS METHOD. This method marks the layer buffer so that it will be refreshed. If you override this method, and don't call super.repaint(), the layers will not be repainted.

Overrides:
repaint in class javax.swing.JComponent

renderDataForProjection

public void renderDataForProjection(Projection proj,
                                    java.awt.Graphics g)
This method is here to provide a default action for Layers as they act as a ProjectionPainter. Normally, ProjectionPainters are expected to receive the projection, gather/create OMGraphics that apply to the projection, and render them into the Graphics provided. This is supposed to be done in the same thread that calls this function, so the caller knows that when this method returns, everything that the ProjectionPainter needed to do is complete.

If the layer doesn't override this method, then the paint(Graphics) method will be called.

Specified by:
renderDataForProjection in interface ProjectionPainter
Parameters:
proj - Projection of the map.
g - java.awt.Graphics to draw into.

isProjectionOK

public boolean isProjectionOK(Projection proj)
Method that responds whether the Layer should render on the map, given a particular projection. The method currently just tests the projection's scale against the min and max values set on the layer.

Parameters:
proj - The projection to test against.
Returns:
true if OK.

added

public void added(java.awt.Container cont)
This method is called when the layer is added to the MapBean

Parameters:
cont - Container

removed

public void removed(java.awt.Container cont)
This method is called after the layer is removed from the MapBean and when the projection changes. We recommend that Layers override this method and nullify memory-intensive variables.

Parameters:
cont - Container

dispose

public void dispose()
Method called when layer detects that it has been removed from MapHandler, assumes it's being thrown away. Use this method to let go of everything and to make any calls necessary to remove from listener lists that might not get picked up via MapHandler calls.


setVisible

public void setVisible(boolean show)
Part of a layer hack to notify the component listener when the component is hidden. These components don't receive the ComponentHidden notification. Remove when it works.

Overrides:
setVisible in class javax.swing.JComponent

addComponentListener

public void addComponentListener(java.awt.event.ComponentListener cl)
Part of a layer hack to notify the component listener when the component is hidden. These components don't receive the ComponentHidden notification. Remove when it works.

Overrides:
addComponentListener in class java.awt.Component

removeComponentListener

public void removeComponentListener(java.awt.event.ComponentListener cl)
Part of a layer hack to notify the component listener when the component is hidden. These components don't receive the ComponentHidden notification. Remove when it works.

Overrides:
removeComponentListener in class java.awt.Component

notifyHideHack

public void notifyHideHack()
Part of a layer hack to notify the component listener when the component is hidden. These components don't receive the ComponentHidden notification. Remove when it works.


setAddToBeanContext

public void setAddToBeanContext(boolean set)
Set whether the Layer should be added to the BeanContext.


getAddToBeanContext

public boolean getAddToBeanContext()
Set whether the Layer should be added to the BeanContext.


setAddAsBackground

public void setAddAsBackground(boolean set)
Mark the layer as one that should be considered a background layer. What that means is up to the MapBean or application.


getAddAsBackground

public boolean getAddAsBackground()
Check to see if the layer is marked as one that should be considered a background layer. What that means is up to the MapBean or application.

Returns:
true if layer is a background layer, meaning that it should be dropped to the bottom of the map and incorporated into a background layer image buffer if one is available.

isReadyToPaint

public boolean isReadyToPaint()
Returns:
the readyToPaint

setReadyToPaint

public void setReadyToPaint(boolean readyToPaint)
Parameters:
readyToPaint - the readyToPaint to set

setRemovable

public void setRemovable(boolean set)
Mark the layer as removable, or one that can be deleted from the application. What that means is up to the LayerHandler or other application components.


isRemovable

public boolean isRemovable()
Check to see if the layer is marked as one that can be removed from an application.

Returns:
true if layer should be allowed to be deleted.

removeConfirmed

public boolean removeConfirmed()
Check to see if the removable layer can be removed now.

Returns:
true if layer should be allowed to be deleted.

findAndInit

public void findAndInit(java.util.Iterator<?> it)
This is the method that your layer can use to find other objects within the MapHandler (BeanContext). This method gets called when the Layer gets added to the MapHandler, or when another object gets added to the MapHandler after the Layer is a member. If the LayerHandler creates the Layer from properties, the LayerHandler will add the Layer to the BeanContext if Layer.addToBeanContext is true. It is false by default. For Layers, this method doesn't do anything by default. If you need your layer to get ahold of another object, then you can use the Iterator to go through the objects to look for the one you need.


findAndInit

public void findAndInit(java.lang.Object obj)
This method is called by the findAndInit(Iterator) method, once for every object inside the iterator. It's here to allow subclasses a way to receive objects and still let the super classes have a shot at the object. So, you can override this method can call super.findAndInit(obj), or override the findAndInit(Iterator) method and call super.findAndInit(obj). Whatever.


childrenAdded

public void childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)
BeanContextMembershipListener method. Called when a new object is added to the BeanContext of this object.

Specified by:
childrenAdded in interface java.beans.beancontext.BeanContextMembershipListener

childrenRemoved

public void childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)
BeanContextMembershipListener method. Called when a new object is removed from the BeanContext of this object. For the Layer, this method doesn't do anything. If your layer does something with the childrenAdded method, or findAndInit, you should take steps in this method to unhook the layer from the object used in those methods.

Specified by:
childrenRemoved in interface java.beans.beancontext.BeanContextMembershipListener

findAndUndo

public void findAndUndo(java.lang.Object obj)
This is the method that does the opposite as the findAndInit(Object). Lets you call super classes with objects that need to be removed. At this level, if the layer detects that it is being removed from the MapHandler, it calls dispose on itself.


getBeanContext

public java.beans.beancontext.BeanContext getBeanContext()
Method for BeanContextChild interface.

Specified by:
getBeanContext in interface java.beans.beancontext.BeanContextChild

setBeanContext

public void setBeanContext(java.beans.beancontext.BeanContext in_bc)
                    throws java.beans.PropertyVetoException
Method for BeanContextChild interface. Gets an iterator from the BeanContext to call findAndInit() over.

Specified by:
setBeanContext in interface java.beans.beancontext.BeanContextChild
Throws:
java.beans.PropertyVetoException

connectToBeanContext

public void connectToBeanContext(java.beans.beancontext.BeanContext in_bc)
                          throws java.beans.PropertyVetoException
Layer method to just connect to the BeanContext, without grabbing the iterator as in setBeanContext(). Good for protected sub-layers where you want to optimize the calling of the findAndInit() method over them.

Throws:
java.beans.PropertyVetoException

disconnectFromBeanContext

public void disconnectFromBeanContext()
                               throws java.beans.PropertyVetoException
Layer method to just disconnect from the BeanContext, without grabbing the iterator as in setBeanContext(). Good for protected sub-layers where you want to optimize the calling of the findAndUndo() method over them.

Throws:
java.beans.PropertyVetoException

addVetoableChangeListener

public void addVetoableChangeListener(java.lang.String propertyName,
                                      java.beans.VetoableChangeListener in_vcl)
Method for BeanContextChild interface. Uses the BeanContextChildSupport to add a listener to this object's property. This listener wants to have the right to veto a property change.

Specified by:
addVetoableChangeListener in interface java.beans.beancontext.BeanContextChild

removeVetoableChangeListener

public void removeVetoableChangeListener(java.lang.String propertyName,
                                         java.beans.VetoableChangeListener in_vcl)
Method for BeanContextChild interface. Uses the BeanContextChildSupport to remove a listener to this object's property. The listener has the power to veto property changes.

Specified by:
removeVetoableChangeListener in interface java.beans.beancontext.BeanContextChild

fireVetoableChange

public void fireVetoableChange(java.lang.String name,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
                        throws java.beans.PropertyVetoException
Report a vetoable property update to any registered listeners. If anyone vetos the change, then fire a new event reverting everyone to the old value and then rethrow the PropertyVetoException.

No event is fired if old and new are equal and non-null.

Overrides:
fireVetoableChange in class javax.swing.JComponent
Parameters:
name - The programmatic name of the property that is about to change
oldValue - The old value of the property
newValue - - The new value of the property
Throws:
java.beans.PropertyVetoException - if the recipient wishes the property change to be rolled back.

clearListeners

public void clearListeners()

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

firePaletteEvent

public void firePaletteEvent(java.awt.event.ComponentEvent event)
Fire a component event to the Layer component listeners, with the palette as the component, letting them know if it's visible or not.


getPalette

public java.awt.Container getPalette()
Return the JDialog, or JInternalFrame, that serves as the palette for the layer. May be null.


resetPalette

protected void resetPalette()
Called when something about the layer has changed that would require the palette to be reconfigured. Will cause getGUI() to be called again. You should take steps before calling this method to make sure that the getGUI() method is ready to recreate the palette components from scratch if needed.


setPaletteVisible

public void setPaletteVisible(boolean visible)
Make the palette visible or not, destroy if invisible.


setWindowSupport

public void setWindowSupport(WindowSupport ws)
Set the WindowSupport object handling the palette.


getWindowSupport

public WindowSupport getWindowSupport()
Get the WindowSupport object handling the palette.


createWindowSupport

protected WindowSupport createWindowSupport()
Callback method to override how window support is created.

Returns:
WindowSupport object for layer palette.

showPalette

public void showPalette()
Make the palette visible. Will automatically determine if we're running in an applet environment and will use a JInternalFrame over a JFrame if necessary.


hidePalette

public void hidePalette()
Hide the layer's palette.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
The default actionPerformed method for Layer. Make sure you call super.actionPerformed if you care about receiving palette show/hide commands. This method is also set up to receive the DisplayPropertiesCmd, and will bring up the Inspector for the layer.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

getIcon

public javax.swing.Icon getIcon()

setIcon

public void setIcon(javax.swing.Icon icon)

isAutoPalette

public boolean isAutoPalette()

setAutoPalette

public void setAutoPalette(boolean autoPalette)

getMaxScale

public float getMaxScale()

setMaxScale

public void setMaxScale(float maxScale)

getMinScale

public float getMinScale()

setMinScale

public void setMinScale(float minScale)

putAttribute

public void putAttribute(java.lang.Object key,
                         java.lang.Object value)

getAttribute

public java.lang.Object getAttribute(java.lang.Object key)

getCoordTransform

public GeoCoordTransformation getCoordTransform()

setCoordTransform

public void setCoordTransform(GeoCoordTransformation coordTranslator)

prependDataPathPrefix

protected java.lang.String prependDataPathPrefix(java.lang.String fileName)
The dataPathPrefix layer attribute lets you append a path to a relative path at runtime. This method tells the layer to check for that layer attribute for such a prefix path, and prepends it to the given string separating them with a '/'.

Parameters:
fileName - to prepend the attribute to


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