com.bbn.openmap.layer
Class OMGraphicHandlerLayer

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
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
Direct Known Subclasses:
AOILayer, ASRPLayer, BasicLayer, BoundsTestLayer, BufferedLayer, DayNightLayer, DemoLayer, DrawingToolLayer, DTEDCoverageLayer, DTEDFrameCacheLayer, DTEDLayer, E00Layer, EarthquakeLayer, EsriLayer, ETOPOLayer, EventLayer, GeoTestLayer, GraticuleLayer, ImageTileLayer, LabelLayer, LinkLayer, LocationLayer, MapTileLayer, MapTileUtilLayer, MIFLayer, MysqlGeometryLayer, NexradLayer, PlotLayer, PlugInLayer, ProjectionResponseLayer, RpfLayer, ScaleDisplayLayer, ShapeLayer, SimpleAnimationLayer, TerrainLayer, TestLayer, TimelineLayer, TimeSliderLayer, VPFFeatureLayer, VPFLayer

public class OMGraphicHandlerLayer
extends Layer
implements GestureResponsePolicy, OMGraphicHandler

The OMGraphicHandlerLayer is a layer that provides OMGraphicHandler support. With this support, the OMGraphicHandlerLayer can accept OMAction instructions for managing OMGraphics, and can perform display filtering as supported by the FilterSupport object.

When extending this class for a simple layer, they only method you need to override is the prepare() method. This is a good class to use to start writing your own layers. Start with overriding the prepare() method, having it return an OMGraphicList containing OMGraphics on the map that are appropriate for the current projection.

The OMGraphicHandlerLayer already has an OMGraphicList variable, so if you extend this class you don't have to manage another one. You can add your OMGraphics to the list provided with getList(). If you create a list of OMGraphics that is reused and simply re-projected when the projection changes, do nothing - that's what happens anyway based on the default ProjectionChangePolicy set for the layer (StandardPCPolicy). You can either create an OMGraphicList in the constructor and set it by calling setList(OMGraphicList), or you can test for a null OMGraphicList returned from getList() in prepare() and create one if it needs to be. If the list isn't null, make sure you still call generate on it. The advantage of waiting to create the list in prepare is that the processing time to create the OMGraphics is delayed until the layer is added to the map. If you create OMGraphics in the constructor, you delay the entire program (maybe startup of the map!) while the OMGraphics are created.

If you let prepare() create a new OMGraphicList based on the new projection, then make sure the ProjectionChangePolicy for the layer is set to a com.bbn.openmap.layer.policy.ResetListPCPolicy, or at least clear out the old graphics at some point before adding new OMGraphics to the list in that method. You just have to do one, not both, of those things. If you are managing a lot of OMGraphics and do not null out the list, you may see your layer appear to lag behind the projection changes. That's because another layer with less work to do finishes and calls repaint, and since your list is still set with OMGraphics ready for the old projection, it will just draw what it had, and then draw again when it has finished working. Nulling out the list will prevent your layer from drawing anything on the new projection until it is ready.

The OMGraphicHandlerLayer has support built in for launching a SwingWorker to do work for you in a separate thread. This behavior is controlled by the ProjectionChangePolicy that is set for the layer. Both the StandardPCPolicy and ListResetPCPolicy launch threads by calling doPrepare() on this layer. The StandardPCPolicy only calls this if the number of OMGraphics on its list is greater than some cutoff value.

useLayerWorker variable is true (default), then doPrepare() will be called when a new ProjectionEvent is received in the projectionChanged method. This will cause prepare() to be called in a separate thread. You can use prepare() to create OMGraphics, the projection will have been set in the layer and is available via getProjection(). You should generate() the OMGraphics in prepare. NOTE: You can override the projectionChanged() method to create/manage OMGraphics any way you want. The SwingWorker only gets launched if doPrepare() gets called.

MouseEvents are not handled by a MapMouseInterpreter, with the layer being the GestureResponsePolicy object dictating how events are responded to. The interpreter does the work of fielding MapMouseEvents, figuring out if they concern an OMGraphic, and asking the policy what it should do in certain situations, including providing tooltips, information, or opportunities to edit OMGraphics. The mouseModes property can be set to the MapMouseMode IDs that the interpreter should respond to.

For OMGraphicHandlerLayers, there are several properties that can be set that dictate important behavior:




     layer.projectionChangePolicy=pcp
     layer.pcp.class=com.bbn.openmap.layer.policy.StandardPCPolicy
 
     layer.renderPolicy=srp
     layer.srp.class=com.bbn.openmap.layer.policy.StandardRenderPolicy
     # or
     layer.renderPolicy=ta
     layer.ta.class=com.bbn.openmap.layer.policy.RenderingHintsRenderPolicy
     layer.ta.renderingHints=KEY_TEXT_ANTIALIASING
     layer.ta.KEY_TEXT_ANTIALIASING=VALUE_TEXT_ANTIALIAS_ON
 
     layer.mouseModes=Gestures
     layer.consumeEvents=true


 

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 consumeEvents
          A flag to tell the layer to be selfish about consuming MouseEvents it receives.
static java.lang.String ConsumeEventsProperty
          The property that can be set to tell the layer to consume mouse events.
protected  FilterSupport filter
          Filter support that can be used to manage OMGraphics.
protected  boolean interruptable
          Flag used to avoid the SwingWorker to be interrupted.
static java.lang.String InterruptableProperty
          The property to tell the layer if the thread launched for prepare() method calls can be interrupted.
protected  ISwingWorker<OMGraphicList> layerWorker
          A SwingWorker that can be used for gathering OMGraphics or doing other work in a different thread.
protected  java.lang.Object LAYERWORKER_LOCK
          Lock object used for managing LayerWorker and queue synchronization.
protected  boolean layerWorkerQueue
          A SwingWorker created if the projection changes when the primary layerworker is off doing work.
static java.util.logging.Logger logger
           
protected  MapMouseInterpreter mouseEventInterpreter
          The MapMouseInterpreter used to catch the MapMouseEvents and direct them to layer as referencing certain OMGraphics.
protected  java.lang.String[] mouseModeIDs
           
static java.lang.String MouseModesProperty
          The property that can be set to tell the layer which mouse modes to listen to.
protected  ProjectionChangePolicy projectionChangePolicy
          The ProjectionChangePolicy object that determines how a layer reacts and sets up the OMGraphicList to be rendered for the layer when the projection changes.
static java.lang.String ProjectionChangePolicyProperty
          The property that can be set for the ProjectionChangePolicy.
protected  RenderPolicy renderPolicy
          The RenderPolicy object that determines how a layer's OMGraphicList is rendered in the layer.paint() method.
static java.lang.String RenderPolicyProperty
          The property that can be set for the RenderPolicy.
protected  OMGraphicList selectedList
          A current list of select OMGraphics.
static java.lang.String TransparencyProperty
          The property to tell the layer how transparent it is.
 
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
OMGraphicHandlerLayer()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Override of Layer's actionPerformed method, adds the capability that calls doPrepare() if the layer is visible and it receives a RedrawCmd command.
 boolean canSetList()
          Indicates if the OMGraphicHandler can have its OMGraphicList set.
 OMGraphicList copy(OMGraphicList omgl)
          Return a copy of OMGraphics.
protected  ISwingWorker<OMGraphicList> createLayerWorker()
          Called from within the layer to create a LayerWorker to use for the prepare() method.
 OMGraphicList cut(OMGraphicList omgl)
          Remove OMGraphics from the layer.
 void deselect(OMGraphicList list)
          Designate a list of OMGraphics as de-selected.
 void dispose()
          Overrides Layer.dispose(), makes sure the OMGraphicList is cleared.
 boolean doAction(OMGraphic graphic, OMAction action)
          Perform the OMAction on the OMGraphic, within the OMGraphicList contained in the layer.
 void doPrepare()
          A method that will launch a LayerWorker thread to call the prepare method.
 OMGraphicList filter(java.awt.Shape withinThisShape)
          Sets all the OMGraphics outside of this shape to be invisible.
 OMGraphicList filter(java.awt.Shape shapeBoundary, boolean getInsideBoundary)
          Filters the OMGraphicHandler graphic list so that graphics inside or outside the given shape will be visible.
 OMGraphicList filter(java.lang.String SQLQuery)
          Depending on the filter's SQL support, returns an OMGraphicList that fit the query.
 boolean getConsumeEvents()
           
 javax.swing.JPanel getDefaultSettingsPanel(java.lang.Class<?> clss, float opaquenessSetting)
          Get a default settings panel that contains the layer transparency setting, the settings button and a layer refresh button.
 FilterSupport getFilter()
          Get the FilterSupport object that is handling the OMGraphicHandler methods.
 java.lang.String getInfoText(OMGraphic omg)
          If applicable, should return a short, informational string about the OMGraphic to be displayed in the InformationDelegator.
 java.util.List<java.awt.Component> getItemsForMapMenu(MapMouseEvent mme)
          Return a JMenu with contents applicable to a pop-up menu for a location over the map.
 java.util.List<java.awt.Component> getItemsForOMGraphicMenu(OMGraphic omg)
          Return a java.util.List containing input for a JMenu with contents applicable to a pop-up menu for a location over an OMGraphic.
protected  ISwingWorker<OMGraphicList> getLayerWorker()
           
 OMGraphicList getList()
          Get the OMGraphicList held by the layer.
 MapMouseListener getMapMouseListener()
          Query asked from the MouseDelegator for interest in receiving MapMouseEvents.
 MapMouseInterpreter getMouseEventInterpreter()
          Get the interpreter used to field and interpret MouseEvents, thereby calling GestureResponsePolicy methods on this layer.
 java.lang.String[] getMouseModeIDsForEvents()
          This is the important method call that determines what MapMouseModes the interpreter for this layer responds to.
 ProjectionChangePolicy getProjectionChangePolicy()
          Get the ProjectionChangePolicy that determines how a layer reacts and gathers OMGraphics for a projection change.
 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 list)
          Overrides Layer getProperties method., also calls that method on Layer.
 javax.swing.JButton getRedrawButton(java.lang.String tooltip)
           
 RenderPolicy getRenderPolicy()
          Get the RenderPolicy that determines how an OMGraphicList is rendered.
 OMGraphicList getSelected()
          Retrieve the list of currently selected OMGraphics.
 javax.swing.JButton getSettingsButton(java.lang.String tooltip)
           
 java.lang.String getToolTipTextFor(OMGraphic omg)
          If applicable, should return a tool tip for the OMGraphic.
 float getTransparency()
          Get the transparency value for this layer.
 javax.swing.JPanel getTransparencyAdjustmentPanel(java.lang.String label, int orientation, float initialValue)
          Create a JPanel that has a slider to control the layer transparency.
 void highlight(OMGraphic omg)
          Fleeting change of appearance for mouse movements over an OMGraphic.
 boolean isCancelled()
          Check to see if it's likely the current thread will be replaced with another one.
 boolean isHighlightable(OMGraphic omg)
          Query asking if OMGraphic is highlight-able, which means that something in the GUI should change when the mouse is moved or dragged over the given OMGraphic.
 boolean isInterruptable()
          Queries for the interruptible flag.
 boolean isSelectable(OMGraphic omg)
          Query asking if an OMGraphic is select-able, or able to be moved, deleted or otherwise modified.
 boolean isWorking()
          A check to see if the LayerWorker (SwingWorker) exists (is doing something).
 boolean leftClick(MapMouseEvent mme)
          A notification that the mouse has been clicked with the left mouse button on the map, and not on any of the OMGraphics.
 boolean mouseOver(MapMouseEvent mme)
          A notification that the mouse cursor has been moved over the map, not over any of the OMGraphics on the GestureResponsePolicy.
 void paint(java.awt.Graphics g)
          The default action is to get the OMGraphicList and render it.
 void paste(OMGraphicList omgl)
          Add OMGraphics to the Layer.
 OMGraphicList prepare()
          This is the main method you should be concerned with when overriding this class.
 void projectionChanged(ProjectionEvent pe)
          From the ProjectionListener interface.
 boolean receivesMapEvents()
          A query from the MapMouseInterpreter wondering if the GestureResponsePolicy wants events pertaining to mouse movements over the map that are not over an OMGraphic.
 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 resetFiltering()
          Remove all filters, and reset all graphics to be visible.
 void select(OMGraphicList list)
          Designate a list of OMGraphics as selected.
 void setConsumeEvents(boolean consume)
          A flag to tell the layer to be selfish about consuming MouseEvents it receives.
 void setFilter(FilterSupport fs)
          Don't set to null.
 void setInterruptable(boolean b)
          Sets the interruptible flag, allowing the current swing worker thread to have interrupt called on it.
protected  void setLayerWorker(ISwingWorker<OMGraphicList> worker)
          Sets the SwingWorker off to call prepare().
 void setList(OMGraphicList omgl)
          Set the OMGraphicList within this OMGraphicHandler.
 void setMouseEventInterpreter(MapMouseInterpreter mmi)
          Set the interpreter used to field and interpret MouseEvents, thereby calling GestureResponsePolicy methods on this layer.
 void setMouseModeIDsForEvents(java.lang.String[] mm)
          Use this method to set which mouse modes this layer responds to.
 void setProjectionChangePolicy(ProjectionChangePolicy pcp)
          Set the ProjectionChangePolicy that determines how a layer reacts and gathers OMGraphics for a projection change.
 void setProperties(java.lang.String prefix, java.util.Properties props)
          Overrides the Layer setProperties method.
 void setRenderPolicy(RenderPolicy rp)
          Set the RenderPolicy that determines how the OMGraphicList is rendered.
 void setTransparency(float value)
          Set the transparency of the layer.
 boolean supportsSQL()
          To find out whether SQL queries are handled.
 void unhighlight(OMGraphic omg)
          Notification to set OMGraphic to normal appearance.
protected  void workerComplete(ISwingWorker<OMGraphicList> worker)
          The LayerWorker calls this method on the layer when it is done working.
 
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 java.beans.beancontext.BeanContextChild
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

logger

public static java.util.logging.Logger logger

ProjectionChangePolicyProperty

public static final java.lang.String ProjectionChangePolicyProperty
The property that can be set for the ProjectionChangePolicy. This property should be set with a scoping marker name used to define a policy class and any other properties that the policy should use. "projectionChangePolicy"

See Also:
ProjectionChangePolicy, StandardPCPolicy, ListResetPCPolicy, Constant Field Values

RenderPolicyProperty

public static final java.lang.String RenderPolicyProperty
The property that can be set for the RenderPolicy. This property should be set with a marker name used to define a policy class and any other properties that the policy should use. "renderPolicy"

See Also:
StandardRenderPolicy, BufferedImageRenderPolicy, RenderingHintsRenderPolicy, Constant Field Values

MouseModesProperty

public static final java.lang.String MouseModesProperty
The property that can be set to tell the layer which mouse modes to listen to. The property should be a space-separated list of mouse mode IDs, which can be specified for a MapMouseMode in the properties file or, if none is specified, the default ID hard-coded into the MapMouseMode. "mouseModes"

See Also:
Constant Field Values

ConsumeEventsProperty

public static final java.lang.String ConsumeEventsProperty
The property that can be set to tell the layer to consume mouse events. The maim reason not to do this is in case you have OMGraphics that you are moving, and you need other layers to respond to let you know when you are over the place you think you need to be.

See Also:
Constant Field Values

TransparencyProperty

public static final java.lang.String TransparencyProperty
The property to tell the layer how transparent it is. 0 is totally clear, 1f is opaque.

See Also:
Constant Field Values

InterruptableProperty

public static final java.lang.String InterruptableProperty
The property to tell the layer if the thread launched for prepare() method calls can be interrupted. If false, the thread will be allowed to complete it's work. This (false) is generally a good setting for layers contacting servers. The default setting is, however, true.

See Also:
Constant Field Values

filter

protected FilterSupport filter
Filter support that can be used to manage OMGraphics.


projectionChangePolicy

protected ProjectionChangePolicy projectionChangePolicy
The ProjectionChangePolicy object that determines how a layer reacts and sets up the OMGraphicList to be rendered for the layer when the projection changes.


renderPolicy

protected RenderPolicy renderPolicy
The RenderPolicy object that determines how a layer's OMGraphicList is rendered in the layer.paint() method.


layerWorker

protected ISwingWorker<OMGraphicList> layerWorker
A SwingWorker that can be used for gathering OMGraphics or doing other work in a different thread.


layerWorkerQueue

protected boolean layerWorkerQueue
A SwingWorker created if the projection changes when the primary layerworker is off doing work. If a bunch of project changes occur before the primary layerworker returns from being interrupted, setting the one in the queue will take care of all of them.


mouseModeIDs

protected java.lang.String[] mouseModeIDs

consumeEvents

protected boolean consumeEvents
A flag to tell the layer to be selfish about consuming MouseEvents it receives. If set to true, it will consume events so that other layers will not receive the events. If false, lower layers will also receive events, which will let them react too. Intended to let other layers provide information about what the mouse is over when editing.


interruptable

protected boolean interruptable
Flag used to avoid the SwingWorker to be interrupted. Useful for layers that load an image from a server such as the WMSPlugin to avoid an ugly java output "Interrupted while loading image".


LAYERWORKER_LOCK

protected final java.lang.Object LAYERWORKER_LOCK
Lock object used for managing LayerWorker and queue synchronization.


mouseEventInterpreter

protected MapMouseInterpreter mouseEventInterpreter
The MapMouseInterpreter used to catch the MapMouseEvents and direct them to layer as referencing certain OMGraphics. Manages how the layer responds to mouse events.


selectedList

protected OMGraphicList selectedList
A current list of select OMGraphics.

Constructor Detail

OMGraphicHandlerLayer

public OMGraphicHandlerLayer()
Method Detail

setInterruptable

public void setInterruptable(boolean b)
Sets the interruptible flag, allowing the current swing worker thread to have interrupt called on it.


isInterruptable

public boolean isInterruptable()
Queries for the interruptible flag.

Returns:
true if interruptible flag is set, allowing interrupt to be called on swing worker threads.

filter

public OMGraphicList filter(java.awt.Shape withinThisShape)
Sets all the OMGraphics outside of this shape to be invisible. Also returns another OMGraphicList containing OMGraphics that are contained within the Shape provided.

Specified by:
filter in interface OMGraphicHandler
Parameters:
withinThisShape - java.awt.Shape object defining a boundary.
Returns:
OMGraphicList containing OMGraphics that are within the Shape.

filter

public OMGraphicList filter(java.awt.Shape shapeBoundary,
                            boolean getInsideBoundary)
Description copied from interface: OMGraphicHandler
Filters the OMGraphicHandler graphic list so that graphics inside or outside the given shape will be visible. Returns an OMGraphicList with those visible shapes. The returned list should not be assumed to be the same OMGraphicList object that is maintained inside the OMGraphicHandler.

Specified by:
filter in interface OMGraphicHandler
Parameters:
shapeBoundary - java.awt.Shape object defining a boundary.
getInsideBoundary - if true, the filter will look for shapes inside and contacting the boundary. If false, the filter will look for shapes outside the boundary.
Returns:
OMGraphicList containing OMGraphics that are within the Shape.
See Also:
OMGraphicHandler.filter(Shape, boolean).

supportsSQL

public boolean supportsSQL()
To find out whether SQL queries are handled.

Specified by:
supportsSQL in interface OMGraphicHandler
See Also:
OMGraphicHandler.supportsSQL().

filter

public OMGraphicList filter(java.lang.String SQLQuery)
Depending on the filter's SQL support, returns an OMGraphicList that fit the query.

Specified by:
filter in interface OMGraphicHandler
Parameters:
SQLQuery - a SELECT SQL statement
Returns:
OMGraphicList containing OMGraphics that meet the SELECT statement criteria.

doAction

public boolean doAction(OMGraphic graphic,
                        OMAction action)
Perform the OMAction on the OMGraphic, within the OMGraphicList contained in the layer.

Specified by:
doAction in interface OMGraphicHandler
Parameters:
graphic - the OMGraphic to do the action on.
action - the OMAction describing what to do to the graphic.
Returns:
true if the action was able to be carried out.

getList

public OMGraphicList getList()
Get the OMGraphicList held by the layer. May be null.

Specified by:
getList in interface OMGraphicHandler
See Also:
OMGeometry.isVisible()

canSetList

public boolean canSetList()
Indicates if the OMGraphicHandler can have its OMGraphicList set.

Specified by:
canSetList in interface OMGraphicHandler

setList

public void setList(OMGraphicList omgl)
Set the OMGraphicList within this OMGraphicHandler. Works if canSetGraphicList == true.

Specified by:
setList in interface OMGraphicHandler

resetFiltering

public void resetFiltering()
Remove all filters, and reset all graphics to be visible.

Specified by:
resetFiltering in interface OMGraphicHandler

setFilter

public void setFilter(FilterSupport fs)
Don't set to null. This is here to let subclasses put a more/less capable FilterSupport in place.


getFilter

public FilterSupport getFilter()
Get the FilterSupport object that is handling the OMGraphicHandler methods.


projectionChanged

public void projectionChanged(ProjectionEvent pe)
From the ProjectionListener interface. The method gets called when the layer is part of the map, and whenever the map projection changes. Will trigger a repaint().

The ProjectionEvent is passed to the current ProjectionChangePolicy object, which determines what will happen on the layer and how. By default, a StandardPCPolicy is notified with the projection change, and it will test the projection for changes and make sure prepare() is called. It will make the decision whether doPrepare() is called, based on the number of OMGraphics on the list, which may launch a swing worker thread to call prepare(). The StandardPCPolicy does not do anything to the OMGraphicList when the projection changes.

If you need the OMGraphicList cleared out with a new projection, you can substitute a ListRestPCPolicy for the StandardPCPolicy. You would want to do this if your OMGraphicList changes for different projections - The reason the OMGraphicList is nulled out is so if another layer finishes before yours does and gets repainted, your old OMGraphics don't get painted along side their new ones - it's a mismatched situation. You can set the ProjectionChangePolicy directly with the setProjectionChangePolicy, or by overriding the getProjectionChangePolicy method and returning the type you want by default if it is null.

Specified by:
projectionChanged in interface ProjectionListener
Parameters:
pe - ProjectionEvent
See Also:
ProjectionChangePolicy, StandardPCPolicy, ListResetPCPolicy

getProjectionChangePolicy

public ProjectionChangePolicy getProjectionChangePolicy()
Get the ProjectionChangePolicy that determines how a layer reacts and gathers OMGraphics for a projection change.


setProjectionChangePolicy

public void setProjectionChangePolicy(ProjectionChangePolicy pcp)
Set the ProjectionChangePolicy that determines how a layer reacts and gathers OMGraphics for a projection change.


getRenderPolicy

public RenderPolicy getRenderPolicy()
Get the RenderPolicy that determines how an OMGraphicList is rendered.


setRenderPolicy

public void setRenderPolicy(RenderPolicy rp)
Set the RenderPolicy that determines how the OMGraphicList is rendered.


setLayerWorker

protected void setLayerWorker(ISwingWorker<OMGraphicList> worker)
Sets the SwingWorker off to call prepare(). If the SwingWorker passed in is not null, start() is called on it.

Parameters:
worker - null to reset the layerWorker variable, or a SwingWorker to start up.

getLayerWorker

protected ISwingWorker<OMGraphicList> getLayerWorker()

createLayerWorker

protected ISwingWorker<OMGraphicList> createLayerWorker()
Called from within the layer to create a LayerWorker to use for the prepare() method. By default, a new LayerWorker is returned. This method may be overridden to make the layer use an extended LayerWorker/SwingWorker class.

Returns:
SwingWorker/LayerWorker

dispose

public void dispose()
Overrides Layer.dispose(), makes sure the OMGraphicList is cleared.

Overrides:
dispose in class Layer

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
Overrides:
renderDataForProjection in class Layer
Parameters:
proj - Projection of the map.
g - java.awt.Graphics to draw into.

paint

public void paint(java.awt.Graphics g)
The default action is to get the OMGraphicList and render it.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - java.awt.Graphics object to render OMGraphics into.

doPrepare

public void doPrepare()
A method that will launch a LayerWorker thread to call the prepare method. This method will set in motion all the steps needed to create and render the current OMGraphicList with the current projection. Nothing more needs to be called, because the LayerWorker will be started, it will call prepare(). Inside the prepare() method, the OMGraphicList should be created and the OMGraphics generated for the current projection that can be picked up in the getProjection() method, and the LayerWorker will call workerComplete() which will call repaint() on this layer.


isWorking

public boolean isWorking()
A check to see if the LayerWorker (SwingWorker) exists (is doing something).


prepare

public OMGraphicList prepare()
This is the main method you should be concerned with when overriding this class. You have to make sure that this method returns an OMGraphicList that is ready to be rendered. That means they need to be generated with the current projection, which can be retrieved by calling getProjection().

This method will be called in a separate thread if doPrepare() is called on the layer. This will automatically cause repaint() to be called, which lets java know to call paint() on this class.

Note that the default action of this method is to get the OMGraphicList as it is currently set in the layer, re-projects the list with the current projection (calls generate() on them), and then returns the current list.

If your layer needs to change what is on the list based on what the current projection is, you can either clear() the list yourself and add new OMGraphics to it (remember to call generate(Projection) on them), and return the list. You also have the option of setting a ListResetPCPolicy, which will automatically set the list to null when the projection changes before calling this method. The OMGraphicHandlerList will ignore a null OMGraphicList.

NOTE: If you call prepare directly, you may need to call repaint(), too. With all invocations of this method that are cause by a projection change, repaint() will be called for you. The method is synchronized in case renderDataForProjection() gets called while in the middle of this method. For a different projection, that would be bad.


isCancelled

public boolean isCancelled()
Check to see if it's likely the current thread will be replaced with another one.

Returns:
true if another layer worker is queued up.

workerComplete

protected void workerComplete(ISwingWorker<OMGraphicList> worker)
The LayerWorker calls this method on the layer when it is done working. If the calling worker is not the same as the "current" worker, then a new worker is created.

Parameters:
worker - the worker that has the graphics, must not be null.

setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties props)
Overrides the Layer setProperties method. Also calls Layer's version. If the ProjectionChangePolicy and RenderPolicy objects are set programmatically, are PropertyConsumers and the .class property is not set, they will still have access to properties if this method is called. Their property prefix will be scoped as if the OMGraphicHandlerLayer had them created, with their prefix being prefix + . + PropertyChangePolicyProperty and prefix + . + RenderPolicyProperty. If the .class property is set, then a new policy object will be created and replace the one set before this method is called.

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

getProperties

public java.util.Properties getProperties(java.util.Properties props)
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 Layer
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)
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 Layer
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.

setMouseEventInterpreter

public void setMouseEventInterpreter(MapMouseInterpreter mmi)
Set the interpreter used to field and interpret MouseEvents, thereby calling GestureResponsePolicy methods on this layer.


getMouseEventInterpreter

public MapMouseInterpreter getMouseEventInterpreter()
Get the interpreter used to field and interpret MouseEvents, thereby calling GestureResponsePolicy methods on this layer. This method checks to see if any mouse modes ids have been set via the getMouseModeIDsForEvents() method, and if there were and the interpreter hasn't been set, it will create a StandardMapMouseInterpreter. Otherwise, it returns whatever has been set as the interpreter, which could be null.


getMapMouseListener

public MapMouseListener getMapMouseListener()
Query asked from the MouseDelegator for interest in receiving MapMouseEvents. This returns a MapMouseInterpreter that has been told to listen for events from the MapMouseModes in setMouseModeIDsForEvents().

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

setConsumeEvents

public void setConsumeEvents(boolean consume)
A flag to tell the layer to be selfish about consuming MouseEvents it receives. If set to true, it will consume events so that other layers will not receive the events. If false, lower layers will also receive events, which will let them react too. Intended to let other layers provide information about what the mouse is over when editing.


getConsumeEvents

public boolean getConsumeEvents()

getMouseModeIDsForEvents

public java.lang.String[] getMouseModeIDsForEvents()
This is the important method call that determines what MapMouseModes the interpreter for this layer responds to. The MapMouseInterpreter calls this so it can respond to MouseDelegator queries. You can programmatically call setMouseModeIDsForEvents with the mode IDs to set these values, or set the mouseModes property for this layer set to a space-separated list of mode IDs.


setMouseModeIDsForEvents

public void setMouseModeIDsForEvents(java.lang.String[] mm)
Use this method to set which mouse modes this layer responds to. The array should contain the mouse mode IDs.


isHighlightable

public boolean isHighlightable(OMGraphic omg)
Query asking if OMGraphic is highlight-able, which means that something in the GUI should change when the mouse is moved or dragged over the given OMGraphic. Highlighting shows that something could happen, or provides cursory information about the OMGraphic. Responding true to this method may cause getInfoText() and getToolTipTextFor() methods to be called (depends on the MapMouseInterpetor).

Specified by:
isHighlightable in interface GestureResponsePolicy

isSelectable

public boolean isSelectable(OMGraphic omg)
Query asking if an OMGraphic is select-able, or able to be moved, deleted or otherwise modified. Responding true to this method may cause select() to be called (depends on the MapMouseInterpertor) so the meaning depends on what the layer does in select.

Specified by:
isSelectable in interface GestureResponsePolicy

getSelected

public OMGraphicList getSelected()
Retrieve the list of currently selected OMGraphics.

Specified by:
getSelected in interface GestureResponsePolicy

highlight

public void highlight(OMGraphic omg)
Fleeting change of appearance for mouse movements over an OMGraphic.

Specified by:
highlight in interface GestureResponsePolicy

unhighlight

public void unhighlight(OMGraphic omg)
Notification to set OMGraphic to normal appearance.

Specified by:
unhighlight in interface GestureResponsePolicy

select

public void select(OMGraphicList list)
Designate a list of OMGraphics as selected.

Specified by:
select in interface GestureResponsePolicy

deselect

public void deselect(OMGraphicList list)
Designate a list of OMGraphics as de-selected.

Specified by:
deselect in interface GestureResponsePolicy

cut

public OMGraphicList cut(OMGraphicList omgl)
Remove OMGraphics from the layer.

Specified by:
cut in interface GestureResponsePolicy

copy

public OMGraphicList copy(OMGraphicList omgl)
Return a copy of OMGraphics.

Specified by:
copy in interface GestureResponsePolicy

paste

public void paste(OMGraphicList omgl)
Add OMGraphics to the Layer.

Specified by:
paste in interface GestureResponsePolicy

getInfoText

public java.lang.String getInfoText(OMGraphic omg)
If applicable, should return a short, informational string about the OMGraphic to be displayed in the InformationDelegator. Return null if nothing should be displayed.

Specified by:
getInfoText in interface GestureResponsePolicy

getToolTipTextFor

public java.lang.String getToolTipTextFor(OMGraphic omg)
If applicable, should return a tool tip for the OMGraphic. Return null if nothing should be shown.

Specified by:
getToolTipTextFor in interface GestureResponsePolicy

getItemsForMapMenu

public java.util.List<java.awt.Component> getItemsForMapMenu(MapMouseEvent mme)
Return a JMenu with contents applicable to a pop-up menu for a location over the map. The pop-up doesn't concern any OMGraphics, and should be presented for a click on the map background.

Specified by:
getItemsForMapMenu in interface GestureResponsePolicy
Parameters:
mme - a MapMouseEvent describing the location over where the menu items should apply, in case different options are appropriate for different places.
Returns:
a JMenu for the map. Return null or empty List if no input required.

getItemsForOMGraphicMenu

public java.util.List<java.awt.Component> getItemsForOMGraphicMenu(OMGraphic omg)
Return a java.util.List containing input for a JMenu with contents applicable to a pop-up menu for a location over an OMGraphic.

Specified by:
getItemsForOMGraphicMenu in interface GestureResponsePolicy
Returns:
a List containing options for the given OMGraphic. Return null or empty list if there are no options.

receivesMapEvents

public boolean receivesMapEvents()
A query from the MapMouseInterpreter wondering if the GestureResponsePolicy wants events pertaining to mouse movements over the map that are not over an OMGraphic. If the GestureResponsePolicy responds true, then the mouseOver and leftClick methods will be called on the GestureResponsePolicy by the interpreter. There is no rightClick method that is called, because a right click will always cause a getItemsForMapMenu() method to be called.

Specified by:
receivesMapEvents in interface GestureResponsePolicy

mouseOver

public boolean mouseOver(MapMouseEvent mme)
A notification that the mouse cursor has been moved over the map, not over any of the OMGraphics on the GestureResponsePolicy. This only gets called if the response to receiveMapEvents is true.

Specified by:
mouseOver in interface GestureResponsePolicy
Parameters:
mme - MapMouseEvent describing the location of the mouse.
Returns:
true of this information is to be considered consumed and should not be passed to anybody else.

leftClick

public boolean leftClick(MapMouseEvent mme)
A notification that the mouse has been clicked with the left mouse button on the map, and not on any of the OMGraphics. This only gets called if the response to receiveMapEvents is true. Right clicks on the map are always reported to the getItemsForMapMenu method.

Specified by:
leftClick in interface GestureResponsePolicy
Parameters:
mme - MapMouseEvent describing the location of the mouse.
Returns:
true of this information is to be considered consumed and should not be passed to anybody else.

getTransparencyAdjustmentPanel

public javax.swing.JPanel getTransparencyAdjustmentPanel(java.lang.String label,
                                                         int orientation,
                                                         float initialValue)
Create a JPanel that has a slider to control the layer transparency. An action listener that calls layer repaint() when the value changes will be added to the slider.

Parameters:
label - the label for the panel around the slider.
orientation - JSlider.HORIZONTAL/JSlider.VERTICAL
initialValue - an initial transparency value between 0-1, 0 being clear.
Returns:
JPanel with controls for transparency setting.

getRedrawButton

public javax.swing.JButton getRedrawButton(java.lang.String tooltip)

getSettingsButton

public javax.swing.JButton getSettingsButton(java.lang.String tooltip)

getDefaultSettingsPanel

public javax.swing.JPanel getDefaultSettingsPanel(java.lang.Class<?> clss,
                                                  float opaquenessSetting)
Get a default settings panel that contains the layer transparency setting, the settings button and a layer refresh button.

Parameters:
clss - The class for i18n translations
opaquenessSetting - The current opaqueness setting, as some fraction of 255. 1 is opaque.
Returns:
JPanel with the components all laid out.

setTransparency

public void setTransparency(float value)
Set the transparency of the layer. This transparency is applied during rendering.

Parameters:
value - 0f for clear, 1f for opaque.

getTransparency

public float getTransparency()
Get the transparency value for this layer.

Returns:
1 if opaque, 0 for clear.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Override of Layer's actionPerformed method, adds the capability that calls doPrepare() if the layer is visible and it receives a RedrawCmd command. Also calls Layer.actionPerformed(ActionEvent).

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Overrides:
actionPerformed in class Layer


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