Class MapCanvas
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- oracle.spatial.network.nfe.vis.maps.core.MapCanvas
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.beans.PropertyChangeListener,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible
public class MapCanvas extends javax.swing.JPanel implements java.beans.PropertyChangeListenerMapCanvas provides a canvas component for displaying and interacting with various spatial data layers.
MapCanvas provides a physical real estate for displaying geospatial contents.
MapCanvas contains a LayerManager which manages all the data and interaction-related layers.
MapCanvas contains a SelectionManager, which manages currently selected spatial objects.
MapCanvas also contains a HoverManager, which keeps a reference to the spatial object currently in hover.
MapCanvas uses an animation based rendering model, where the entire scene is repeatedly rendered in a rapid-firing Swing timer based on a dynamically adjusted frame rate. When rendering each frame, MapCanvas will ask each layer to update its data and graphics model as necessary, then render its contents to the canvas.
MapCanvas uses a single Event manager to handle all input events, as well as feature selection/hover related events. In a nutshell, when MapCanvas intercepts a user or system event, it will poll each layer, asking if it is willing or able to handle the event. If a layer agrees to handle an event, then the layer's handleEvent() method is invoked. The event is then stopped from propagating further down to remaining layers.
MapCanvas also maintains the current map region, and keeps track of both the device size and query window size. When the map region is changed in any way, MapCanvas will notify each layer which can then react properly.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROGRESS_INDETERMINATEstatic java.lang.StringPROGRESS_STATEstatic java.lang.StringPROGRESS_STRINGstatic java.lang.StringPROGRESS_VALUE-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description MapCanvas()MapCanvas(LayerManager layerManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactuallySetCursor()Calls the Component superclass setCursor() methodvoidaddChangeListener(javax.swing.event.ChangeListener l)Adds a change listener to listen for queryWindow changes.protected voidfireStateChanged()CoreLoopgetCoreLoop()Gets the instance of Core Loop used by this canvas.EventManagergetEventManager()Gets the Event Manager instance used by this canvas.java.awt.FramegetFrameForDialog()Gets the containing frameLayerManagergetLayerManager()Returns the LayerManager associated with this canvas.MapRegiongetMapRegion()Returns the current MapRegionlonggetPaintTime()Returns the time spent on painting the last framejavax.swing.JPopupMenugetPopupMenu()Gets the current pop up menu associated to this canvas (if any)javax.swing.JProgressBargetProgressBar()ProgressIndicatorLayergetProgressIndicator()Returns the currentProgressIndicatorLayerassociated to the MapCanvasMapUndoManagergetUndoManager()Returns the UndoManager associated with this canvas.java.awt.geom.AffineTransformgetViewportTransform()A convenience method to get the viewport transformation matrix of the current map region.protected voidpaintComponent(java.awt.Graphics g)Paint the canvas.voidpropertyChange(java.beans.PropertyChangeEvent evt)voidpropertyChange(java.lang.Object src, java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)This method gets called when a bound property is changed.voidremoveChangeListener(javax.swing.event.ChangeListener l)Removes the given listener from listening for queryWindow changesvoidsetCoreLoop(CoreLoop loop)Sets the Core Loop instance to be used by this canvas.voidsetCursor(java.awt.Cursor cursor)voidsetEventManager(EventManager eventManager)Sets the Event Manager instance to be used by this canvas.voidsetLayerManager(LayerManager layerManager)Sets a LayerManager on this canvas.voidsetMapRegion(MapRegion mapRegion)Sets the MapRegionvoidsetPopupMenu(javax.swing.JPopupMenu popUpMenu)Sets a pop up menu to the canvasvoidsetUndoManager(MapUndoManager undoManager)Sets an UndoManager on this canvas.voidupdate(long elapsedTime)Update all graphics contents as necessary before repainting the next frame.voidzoomToLayer(Layer layer)Zoom the map to the bounding box of the specified layer's contents.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, 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
-
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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
PROGRESS_STATE
public static final java.lang.String PROGRESS_STATE
- See Also:
- Constant Field Values
-
PROGRESS_VALUE
public static final java.lang.String PROGRESS_VALUE
- See Also:
- Constant Field Values
-
PROGRESS_STRING
public static final java.lang.String PROGRESS_STRING
- See Also:
- Constant Field Values
-
PROGRESS_INDETERMINATE
public static final java.lang.String PROGRESS_INDETERMINATE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MapCanvas
public MapCanvas()
-
MapCanvas
public MapCanvas(LayerManager layerManager)
-
-
Method Detail
-
setCursor
public void setCursor(java.awt.Cursor cursor)
- Overrides:
setCursorin classjava.awt.Component
-
actuallySetCursor
public void actuallySetCursor()
Calls the Component superclass setCursor() method
-
getFrameForDialog
public java.awt.Frame getFrameForDialog()
Gets the containing frame- Returns:
- a Frame instance
-
paintComponent
protected void paintComponent(java.awt.Graphics g)
Paint the canvas.- Overrides:
paintComponentin classjavax.swing.JComponent
-
getPaintTime
public long getPaintTime()
Returns the time spent on painting the last frame- Returns:
-
update
public void update(long elapsedTime)
Update all graphics contents as necessary before repainting the next frame.- Parameters:
elapsedTime- the elapsed time since last update, in milliseconds
-
getLayerManager
public LayerManager getLayerManager()
Returns the LayerManager associated with this canvas. Use the LayerManager to add or remove a layer.- Returns:
- the LayerManager associated.
-
setLayerManager
public void setLayerManager(LayerManager layerManager)
Sets a LayerManager on this canvas.- Parameters:
layerManager-
-
getUndoManager
public MapUndoManager getUndoManager()
Returns the UndoManager associated with this canvas. Use to keep track of changes.- Returns:
- the UndoManager associated.
-
setUndoManager
public void setUndoManager(MapUndoManager undoManager)
Sets an UndoManager on this canvas.- Parameters:
undoManager-
-
getMapRegion
public MapRegion getMapRegion()
Returns the current MapRegion- Returns:
-
setMapRegion
public void setMapRegion(MapRegion mapRegion)
Sets the MapRegion- Parameters:
mapRegion-
-
getViewportTransform
public java.awt.geom.AffineTransform getViewportTransform()
A convenience method to get the viewport transformation matrix of the current map region. Same as calling getMapRegion.getViewportTransform(). A viewport transformation defines the mapping from a rectangular region (or window) of the world-coordinate system onto a rectangular region on the device (in this case, this canvas). In computer graphics terms it is also known as the window-to-viewport transformation.
-
getProgressIndicator
public ProgressIndicatorLayer getProgressIndicator()
Returns the currentProgressIndicatorLayerassociated to the MapCanvas- Returns:
-
zoomToLayer
public void zoomToLayer(Layer layer)
Zoom the map to the bounding box of the specified layer's contents.- Parameters:
layer- the layer whose data MBR will be zoomed to.
-
getEventManager
public EventManager getEventManager()
Gets the Event Manager instance used by this canvas.- Returns:
-
setEventManager
public void setEventManager(EventManager eventManager)
Sets the Event Manager instance to be used by this canvas.- Parameters:
eventManager-
-
getCoreLoop
public CoreLoop getCoreLoop()
Gets the instance of Core Loop used by this canvas.- Returns:
-
setCoreLoop
public void setCoreLoop(CoreLoop loop)
Sets the Core Loop instance to be used by this canvas.- Parameters:
loop-
-
setPopupMenu
public void setPopupMenu(javax.swing.JPopupMenu popUpMenu)
Sets a pop up menu to the canvas- Parameters:
popUpMenu-
-
getPopupMenu
public javax.swing.JPopupMenu getPopupMenu()
Gets the current pop up menu associated to this canvas (if any)- Returns:
-
addChangeListener
public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a change listener to listen for queryWindow changes.- Parameters:
l-
-
removeChangeListener
public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes the given listener from listening for queryWindow changes- Parameters:
l-
-
fireStateChanged
protected void fireStateChanged()
-
propertyChange
public void propertyChange(java.lang.Object src, java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)This method gets called when a bound property is changed.- Parameters:
source- the bean that fired the eventpropertyName- the programmatic name of the property that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener
-
getProgressBar
public javax.swing.JProgressBar getProgressBar()
-
-