public class MapView extends NavigatableComponent implements java.beans.PropertyChangeListener, Preferences.PreferenceChangedListener, LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener
MapFrame
for browsing the map. It use is to
provide the MapMode's enough capabilities to operate.MapView
holds meta-data about the data set currently displayed, as scale level,
center point viewed, what scrolling mode or editing mode is selected or with
what projection the map is viewed etc..MapView
is able to administrate several layers.Modifier and Type | Class and Description |
---|---|
private class |
MapView.LayerInvalidatedListener
An invalidation listener that simply calls repaint() for now.
|
static interface |
MapView.RepaintListener
This is a listener that gets informed whenever repaint is called for this MapView.
|
private static class |
MapView.WarningLayerPainter
A layer painter that issues a warning when being called.
|
NavigatableComponent.ZoomChangeListener
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
private MapView.LayerInvalidatedListener |
invalidatedListener
The listener that listens to invalidations of all layers.
|
private java.awt.Rectangle |
lastClipBounds |
java.awt.event.MouseEvent |
lastMEvent
The last event performed by mouse.
|
private int |
lastViewID |
private MainLayerManager |
layerManager
A list of all layers currently loaded.
|
private MapMover |
mapMover |
private java.util.List<Layer> |
nonChangedLayers |
private java.awt.image.BufferedImage |
nonChangedLayersBuffer |
private java.awt.image.BufferedImage |
offscreenBuffer |
private java.awt.Point |
oldLoc |
private java.awt.Dimension |
oldSize |
private java.util.concurrent.atomic.AtomicBoolean |
paintPreferencesChanged |
PlayHeadMarker |
playHeadMarker
The play head marker: there is only one of these so it isn't in any specific layer
|
private java.util.HashMap<Layer,MapViewPaintable.LayerPainter> |
registeredLayers
This is a map of all Layers that have been added to this view.
|
private java.util.concurrent.CopyOnWriteArrayList<MapView.RepaintListener> |
repaintListeners |
private SelectionChangedListener |
repaintSelectionChangedListener |
private java.util.Set<MapViewPaintable> |
temporaryLayers
Temporary layers (selection rectangle, etc.) that are never cached and
drawn on top of regular layers.
|
boolean |
viewportFollowing |
private boolean |
virtualNodesEnabled |
cursorManager, initialViewport, isSelectablePredicate, PROP_SNAP_DISTANCE, PROP_ZOOM_INTERMEDIATE_STEPS, PROP_ZOOM_RATIO, PROPNAME_CENTER, PROPNAME_SCALE
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
MapView(MainLayerManager layerManager,
javax.swing.JPanel contentPane,
ViewportData viewportData)
Constructs a new
MapView . |
Modifier and Type | Method and Description |
---|---|
void |
activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Called whenever the active or edit layer changed.
|
void |
addRepaintListener(MapView.RepaintListener l)
Adds a listener that gets informed whenever repaint() is called for this class.
|
boolean |
addTemporaryLayer(MapViewPaintable mvp)
Adds a new temporary layer.
|
void |
destroy()
Destroy this map view panel.
|
private void |
drawTemporaryLayers(java.awt.Graphics2D tempG,
Bounds box) |
private void |
drawWorldBorders(java.awt.Graphics2D tempG) |
java.lang.String |
getLayerInformationForSourceTag()
Get a string representation of all layers suitable for the
source changeset tag. |
MainLayerManager |
getLayerManager()
Returns the layer manager.
|
static java.util.List<? extends javax.swing.JComponent> |
getMapNavigationComponents(MapView forMapView)
Adds the map navigation components to a
|
java.util.List<MapViewPaintable> |
getTemporaryLayers()
Gets a list of temporary layers.
|
boolean |
isActiveLayerDrawable()
Replies true if the active data layer (edit layer) is drawable.
|
boolean |
isActiveLayerVisible()
Replies true if the active data layer (edit layer) is visible.
|
boolean |
isVirtualNodesEnabled()
Checks if virtual nodes should be drawn.
|
void |
layerAdded(LayerManager.LayerAddEvent e)
Notifies this listener that a layer has been added.
|
void |
layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Notifies this listener that the order of layers was changed.
|
void |
layerRemoving(LayerManager.LayerRemoveEvent e)
Notifies this listener that a alayer was just removed.
|
void |
moveLayer(Layer layer,
int pos)
Moves the layer to the given new position.
|
void |
paint(java.awt.Graphics g)
Draw the component.
|
void |
paintLayer(Layer layer,
java.awt.Graphics2D g)
Paints the given layer to the graphics object, using the current state of this map view.
|
void |
preferenceChanged(Preferences.PreferenceChangeEvent e)
Trigerred when a preference entry value changes.
|
boolean |
prepareToDraw()
Sets up the viewport to prepare for drawing the view.
|
void |
propertyChange(java.beans.PropertyChangeEvent evt) |
void |
rememberLastPositionOnScreen()
Call this method to keep map position on screen during next repaint
|
void |
removeRepaintListener(MapView.RepaintListener l)
Removes a registered repaint listener.
|
boolean |
removeTemporaryLayer(MapViewPaintable mvp)
Removes a layer previously added as temporary layer.
|
void |
repaint() |
void |
repaint(long tm,
int x,
int y,
int width,
int height) |
void |
scheduleZoomTo(ViewportData viewportData)
Schedule a zoom to the given position on the next redraw.
|
void |
setVirtualNodesEnabled(boolean enabled) |
addNotify, addZoomChangeListener, fireZoomChanged, fixProjection, getAffineTransform, getAllNearest, getAllNearest, getCenter, getCursorManager, getDist100Pixel, getDist100Pixel, getDist100PixelText, getDistText, getDistText, getEastNorth, getLatLon, getLatLon, getLatLonBounds, getMaxProjectionBounds, getMaxScale, getNativeScaleLayer, getNearestNode, getNearestNode, getNearestNode, getNearestNodeOrWay, getNearestNodes, getNearestNodes, getNearestNodesOrWays, getNearestNodesOrWays, getNearestWay, getNearestWays, getNearestWays, getNearestWaySegment, getNearestWaySegment, getNearestWaySegment, getNearestWaySegments, getNearestWaySegments, getPoint, getPoint, getPoint, getPoint2D, getPoint2D, getPoint2D, getProjection, getProjectionBounds, getProjectionBounds, getRealBounds, getScale, getState, getViewID, hasZoomRedoEntries, hasZoomUndoEntries, helpTopic, isVisibleOnScreen, project, removeNotify, removeZoomChangeListener, resetCursor, scaleFloor, scaleRound, scaleSnap, scaleZoomIn, scaleZoomManyTimes, scaleZoomOut, setNativeScaleLayer, setNewCursor, setNewCursor, smoothScrollTo, updateLocationState, zoomIn, zoomManyTimes, zoomNext, zoomOut, zoomPrevious, zoomTo, zoomTo, zoomTo, zoomTo, zoomTo, zoomTo, zoomTo, zoomTo, zoomToFactor, zoomToFactor, zoomToFactor
addAncestorListener, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, setVisible, unregisterKeyboardAction, update, updateUI
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
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, getAccessibleContext, 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, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public boolean viewportFollowing
private final MainLayerManager layerManager
public transient PlayHeadMarker playHeadMarker
public java.awt.event.MouseEvent lastMEvent
private final transient java.util.Set<MapViewPaintable> temporaryLayers
private transient java.awt.image.BufferedImage nonChangedLayersBuffer
private transient java.awt.image.BufferedImage offscreenBuffer
private final transient java.util.List<Layer> nonChangedLayers
private int lastViewID
private final java.util.concurrent.atomic.AtomicBoolean paintPreferencesChanged
private java.awt.Rectangle lastClipBounds
private final MapView.LayerInvalidatedListener invalidatedListener
private final java.util.HashMap<Layer,MapViewPaintable.LayerPainter> registeredLayers
private java.awt.Dimension oldSize
private java.awt.Point oldLoc
private boolean virtualNodesEnabled
private final transient SelectionChangedListener repaintSelectionChangedListener
private final transient java.util.concurrent.CopyOnWriteArrayList<MapView.RepaintListener> repaintListeners
public MapView(MainLayerManager layerManager, javax.swing.JPanel contentPane, ViewportData viewportData)
MapView
.layerManager
- The layers to display.contentPane
- Ignored. Main content pane is used.viewportData
- the initial viewport of the map. Can be null, then
the viewport is derived from the layer data.public static java.util.List<? extends javax.swing.JComponent> getMapNavigationComponents(MapView forMapView)
forMapView
- The map view to get the components for.public void rememberLastPositionOnScreen()
public void layerAdded(LayerManager.LayerAddEvent e)
LayerManager.LayerChangeListener
Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
layerAdded
in interface LayerManager.LayerChangeListener
e
- The new added layer eventpublic boolean isActiveLayerDrawable()
public boolean isActiveLayerVisible()
public void layerRemoving(LayerManager.LayerRemoveEvent e)
LayerManager.LayerChangeListener
Listeners are called in the EDT thread after the layer was removed.
Use LayerManager.LayerRemoveEvent.scheduleRemoval(Collection)
to remove more layers.
You should not do blocking or long-running tasks in this method.
layerRemoving
in interface LayerManager.LayerChangeListener
e
- The layer to be removed (as event)public void setVirtualNodesEnabled(boolean enabled)
public boolean isVirtualNodesEnabled()
false
Rendering.render(DataSet, boolean, Bounds)
public void moveLayer(Layer layer, int pos)
layer
- The layer to movepos
- The new position of the layerpublic void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
LayerManager.LayerChangeListener
Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
layerOrderChanged
in interface LayerManager.LayerChangeListener
e
- The order change event.public void paintLayer(Layer layer, java.awt.Graphics2D g)
layer
- The layer to draw.g
- A graphics object. It should have the width and height of this componentjava.lang.IllegalArgumentException
- If the layer is not part of this map view.public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
private void drawTemporaryLayers(java.awt.Graphics2D tempG, Bounds box)
private void drawWorldBorders(java.awt.Graphics2D tempG)
public boolean prepareToDraw()
true
if the view can be drawn, false
otherwise.public void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
MainLayerManager.ActiveLayerChangeListener
You can be sure that this layer is still contained in this set.
Listeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
activeOrEditLayerChanged
in interface MainLayerManager.ActiveLayerChangeListener
e
- The change event.public boolean addTemporaryLayer(MapViewPaintable mvp)
A temporary layer is a layer that is painted above all normal layers. Layers are painted in the order they are added.
mvp
- The layer to paint.true
if the layer was added.public boolean removeTemporaryLayer(MapViewPaintable mvp)
mvp
- The layer to remove.true
if that layer was removed.public java.util.List<MapViewPaintable> getTemporaryLayers()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
public void preferenceChanged(Preferences.PreferenceChangeEvent e)
Preferences.PreferenceChangedListener
preferenceChanged
in interface Preferences.PreferenceChangedListener
e
- the preference change eventpublic void destroy()
public java.lang.String getLayerInformationForSourceTag()
source
changeset tag.public void addRepaintListener(MapView.RepaintListener l)
l
- The listener.public void removeRepaintListener(MapView.RepaintListener l)
l
- The listener.public void repaint(long tm, int x, int y, int width, int height)
repaint
in class javax.swing.JComponent
public void repaint()
repaint
in class java.awt.Component
public final MainLayerManager getLayerManager()
public void scheduleZoomTo(ViewportData viewportData)
viewportData
- the viewport to zoom to