public class MapViewPath extends MapPath2D
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)
.
Modifier and Type | Class and Description |
---|---|
private class |
MapViewPath.AbstractMapPathVisitor |
private class |
MapViewPath.ClampingPathVisitor |
private class |
MapViewPath.LineVisitor |
private class |
MapViewPath.OffsetPathVisitor |
static interface |
MapViewPath.PathSegmentConsumer
This class is used to visit the segments of this path.
|
private static interface |
MapViewPath.PathVisitor |
Modifier and Type | Field and Description |
---|---|
private MapViewState |
state |
Constructor and Description |
---|
MapViewPath(MapView mv)
Create a new path
|
MapViewPath(MapViewState state)
Create a new path
|
Modifier and Type | Method and Description |
---|---|
MapViewPath |
append(java.lang.Iterable<? extends ILatLon> nodes,
boolean connect)
Append a list of nodes
|
MapViewPath |
appendClosed(java.lang.Iterable<? extends ILatLon> nodes,
boolean connect)
Append a list of nodes as closed way.
|
void |
appendFromEastNorth(java.awt.geom.Path2D.Double path)
Converts a path in east/north coordinates to view space.
|
private void |
appendWay(java.lang.Iterable<? extends ILatLon> nodes,
boolean connect,
boolean close) |
java.awt.Shape |
computeClippedLine(java.awt.Stroke stroke)
Compute a line that is similar to the current path expect for that parts outside the screen are skipped using moveTo commands.
|
double |
getLength()
Gets the length of the way in visual space.
|
MapViewState |
getMapViewState()
Gets the map view state this path is used for.
|
MapViewPath |
lineTo(EastNorth eastNorth)
Draw a line to the position.
|
MapViewPath |
lineTo(ILatLon n)
Draw a line to the node.
|
MapViewPath |
lineTo(MapViewState.MapViewPoint p)
Draw a line to the view position of given point
|
MapViewPath |
moveTo(EastNorth eastNorth)
Move the cursor to the given position.
|
MapViewPath |
moveTo(ILatLon n)
Move the cursor to the given node.
|
MapViewPath |
moveTo(MapViewState.MapViewPoint p)
Move the path to the view position of given point
|
MapViewPath |
offset(double viewOffset)
Create a new
MapViewPath that is the same as the current one except that it is offset in the view. |
MapViewPath |
shapeAround(EastNorth eastNorth,
SymbolShape symbol,
double size)
Add the given shape centered around the current position.
|
MapViewPath |
shapeAround(ILatLon p1,
SymbolShape symbol,
double size)
Add the given shape centered around the current node.
|
MapViewPath |
shapeAround(MapViewState.MapViewPoint p,
SymbolShape symbol,
double size)
Add the given shape centered around the given point
|
boolean |
visitClippedLine(double strokeLength,
MapViewPath.PathSegmentConsumer consumer)
Visits all straight segments of this path.
|
boolean |
visitClippedLine(java.awt.Stroke stroke,
MapViewPath.PathSegmentConsumer consumer)
Visits all straight segments of this path.
|
double |
visitLine(MapViewPath.PathSegmentConsumer consumer)
Visits all segments of this path.
|
append, clone, curveTo, getBounds2D, getPathIterator, lineTo, moveTo, quadTo, transform
append, closePath, contains, contains, contains, contains, contains, contains, contains, contains, createTransformedShape, getBounds, getCurrentPoint, getPathIterator, getWindingRule, intersects, intersects, intersects, intersects, reset, setWindingRule
private final MapViewState state
public MapViewPath(MapView mv)
mv
- The map view to use for coordinate conversion.public MapViewPath(MapViewState state)
state
- The state to use for coordinate conversion.public MapViewState getMapViewState()
public MapViewPath moveTo(ILatLon n)
n
- The nodepublic MapViewPath moveTo(EastNorth eastNorth)
eastNorth
- The positionpublic MapViewPath moveTo(MapViewState.MapViewPoint p)
MapPath2D
public MapViewPath lineTo(ILatLon n)
line clamping to view is done automatically.
n
- The nodepublic MapViewPath lineTo(EastNorth eastNorth)
line clamping to view is done automatically.
eastNorth
- The positionpublic MapViewPath lineTo(MapViewState.MapViewPoint p)
MapPath2D
public MapViewPath shapeAround(ILatLon p1, SymbolShape symbol, double size)
p1
- The point to draw aroundsymbol
- The symbol typesize
- The size of the symbol in pixelpublic MapViewPath shapeAround(EastNorth eastNorth, SymbolShape symbol, double size)
eastNorth
- The point to draw aroundsymbol
- The symbol typesize
- The size of the symbol in pixelpublic MapViewPath shapeAround(MapViewState.MapViewPoint p, SymbolShape symbol, double size)
MapPath2D
shapeAround
in class MapPath2D
p
- The point to draw aroundsymbol
- The symbol typesize
- The size of the symbol in pixelpublic MapViewPath append(java.lang.Iterable<? extends ILatLon> nodes, boolean connect)
nodes
- The nodes to appendconnect
- true
if we should use a lineTo as first command.public MapViewPath appendClosed(java.lang.Iterable<? extends ILatLon> nodes, boolean connect)
nodes
- The nodes to appendconnect
- true
if we should use a lineTo as first command.private void appendWay(java.lang.Iterable<? extends ILatLon> nodes, boolean connect, boolean close)
public void appendFromEastNorth(java.awt.geom.Path2D.Double path)
path
- The pathpublic double visitLine(MapViewPath.PathSegmentConsumer consumer)
consumer
- The consumer to send path segments topublic java.awt.Shape computeClippedLine(java.awt.Stroke stroke)
stroke
- The stroke to compute the line for.public boolean visitClippedLine(java.awt.Stroke stroke, MapViewPath.PathSegmentConsumer consumer)
stroke
- The stroke to take the dash information from.consumer
- The consumer to call for each segmentpublic boolean visitClippedLine(double strokeLength, MapViewPath.PathSegmentConsumer consumer)
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 segmentpublic double getLength()
public MapViewPath offset(double viewOffset)
MapViewPath
that is the same as the current one except that it is offset in the view.viewOffset
- The offset in view pixels