Class PaintVisitor
- java.lang.Object
-
- org.openstreetmap.josm.gui.layer.validation.PaintVisitor
-
- All Implemented Interfaces:
OsmPrimitiveVisitor
,ValidatorVisitor
public class PaintVisitor extends java.lang.Object implements OsmPrimitiveVisitor, ValidatorVisitor
Visitor that highlights the primitives affected by an error- Since:
- 5671, 12823 (moved from
data.validation
package)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
PaintVisitor.PaintedPoint
protected static class
PaintVisitor.PaintedSegment
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Color
color
The severity colorprivate java.awt.Graphics2D
g
The graphicsprivate MapView
mv
The MapViewprivate java.util.Set<PaintVisitor.PaintedPoint>
paintedPoints
private java.util.Set<PaintVisitor.PaintedSegment>
paintedSegments
private boolean
selected
Is the error selected ?
-
Constructor Summary
Constructors Constructor Description PaintVisitor(java.awt.Graphics2D g, MapView mv)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearPaintedObjects()
Clears the internal painted objects collections.protected void
drawNode(Node n, java.awt.Color color)
Draws a circle around the nodeprotected void
drawSegment(java.awt.Point p1, java.awt.Point p2, java.awt.Color color)
Draws a line around the segmentprotected void
drawSegment(Node n1, Node n2, java.awt.Color color)
Draws a line around the segmentprivate static java.awt.Color
getHighlightColor(java.awt.Color color)
Gets the color to draw highlight markers with.protected boolean
isNodeVisible(Node n)
Checks if the given node is in the visible area.protected boolean
isSegmentVisible(Node n1, Node n2)
Checks if the given segment is in the visible area.void
visit(java.util.List<Node> nodes)
Visit a list of nodes that are part of the errorvoid
visit(Node n)
Draw a small rectangle.void
visit(OsmPrimitive p)
Visit a OSM primitive, e.g.void
visit(Relation r)
Visiting call for relations.void
visit(Way w)
Visiting call for lines.void
visit(WaySegment ws)
Visit a way segment that was part of the errorvoid
visit(TestError error)
Visit a test error
-
-
-
Field Detail
-
g
private final java.awt.Graphics2D g
The graphics
-
color
private java.awt.Color color
The severity color
-
selected
private boolean selected
Is the error selected ?
-
paintedPoints
private final java.util.Set<PaintVisitor.PaintedPoint> paintedPoints
-
paintedSegments
private final java.util.Set<PaintVisitor.PaintedSegment> paintedSegments
-
-
Constructor Detail
-
PaintVisitor
public PaintVisitor(java.awt.Graphics2D g, MapView mv)
Constructor- Parameters:
g
- The graphicsmv
- The Mapview
-
-
Method Detail
-
visit
public void visit(TestError error)
Description copied from interface:ValidatorVisitor
Visit a test error- Specified by:
visit
in interfaceValidatorVisitor
- Parameters:
error
- The test error to visit
-
visit
public void visit(OsmPrimitive p)
Description copied from interface:ValidatorVisitor
Visit a OSM primitive, e.g. to highlight it- Specified by:
visit
in interfaceValidatorVisitor
- Parameters:
p
- The primitive
-
drawNode
protected void drawNode(Node n, java.awt.Color color)
Draws a circle around the node- Parameters:
n
- The nodecolor
- The circle color
-
drawSegment
protected void drawSegment(java.awt.Point p1, java.awt.Point p2, java.awt.Color color)
Draws a line around the segment- Parameters:
p1
- The first point of segmentp2
- The second point of segmentcolor
- The color
-
drawSegment
protected void drawSegment(Node n1, Node n2, java.awt.Color color)
Draws a line around the segment- Parameters:
n1
- The first node of segmentn2
- The second node of segmentcolor
- The color
-
visit
public void visit(Node n)
Draw a small rectangle. White if selected (as always) or red otherwise.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Parameters:
n
- The node to draw.
-
visit
public void visit(Way w)
Description copied from interface:OsmPrimitiveVisitor
Visiting call for lines.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Parameters:
w
- The way to inspect.
-
visit
public void visit(WaySegment ws)
Description copied from interface:ValidatorVisitor
Visit a way segment that was part of the error- Specified by:
visit
in interfaceValidatorVisitor
- Parameters:
ws
- The way segment
-
visit
public void visit(Relation r)
Description copied from interface:OsmPrimitiveVisitor
Visiting call for relations.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Parameters:
r
- The relation to inspect.
-
isNodeVisible
protected boolean isNodeVisible(Node n)
Checks if the given node is in the visible area.- Parameters:
n
- The node to check for visibility- Returns:
- true if the node is visible
-
isSegmentVisible
protected boolean isSegmentVisible(Node n1, Node n2)
Checks if the given segment is in the visible area. NOTE: This will return true for a small number of non-visible segments.- Parameters:
n1
- The first point of the segment to checkn2
- The second point of the segment to check- Returns:
true
if the segment is visible
-
visit
public void visit(java.util.List<Node> nodes)
Description copied from interface:ValidatorVisitor
Visit a list of nodes that are part of the error- Specified by:
visit
in interfaceValidatorVisitor
- Parameters:
nodes
- The nodes
-
getHighlightColor
private static java.awt.Color getHighlightColor(java.awt.Color color)
Gets the color to draw highlight markers with.- Parameters:
color
- severity color- Returns:
- The color.
-
clearPaintedObjects
public void clearPaintedObjects()
Clears the internal painted objects collections.
-
-