Class NavigatableComponent
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Helpful
- Direct Known Subclasses:
MapView
MapMover. Used as map view and for the
zoomer in the download dialog.- Since:
- 41
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classListener for mouse movement events.private classThread class for smooth scrolling.static interfaceInterface to notify listeners of the change of the zoom area.private static classNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleprivate final ComponentAdapterprotected final CursorManagerprivate final HierarchyListenerprotected ViewportDataTo determine if a primitive is currently selectable.private NativeScaleLayerThe layer which scale is set to.private IPrimitiveprivate final CopyOnWriteArrayList<PrimitiveHoverListener>private final NavigatableComponent.PrimitiveHoverMouseListenerprivate final ProjectionChangeListenerMain uses weak link to store this, so we need to keep a reference.static final IntegerPropertySnap distancestatic final BooleanPropertyDivide intervals between native resolution levels to smaller steps if they are much larger than zoom ratiostatic final DoublePropertyZoom steps to get double scalestatic final BooleanPropertyscale follows native resolution of layer status when layer is createdprivate MapViewStateThe current state (scale, center, ...) of this map view.private static final CopyOnWriteArrayList<NavigatableComponent.ZoomChangeListener>the zoom listenersprivate final Stack<NavigatableComponent.ZoomData>private longprivate final Stack<NavigatableComponent.ZoomData>Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidAdds a primitive hover listenerprivate voidstatic voidAdds a zoom change listenerprotected voidSend aPrimitiveHoverListener.PrimitiveHoverEventto registeredPrimitiveHoverListenersprotected static voidvoidChanges the projection settings used for this map view.Creates an affine transform that is used to convert the east/north coordinates to view coordinates.final List<OsmPrimitive>getAllNearest(Point p, Collection<OsmPrimitive> ignore, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.final List<OsmPrimitive>getAllNearest(Point p, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.private BBoxReturns the current center of the viewport.Gets the cursor manager that is used for this NavigatableComponent.doubleGet the distance in meter that correspond to 100 px on screen.doublegetDist100Pixel(boolean alwaysPositive) Get the distance in meter that correspond to 100 px on screen.Returns the text describing the distance in meter that correspond to 100 px on screen.static StringgetDistText(double dist) Returns the text describing the given distance in the current system of measurement.static StringgetDistText(double dist, NumberFormat format, double threshold) Returns the text describing the given distance in the current system of measurement.getEastNorth(int x, int y) Returns geographic coordinates from a specific pixel coordination on the screen.getLatLon(double x, double y) Returns unprojected geographic coordinates for a specific pixel position on the screen.getLatLon(int x, int y) Returns unprojected geographic coordinates for a specific pixel position on the screen.Returns minimum bounds that will cover a given rectangle.doubleGet a max scale for projection that describes world in 1/512 of the projection unitReplies the layer which scale is set to.final NodegetNearestNode(Point p, Predicate<OsmPrimitive> predicate) Convenience method togetNearestNode(Point, Predicate, boolean).final NodegetNearestNode(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) The *result* depends on the current map selection state IF use_selected is true.final NodegetNearestNode(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected, Collection<OsmPrimitive> preferredRefs) The *result* depends on the current map selection state IF use_selected is truefinal OsmPrimitivegetNearestNodeOrWay(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) The *result* depends on the current map selection state IF use_selected is true.getNearestNodes(Point p, Collection<Node> ignore, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.getNearestNodes(Point p, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.getNearestNodesImpl(Point p, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.final List<OsmPrimitive>getNearestNodesOrWays(Point p, Collection<OsmPrimitive> ignore, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.final List<OsmPrimitive>getNearestNodesOrWays(Point p, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.final WaygetNearestWay(Point p, Predicate<OsmPrimitive> predicate) The *result* depends on the current map selection state.getNearestWays(Point p, Collection<Way> ignore, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.getNearestWays(Point p, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.final WaySegmentgetNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate) Convenience method togetNearestWaySegment(Point, Predicate, boolean).final WaySegmentgetNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) The *result* depends on the current map selection state IF use_selected is true.final WaySegmentgetNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected, Collection<OsmPrimitive> preferredRefs) The *result* depends on the current map selection state IF use_selected is true.final List<WaySegment>getNearestWaySegments(Point p, Collection<WaySegment> ignore, Predicate<OsmPrimitive> predicate) The result *order* depends on the current map selection state.final List<WaySegment>getNearestWaySegments(Point p, Predicate<OsmPrimitive> predicate) The result *order* depends on the current map selection state.private Map<Double,List<WaySegment>> getNearestWaySegmentsImpl(Point p, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*.looses precision, may overflow (depends on p and current scale)looses precision, may overflow (depends on p and current scale)looses precision, may overflow (depends on p and current scale)looses precision, may overflow (depends on p and current scale)Return the point on the screen where this Coordinate would be.getPoint2D(ILatLon latlon) Return the point on the screen where this Coordinate would be.getPoint2D(LatLon latlon) Return the point on the screen where this Coordinate would be.getPoint2D(Node n) Return the point on the screen where this Node would be.Returns the projection to be used in calculating stuff.Determines the projection bounds of view area.Determines the projection bounds of given rectangle.doublegetScale()Returns the current scale.getState()Gets the current view state.intReturn an ID which is unique as long as viewport dimensions are the samebooleanDetermines if zoom history contains "redo" entries.booleanDetermines if zoom history contains "undo" entries.Returns the help topic on JOSM wiki for this feature.private booleanisPrecedenceNode(Node osm, Point p, boolean useSelected) This is used as a helper routine togetNearestNodeOrWay(Point, Predicate, boolean)It decides, whether to yield the node to be tested or look for further (way) candidates.protected booleanstatic Point2Dif r = 0 returns a, if r=1 returns b, if r = 0.5 returns center between a and b, etc.private voidpushZoomUndo(EastNorth center, double scale) voidvoidRemoves a primitive hover listenerprivate voidstatic voidRemoves a zoom change listenervoidresetCursor(Object reference) Remove the new cursor and reset to previousdoublescaleFloor(double scale) Get a scale snapped to native resolutions.doublescaleRound(double scale) Get a scale snapped to native resolutions, use round method.doublescaleSnap(double scale, boolean floor) Get a scale snapped to native resolutions.doubleGet a new scale that is zoomed in from previous scale and snapped to selected native scale layer.doublescaleZoomManyTimes(int times) Get a new scale that is zoomed in/out a number of times from previous scale and snapped to selected native scale layer.doubleGet a new scale that is zoomed out from previous scale and snapped to selected native scale layer.voidsetNativeScaleLayer(NativeScaleLayer nativeScaleLayer) Choose a layer that scale will be snap to its native scales.voidsetNewCursor(int cursor, Object reference) Set new cursor.voidsetNewCursor(Cursor cursor, Object reference) Set new cursor.voidsmoothScrollTo(EastNorth newCenter) Create a thread that moves the viewport to the given center in an animated fashion.private voidupdateHoveredPrimitive(IPrimitive hovered, MouseEvent e) protected voidvoidzoomIn()Zoom in current view.voidzoomManyTimes(double x, double y, int times) voidzoomNext()Zoom to next location.private voidzoomNoUndoTo(EastNorth newCenter, double newScale, boolean initial) Zoom to the given coordinate without adding to the zoom undo buffer.voidzoomOut()Zoom out current view.voidZoom to previous location.voidZoom to given bounds.voidZoom to given east/north.voidZoom to the given coordinate and scale.voidZoom to the given coordinate and scale.voidZoom to given lat/lon.voidZoom to given lat/lon.voidSet the new dimension to the view.voidzoomTo(ProjectionBounds box) Zoom to given projection bounds.voidzoomTo(ViewportData viewport) Zoom to given viewport data.voidzoomToFactor(double factor) voidzoomToFactor(double x, double y, double factor) voidzoomToFactor(EastNorth newCenter, double factor) Methods inherited from class javax.swing.JComponent
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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, updateUIMethods 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, validateTreeMethods 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, 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, 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, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
ALIGNMENT_EPSILON
- See Also:
-
isSelectablePredicate
To determine if a primitive is currently selectable. -
PROP_SNAP_DISTANCE
Snap distance -
PROP_ZOOM_RATIO
Zoom steps to get double scale -
PROP_ZOOM_INTERMEDIATE_STEPS
Divide intervals between native resolution levels to smaller steps if they are much larger than zoom ratio -
PROP_ZOOM_SCALE_FOLLOW_NATIVE_RES_AT_LOAD
scale follows native resolution of layer status when layer is created -
nativeScaleLayer
The layer which scale is set to. -
zoomChangeListeners
private static final CopyOnWriteArrayList<NavigatableComponent.ZoomChangeListener> zoomChangeListenersthe zoom listeners -
primitiveHoverListeners
-
previousHoveredPrimitive
-
primitiveHoverMouseListenerHelper
-
initialViewport
-
cursorManager
-
state
The current state (scale, center, ...) of this map view. -
projectionChangeListener
Main uses weak link to store this, so we need to keep a reference. -
zoomUndoBuffer
-
zoomRedoBuffer
-
zoomTimestamp
-
-
Constructor Details
-
NavigatableComponent
public NavigatableComponent()Constructs a newNavigatableComponent.
-
-
Method Details
-
fireZoomChanged
-
removePrimitiveHoverListener
Removes a primitive hover listener- Parameters:
listener- the listener. Ignored if null or already absent.- Since:
- 18574
-
addPrimitiveHoverListener
Adds a primitive hover listener- Parameters:
listener- the listener. Ignored if null or already registered.- Since:
- 18574
-
firePrimitiveHovered
Send aPrimitiveHoverListener.PrimitiveHoverEventto registeredPrimitiveHoverListeners- Parameters:
e- primitive hover event information- Since:
- 18574
-
updateHoveredPrimitive
-
addNotify
- Overrides:
addNotifyin classJComponent
-
removeNotify
- Overrides:
removeNotifyin classJComponent
-
addPrimitiveHoverMouseListeners
-
removePrimitiveHoverMouseListeners
-
setNativeScaleLayer
Choose a layer that scale will be snap to its native scales.- Parameters:
nativeScaleLayer- layer to which scale will be snapped
-
getNativeScaleLayer
Replies the layer which scale is set to.- Returns:
- the current scale layer (may be
null)
-
scaleZoomIn
Get a new scale that is zoomed in from previous scale and snapped to selected native scale layer.- Returns:
- new scale
-
scaleZoomOut
Get a new scale that is zoomed out from previous scale and snapped to selected native scale layer.- Returns:
- new scale
-
scaleZoomManyTimes
Get a new scale that is zoomed in/out a number of times from previous scale and snapped to selected native scale layer.- Parameters:
times- count of zoom operations, negative means zoom in- Returns:
- new scale
-
scaleRound
Get a scale snapped to native resolutions, use round method. It gives nearest step from scale list. Use round method.- Parameters:
scale- to snap- Returns:
- snapped scale
-
scaleFloor
Get a scale snapped to native resolutions. It gives nearest lower step from scale list, usable to fit objects.- Parameters:
scale- to snap- Returns:
- snapped scale
-
scaleSnap
Get a scale snapped to native resolutions. It gives nearest lower step from scale list, usable to fit objects.- Parameters:
scale- to snapfloor- use floor instead of round, set true when fitting view to objects- Returns:
- new scale
-
zoomIn
Zoom in current view. Use configured zoom step and scaling settings. -
zoomOut
Zoom out current view. Use configured zoom step and scaling settings. -
updateLocationState
-
isVisibleOnScreen
-
fixProjection
Changes the projection settings used for this map view.Made public temporarily, will be made private later.
-
getState
Gets the current view state. This includes the scale, the current view area and the position.- Returns:
- The current state.
-
getDistText
Returns the text describing the given distance in the current system of measurement.- Parameters:
dist- The distance in metres.- Returns:
- the text describing the given distance in the current system of measurement.
- Since:
- 3406
-
getDistText
Returns the text describing the given distance in the current system of measurement.- Parameters:
dist- The distance in metresformat- ANumberFormatto format the area valuethreshold- Values lower than thisthresholdare displayed as"< [threshold]"- Returns:
- the text describing the given distance in the current system of measurement.
- Since:
- 7135
-
getDist100PixelText
Returns the text describing the distance in meter that correspond to 100 px on screen.- Returns:
- the text describing the distance in meter that correspond to 100 px on screen
-
getDist100Pixel
Get the distance in meter that correspond to 100 px on screen.- Returns:
- the distance in meter that correspond to 100 px on screen
-
getDist100Pixel
Get the distance in meter that correspond to 100 px on screen.- Parameters:
alwaysPositive- if true, makes sure the return value is always > 0. (Two points 100 px apart can appear to be identical if the user has zoomed out a lot and the projection code does something funny.)- Returns:
- the distance in meter that correspond to 100 px on screen
-
getCenter
Returns the current center of the viewport.(Use
zoomTo(EastNorth)to the change the center.)- Returns:
- the current center of the viewport
-
getScale
Returns the current scale.In east/north units per pixel.
- Returns:
- the current scale
-
getEastNorth
Returns geographic coordinates from a specific pixel coordination on the screen.- Parameters:
x- X-Pixelposition to get coordinate fromy- Y-Pixelposition to get coordinate from- Returns:
- Geographic coordinates from a specific pixel coordination on the screen.
-
getProjectionBounds
Determines the projection bounds of view area.- Returns:
- the projection bounds of view area
-
getMaxProjectionBounds
-
getRealBounds
-
getLatLon
Returns unprojected geographic coordinates for a specific pixel position on the screen.- Parameters:
x- X-Pixelposition to get coordinate fromy- Y-Pixelposition to get coordinate from- Returns:
- Geographic unprojected coordinates from a specific pixel position on the screen.
-
getLatLon
Returns unprojected geographic coordinates for a specific pixel position on the screen.- Parameters:
x- X-Pixelposition to get coordinate fromy- Y-Pixelposition to get coordinate from- Returns:
- Geographic unprojected coordinates from a specific pixel position on the screen.
-
getProjectionBounds
Determines the projection bounds of given rectangle.- Parameters:
r- rectangle- Returns:
- the projection bounds of
r
-
getLatLonBounds
Returns minimum bounds that will cover a given rectangle.- Parameters:
r- rectangle- Returns:
- Minimum bounds that will cover rectangle
-
getAffineTransform
Creates an affine transform that is used to convert the east/north coordinates to view coordinates.- Returns:
- The affine transform.
-
getPoint2D
Return the point on the screen where this Coordinate would be.- Parameters:
p- The point, where this geopoint would be drawn.- Returns:
- The point on screen where "point" would be drawn, relative to the own top/left.
-
getPoint2D
Return the point on the screen where this Coordinate would be.Alternative:
getState(), thenMapViewState.getPointFor(ILatLon)- Parameters:
latlon- The point, where this geopoint would be drawn.- Returns:
- The point on screen where "point" would be drawn, relative to the own top/left.
-
getPoint2D
Return the point on the screen where this Coordinate would be.Alternative:
getState(), thenMapViewState.getPointFor(ILatLon)- Parameters:
latlon- The point, where this geopoint would be drawn.- Returns:
- The point on screen where "point" would be drawn, relative to the own top/left.
-
getPoint2D
Return the point on the screen where this Node would be.Alternative:
getState(), thenMapViewState.getPointFor(ILatLon)- Parameters:
n- The node, where this geopoint would be drawn.- Returns:
- The point on screen where "node" would be drawn, relative to the own top/left.
-
getPoint
looses precision, may overflow (depends on p and current scale)- Parameters:
p- east/north- Returns:
- point
- See Also:
-
getPoint
looses precision, may overflow (depends on p and current scale)- Parameters:
latlon- lat/lon- Returns:
- point
- Since:
- 12725
- See Also:
-
getPoint
looses precision, may overflow (depends on p and current scale)- Parameters:
latlon- lat/lon- Returns:
- point
- See Also:
-
getPoint
looses precision, may overflow (depends on p and current scale)- Parameters:
n- node- Returns:
- point
- See Also:
-
zoomTo
Zoom to the given coordinate and scale.- Parameters:
newCenter- The center x-value (easting) to zoom to.newScale- The scale to use.
-
zoomTo
Zoom to the given coordinate and scale.- Parameters:
center- The center x-value (easting) to zoom to.scale- The scale to use.initial- true if this call initializes the viewport.
-
zoomNoUndoTo
Zoom to the given coordinate without adding to the zoom undo buffer.- Parameters:
newCenter- The center x-value (easting) to zoom to.newScale- The scale to use.initial- true if this call initializes the viewport.
-
zoomTo
Zoom to given east/north.- Parameters:
newCenter- new center coordinates
-
zoomTo
Zoom to given lat/lon.- Parameters:
newCenter- new center coordinates- Since:
- 12725
-
zoomTo
Zoom to given lat/lon.- Parameters:
newCenter- new center coordinates
-
smoothScrollTo
Create a thread that moves the viewport to the given center in an animated fashion.- Parameters:
newCenter- new east/north center
-
zoomManyTimes
-
zoomToFactor
-
zoomToFactor
-
zoomToFactor
-
zoomTo
Zoom to given projection bounds.- Parameters:
box- new projection bounds
-
zoomTo
Zoom to given bounds.- Parameters:
box- new bounds
-
zoomTo
Zoom to given viewport data.- Parameters:
viewport- new viewport data
-
zoomTo
Set the new dimension to the view.- Parameters:
v- box to zoom to
-
pushZoomUndo
-
zoomPrevious
Zoom to previous location. -
zoomNext
Zoom to next location. -
hasZoomUndoEntries
Determines if zoom history contains "undo" entries.- Returns:
trueif zoom history contains "undo" entries
-
hasZoomRedoEntries
Determines if zoom history contains "redo" entries.- Returns:
trueif zoom history contains "redo" entries
-
getBBox
-
getNearestNodesImpl
The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the distance to point p.- Parameters:
p- pointpredicate- predicate to match- Returns:
- a sorted map with the keys representing the distance of their associated nodes to point p.
-
getNearestNodes
public final List<Node> getNearestNodes(Point p, Collection<Node> ignore, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the distance to point p.- Parameters:
p- the point for which to search the nearest segment.ignore- a collection of nodes which are not to be returned.predicate- the returned objects have to fulfill certain properties.- Returns:
- All nodes nearest to point p that are in a belt from dist(nearest) to dist(nearest)+4px around p and that are not in ignore.
-
getNearestNodes
The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the distance to point p.- Parameters:
p- the point for which to search the nearest segment.predicate- the returned objects have to fulfill certain properties.- Returns:
- All nodes nearest to point p that are in a belt from dist(nearest) to dist(nearest)+4px around p.
- See Also:
-
getNearestNode
The *result* depends on the current map selection state IF use_selected is true.If more than one node within node.snap-distance pixels is found, the nearest node selected is returned IF use_selected is true.
Else the nearest new/id=0 node within about the same distance as the true nearest node is returned.
If no such node is found either, the true nearest node to p is returned.
Finally, if a node is not found at all,
nullis returned.- Parameters:
p- the screen pointpredicate- this parameter imposes a condition on the returned object, e.g. give the nearest node that is tagged.useSelected- make search depend on selection- Returns:
- A node within snap-distance to point p, that is chosen by the algorithm described.
-
getNearestNode
public final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected, Collection<OsmPrimitive> preferredRefs) The *result* depends on the current map selection state IF use_selected is trueIf more than one node within node.snap-distance pixels is found, the nearest node selected is returned IF use_selected is true.
If there are no selected nodes near that point, the node that is related to some of the preferredRefs
Else the nearest new/id=0 node within about the same distance as the true nearest node is returned.
If no such node is found either, the true nearest node to p is returned.
Finally, if a node is not found at all,
nullis returned.- Parameters:
p- the screen pointpredicate- this parameter imposes a condition on the returned object, e.g. give the nearest node that is tagged.useSelected- make search depend on selectionpreferredRefs- primitives, whose nodes we prefer- Returns:
- A node within snap-distance to point p, that is chosen by the algorithm described.
- Since:
- 6065
-
getNearestNode
Convenience method togetNearestNode(Point, Predicate, boolean).- Parameters:
p- the screen pointpredicate- this parameter imposes a condition on the returned object, e.g. give the nearest node that is tagged.- Returns:
- The nearest node to point p.
-
getNearestWaySegmentsImpl
private Map<Double,List<WaySegment>> getNearestWaySegmentsImpl(Point p, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the distance to point p.- Parameters:
p- the screen pointpredicate- this parameter imposes a condition on the returned object, e.g. give the nearest node that is tagged.- Returns:
- a sorted map with the keys representing the perpendicular distance of their associated way segments to point p.
-
getNearestWaySegments
public final List<WaySegment> getNearestWaySegments(Point p, Collection<WaySegment> ignore, Predicate<OsmPrimitive> predicate) The result *order* depends on the current map selection state. Segments within 10px of p are searched and sorted by their distance top, then, within groups of equally distant segments, prefer those that are selected.- Parameters:
p- the point for which to search the nearest segments.ignore- a collection of segments which are not to be returned.predicate- the returned objects have to fulfill certain properties.- Returns:
- all segments within 10px of p that are not in ignore, sorted by their perpendicular distance.
-
getNearestWaySegments
The result *order* depends on the current map selection state.- Parameters:
p- the point for which to search the nearest segments.predicate- the returned objects have to fulfill certain properties.- Returns:
- all segments within 10px of p, sorted by their perpendicular distance.
- See Also:
-
getNearestWaySegment
public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) The *result* depends on the current map selection state IF use_selected is true.- Parameters:
p- the point for which to search the nearest segment.predicate- the returned object has to fulfill certain properties.useSelected- whether selected way segments should be preferred.- Returns:
- The nearest way segment to point p, and, depending on use_selected, prefers a selected way segment, if found.
- See Also:
-
getNearestWaySegment
public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected, Collection<OsmPrimitive> preferredRefs) The *result* depends on the current map selection state IF use_selected is true.- Parameters:
p- the point for which to search the nearest segment.predicate- the returned object has to fulfill certain properties.useSelected- whether selected way segments should be preferred.preferredRefs- - prefer segments related to these primitives, may be null- Returns:
- The nearest way segment to point p, and, depending on use_selected, prefers a selected way segment, if found. Also prefers segments of ways that are related to one of preferredRefs primitives
- Since:
- 6065
- See Also:
-
getNearestWaySegment
Convenience method togetNearestWaySegment(Point, Predicate, boolean).- Parameters:
p- the point for which to search the nearest segment.predicate- the returned object has to fulfill certain properties.- Returns:
- The nearest way segment to point p.
-
getNearestWays
public final List<Way> getNearestWays(Point p, Collection<Way> ignore, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the perpendicular distance to point p.- Parameters:
p- the point for which to search the nearest ways.ignore- a collection of ways which are not to be returned.predicate- the returned object has to fulfill certain properties.- Returns:
- all nearest ways to the screen point given that are not in ignore.
- See Also:
-
getNearestWays
The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the perpendicular distance to point p.- Parameters:
p- the point for which to search the nearest ways.predicate- the returned object has to fulfill certain properties.- Returns:
- all nearest ways to the screen point given.
- See Also:
-
getNearestWay
The *result* depends on the current map selection state.- Parameters:
p- the point for which to search the nearest segment.predicate- the returned object has to fulfill certain properties.- Returns:
- The nearest way to point p, prefer a selected way if there are multiple nearest.
- See Also:
-
getNearestNodesOrWays
public final List<OsmPrimitive> getNearestNodesOrWays(Point p, Collection<OsmPrimitive> ignore, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the distance to point p.First, nodes will be searched. If there are nodes within BBox found, return a collection of those nodes only.
If no nodes are found, search for nearest ways. If there are ways within BBox found, return a collection of those ways only.
If nothing is found, return an empty collection.
- Parameters:
p- The point on screen.ignore- a collection of ways which are not to be returned.predicate- the returned object has to fulfill certain properties.- Returns:
- Primitives nearest to the given screen point that are not in ignore.
- See Also:
-
getNearestNodesOrWays
The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the distance to point p.- Parameters:
p- The point on screen.predicate- the returned object has to fulfill certain properties.- Returns:
- Primitives nearest to the given screen point.
- See Also:
-
isPrecedenceNode
This is used as a helper routine togetNearestNodeOrWay(Point, Predicate, boolean)It decides, whether to yield the node to be tested or look for further (way) candidates.- Parameters:
osm- node to checkp- point clickeduseSelected- whether to prefer selected nodes- Returns:
- true, if the node fulfills the properties of the function body
-
getNearestNodeOrWay
public final OsmPrimitive getNearestNodeOrWay(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) The *result* depends on the current map selection state IF use_selected is true.IF use_selected is true, use
getNearestNode(Point, Predicate)to find the nearest, selected node. If not found, trygetNearestWaySegment(Point, Predicate)to find the nearest selected way.IF use_selected is false, or if no selected primitive was found, do the following.
If the nearest node found is within 4px of p, simply take it. Else, find the nearest way segment. Then, if p is closer to its middle than to the node, take the way segment, else take the node.
Finally, if no nearest primitive is found at all, return
null.- Parameters:
p- The point on screen.predicate- the returned object has to fulfill certain properties.useSelected- whether to prefer primitives that are currently selected or referred by selected primitives- Returns:
- A primitive within snap-distance to point p, that is chosen by the algorithm described.
- See Also:
-
project
if r = 0 returns a, if r=1 returns b, if r = 0.5 returns center between a and b, etc.- Parameters:
r- scale valuea- root of vectorb- vector- Returns:
- new point at a + r*(ab)
-
getAllNearest
public final List<OsmPrimitive> getAllNearest(Point p, Collection<OsmPrimitive> ignore, Predicate<OsmPrimitive> predicate) The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the distance to point p.- Parameters:
p- The point on screen.ignore- a collection of ways which are not to be returned.predicate- the returned object has to fulfill certain properties.- Returns:
- a list of all objects that are nearest to point p and not in ignore or an empty list if nothing was found.
-
getAllNearest
The *result* does not depend on the current map selection state, neither does the result *order*. It solely depends on the distance to point p.- Parameters:
p- The point on screen.predicate- the returned object has to fulfill certain properties.- Returns:
- a list of all objects that are nearest to point p or an empty list if nothing was found.
- See Also:
-
getProjection
Returns the projection to be used in calculating stuff.- Returns:
- The projection to be used in calculating stuff.
-
helpTopic
Description copied from interface:HelpfulReturns the help topic on JOSM wiki for this feature. -
getViewID
Return an ID which is unique as long as viewport dimensions are the same- Returns:
- A unique ID, as long as viewport dimensions are the same
-
setNewCursor
Set new cursor.- Parameters:
cursor- The new cursor to use.reference- A reference object that can be passed to the next set/reset calls to identify the caller.
-
setNewCursor
Set new cursor.- Parameters:
cursor- the type of predefined cursorreference- A reference object that can be passed to the next set/reset calls to identify the caller.
-
resetCursor
Remove the new cursor and reset to previous- Parameters:
reference- Cursor reference
-
getCursorManager
Gets the cursor manager that is used for this NavigatableComponent.- Returns:
- The cursor manager.
-
getMaxScale
Get a max scale for projection that describes world in 1/512 of the projection unit- Returns:
- max scale