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

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

public class StyledMapRenderer
extends AbstractMapRenderer

A map renderer which renders a map according to style rules in a set of style sheets.


Nested Class Summary
private  class StyledMapRenderer.OffsetIterator
          Iterates over a list of Way Nodes and returns screen coordinates that represent a line that is shifted by a certain offset perpendicular to the way direction.
private  class StyledMapRenderer.StyleCollector
           
private static class StyledMapRenderer.StyleRecord
           
 
Field Summary
private  double circum
           
private static double cosPHI
           
private static int FLAG_DISABLED
           
private static int FLAG_MEMBER_OF_SELECTED
           
private static int FLAG_NORMAL
           
private static int FLAG_SELECTED
           
private  java.awt.Color highlightColorTransparent
           
private  java.util.Collection<WaySegment> highlightWaySegments
           
private static java.lang.Boolean IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG
           
private  boolean isOutlineOnly
           
private  boolean leftHandTraffic
           
private  java.awt.Font orderFont
           
private  MapPaintSettings paintSettings
           
private static double PHI
           
private  java.awt.Color relationSelectedColor
           
private  boolean showIcons
           
private  boolean showNames
           
private static double sinPHI
           
private  ElemStyles styles
           
private  boolean useStrokes
           
 
Fields inherited from class org.openstreetmap.josm.data.osm.visitor.paint.AbstractMapRenderer
backgroundColor, g, highlightColor, inactiveColor, isInactiveMode, nc, nodeColor, segmentNumberSpace, selectedColor, virtualNodeSize, virtualNodeSpace
 
Constructor Summary
StyledMapRenderer(java.awt.Graphics2D g, NavigatableComponent nc, boolean isInactiveMode)
          
 
Method Summary
private  java.awt.Polygon buildPolygon(java.awt.Point center, int radius, int sides)
           
private  java.awt.Polygon buildPolygon(java.awt.Point center, int radius, int sides, double rotation)
           
private  void collectNodeStyles(DataSet data, StyledMapRenderer.StyleCollector sc, BBox bbox)
           
private  void collectRelationStyles(DataSet data, StyledMapRenderer.StyleCollector sc, BBox bbox)
           
private  void collectWayStyles(DataSet data, StyledMapRenderer.StyleCollector sc, BBox bbox)
           
private  void displaySegments(java.awt.geom.GeneralPath path, java.awt.geom.GeneralPath orientationArrows, java.awt.geom.GeneralPath onewayArrows, java.awt.geom.GeneralPath onewayArrowsCasing, java.awt.Color color, java.awt.BasicStroke line, java.awt.BasicStroke dashes, java.awt.Color dashedColor)
           
protected  void drawArea(OsmPrimitive osm, java.awt.geom.Path2D.Double path, java.awt.Color color, MapImage fillImage, TextElement text)
           
 void drawArea(Relation r, java.awt.Color color, MapImage fillImage, TextElement text)
           
 void drawArea(Way w, java.awt.Color color, MapImage fillImage, TextElement text)
           
 void drawBoxText(Node n, BoxTextElemStyle bs)
           
 void drawLinePattern(Way way, java.awt.Image pattern)
           
 void drawNode(Node n, java.awt.Color color, int size, boolean fill)
          Draw the node as small rectangle with the given color.
 void drawNodeIcon(Node n, java.awt.Image img, float alpha, boolean selected, boolean member)
           
 void drawNodeSymbol(Node n, NodeElemStyle.Symbol s, java.awt.Color fillColor, java.awt.Color strokeColor)
           
 void drawOrderNumber(Node n1, Node n2, int orderNumber, java.awt.Color clr)
          Draw a number of the order of the two consecutive nodes within the parents way
private  void drawPathHighlight(java.awt.geom.GeneralPath path, java.awt.BasicStroke line)
          highlights a given GeneralPath using the settings from BasicStroke to match the line's style.
private  void drawPointHighlight(java.awt.Point p, int size)
          highlights a given point by drawing a rounded rectangle around it.
 void drawRestriction(java.awt.Image img, java.awt.Point pVia, double vx, double vx2, double vy, double vy2, double angle, boolean selected)
           
 void drawRestriction(Relation r, MapImage icon)
           
 void drawTextOnPath(Way way, TextElement text)
           
 void drawWay(Way way, java.awt.Color color, java.awt.BasicStroke line, java.awt.BasicStroke dashes, java.awt.Color dashedColor, float offset, boolean showOrientation, boolean showHeadArrowOnly, boolean showOneway, boolean onewayReversed)
          draw way
 double getCircum()
           
 void getColors()
          Reads the color definitions from preferences.
private  java.awt.geom.Path2D.Double getPath(Way w)
           
protected  void getSettings(boolean virtual)
          Reads all the settings from preferences.
private  boolean isAreaVisible(java.awt.geom.Path2D.Double area)
           
static boolean isGlyphVectorDoubleTranslationBug()
          Check, if this System has the GlyphVector double translation bug.
 boolean isInactiveMode()
           
 boolean isShowIcons()
           
 boolean isShowNames()
           
private  double[] pointAt(double t, java.awt.Polygon poly, double pathLength)
           
 void render(DataSet data, boolean renderVirtualNodes, Bounds bounds)
          Renders the OSM data in data
 
Methods inherited from class org.openstreetmap.josm.data.osm.visitor.paint.AbstractMapRenderer
drawOrderNumber, drawVirtualNodes, isLargeSegment, isSegmentVisible, visitVirtual
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG

private static java.lang.Boolean IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG

styles

private ElemStyles styles

circum

private double circum

paintSettings

private MapPaintSettings paintSettings

relationSelectedColor

private java.awt.Color relationSelectedColor

highlightColorTransparent

private java.awt.Color highlightColorTransparent

FLAG_NORMAL

private static int FLAG_NORMAL

FLAG_DISABLED

private static int FLAG_DISABLED

FLAG_MEMBER_OF_SELECTED

private static int FLAG_MEMBER_OF_SELECTED

FLAG_SELECTED

private static int FLAG_SELECTED

PHI

private static final double PHI

cosPHI

private static final double cosPHI

sinPHI

private static final double sinPHI

highlightWaySegments

private java.util.Collection<WaySegment> highlightWaySegments

useStrokes

private boolean useStrokes

showNames

private boolean showNames

showIcons

private boolean showIcons

isOutlineOnly

private boolean isOutlineOnly

orderFont

private java.awt.Font orderFont

leftHandTraffic

private boolean leftHandTraffic
Constructor Detail

StyledMapRenderer

public StyledMapRenderer(java.awt.Graphics2D g,
                         NavigatableComponent nc,
                         boolean isInactiveMode)

Method Detail

isGlyphVectorDoubleTranslationBug

public static boolean isGlyphVectorDoubleTranslationBug()
Check, if this System has the GlyphVector double translation bug. With this bug, gv.setGlyphTransform(i, trfm) has a different effect than on most other systems, namely the translation components ("m02" & "m12", AffineTransform) appear to be twice as large, as they actually are. The rotation is unaffected (scale & shear not tested so far). This bug has only been observed on Mac OS X, see #7841.

Returns:
true, if the GlyphVector double translation bug is present on this System

buildPolygon

private java.awt.Polygon buildPolygon(java.awt.Point center,
                                      int radius,
                                      int sides)

buildPolygon

private java.awt.Polygon buildPolygon(java.awt.Point center,
                                      int radius,
                                      int sides,
                                      double rotation)

collectNodeStyles

private void collectNodeStyles(DataSet data,
                               StyledMapRenderer.StyleCollector sc,
                               BBox bbox)

collectRelationStyles

private void collectRelationStyles(DataSet data,
                                   StyledMapRenderer.StyleCollector sc,
                                   BBox bbox)

collectWayStyles

private void collectWayStyles(DataSet data,
                              StyledMapRenderer.StyleCollector sc,
                              BBox bbox)

displaySegments

private void displaySegments(java.awt.geom.GeneralPath path,
                             java.awt.geom.GeneralPath orientationArrows,
                             java.awt.geom.GeneralPath onewayArrows,
                             java.awt.geom.GeneralPath onewayArrowsCasing,
                             java.awt.Color color,
                             java.awt.BasicStroke line,
                             java.awt.BasicStroke dashes,
                             java.awt.Color dashedColor)

drawArea

protected void drawArea(OsmPrimitive osm,
                        java.awt.geom.Path2D.Double path,
                        java.awt.Color color,
                        MapImage fillImage,
                        TextElement text)

drawArea

public void drawArea(Relation r,
                     java.awt.Color color,
                     MapImage fillImage,
                     TextElement text)

drawArea

public void drawArea(Way w,
                     java.awt.Color color,
                     MapImage fillImage,
                     TextElement text)

drawBoxText

public void drawBoxText(Node n,
                        BoxTextElemStyle bs)

drawLinePattern

public void drawLinePattern(Way way,
                            java.awt.Image pattern)

drawNode

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

Specified by:
drawNode in class AbstractMapRenderer
Parameters:
n - The node to draw.
color - The color of the node.

drawNodeIcon

public void drawNodeIcon(Node n,
                         java.awt.Image img,
                         float alpha,
                         boolean selected,
                         boolean member)

drawNodeSymbol

public void drawNodeSymbol(Node n,
                           NodeElemStyle.Symbol s,
                           java.awt.Color fillColor,
                           java.awt.Color strokeColor)

drawOrderNumber

public void drawOrderNumber(Node n1,
                            Node n2,
                            int orderNumber,
                            java.awt.Color clr)
Draw a number of the order of the two consecutive nodes within the parents way


drawPathHighlight

private void drawPathHighlight(java.awt.geom.GeneralPath path,
                               java.awt.BasicStroke line)
highlights a given GeneralPath using the settings from BasicStroke to match the line's style. Width of the highlight is hard coded.

Parameters:
path -
line -

drawPointHighlight

private void drawPointHighlight(java.awt.Point p,
                                int size)
highlights a given point by drawing a rounded rectangle around it. Give the size of the object you want to be highlighted, width is added automatically.


drawRestriction

public void drawRestriction(java.awt.Image img,
                            java.awt.Point pVia,
                            double vx,
                            double vx2,
                            double vy,
                            double vy2,
                            double angle,
                            boolean selected)

drawRestriction

public void drawRestriction(Relation r,
                            MapImage icon)

drawTextOnPath

public void drawTextOnPath(Way way,
                           TextElement text)

drawWay

public void drawWay(Way way,
                    java.awt.Color color,
                    java.awt.BasicStroke line,
                    java.awt.BasicStroke dashes,
                    java.awt.Color dashedColor,
                    float offset,
                    boolean showOrientation,
                    boolean showHeadArrowOnly,
                    boolean showOneway,
                    boolean onewayReversed)
draw way

Parameters:
showOrientation - show arrows that indicate the technical orientation of the way (defined by order of nodes)
showOneway - show symbols that indicate the direction of the feature, e.g. oneway street or waterway
onewayReversed - for oneway=-1 and similar

getCircum

public double getCircum()

getColors

public void getColors()
Description copied from class: AbstractMapRenderer
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.

Overrides:
getColors in class AbstractMapRenderer

getSettings

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

Overrides:
getSettings in class AbstractMapRenderer
Parameters:
virtual - true if virtual nodes are used

getPath

private java.awt.geom.Path2D.Double getPath(Way w)

isAreaVisible

private boolean isAreaVisible(java.awt.geom.Path2D.Double area)

isInactiveMode

public boolean isInactiveMode()

isShowIcons

public boolean isShowIcons()

isShowNames

public boolean isShowNames()

pointAt

private double[] pointAt(double t,
                         java.awt.Polygon poly,
                         double pathLength)

render

public void render(DataSet data,
                   boolean renderVirtualNodes,
                   Bounds bounds)
Description copied from interface: Rendering

Renders the OSM data in data

Parameters:
data - the data set to be rendered
renderVirtualNodes - if true, renders virtual nodes. Otherwise, ignores them.
bounds - the bounding box for the data to be rendered. Only objects within or intersecting with bbox are rendered


JOSM