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

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

public abstract class AbstractMapRenderer
extends java.lang.Object
implements Rendering

Abstract common superclass for Rendering implementations.


Field Summary
protected  java.awt.Color backgroundColor
          Color Preference for background
protected  java.awt.Graphics2D g
          the graphics context to which the visitor renders OSM objects
protected  java.awt.Color highlightColor
          Color Preference for hightlighted objects
protected  java.awt.Color inactiveColor
          Color Preference for inactive objects
protected  boolean isInactiveMode
          if true, the paint visitor shall render OSM objects such that they look inactive.
protected  NavigatableComponent nc
          the map viewport - provides projection and hit detection functionality
protected  java.awt.Color nodeColor
          Color Preference for nodes
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 virtualNodeSize
          Preference: size of virtual nodes (0 displayes display)
protected  int virtualNodeSpace
          Preference: minimum space (displayed way length) to display virtual nodes
 
Constructor Summary
AbstractMapRenderer(java.awt.Graphics2D g, NavigatableComponent nc, boolean isInactiveMode)
          Creates an abstract paint visitor
 
Method Summary
abstract  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, java.awt.Color clr)
          Draw an number of the order of the two consecutive nodes within the parents way
 void drawVirtualNodes(DataSet data, BBox bbox)
          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 isSegmentVisible(java.awt.Point p1, java.awt.Point p2)
          Checks if segment is visible in display.
 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
 
Methods inherited from interface org.openstreetmap.josm.data.osm.visitor.paint.Rendering
render
 

Field Detail

g

protected java.awt.Graphics2D g
the graphics context to which the visitor renders OSM objects


nc

protected NavigatableComponent nc
the map viewport - provides projection and hit detection functionality


isInactiveMode

protected boolean 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.


backgroundColor

protected java.awt.Color backgroundColor
Color Preference for background


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


highlightColor

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


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

Constructor Detail

AbstractMapRenderer

public AbstractMapRenderer(java.awt.Graphics2D g,
                           NavigatableComponent nc,
                           boolean isInactiveMode)
                    throws java.lang.IllegalArgumentException

Creates an abstract paint visitor

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

drawNode

public abstract 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.

drawOrderNumber

protected void drawOrderNumber(java.awt.Point p1,
                               java.awt.Point p2,
                               int orderNumber,
                               java.awt.Color clr)
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.

drawVirtualNodes

public void drawVirtualNodes(DataSet data,
                             BBox bbox)
Draws virtual nodes.

Parameters:
data - The data set being rendered.
bbox - The bounding box being displayed.

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

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

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.

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.


JOSM