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
Renderingimplementations.- Since:
- 4087
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.ColorbackgroundColorColor Preference for backgroundprotected booleandoSlowOperationsPerforms slow operations by default.protected java.awt.Graphics2Dgthe graphics context to which the visitor renders OSM objectsprotected java.awt.ColorhighlightColorColor Preference for highlighted objectsprotected java.awt.ColorinactiveColorColor Preference for inactive objectsprotected booleanisInactiveModeif true, the paint visitor shall render OSM objects such that they look inactive.protected MapViewStatemapStateTheMapViewStateto use to convert between coordinates.protected NavigatableComponentncthe map viewport - provides projection and hit detection functionalityprotected java.awt.ColornodeColorColor Preference for nodesprotected java.awt.ColorrelationSelectedColorColor Preference for members of selected relationsprotected intsegmentNumberSpacePreference: minimum space (displayed way length) to display segment numbersprotected java.awt.ColorselectedColorColor Preference for selected objectsprotected intvirtualNodeSizePreference: size of virtual nodes (0 displays display)protected intvirtualNodeSpacePreference: minimum space (displayed way length) to display virtual nodes
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMapRenderer(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 voiddrawNode(INode n, java.awt.Color color, int size, boolean fill)Draw the node as small square with the given color.protected voiddrawOrderNumber(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 wayvoiddrawVirtualNodes(OsmData<?,?,?,?> data, BBox bbox)Draws virtual nodes.voidenableSlowOperations(boolean enable)Sets whether slow operations such as text rendering must be performed (true by default).voidgetColors()Reads the color definitions from preferences.protected voidgetSettings(boolean virtual)Reads all the settings from preferences.static booleanisLargeSegment(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2, int space)Checks if a way segment is large enough for additional information display.protected booleanisSegmentVisible(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2)Checks if segment is visible in display.protected booleanisSegmentVisible(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2, MapViewState.MapViewRectangle view)Checks if segment is visible in display.voidvisitVirtual(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
TheMapViewStateto 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- ifgis nulljava.lang.IllegalArgumentException- ifncis 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-trueif 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:
trueif 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:
trueif 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:
trueif 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
-
-