|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.bbn.openmap.Layer
com.bbn.openmap.layer.OMGraphicHandlerLayer
public class OMGraphicHandlerLayer
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
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 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 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 |
---|
public static java.util.logging.Logger logger
public static final java.lang.String ProjectionChangePolicyProperty
ProjectionChangePolicy
,
StandardPCPolicy
,
ListResetPCPolicy
,
Constant Field Valuespublic static final java.lang.String RenderPolicyProperty
StandardRenderPolicy
,
BufferedImageRenderPolicy
,
RenderingHintsRenderPolicy
,
Constant Field Valuespublic static final java.lang.String MouseModesProperty
public static final java.lang.String ConsumeEventsProperty
public static final java.lang.String TransparencyProperty
public static final java.lang.String InterruptableProperty
protected FilterSupport filter
protected ProjectionChangePolicy projectionChangePolicy
protected RenderPolicy renderPolicy
protected ISwingWorker<OMGraphicList> layerWorker
protected boolean layerWorkerQueue
protected java.lang.String[] mouseModeIDs
protected boolean consumeEvents
protected boolean interruptable
protected final java.lang.Object LAYERWORKER_LOCK
protected MapMouseInterpreter mouseEventInterpreter
protected OMGraphicList selectedList
Constructor Detail |
---|
public OMGraphicHandlerLayer()
Method Detail |
---|
public void setInterruptable(boolean b)
public boolean isInterruptable()
public OMGraphicList filter(java.awt.Shape withinThisShape)
filter
in interface OMGraphicHandler
withinThisShape
- java.awt.Shape object defining a
boundary.
public OMGraphicList filter(java.awt.Shape shapeBoundary, boolean getInsideBoundary)
OMGraphicHandler
filter
in interface OMGraphicHandler
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.
OMGraphicHandler.filter(Shape, boolean).
public boolean supportsSQL()
supportsSQL
in interface OMGraphicHandler
OMGraphicHandler.supportsSQL().
public OMGraphicList filter(java.lang.String SQLQuery)
filter
in interface OMGraphicHandler
SQLQuery
- a SELECT SQL statement
public boolean doAction(OMGraphic graphic, OMAction action)
doAction
in interface OMGraphicHandler
graphic
- the OMGraphic to do the action on.action
- the OMAction describing what to do to the
graphic.
public OMGraphicList getList()
getList
in interface OMGraphicHandler
OMGeometry.isVisible()
public boolean canSetList()
canSetList
in interface OMGraphicHandler
public void setList(OMGraphicList omgl)
setList
in interface OMGraphicHandler
public void resetFiltering()
resetFiltering
in interface OMGraphicHandler
public void setFilter(FilterSupport fs)
public FilterSupport getFilter()
public void projectionChanged(ProjectionEvent pe)
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.
projectionChanged
in interface ProjectionListener
pe
- ProjectionEventProjectionChangePolicy
,
StandardPCPolicy
,
ListResetPCPolicy
public ProjectionChangePolicy getProjectionChangePolicy()
public void setProjectionChangePolicy(ProjectionChangePolicy pcp)
public RenderPolicy getRenderPolicy()
public void setRenderPolicy(RenderPolicy rp)
protected void setLayerWorker(ISwingWorker<OMGraphicList> worker)
worker
- null to reset the layerWorker variable, or a SwingWorker to
start up.protected ISwingWorker<OMGraphicList> getLayerWorker()
protected ISwingWorker<OMGraphicList> createLayerWorker()
public void dispose()
dispose
in class Layer
public void renderDataForProjection(Projection proj, java.awt.Graphics g)
If the layer doesn't override this method, then the paint(Graphics) method will be called.
renderDataForProjection
in interface ProjectionPainter
renderDataForProjection
in class Layer
proj
- Projection of the map.g
- java.awt.Graphics to draw into.public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
g
- java.awt.Graphics object to render OMGraphics into.public void doPrepare()
public boolean isWorking()
public OMGraphicList prepare()
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.
public boolean isCancelled()
protected void workerComplete(ISwingWorker<OMGraphicList> worker)
worker
- the worker that has the graphics, must not be null.public void setProperties(java.lang.String prefix, java.util.Properties props)
setProperties
in interface PropertyConsumer
setProperties
in class Layer
prefix
- the token to prefix the property namesprops
- the Properties
objectpublic java.util.Properties getProperties(java.util.Properties props)
getProperties
in interface PropertyConsumer
getProperties
in class Layer
props
- a Properties object to load the PropertyConsumer properties
into. If props equals null, then a new Properties object should be
created.
public java.util.Properties getPropertyInfo(java.util.Properties list)
getPropertyInfo
in interface PropertyConsumer
getPropertyInfo
in class Layer
list
- a Properties object to load the PropertyConsumer properties
into. If getList equals null, then a new Properties object should
be created.
public void setMouseEventInterpreter(MapMouseInterpreter mmi)
public MapMouseInterpreter getMouseEventInterpreter()
public MapMouseListener getMapMouseListener()
getMapMouseListener
in class Layer
public void setConsumeEvents(boolean consume)
public boolean getConsumeEvents()
public java.lang.String[] getMouseModeIDsForEvents()
public void setMouseModeIDsForEvents(java.lang.String[] mm)
public boolean isHighlightable(OMGraphic omg)
isHighlightable
in interface GestureResponsePolicy
public boolean isSelectable(OMGraphic omg)
isSelectable
in interface GestureResponsePolicy
public OMGraphicList getSelected()
getSelected
in interface GestureResponsePolicy
public void highlight(OMGraphic omg)
highlight
in interface GestureResponsePolicy
public void unhighlight(OMGraphic omg)
unhighlight
in interface GestureResponsePolicy
public void select(OMGraphicList list)
select
in interface GestureResponsePolicy
public void deselect(OMGraphicList list)
deselect
in interface GestureResponsePolicy
public OMGraphicList cut(OMGraphicList omgl)
cut
in interface GestureResponsePolicy
public OMGraphicList copy(OMGraphicList omgl)
copy
in interface GestureResponsePolicy
public void paste(OMGraphicList omgl)
paste
in interface GestureResponsePolicy
public java.lang.String getInfoText(OMGraphic omg)
getInfoText
in interface GestureResponsePolicy
public java.lang.String getToolTipTextFor(OMGraphic omg)
getToolTipTextFor
in interface GestureResponsePolicy
public java.util.List<java.awt.Component> getItemsForMapMenu(MapMouseEvent mme)
getItemsForMapMenu
in interface GestureResponsePolicy
mme
- a MapMouseEvent describing the location over where the menu
items should apply, in case different options are appropriate for
different places.
public java.util.List<java.awt.Component> getItemsForOMGraphicMenu(OMGraphic omg)
getItemsForOMGraphicMenu
in interface GestureResponsePolicy
public boolean receivesMapEvents()
receivesMapEvents
in interface GestureResponsePolicy
public boolean mouseOver(MapMouseEvent mme)
mouseOver
in interface GestureResponsePolicy
mme
- MapMouseEvent describing the location of the mouse.
public boolean leftClick(MapMouseEvent mme)
leftClick
in interface GestureResponsePolicy
mme
- MapMouseEvent describing the location of the mouse.
public javax.swing.JPanel getTransparencyAdjustmentPanel(java.lang.String label, int orientation, float initialValue)
label
- the label for the panel around the slider.orientation
- JSlider.HORIZONTAL/JSlider.VERTICALinitialValue
- an initial transparency value between 0-1, 0 being clear.
public javax.swing.JButton getRedrawButton(java.lang.String tooltip)
public javax.swing.JButton getSettingsButton(java.lang.String tooltip)
public javax.swing.JPanel getDefaultSettingsPanel(java.lang.Class<?> clss, float opaquenessSetting)
clss
- The class for i18n translationsopaquenessSetting
- The current opaqueness setting, as some fraction of 255. 1 is
opaque.
public void setTransparency(float value)
value
- 0f for clear, 1f for opaque.public float getTransparency()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
actionPerformed
in class Layer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |