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.validationpackage)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPaintVisitor.PaintedPointprotected static classPaintVisitor.PaintedSegment
-
Field Summary
Fields Modifier and Type Field Description private java.awt.ColorcolorThe severity colorprivate java.awt.Graphics2DgThe graphicsprivate MapViewmvThe MapViewprivate java.util.Set<PaintVisitor.PaintedPoint>paintedPointsprivate java.util.Set<PaintVisitor.PaintedSegment>paintedSegmentsprivate booleanselectedIs 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 voidclearPaintedObjects()Clears the internal painted objects collections.protected voiddrawNode(Node n, java.awt.Color color)Draws a circle around the nodeprotected voiddrawSegment(java.awt.Point p1, java.awt.Point p2, java.awt.Color color)Draws a line around the segmentprotected voiddrawSegment(Node n1, Node n2, java.awt.Color color)Draws a line around the segmentprivate static java.awt.ColorgetHighlightColor(java.awt.Color color)Gets the color to draw highlight markers with.protected booleanisNodeVisible(Node n)Checks if the given node is in the visible area.protected booleanisSegmentVisible(Node n1, Node n2)Checks if the given segment is in the visible area.voidvisit(java.util.List<Node> nodes)Visit a list of nodes that are part of the errorvoidvisit(Node n)Draw a small rectangle.voidvisit(OsmPrimitive p)Visit a OSM primitive, e.g.voidvisit(Relation r)Visiting call for relations.voidvisit(Way w)Visiting call for lines.voidvisit(WaySegment ws)Visit a way segment that was part of the errorvoidvisit(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:ValidatorVisitorVisit a test error- Specified by:
visitin interfaceValidatorVisitor- Parameters:
error- The test error to visit
-
visit
public void visit(OsmPrimitive p)
Description copied from interface:ValidatorVisitorVisit a OSM primitive, e.g. to highlight it- Specified by:
visitin 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:
visitin interfaceOsmPrimitiveVisitor- Parameters:
n- The node to draw.
-
visit
public void visit(Way w)
Description copied from interface:OsmPrimitiveVisitorVisiting call for lines.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Parameters:
w- The way to inspect.
-
visit
public void visit(WaySegment ws)
Description copied from interface:ValidatorVisitorVisit a way segment that was part of the error- Specified by:
visitin interfaceValidatorVisitor- Parameters:
ws- The way segment
-
visit
public void visit(Relation r)
Description copied from interface:OsmPrimitiveVisitorVisiting call for relations.- Specified by:
visitin 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:
trueif the segment is visible
-
visit
public void visit(java.util.List<Node> nodes)
Description copied from interface:ValidatorVisitorVisit a list of nodes that are part of the error- Specified by:
visitin 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.
-
-