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 Object implements Rendering

Abstract common superclass for Rendering implementations.

Since:
4087
  • Field Details

    • g

      protected final 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
      The MapViewState 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

      Color Preference for background
    • inactiveColor

      protected Color inactiveColor
      Color Preference for inactive objects
    • selectedColor

      protected Color selectedColor
      Color Preference for selected objects
    • relationSelectedColor

      Color Preference for members of selected relations
    • nodeColor

      protected Color nodeColor
      Color Preference for nodes
    • highlightColor

      protected 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 Details

    • AbstractMapRenderer

      protected AbstractMapRenderer(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:
      IllegalArgumentException - if g is null
      IllegalArgumentException - if nc is null
  • Method Details

    • drawNode

      public abstract void drawNode(INode n, 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 pixels
      fill - determines if the square must be filled
    • drawOrderNumber

      protected void drawOrderNumber(MapViewState.MapViewPoint p1, MapViewState.MapViewPoint p2, int orderNumber, 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 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 getColors() 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

      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:
    • isSegmentVisible

      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(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