org.openstreetmap.josm.data.osm.visitor.paint
Class WireframeMapRenderer

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.visitor.paint.AbstractMapRenderer
      extended by org.openstreetmap.josm.data.osm.visitor.paint.WireframeMapRenderer
All Implemented Interfaces:
Rendering, Visitor

public class WireframeMapRenderer
extends AbstractMapRenderer
implements Visitor

A map renderer that paints a simple scheme of every primitive it visits to a previous set graphic environment.


Field Summary
protected  java.awt.Color backgroundColor
          Color Preference for background
protected  java.awt.Color connectionColor
          Color Preference for multiply connected nodes
protected  int connectionNodeSize
          Preference: size of multiply connected nodes
private static double cosPHI
          Helper variable for #drawSgement
protected  java.awt.Color currentColor
          Color cache to draw subsequent segments of same color as one Path.
protected  java.awt.geom.GeneralPath currentPath
          Path store to draw subsequent segments of same color as one Path.
protected  java.awt.Color dfltWayColor
          Color Preference for ways not matching any other group
private  DataSet ds
          DataSet passed to the @{link render} function to overcome the argument limitations of @{link Visitor} interface.
protected  boolean fillConnectionNode
          Preference: should multiply connected nodes be filled
protected  boolean fillSelectedNode
          Preference: should selected nodes be filled
protected  boolean fillTaggedNode
          Preference: should tagged nodes be filled
protected  boolean fillUnselectedNode
          Preference: should unselected nodes be filled
protected  java.awt.Color highlightColor
          Color Preference for hightlighted objects
protected  java.awt.Color inactiveColor
          Color Preference for inactive objects
protected  java.awt.Color nodeColor
          Color Preference for nodes
private static double PHI
          Helper variable for #drawSgement
private  java.awt.Stroke relatedWayStroke
          Helper variable for {@link #visit(Relation)
protected  java.awt.Color relationColor
          Color Preference for relations
protected  int segmentNumberSpace
          Preference: minimum space (displayed way length) to display segment numbers
protected  java.awt.Color selectedColor
          Color Preference for selected objects
protected  int selectedNodeSize
          Preference: size of selected nodes
protected  boolean showDirectionArrow
          Preference: should directional arrows be displayed
protected  boolean showHeadArrowOnly
          Preference: should only the last arrow of a way be displayed
protected  boolean showOnewayArrow
          Preference: should arrows for oneways be displayed
protected  boolean showOrderNumber
          Preference: should the segement numbers of ways be displayed
private static double sinPHI
          Helper variable for #drawSgement
protected  java.awt.Color taggedColor
          Color Preference for tagged nodes
protected  java.awt.Color taggedConnectionColor
          Color Preference for tagged and multiply connected nodes
protected  int taggedNodeSize
          Preference: size of tagged nodes
protected  int unselectedNodeSize
          Preference: size of unselected nodes
protected  java.awt.Color untaggedWayColor
          Color Preference for untagged ways
protected  int virtualNodeSize
          Preference: size of virtual nodes (0 displayes display)
protected  int virtualNodeSpace
          Preference: minimum space (displayed way length) to display virtual nodes
 
Fields inherited from class org.openstreetmap.josm.data.osm.visitor.paint.AbstractMapRenderer
g, isInactiveMode, nc
 
Constructor Summary
WireframeMapRenderer(java.awt.Graphics2D g, NavigatableComponent nc, boolean isInactiveMode)
          Creates an wireframe render
 
Method Summary
protected  void displaySegments()
          Finally display all segments in currect path.
protected  void displaySegments(java.awt.Color newColor)
          Finally display all segments in currect path.
 void drawNode(Node n, java.awt.Color color, int size, boolean fill)
          Draw the node as small rectangle with the given color.
protected  void drawOrderNumber(java.awt.Point p1, java.awt.Point p2, int orderNumber)
          Draw an number of the order of the two consecutive nodes within the parents way
protected  void drawSegment(java.awt.geom.GeneralPath path, java.awt.Point p1, java.awt.Point p2, boolean showDirection)
          Draw a line with the given color.
protected  void drawSegment(java.awt.Point p1, java.awt.Point p2, java.awt.Color col, boolean showDirection)
          Draw a line with the given color.
 void drawVirtualNodes(java.util.Collection<Way> ways, java.util.Collection<WaySegment> highlightVirtualNodes)
          Draws virtual nodes.
 void getColors()
          Reads the color definitions from preferences.
protected  void getSettings(boolean virtual)
          Reads all the settings from preferences.
static boolean isLargeSegment(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, int space)
          Checks if a way segemnt is large enough for additional information display.
protected  boolean isPolygonVisible(java.awt.Polygon polygon)
          Checks if a polygon is visible in display.
protected  boolean isSegmentVisible(java.awt.Point p1, java.awt.Point p2)
          Checks if segment is visible in display.
private static int max(int a, int b, int c, int d)
          Helper function to calculate maximum of 4 values.
 void render(DataSet data, boolean virtual, Bounds bounds)
          Renders the dataset for display.
 void visit(Changeset cs)
          Visitor for changesets not used in this class
 void visit(Node n)
          Draw a small rectangle.
 void visit(Relation r)
          Draw objects used in relations.
 void visit(Way w)
          Draw a line for all way segments.
 void visitVirtual(java.awt.geom.GeneralPath path, Way w)
          Creates path for drawing virtual nodes for one way.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inactiveColor

protected java.awt.Color inactiveColor
Color Preference for inactive objects


selectedColor

protected java.awt.Color selectedColor
Color Preference for selected objects


nodeColor

protected java.awt.Color nodeColor
Color Preference for nodes


dfltWayColor

protected java.awt.Color dfltWayColor
Color Preference for ways not matching any other group


relationColor

protected java.awt.Color relationColor
Color Preference for relations


untaggedWayColor

protected java.awt.Color untaggedWayColor
Color Preference for untagged ways


backgroundColor

protected java.awt.Color backgroundColor
Color Preference for background


highlightColor

protected java.awt.Color highlightColor
Color Preference for hightlighted objects


taggedColor

protected java.awt.Color taggedColor
Color Preference for tagged nodes


connectionColor

protected java.awt.Color connectionColor
Color Preference for multiply connected nodes


taggedConnectionColor

protected java.awt.Color taggedConnectionColor
Color Preference for tagged and multiply connected nodes


showDirectionArrow

protected boolean showDirectionArrow
Preference: should directional arrows be displayed


showOnewayArrow

protected boolean showOnewayArrow
Preference: should arrows for oneways be displayed


showHeadArrowOnly

protected boolean showHeadArrowOnly
Preference: should only the last arrow of a way be displayed


showOrderNumber

protected boolean showOrderNumber
Preference: should the segement numbers of ways be displayed


fillSelectedNode

protected boolean fillSelectedNode
Preference: should selected nodes be filled


fillUnselectedNode

protected boolean fillUnselectedNode
Preference: should unselected nodes be filled


fillTaggedNode

protected boolean fillTaggedNode
Preference: should tagged nodes be filled


fillConnectionNode

protected boolean fillConnectionNode
Preference: should multiply connected nodes be filled


selectedNodeSize

protected int selectedNodeSize
Preference: size of selected nodes


unselectedNodeSize

protected int unselectedNodeSize
Preference: size of unselected nodes


connectionNodeSize

protected int connectionNodeSize
Preference: size of multiply connected nodes


taggedNodeSize

protected int taggedNodeSize
Preference: size of tagged nodes


virtualNodeSize

protected int virtualNodeSize
Preference: size of virtual nodes (0 displayes display)


virtualNodeSpace

protected int virtualNodeSpace
Preference: minimum space (displayed way length) to display virtual nodes


segmentNumberSpace

protected int segmentNumberSpace
Preference: minimum space (displayed way length) to display segment numbers


currentColor

protected java.awt.Color currentColor
Color cache to draw subsequent segments of same color as one Path.


currentPath

protected java.awt.geom.GeneralPath currentPath
Path store to draw subsequent segments of same color as one Path.


ds

private DataSet ds
DataSet passed to the @{link render} function to overcome the argument limitations of @{link Visitor} interface. Only valid until end of rendering call.


PHI

private static final double PHI
Helper variable for #drawSgement


cosPHI

private static final double cosPHI
Helper variable for #drawSgement


sinPHI

private static final double sinPHI
Helper variable for #drawSgement


relatedWayStroke

private java.awt.Stroke relatedWayStroke
Helper variable for {@link #visit(Relation)

Constructor Detail

WireframeMapRenderer

public WireframeMapRenderer(java.awt.Graphics2D g,
                            NavigatableComponent nc,
                            boolean isInactiveMode)
Creates an wireframe render

Parameters:
g - the graphics context. Must not be null.
nc - the map viewport. Must not be null.
isInactiveMode - if true, the paint visitor shall render OSM objects such that they look inactive. Example: rendering of data in an inactive layer using light gray as color only.
Throws:
java.lang.IllegalArgumentException - thrown if g is null
java.lang.IllegalArgumentException - thrown if nc is null
Method Detail

getColors

public void getColors()
Reads the color definitions from preferences. This function is public, so that color names in preferences can be displayed even without calling the wireframe display before.


getSettings

protected void getSettings(boolean virtual)
Reads all the settings from preferences. Calls the @{link #getColors} function.

Parameters:
virtual - true if virtual nodes are used

render

public void render(DataSet data,
                   boolean virtual,
                   Bounds bounds)
Renders the dataset for display.

Specified by:
render in interface Rendering
Parameters:
data - DataSet to display
virtual - true if virtual nodes are used
bounds - display boundaries

max

private static final int max(int a,
                             int b,
                             int c,
                             int d)
Helper function to calculate maximum of 4 values.

Parameters:
a - First value
b - Second value
c - Third value
d - Fourth value

visit

public void visit(Node n)
Draw a small rectangle. White if selected (as always) or red otherwise.

Specified by:
visit in interface Visitor
Parameters:
n - The node to draw.

isLargeSegment

public static boolean isLargeSegment(java.awt.geom.Point2D p1,
                                     java.awt.geom.Point2D p2,
                                     int space)
Checks if a way segemnt is large enough for additional information display.

Parameters:
p1 - First point of the way segment.
p2 - Second point of the way segment.
space - The free space to check against.
Returns:
true if segment is larger than required space

drawVirtualNodes

public void drawVirtualNodes(java.util.Collection<Way> ways,
                             java.util.Collection<WaySegment> highlightVirtualNodes)
Draws virtual nodes.

Parameters:
ways - The ways to draw nodes for.
highlightVirtualNodes - Way segements, where nodesshould be highlighted.

visitVirtual

public void visitVirtual(java.awt.geom.GeneralPath path,
                         Way w)
Creates path for drawing virtual nodes for one way.

Parameters:
path - The path to append drawing to.
w - The ways to draw node for.

visit

public void visit(Way w)
Draw a line for all way segments.

Specified by:
visit in interface Visitor
Parameters:
w - The way to draw.

visit

public void visit(Relation r)
Draw objects used in relations.

Specified by:
visit in interface Visitor
Parameters:
r - The relation to draw.

visit

public void visit(Changeset cs)
Visitor for changesets not used in this class

Specified by:
visit in interface Visitor
Parameters:
cs - The changeset for inspection.

drawOrderNumber

protected void drawOrderNumber(java.awt.Point p1,
                               java.awt.Point p2,
                               int orderNumber)
Draw an number of the order of the two consecutive nodes within the parents way

Parameters:
p1 - First point of the way segment.
p2 - Second point of the way segment.
orderNumber - The number of the segment in the way.

drawNode

public void drawNode(Node n,
                     java.awt.Color color,
                     int size,
                     boolean fill)
Draw the node as small rectangle with the given color.

Parameters:
n - The node to draw.
color - The color of the node.

drawSegment

protected void drawSegment(java.awt.geom.GeneralPath path,
                           java.awt.Point p1,
                           java.awt.Point p2,
                           boolean showDirection)
Draw a line with the given color.

Parameters:
path - The path to append this segment.
p1 - First point of the way segment.
p2 - Second point of the way segment.
showDirection - true if segment direction should be indicated

drawSegment

protected void drawSegment(java.awt.Point p1,
                           java.awt.Point p2,
                           java.awt.Color col,
                           boolean showDirection)
Draw a line with the given color.

Parameters:
p1 - First point of the way segment.
p2 - Second point of the way segment.
col - The color to use for drawing line.
showDirection - true if segment direction should be indicated.

isSegmentVisible

protected boolean isSegmentVisible(java.awt.Point p1,
                                   java.awt.Point p2)
Checks if segment is visible in display.

Parameters:
p1 - First point of the way segment.
p2 - Second point of the way segment.
Returns:
true if segment is visible.

isPolygonVisible

protected boolean isPolygonVisible(java.awt.Polygon polygon)
Checks if a polygon is visible in display.

Parameters:
polygon - The polygon to check.
Returns:
true if polygon is visible.

displaySegments

protected void displaySegments()
Finally display all segments in currect path.


displaySegments

protected void displaySegments(java.awt.Color newColor)
Finally display all segments in currect path.

Parameters:
newColor - This color is set after the path is drawn.


JOSM