Class AbstractMapRenderer
- java.lang.Object
-
- 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.- Since:
- 4087
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Color
backgroundColor
Color Preference for backgroundprotected boolean
doSlowOperations
Performs slow operations by default.protected java.awt.Graphics2D
g
the graphics context to which the visitor renders OSM objectsprotected java.awt.Color
highlightColor
Color Preference for highlighted objectsprotected java.awt.Color
inactiveColor
Color Preference for inactive objectsprotected boolean
isInactiveMode
if true, the paint visitor shall render OSM objects such that they look inactive.protected MapViewState
mapState
TheMapViewState
to use to convert between coordinates.protected NavigatableComponent
nc
the map viewport - provides projection and hit detection functionalityprotected java.awt.Color
nodeColor
Color Preference for nodesprotected java.awt.Color
relationSelectedColor
Color Preference for members of selected relationsprotected int
segmentNumberSpace
Preference: minimum space (displayed way length) to display segment numbersprotected java.awt.Color
selectedColor
Color Preference for selected objectsprotected int
virtualNodeSize
Preference: size of virtual nodes (0 displays display)protected int
virtualNodeSpace
Preference: minimum space (displayed way length) to display virtual nodes
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMapRenderer(java.awt.Graphics2D g, NavigatableComponent nc, boolean isInactiveMode)
Creates an abstract paint visitor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
drawNode(INode n, java.awt.Color color, int size, boolean fill)
Draw the node as small square with the given color.protected void
drawOrderNumber(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2, int orderNumber, java.awt.Color clr)
Draw an number of the order of the two consecutive nodes within the parents wayvoid
drawVirtualNodes(OsmData<?,?,?,?> data, BBox bbox)
Draws virtual nodes.void
enableSlowOperations(boolean enable)
Sets whether slow operations such as text rendering must be performed (true by default).void
getColors()
Reads the color definitions from preferences.protected void
getSettings(boolean virtual)
Reads all the settings from preferences.static boolean
isLargeSegment(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2, int space)
Checks if a way segment is large enough for additional information display.protected boolean
isSegmentVisible(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2)
Checks if segment is visible in display.protected boolean
isSegmentVisible(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2, MapViewState.MapViewRectangle view)
Checks if segment is visible in display.void
visitVirtual(java.awt.geom.Path2D path, IWay<?> w)
Creates path for drawing virtual nodes for one way.
-
-
-
Field Detail
-
g
protected final java.awt.Graphics2D g
the graphics context to which the visitor renders OSM objects
-
nc
protected final NavigatableComponent nc
the map viewport - provides projection and hit detection functionality
-
mapState
protected final MapViewState mapState
TheMapViewState
to use to convert between coordinates.
-
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
-
relationSelectedColor
protected java.awt.Color relationSelectedColor
Color Preference for members of selected relations
-
nodeColor
protected java.awt.Color nodeColor
Color Preference for nodes
-
highlightColor
protected java.awt.Color highlightColor
Color Preference for highlighted objects
-
virtualNodeSize
protected int virtualNodeSize
Preference: size of virtual nodes (0 displays 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
-
doSlowOperations
protected boolean doSlowOperations
Performs slow operations by default. Can be disabled when fast partial rendering is required
-
-
Constructor Detail
-
AbstractMapRenderer
protected AbstractMapRenderer(java.awt.Graphics2D g, NavigatableComponent nc, boolean isInactiveMode)
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
- ifg
is nulljava.lang.IllegalArgumentException
- ifnc
is null
-
-
Method Detail
-
drawNode
public abstract void drawNode(INode n, java.awt.Color color, int size, boolean fill)
Draw the node as small square with the given color.- Parameters:
n
- The node to draw.color
- The color of the node.size
- size in pixelsfill
- determines if the square must be filled
-
drawOrderNumber
protected void drawOrderNumber(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint 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.clr
- The color to use for drawing the text.- Since:
- 10827
-
drawVirtualNodes
public void drawVirtualNodes(OsmData<?,?,?,?> data, BBox bbox)
Draws virtual nodes.- Parameters:
data
- The data set being rendered.bbox
- The bounding box being displayed.- Since:
- 13810 (signature)
-
getColors
public void getColors()
Reads the color definitions from preferences. This function ispublic
, 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 thegetColors()
function.- Parameters:
virtual
-true
if virtual nodes are used
-
isLargeSegment
public static boolean isLargeSegment(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2, int space)
Checks if a way segment 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- Since:
- 10827
-
isSegmentVisible
protected boolean isSegmentVisible(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint 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 may be visible.- Since:
- 10827
- See Also:
for a more efficient version (cache the view)
-
isSegmentVisible
protected boolean isSegmentVisible(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2, MapViewState.MapViewRectangle view)
Checks if segment is visible in display.- Parameters:
p1
- First point of the way segment.p2
- Second point of the way segment.view
- The current view to check- Returns:
true
if segment may be visible.- Since:
- 18501
-
visitVirtual
public void visitVirtual(java.awt.geom.Path2D path, IWay<?> 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.- Since:
- 10827, 13810 (signature)
-
enableSlowOperations
public final void enableSlowOperations(boolean enable)
Sets whether slow operations such as text rendering must be performed (true by default).- Parameters:
enable
- whether slow operations such as text rendering must be performed- Since:
- 13987
-
-