Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.layer
Class OMGraphicHandlerLayer

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  com.bbn.openmap.Layer
                      com.bbn.openmap.layer.OMGraphicHandlerLayer

All Implemented Interfaces:
  java.awt.event.ActionListener, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.util.EventListener, GestureResponsePolicy, java.awt.image.ImageObserver, java.awt.MenuContainer, ProjectionListener, ProjectionPainter, PropertyConsumer, java.io.Serializable

Direct Known Subclasses:
  ASRPLayer, BasicLayer, DayNightLayer, DemoLayer, DrawingToolLayer, DTEDCoverageLayer, DTEDFrameCacheLayer, E00Layer, EarthquakeLayer, EsriLayer, ETOPOLayer, GraticuleLayer, ImageTileLayer, LabelLayer, LinkLayer, MIFLayer, MysqlGeometryLayer, NexradLayer, PlotLayer, PlugInLayer, RpfLayer, ScaleDisplayLayer, ShapeLayer, TerrainLayer, TestLayer, VPFLayer

public class OMGraphicHandlerLayer
extends Layer
implements GestureResponsePolicy

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 inherited from class javax.swing.JComponent
`javax.swing.JComponent.AccessibleJComponent`

Nested classes inherited from class java.awt.Container
`java.awt.Container.AccessibleAWTContainer`

Nested classes inherited from class java.awt.Component
`java.awt.Component.AccessibleAWTComponent, 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 SwingWorker` | `layerWorker` A SwingWorker that can be used for gathering OMGraphics or doing other work in a different thread.
`protected java.lang.Object` | `LAYERWORKER_LOCK` Set when the something has changed while a swing worker is gathering graphics, and we want it to stop early.
`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, DisplayPaletteCmd, DisplayPropertiesCmd, doHack, HidePaletteCmd, i18n, IDListeners, localHackList, lsListeners, maxScale, MaxScaleProperty, minScale, MinScaleProperty, palette, paletteListener, PrettyNameProperty, propertyPrefix, RedrawCmd, removable, RemovableProperty, SWING_PACKAGE, 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
`boolean` | `canSetList()` Indicates if the OMGraphicHandler can have its OMGraphicList set.
`OMGraphicList` | `copy(OMGraphicList omgl)` Return a copy of an OMGraphic.
`protected SwingWorker` | `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 deselected.
`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)`
`OMGraphicList` | `filter(java.lang.String SQLQuery)` Depending on the filter's SQL support, returns an OMGraphicList that fit the query.
`boolean` | `getConsumeEvents()`
`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` | `getItemsForMapMenu(MapMouseEvent mme)` Return a JMenu with contents applicable to a popup menu for a location over the map.
`java.util.List` | `getItemsForOMGraphicMenu(OMGraphic omg)` Return a java.util.List containing input for a JMenu with contents applicable to a popup menu for a location over an OMGraphic.
`protected SwingWorker` | `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.
`RenderPolicy` | `getRenderPolicy()` Get the RenderPolicy that determines how an OMGraphicList is rendered.
`OMGraphicList` | `getSelected()` Retrieve the list of currently selected OMGraphics.
`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.
`protected void` | `interrupt()`
`boolean` | `isCancelled()` Check to see if the cancelled flag has been set.
`boolean` | `isHighlightable(OMGraphic omg)` Query asking if OMGraphic is highlightable, 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 interruptable flag.
`boolean` | `isSelectable(OMGraphic omg)` Query asking if an OMGraphic is selectable, or able to be moved, deleted or otherwise modified.
`boolean` | `isWorking()` A check to see if the SwingWorker 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` | `setCancelled(boolean set)` Used to set the cancelled flag in the layer.
`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 interruptable flag
`protected void` | `setLayerWorker(SwingWorker 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(com.bbn.openmap.layer.OMGraphicHandlerLayer.LayerWorker worker)` The LayerWorker calls this method on the layer when it is done working.

Methods inherited from class com.bbn.openmap.Layer
`actionPerformed, addComponentListener, added, addInfoDisplayListener, addLayerStatusListener, addMouseListener, addVetoableChangeListener, childrenAdded, childrenRemoved, clearListeners, connectToBeanContext, createWindowSupport, 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, getGUI, getIcon, getMaxScale, getMinScale, getPackage, getPalette, getProjection, getPropertyPrefix, getWindowSupport, hasGUI, hidePalette, isAutoPalette, isProjectionOK, isRemovable, notifyHideHack, putAttribute, removeComponentListener, removeConfirmed, removed, removeInfoDisplayListener, removeLayerStatusListener, removeVetoableChangeListener, repaint, resetPalette, setAddAsBackground, setAddToBeanContext, setAutoPalette, setBeanContext, setIcon, setMaxScale, setMinScale, setName, setPaletteVisible, setProjection, setProjection, setProperties, setPropertyPrefix, setRemovable, setVisible, setWindowSupport, showPalette`

Methods inherited from class javax.swing.JComponent
`addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

### 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 SwingWorker layerWorker

  A SwingWorker that can be used for gathering OMGraphics or doing other work in a different thread.

### 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 is occuring.

### interruptable

    protected boolean interruptable

  Flag used to avoid the SwingWorker to be interrupted. Usefull 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

  Set when the something has changed while a swing worker is gathering graphics, and we want it to stop early.

### mouseEventInterpreter

    protected MapMouseInterpreter mouseEventInterpreter

  The MapMouseInterpreter used to catch the MapMouseEvents and direct them to layer as referencing certain OMGraphics. Mananges 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 interruptable flag

### isInterruptable

    public boolean isInterruptable()

  Queries for the interruptable flag.

  Returns:

### 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.

### filter

    public OMGraphicList filter(java.awt.Shape shapeBoundary,
                                boolean getInsideBoundary)

  See Also:
    `OMGraphicHandler.filter(Shape, boolean).`

### supportsSQL

    public boolean supportsSQL()

  To find out whether SQL queries are handled.

  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.

### doAction

    public boolean doAction(OMGraphic graphic,
                            OMAction action)

  Perform the OMAction on the OMGraphic, within the OMGraphicList contained in the layer.

### getList

    public OMGraphicList getList()

  Get the OMGraphicList held by the layer. May be null.

### canSetList

    public boolean canSetList()

  Indicates if the OMGraphicHandler can have its OMGraphicList set.

### setList

    public void setList(OMGraphicList omgl)

  Set the OMGraphicList within this OMGraphicHandler. Works if canSetGraphicList == true.

### resetFiltering

    public void resetFiltering()

  Remove all filters, and reset all graphics to be visible.

### 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.

### interrupt

    protected void interrupt()

### setLayerWorker

    protected void setLayerWorker(SwingWorker 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 SwingWorker getLayerWorker()

### createLayerWorker

    protected SwingWorker 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

### 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.

  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 SwingWorker 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, reprojects 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.

### setCancelled

    public void setCancelled(boolean set)

  Used to set the cancelled flag in the layer. The swing worker checks this once in a while to see if the projection has changed since it started working. If this is set to true, the swing worker quits when it is safe.

### isCancelled

    public boolean isCancelled()

  Check to see if the cancelled flag has been set.

### workerComplete

    protected void workerComplete(com.bbn.openmap.layer.OMGraphicHandlerLayer.LayerWorker 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.

### 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 and are PropertyConsumers, 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.

  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

### 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 is occuring.

### 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 highlightable, 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 selectable, 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 deselected.

  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 an OMGraphic. Not implemented yet.

  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 getItemsForMapMenu(MapMouseEvent mme)

  Return a JMenu with contents applicable to a popup menu for a location over the map. The popup 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 getItemsForOMGraphicMenu(OMGraphic omg)

  Return a java.util.List containing input for a JMenu with contents applicable to a popup 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:

### 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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