public class NavigatableComponent extends JComponent implements Helpful
MapMover
. Used as map view and for the
zoomer in the download dialog.Modifier and Type | Class and Description |
---|---|
static interface |
NavigatableComponent.ZoomChangeListener
Interface to notify listeners of the change of the zoom area.
|
private class |
NavigatableComponent.ZoomData |
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected EastNorth |
center
Center n/e coordinate of the desired screen center.
|
protected CursorManager |
cursorManager |
protected ViewportData |
initialViewport |
Predicate<OsmPrimitive> |
isSelectablePredicate |
private Polygon |
paintPoly |
private Rectangle |
paintRect |
private Object |
paintRequestLock |
static IntegerProperty |
PROP_SNAP_DISTANCE |
static String |
PROPNAME_CENTER |
static String |
PROPNAME_SCALE |
private double |
scale |
private static CopyOnWriteArrayList<NavigatableComponent.ZoomChangeListener> |
zoomChangeListeners
the zoom listeners
|
private Stack<NavigatableComponent.ZoomData> |
zoomRedoBuffer |
private Date |
zoomTimestamp |
private Stack<NavigatableComponent.ZoomData> |
zoomUndoBuffer |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
NavigatableComponent()
Constructs a new
NavigatableComponent . |
Modifier and Type | Method and Description |
---|---|
static void |
addZoomChangeListener(NavigatableComponent.ZoomChangeListener listener)
Adds a zoom change listener
|
private static EastNorth |
calculateDefaultCenter() |
protected static void |
fireZoomChanged() |
AffineTransform |
getAffineTransform() |
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*.
|
List<OsmPrimitive> |
getAllNearest(Point p,
Predicate<OsmPrimitive> predicate)
The *result* does not depend on the current map selection state, neither does the result *order*.
|
static String |
getAreaText(double area)
Returns the text describing the given area in the current system of measurement.
|
static String |
getAreaText(double area,
NumberFormat format,
double threshold)
Returns the text describing the given area in the current system of measurement.
|
private BBox |
getBBox(Point p,
int snapDistance) |
EastNorth |
getCenter()
Returns the current center of the viewport.
|
protected DataSet |
getCurrentDataSet() |
CursorManager |
getCursorManager()
Gets the cursor manager that is used for this NavigatableComponent.
|
double |
getDist100Pixel()
Get the distance in meter that correspond to 100 px on screen.
|
double |
getDist100Pixel(boolean alwaysPositive)
Get the distance in meter that correspond to 100 px on screen.
|
String |
getDist100PixelText() |
static String |
getDistText(double dist)
Returns the text describing the given distance in the current system of measurement.
|
static String |
getDistText(double dist,
NumberFormat format,
double threshold)
Returns the text describing the given distance in the current system of measurement.
|
EastNorth |
getEastNorth(int x,
int y) |
LatLon |
getLatLon(double x,
double y) |
LatLon |
getLatLon(int x,
int y) |
Bounds |
getLatLonBounds(Rectangle r) |
ProjectionBounds |
getMaxProjectionBounds() |
Node |
getNearestNode(Point p,
Predicate<OsmPrimitive> predicate)
Convenience method to
getNearestNode(Point, Predicate, boolean) . |
Node |
getNearestNode(Point p,
Predicate<OsmPrimitive> predicate,
boolean useSelected)
The *result* depends on the current map selection state IF use_selected is true.
|
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 true
If more than one node within node.snap-distance pixels is found,
the nearest node selected is returned IF use_selected is true.
|
OsmPrimitive |
getNearestNodeOrWay(Point p,
Predicate<OsmPrimitive> predicate,
boolean use_selected)
The *result* depends on the current map selection state IF use_selected is true.
|
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*.
|
List<Node> |
getNearestNodes(Point p,
Predicate<OsmPrimitive> predicate)
The *result* does not depend on the current map selection state,
neither does the result *order*.
|
private Map<Double,List<Node>> |
getNearestNodesImpl(Point p,
Predicate<OsmPrimitive> predicate)
The *result* does not depend on the current map selection state, neither does the result *order*.
|
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*.
|
List<OsmPrimitive> |
getNearestNodesOrWays(Point p,
Predicate<OsmPrimitive> predicate)
The *result* does not depend on the current map selection state,
neither does the result *order*.
|
Way |
getNearestWay(Point p,
Predicate<OsmPrimitive> predicate)
The *result* depends on the current map selection state.
|
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*.
|
List<Way> |
getNearestWays(Point p,
Predicate<OsmPrimitive> predicate)
The *result* does not depend on the current map selection state,
neither does the result *order*.
|
WaySegment |
getNearestWaySegment(Point p,
Predicate<OsmPrimitive> predicate)
Convenience method to
getNearestWaySegment(Point, Predicate, boolean) . |
WaySegment |
getNearestWaySegment(Point p,
Predicate<OsmPrimitive> predicate,
boolean useSelected)
The *result* depends on the current map selection state IF use_selected is true.
|
WaySegment |
getNearestWaySegment(Point p,
Predicate<OsmPrimitive> predicate,
boolean use_selected,
Collection<OsmPrimitive> preferredRefs)
The *result* depends on the current map selection state IF use_selected is true.
|
List<WaySegment> |
getNearestWaySegments(Point p,
Collection<WaySegment> ignore,
Predicate<OsmPrimitive> predicate)
The result *order* depends on the current map selection state.
|
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*.
|
Point |
getPoint(EastNorth p) |
Point |
getPoint(LatLon latlon) |
Point |
getPoint(Node n) |
Point2D |
getPoint2D(EastNorth p)
Return the point on the screen where this Coordinate would be.
|
Point2D |
getPoint2D(LatLon latlon) |
Point2D |
getPoint2D(Node n) |
Projection |
getProjection() |
ProjectionBounds |
getProjectionBounds() |
Bounds |
getRealBounds() |
double |
getScale()
Returns the current scale.
|
int |
getViewID()
Return a ID which is unique as long as viewport dimensions are the same
|
boolean |
hasZoomRedoEntries() |
boolean |
hasZoomUndoEntries() |
String |
helpTopic() |
private boolean |
isPrecedenceNode(Node osm,
Point p,
boolean use_selected)
This is used as a helper routine to
getNearestNodeOrWay(Point, Predicate, boolean)
It decides, whether to yield the node to be tested or look for further (way) candidates. |
void |
paint(Graphics g) |
static double |
perDist(Point2D pt,
Point2D a,
Point2D b) |
static Point2D |
project(double r,
Point2D a,
Point2D b)
if r = 0 returns a, if r=1 returns b,
if r = 0.5 returns center between a and b, etc..
|
static Point2D |
project(Point2D pt,
Point2D a,
Point2D b) |
private void |
pushZoomUndo(EastNorth center,
double scale) |
static void |
removeZoomChangeListener(NavigatableComponent.ZoomChangeListener listener)
Removes a zoom change listener
|
void |
requestClearPoly()
Requests to clear the polyline previously drawn.
|
void |
requestClearRect()
Requests to clear the rectangled previously drawn.
|
void |
requestPaintPoly(Polygon p)
Requests to paint the given
Polygon as a polyline (unclosed polygon). |
void |
requestPaintRect(Rectangle r)
Requests to paint the given
Rectangle . |
void |
resetCursor(Object reference)
Remove the new cursor and reset to previous
|
void |
setNewCursor(Cursor cursor,
Object reference)
Set new cursor.
|
void |
setNewCursor(int cursor,
Object reference)
Set new cursor.
|
void |
smoothScrollTo(EastNorth newCenter)
Create a thread that moves the viewport to the given center in an animated fashion.
|
void |
smoothScrollTo(LatLon newCenter) |
void |
zoomNext() |
private void |
zoomNoUndoTo(EastNorth newCenter,
double newScale,
boolean initial)
Zoom to the given coordinate without adding to the zoom undo buffer.
|
void |
zoomPrevious() |
void |
zoomTo(BoundingXYVisitor box)
Set the new dimension to the view.
|
void |
zoomTo(Bounds box) |
void |
zoomTo(EastNorth newCenter) |
void |
zoomTo(EastNorth newCenter,
double newScale)
Zoom to the given coordinate and scale.
|
void |
zoomTo(EastNorth newCenter,
double newScale,
boolean initial)
Zoom to the given coordinate and scale.
|
void |
zoomTo(LatLon newCenter) |
void |
zoomTo(ProjectionBounds box) |
void |
zoomTo(ViewportData viewport) |
void |
zoomToFactor(double factor) |
void |
zoomToFactor(double x,
double y,
double factor) |
void |
zoomToFactor(EastNorth newCenter,
double factor) |
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, 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, 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
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, 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 transient Predicate<OsmPrimitive> isSelectablePredicate
public static final IntegerProperty PROP_SNAP_DISTANCE
public static final String PROPNAME_CENTER
public static final String PROPNAME_SCALE
private static final CopyOnWriteArrayList<NavigatableComponent.ZoomChangeListener> zoomChangeListeners
private double scale
private final transient Object paintRequestLock
protected transient ViewportData initialViewport
protected final transient CursorManager cursorManager
private final Stack<NavigatableComponent.ZoomData> zoomUndoBuffer
private final Stack<NavigatableComponent.ZoomData> zoomRedoBuffer
private Date zoomTimestamp
public NavigatableComponent()
NavigatableComponent
.public static void removeZoomChangeListener(NavigatableComponent.ZoomChangeListener listener)
listener
- the listener. Ignored if null or already absentpublic static void addZoomChangeListener(NavigatableComponent.ZoomChangeListener listener)
listener
- the listener. Ignored if null or already registered.protected static void fireZoomChanged()
protected DataSet getCurrentDataSet()
private static EastNorth calculateDefaultCenter()
public static String getDistText(double dist)
dist
- The distance in metres.public static String getDistText(double dist, NumberFormat format, double threshold)
dist
- The distance in metresformat
- A NumberFormat
to format the area valuethreshold
- Values lower than this threshold
are displayed as "< [threshold]"
public static String getAreaText(double area)
area
- The distance in square metres.public static String getAreaText(double area, NumberFormat format, double threshold)
area
- The area in square metresformat
- A NumberFormat
to format the area valuethreshold
- Values lower than this threshold
are displayed as "< [threshold]"
public String getDist100PixelText()
public double getDist100Pixel()
public double getDist100Pixel(boolean alwaysPositive)
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.)public EastNorth getCenter()
zoomTo(EastNorth)
to the change the center.)public double getScale()
public EastNorth getEastNorth(int x, int y)
x
- X-Pixelposition to get coordinate fromy
- Y-Pixelposition to get coordinate frompublic ProjectionBounds getProjectionBounds()
public ProjectionBounds getMaxProjectionBounds()
public Bounds getRealBounds()
public LatLon getLatLon(int x, int y)
x
- X-Pixelposition to get coordinate fromy
- Y-Pixelposition to get coordinate frompublic Bounds getLatLonBounds(Rectangle r)
r
- rectanglepublic AffineTransform getAffineTransform()
public Point2D getPoint2D(EastNorth p)
p
- The point, where this geopoint would be drawn.public Point2D getPoint2D(LatLon latlon)
public Point2D getPoint2D(Node n)
public void zoomTo(EastNorth newCenter, double newScale)
newCenter
- The center x-value (easting) to zoom to.newScale
- The scale to use.public void zoomTo(EastNorth newCenter, double newScale, boolean initial)
newCenter
- The center x-value (easting) to zoom to.newScale
- The scale to use.initial
- true if this call initializes the viewport.private void zoomNoUndoTo(EastNorth newCenter, double newScale, boolean initial)
newCenter
- The center x-value (easting) to zoom to.newScale
- The scale to use.initial
- true if this call initializes the viewport.public void smoothScrollTo(LatLon newCenter)
public void smoothScrollTo(EastNorth newCenter)
newCenter
- new east/north centerpublic void zoomToFactor(double x, double y, double factor)
public void zoomToFactor(EastNorth newCenter, double factor)
public void zoomToFactor(double factor)
public void zoomTo(ProjectionBounds box)
public void zoomTo(ViewportData viewport)
public void zoomTo(BoundingXYVisitor box)
box
- box to zoom toprivate void pushZoomUndo(EastNorth center, double scale)
public void zoomPrevious()
public void zoomNext()
public boolean hasZoomUndoEntries()
public boolean hasZoomRedoEntries()
private Map<Double,List<Node>> getNearestNodesImpl(Point p, Predicate<OsmPrimitive> predicate)
p
- pointpredicate
- predicate to matchpublic final List<Node> getNearestNodes(Point p, Collection<Node> ignore, Predicate<OsmPrimitive> predicate)
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.public final List<Node> getNearestNodes(Point p, Predicate<OsmPrimitive> predicate)
p
- the point for which to search the nearest segment.predicate
- the returned objects have to fulfill certain properties.getNearestNodes(Point, Collection, Predicate)
public final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected)
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 selectionpublic final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected, Collection<OsmPrimitive> preferredRefs)
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 preferpublic final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate)
getNearestNode(Point, Predicate, boolean)
.p
- the screen pointpredicate
- this parameter imposes a condition on the returned object, e.g.
give the nearest node that is tagged.private Map<Double,List<WaySegment>> getNearestWaySegmentsImpl(Point p, Predicate<OsmPrimitive> predicate)
p
- the screen pointpredicate
- this parameter imposes a condition on the returned object, e.g.
give the nearest node that is tagged.public final List<WaySegment> getNearestWaySegments(Point p, Collection<WaySegment> ignore, Predicate<OsmPrimitive> predicate)
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.public final List<WaySegment> getNearestWaySegments(Point p, Predicate<OsmPrimitive> predicate)
p
- the point for which to search the nearest segments.predicate
- the returned objects have to fulfill certain properties.getNearestWaySegments(Point, Collection, Predicate)
public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected)
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.getNearestWaySegments(Point, Collection, Predicate)
public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate, boolean use_selected, Collection<OsmPrimitive> preferredRefs)
p
- the point for which to search the nearest segment.predicate
- the returned object has to fulfill certain properties.use_selected
- whether selected way segments should be preferred.preferredRefs
- - prefer segments related to these primitives, may be nullgetNearestWaySegments(Point, Collection, Predicate)
public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate)
getNearestWaySegment(Point, Predicate, boolean)
.p
- the point for which to search the nearest segment.predicate
- the returned object has to fulfill certain properties.public final List<Way> getNearestWays(Point p, Collection<Way> ignore, Predicate<OsmPrimitive> predicate)
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.getNearestWaySegments(Point, Collection, Predicate)
public final List<Way> getNearestWays(Point p, Predicate<OsmPrimitive> predicate)
p
- the point for which to search the nearest ways.predicate
- the returned object has to fulfill certain properties.getNearestWays(Point, Collection, Predicate)
public final Way getNearestWay(Point p, Predicate<OsmPrimitive> predicate)
p
- the point for which to search the nearest segment.predicate
- the returned object has to fulfill certain properties.getNearestWaySegment(Point, Predicate)
public final List<OsmPrimitive> getNearestNodesOrWays(Point p, Collection<OsmPrimitive> ignore, Predicate<OsmPrimitive> predicate)
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.getNearestNodes(Point, Collection, Predicate)
,
getNearestWays(Point, Collection, Predicate)
public final List<OsmPrimitive> getNearestNodesOrWays(Point p, Predicate<OsmPrimitive> predicate)
p
- The point on screen.predicate
- the returned object has to fulfill certain properties.getNearestNodesOrWays(Point, Collection, Predicate)
private boolean isPrecedenceNode(Node osm, Point p, boolean use_selected)
getNearestNodeOrWay(Point, Predicate, boolean)
It decides, whether to yield the node to be tested or look for further (way) candidates.osm
- node to checkp
- point clickeduse_selected
- whether to prefer selected nodespublic final OsmPrimitive getNearestNodeOrWay(Point p, Predicate<OsmPrimitive> predicate, boolean use_selected)
getNearestNode(Point, Predicate)
to find
the nearest, selected node. If not found, try getNearestWaySegment(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.p
- The point on screen.predicate
- the returned object has to fulfill certain properties.use_selected
- whether to prefer primitives that are currently selected or referred by selected primitivesgetNearestNode(Point, Predicate)
,
getNearestWay(Point, Predicate)
public static Point2D project(Point2D pt, Point2D a, Point2D b)
pt
- point to project onto (ab)a
- root of vectorb
- vectorpublic static Point2D project(double r, Point2D a, Point2D b)
r
- scale valuea
- root of vectorb
- vectorpublic final List<OsmPrimitive> getAllNearest(Point p, Collection<OsmPrimitive> ignore, Predicate<OsmPrimitive> predicate)
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.public final List<OsmPrimitive> getAllNearest(Point p, Predicate<OsmPrimitive> predicate)
p
- The point on screen.predicate
- the returned object has to fulfill certain properties.getAllNearest(Point, Collection, Predicate)
public Projection getProjection()
public int getViewID()
public void setNewCursor(Cursor cursor, Object reference)
cursor
- The new cursor to use.reference
- A reference object that can be passed to the next set/reset calls to identify the caller.public void setNewCursor(int cursor, Object reference)
cursor
- the type of predefined cursorreference
- A reference object that can be passed to the next set/reset calls to identify the caller.public void resetCursor(Object reference)
reference
- Cursor referencepublic CursorManager getCursorManager()
public void paint(Graphics g)
paint
in class JComponent
public void requestPaintRect(Rectangle r)
Rectangle
.r
- The Rectangle to drawrequestClearRect()
public void requestPaintPoly(Polygon p)
Polygon
as a polyline (unclosed polygon).p
- The Polygon to drawrequestClearPoly()
public void requestClearRect()
requestPaintRect(java.awt.Rectangle)
public void requestClearPoly()
requestPaintPoly(java.awt.Polygon)