com.esri.map
Class MapOverlay
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.esri.map.MapOverlay
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable
public abstract class MapOverlay
- extends JComponent
Inherit this class to create a component that can be used to alter or block
interactions with the map control and to paint on-top of the MapControl.
In the subclass, override each of the onMouseXXX methods for the mouse
functionality you wish to override. Any methods not overridden will pass
handling of the mouse event through to the parent of this instance. This will
either be another MapOverlay or the map control. If you wish to
allow the default map handling of mouse events in addition to your own
functionality, call the super class version of the method. Be aware that
map overlays higher up the stack can block events that are passed
from overlays lower down. This means that an application using multiple
interaction overlays will need careful design to give the expected behavior.
In addition to overriding the handling of mouse messages, subclasses of this
class can draw on top of the map by overriding the onPaint method.
To use your subclass, create an instance and call JMap.addMapOverlay(MapOverlay)
.
By default the subclass will be active. This means that it will be able to
draw itself and handle mouse events. To suspend the functionality of your
subclass, call setActive(false). Note that anything drawn by your subclass
will be hidden while the class is inactive.
- See Also:
- Serialized Form
Constructor Summary |
MapOverlay()
Default constructor. |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, 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, setVisible, 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, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, 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, removeComponentListener, 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, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
MapOverlay
public MapOverlay()
- Default constructor.
setActive
public void setActive(boolean active)
- Call this method to enable/disable handling of mouse messages in a
subclass.
- Parameters:
active
- Set true to handle mouse messages and draw on the map, false
to ignore mouse messages.
isActive
public boolean isActive()
- Checks if the overlay is active.
- Returns:
- True if handling mouse messages, false otherwise.
onMouseWheelMoved
public void onMouseWheelMoved(MouseWheelEvent event)
- Override to handle mouse wheel moved events. Call the superclass method
if you want to pass this event through to the overlay underneath this one
or to the map if this overlay is at the bottom of the stack. Note that
the override will not be called if isActive returns false.
- Parameters:
event
- Mouse wheel event parameters
onMouseDragged
public void onMouseDragged(MouseEvent event)
- Override to handle mouse dragged events. Call the superclass method if
you want to pass this event through to the overlay underneath this one or
to the map if this overlay is at the bottom of the stack. Note that the
override will not be called if isActive returns false.
- Parameters:
event
- Mouse dragged event parameters
onMouseMoved
public void onMouseMoved(MouseEvent event)
- Override to handle mouse moved events. Call the superclass method if you
want to pass this event through to the overlay underneath this one or to
the map if this overlay is at the bottom of the stack. Note that the
override will not be called if isActive returns false.
- Parameters:
event
- Mouse moved event parameters
onMouseClicked
public void onMouseClicked(MouseEvent event)
- Override to handle mouse clicked events. Call the superclass method if
you want to pass this event through to the overlay underneath this one or
to the map if this overlay is at the bottom of the stack. Note that the
override will not be called if isActive returns false.
- Parameters:
event
- Mouse clicked event parameters
onMouseEntered
public void onMouseEntered(MouseEvent event)
- Override to handle mouse entered events. Call the superclass method if
you want to pass this event through to the overlay underneath this one or
to the map if this overlay is at the bottom of the stack. Note that the
override will not be called if isActive returns false.
- Parameters:
event
- Mouse entered event parameters
onMouseExited
public void onMouseExited(MouseEvent event)
- Override to handle mouse exited events. Call the superclass method if you
want to pass this event through to the overlay underneath this one or to
the map if this overlay is at the bottom of the stack. Note that the
override will not be called if isActive returns false.
- Parameters:
event
- Mouse exited event parameters
onMousePressed
public void onMousePressed(MouseEvent event)
- Override to handle mouse pressed events. Call the superclass method if
you want to pass this event through to the overlay underneath this one or
to the map if this overlay is at the bottom of the stack. Note that the
override will not be called if isActive returns false.
- Parameters:
event
- Mouse pressed event parameters
onMouseReleased
public void onMouseReleased(MouseEvent event)
- Override to handle mouse released events. Call the superclass method if
you want to pass this event through to the overlay underneath this one or
to the map if this overlay is at the bottom of the stack. Note that the
override will not be called if isActive returns false.
- Parameters:
event
- Mouse released event parameters
onRemoved
public void onRemoved()
- Override to do any clean up required by the overlay when it is removed from the map.
paintComponent
protected void paintComponent(Graphics graphics)
- Overrides:
paintComponent
in class JComponent
onPaint
public void onPaint(Graphics graphics)
- Override to draw on top of the map. Note that the override will not be
called if isActive returns false.
- Parameters:
graphics
-
getMap
public JMap getMap()
- Gets the map that this overlay belongs to.
- Returns:
- Reference to the parent map.
getMouseMapPoint
protected Point getMouseMapPoint(Point2D mousePoint)
- Convenience method to allow subclasses to convert mouse point to a map
point.
- Parameters:
mousePoint
- Point at which mouse event occurred.
- Returns:
- Mouse point in map coordinates
setMap
protected void setMap(JMap map)
- Called internally by JMap when adding interaction overlays to the map.
Override this if you wish to add map event listeners. Remember to call
the superclass version of this method.
- Parameters:
map
-
Copyright © 2012. All Rights Reserved.