Package org.openstreetmap.josm.gui.draw
Class MapViewPath
java.lang.Object
java.awt.geom.Path2D
java.awt.geom.Path2D.Double
org.openstreetmap.josm.gui.draw.MapPath2D
org.openstreetmap.josm.gui.draw.MapViewPath
- All Implemented Interfaces:
Shape,Serializable,Cloneable
This is a version of a java Path2D that allows you to add points to it by simply giving their east/north, lat/lon or node coordinates.
It is possible to clip the part of the path that is outside the view. This is useful when drawing dashed lines. Those lines use up a lot of
performance if the zoom level is high and the part outside the view is long. See computeClippedLine(Stroke).
- Since:
- 10875
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classprivate final classprivate classstatic interfaceThis class is used to visit the segments of this path.private static interfaceNested classes/interfaces inherited from class java.awt.geom.Path2D
Path2D.Double, Path2D.Float -
Field Summary
FieldsFields inherited from class java.awt.geom.Path2D
WIND_EVEN_ODD, WIND_NON_ZERO -
Constructor Summary
ConstructorsConstructorDescriptionMapViewPath(MapView mv) Create a new pathMapViewPath(MapViewState state) Create a new path -
Method Summary
Modifier and TypeMethodDescriptionAppend a list of nodesappendClosed(Iterable<? extends ILatLon> nodes, boolean connect) Append a list of nodes as closed way.voidConverts a path in east/north coordinates to view space.private voidcomputeClippedLine(Stroke stroke) Compute a line that is similar to the current path expect for that parts outside the screen are skipped using moveTo commands.doubleGets the length of the way in visual space.Gets the map view state this path is used for.Draw a line to the position.Draw a line to the node.Draw a line to the view position of given pointMove the cursor to the given position.Move the cursor to the given node.Move the path to the view position of given pointoffset(double viewOffset) Create a newMapViewPaththat is the same as the current one except that it is offset in the view.shapeAround(EastNorth eastNorth, SymbolShape symbol, double size) Add the given shape centered around the current position.shapeAround(ILatLon p1, SymbolShape symbol, double size) Add the given shape centered around the current node.shapeAround(MapViewState.MapViewPoint p, SymbolShape symbol, double size) Add the given shape centered around the given pointbooleanvisitClippedLine(double strokeLength, MapViewPath.PathSegmentConsumer consumer) Visits all straight segments of this path.booleanvisitClippedLine(Stroke stroke, MapViewPath.PathSegmentConsumer consumer) Visits all straight segments of this path.doublevisitLine(MapViewPath.PathSegmentConsumer consumer) Visits all segments of this path.Methods inherited from class java.awt.geom.Path2D.Double
append, clone, curveTo, getBounds2D, getPathIterator, lineTo, moveTo, quadTo, transform, trimToSizeMethods inherited from class java.awt.geom.Path2D
append, closePath, contains, contains, contains, contains, contains, contains, contains, contains, createTransformedShape, getBounds, getCurrentPoint, getPathIterator, getWindingRule, intersects, intersects, intersects, intersects, reset, setWindingRule
-
Field Details
-
state
-
-
Constructor Details
-
MapViewPath
Create a new path- Parameters:
mv- The map view to use for coordinate conversion.
-
MapViewPath
Create a new path- Parameters:
state- The state to use for coordinate conversion.
-
-
Method Details
-
getMapViewState
Gets the map view state this path is used for.- Returns:
- The state.
- Since:
- 11748
-
moveTo
Move the cursor to the given node.- Parameters:
n- The node- Returns:
- this for easy chaining.
-
moveTo
Move the cursor to the given position.- Parameters:
eastNorth- The position- Returns:
- this for easy chaining.
-
moveTo
Description copied from class:MapPath2DMove the path to the view position of given point -
lineTo
Draw a line to the node.line clamping to view is done automatically.
- Parameters:
n- The node- Returns:
- this for easy chaining.
-
lineTo
Draw a line to the position.line clamping to view is done automatically.
- Parameters:
eastNorth- The position- Returns:
- this for easy chaining.
-
lineTo
Description copied from class:MapPath2DDraw a line to the view position of given point -
shapeAround
Add the given shape centered around the current node.- Parameters:
p1- The point to draw aroundsymbol- The symbol typesize- The size of the symbol in pixel- Returns:
- this for easy chaining.
-
shapeAround
Add the given shape centered around the current position.- Parameters:
eastNorth- The point to draw aroundsymbol- The symbol typesize- The size of the symbol in pixel- Returns:
- this for easy chaining.
-
shapeAround
Description copied from class:MapPath2DAdd the given shape centered around the given point- Overrides:
shapeAroundin classMapPath2D- Parameters:
p- The point to draw aroundsymbol- The symbol typesize- The size of the symbol in pixel- Returns:
- this for easy chaining.
-
append
Append a list of nodes- Parameters:
nodes- The nodes to appendconnect-trueif we should use a lineTo as first command.- Returns:
- this for easy chaining.
-
appendClosed
Append a list of nodes as closed way.- Parameters:
nodes- The nodes to appendconnect-trueif we should use a lineTo as first command.- Returns:
- this for easy chaining.
-
appendWay
-
appendFromEastNorth
Converts a path in east/north coordinates to view space.- Parameters:
path- The path- Since:
- 11748
-
visitLine
Visits all segments of this path.- Parameters:
consumer- The consumer to send path segments to- Returns:
- the total line length
- Since:
- 11748
-
computeClippedLine
Compute a line that is similar to the current path expect for that parts outside the screen are skipped using moveTo commands. The line is computed in a way that dashes stay in their place when moving the view. The resulting line is not intended to fill areas.- Parameters:
stroke- The stroke to compute the line for.- Returns:
- The new line shape.
- Since:
- 11147
-
visitClippedLine
Visits all straight segments of this path. The segments are clamped to the view. If they are clamped, the start points are aligned with the pattern.- Parameters:
stroke- The stroke to take the dash information from.consumer- The consumer to call for each segment- Returns:
- false if visiting the path failed because there e.g. were non-straight segments.
- Since:
- 11147
-
visitClippedLine
Visits all straight segments of this path. The segments are clamped to the view. If they are clamped, the start points are aligned with the pattern.- Parameters:
strokeLength- The dash pattern length. 0 to use no pattern. Only segments of this length will be removed from the line.consumer- The consumer to call for each segment- Returns:
- false if visiting the path failed because there e.g. were non-straight segments.
- Since:
- 11147
-
getLength
Gets the length of the way in visual space.- Returns:
- The length.
- Since:
- 11748
-
offset
Create a newMapViewPaththat is the same as the current one except that it is offset in the view.- Parameters:
viewOffset- The offset in view pixels- Returns:
- The new path
- Since:
- 12505
-