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

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.visitor.paint.MapPainter

public class MapPainter
extends java.lang.Object


Nested Class Summary
 class MapPainter.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.
 
Field Summary
private  java.awt.Color backgroundColor
           
private  double circum
           
private static double cosPHI
           
private  java.awt.Graphics2D g
           
private  java.awt.Color highlightColor
           
private  java.awt.Color highlightColorTransparent
           
private  java.util.Collection<WaySegment> highlightWaySegments
           
private  boolean inactive
           
private  java.awt.Color inactiveColor
           
private static java.lang.Boolean IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG
           
private  boolean isOutlineOnly
           
private  boolean leftHandTraffic
           
private  NavigatableComponent nc
           
private  java.awt.Color nodeColor
           
private  java.awt.Font orderFont
           
private static double PHI
           
private  java.awt.Color relationSelectedColor
           
private  int segmentNumberSpace
           
private  java.awt.Color selectedColor
           
private  MapPaintSettings settings
           
private  boolean showIcons
           
private  boolean showNames
           
private static double sinPHI
           
private  boolean useStrokes
           
private  int virtualNodeSize
           
private  int virtualNodeSpace
           
 
Constructor Summary
MapPainter(MapPaintSettings settings, java.awt.Graphics2D g, boolean inactive, NavigatableComponent nc, boolean virtual, double circum, boolean leftHandTraffic, java.util.Collection<WaySegment> highlightWaySegments)
           
 
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 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
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
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 drawVirtualNodes(java.util.Collection<Way> ways, java.util.Collection<WaySegment> highlightVirtualNodes)
           
 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()
           
private  java.awt.geom.Path2D.Double getPath(Way w)
           
private  boolean isAreaVisible(java.awt.geom.Path2D.Double area)
           
static boolean isGlyphVectorDoubleTranslationBug()
          Check, if this System has the GlyphVector double translation bug.
 boolean isInactiveMode()
           
private static boolean isLargeSegment(java.awt.Point p1, java.awt.Point p2, int space)
           
private  boolean isSegmentVisible(java.awt.Point p1, java.awt.Point p2)
           
 boolean isShowIcons()
           
 boolean isShowNames()
           
private  double[] pointAt(double t, java.awt.Polygon poly, double pathLength)
           
 void visitVirtual(java.awt.geom.GeneralPath path, Way w)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

g

private final java.awt.Graphics2D g

nc

private final NavigatableComponent nc

inactive

private final boolean inactive

settings

private final MapPaintSettings settings

highlightWaySegments

private final java.util.Collection<WaySegment> highlightWaySegments

useStrokes

private final boolean useStrokes

showNames

private final boolean showNames

showIcons

private final boolean showIcons

isOutlineOnly

private final boolean isOutlineOnly

inactiveColor

private final java.awt.Color inactiveColor

selectedColor

private final java.awt.Color selectedColor

relationSelectedColor

private final java.awt.Color relationSelectedColor

nodeColor

private final java.awt.Color nodeColor

highlightColor

private final java.awt.Color highlightColor

highlightColorTransparent

private final java.awt.Color highlightColorTransparent

backgroundColor

private final java.awt.Color backgroundColor

orderFont

private final java.awt.Font orderFont

virtualNodeSize

private final int virtualNodeSize

virtualNodeSpace

private final int virtualNodeSpace

segmentNumberSpace

private final int segmentNumberSpace

circum

private final double circum

leftHandTraffic

private final boolean leftHandTraffic

PHI

private static final double PHI

cosPHI

private static final double cosPHI

sinPHI

private static final double sinPHI

IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG

private static java.lang.Boolean IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG
Constructor Detail

MapPainter

public MapPainter(MapPaintSettings settings,
                  java.awt.Graphics2D g,
                  boolean inactive,
                  NavigatableComponent nc,
                  boolean virtual,
                  double circum,
                  boolean leftHandTraffic,
                  java.util.Collection<WaySegment> highlightWaySegments)
Method Detail

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

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)

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 -

isSegmentVisible

private boolean isSegmentVisible(java.awt.Point p1,
                                 java.awt.Point p2)

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

drawTextOnPath

public void drawTextOnPath(Way way,
                           TextElement text)

pointAt

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

drawLinePattern

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

drawNodeIcon

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

buildPolygon

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

buildPolygon

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

drawNodeSymbol

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

drawNode

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

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.


drawBoxText

public void drawBoxText(Node n,
                        BoxTextElemStyle bs)

getPath

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

drawArea

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

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)

isAreaVisible

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

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)

drawVirtualNodes

public void drawVirtualNodes(java.util.Collection<Way> ways,
                             java.util.Collection<WaySegment> highlightVirtualNodes)

visitVirtual

public void visitVirtual(java.awt.geom.GeneralPath path,
                         Way w)

isLargeSegment

private static boolean isLargeSegment(java.awt.Point p1,
                                      java.awt.Point p2,
                                      int space)

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


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


isShowNames

public boolean isShowNames()

getCircum

public double getCircum()

isShowIcons

public boolean isShowIcons()

isInactiveMode

public boolean isInactiveMode()


JOSM