public class StyledMapRenderer extends AbstractMapRenderer
A map renderer which renders a map according to style rules in a set of style sheets.
Modifier and Type | Class and Description |
---|---|
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 |
Modifier and Type | Field and Description |
---|---|
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 Color |
highlightColorTransparent |
private int |
highlightLineWidth |
private int |
highlightPointRadius |
private int |
highlightStep |
private Collection<WaySegment> |
highlightWaySegments |
private static Boolean |
IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG |
private boolean |
isOutlineOnly |
private boolean |
leftHandTraffic |
private Font |
orderFont |
private MapPaintSettings |
paintSettings |
private static double |
PHI |
private Color |
relationSelectedColor |
private boolean |
showIcons |
private boolean |
showNames |
private static double |
sinPHI |
private ElemStyles |
styles |
private boolean |
useStrokes |
private boolean |
useWiderHighlight |
private int |
widerHighlight |
backgroundColor, g, highlightColor, inactiveColor, isInactiveMode, nc, nodeColor, segmentNumberSpace, selectedColor, virtualNodeSize, virtualNodeSpace
Constructor and Description |
---|
StyledMapRenderer(Graphics2D g,
NavigatableComponent nc,
boolean isInactiveMode) |
Modifier and Type | Method and Description |
---|---|
private Polygon |
buildPolygon(Point center,
int radius,
int sides) |
private Polygon |
buildPolygon(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(GeneralPath path,
GeneralPath orientationArrows,
GeneralPath onewayArrows,
GeneralPath onewayArrowsCasing,
Color color,
BasicStroke line,
BasicStroke dashes,
Color dashedColor) |
private void |
displayText(GlyphVector gv,
String s,
int x,
int y,
boolean disabled,
TextElement text)
Displays text at specified position including its halo, if applicable.
|
protected void |
drawArea(OsmPrimitive osm,
Path2D.Double path,
Color color,
MapImage fillImage,
TextElement text) |
void |
drawArea(Relation r,
Color color,
MapImage fillImage,
TextElement text) |
void |
drawArea(Way w,
Color color,
MapImage fillImage,
TextElement text) |
void |
drawBoxText(Node n,
BoxTextElemStyle bs) |
void |
drawLinePattern(Way way,
Image pattern)
Deprecated.
|
void |
drawNode(Node n,
Color color,
int size,
boolean fill)
Draw the node as small rectangle with the given color.
|
void |
drawNodeIcon(Node n,
Image img,
float alpha,
boolean selected,
boolean member) |
void |
drawNodeSymbol(Node n,
NodeElemStyle.Symbol s,
Color fillColor,
Color strokeColor) |
void |
drawOrderNumber(Node n1,
Node n2,
int orderNumber,
Color clr)
Draw a number of the order of the two consecutive nodes within the
parents way
|
private void |
drawPathHighlight(GeneralPath path,
BasicStroke line)
highlights a given GeneralPath using the settings from BasicStroke to match the line's
style.
|
private void |
drawPointHighlight(Point p,
int size)
highlights a given point by drawing a rounded rectangle around it.
|
void |
drawRepeatImage(Way way,
Image pattern,
float offset,
float spacing,
float phase,
RepeatImageElemStyle.LineImageAlignment align)
Draw an image along a way repeatedly.
|
void |
drawRestriction(Image img,
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,
Color color,
BasicStroke line,
BasicStroke dashes,
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 Path2D.Double |
getPath(Way w) |
protected void |
getSettings(boolean virtual)
Reads all the settings from preferences.
|
private boolean |
isAreaVisible(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,
Polygon poly,
double pathLength) |
void |
render(DataSet data,
boolean renderVirtualNodes,
Bounds bounds)
Renders the OSM data in
data |
drawOrderNumber, drawVirtualNodes, isLargeSegment, isSegmentVisible, visitVirtual
private static Boolean IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG
private ElemStyles styles
private double circum
private MapPaintSettings paintSettings
private Color relationSelectedColor
private Color highlightColorTransparent
private static final int FLAG_NORMAL
private static final int FLAG_DISABLED
private static final int FLAG_MEMBER_OF_SELECTED
private static final int FLAG_SELECTED
private static final double PHI
private static final double cosPHI
private static final double sinPHI
private Collection<WaySegment> highlightWaySegments
private int highlightLineWidth
private int highlightPointRadius
private int widerHighlight
private int highlightStep
private boolean useWiderHighlight
private boolean useStrokes
private boolean showNames
private boolean showIcons
private boolean isOutlineOnly
private boolean leftHandTraffic
public StyledMapRenderer(Graphics2D g, NavigatableComponent nc, boolean isInactiveMode)
public static boolean isGlyphVectorDoubleTranslationBug()
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.private Polygon buildPolygon(Point center, int radius, int sides)
private Polygon buildPolygon(Point center, int radius, int sides, double rotation)
private void collectNodeStyles(DataSet data, StyledMapRenderer.StyleCollector sc, BBox bbox)
private void collectWayStyles(DataSet data, StyledMapRenderer.StyleCollector sc, BBox bbox)
private void collectRelationStyles(DataSet data, StyledMapRenderer.StyleCollector sc, BBox bbox)
private void displaySegments(GeneralPath path, GeneralPath orientationArrows, GeneralPath onewayArrows, GeneralPath onewayArrowsCasing, Color color, BasicStroke line, BasicStroke dashes, Color dashedColor)
private void displayText(GlyphVector gv, String s, int x, int y, boolean disabled, TextElement text)
gv
- Text's glyphs to display. If null
, use text from s
instead.s
- text to display if gv
is null
x
- X positiony
- Y positiondisabled
- true
if element is disabled (filtered out)text
- text style to useprotected void drawArea(OsmPrimitive osm, Path2D.Double path, Color color, MapImage fillImage, TextElement text)
public void drawArea(Relation r, Color color, MapImage fillImage, TextElement text)
public void drawArea(Way w, Color color, MapImage fillImage, TextElement text)
public void drawBoxText(Node n, BoxTextElemStyle bs)
@Deprecated public void drawLinePattern(Way way, Image pattern)
public void drawRepeatImage(Way way, Image pattern, float offset, float spacing, float phase, RepeatImageElemStyle.LineImageAlignment align)
way
- the waypattern
- the imageoffset
- offset from the wayspacing
- spacing between two imagesphase
- initial spacingalign
- alignment of the image. The top, center or bottom edge
can be aligned with the way.public void drawNode(Node n, Color color, int size, boolean fill)
AbstractMapRenderer
drawNode
in class AbstractMapRenderer
n
- The node to draw.color
- The color of the node.public void drawNodeIcon(Node n, Image img, float alpha, boolean selected, boolean member)
public void drawNodeSymbol(Node n, NodeElemStyle.Symbol s, Color fillColor, Color strokeColor)
public void drawOrderNumber(Node n1, Node n2, int orderNumber, Color clr)
private void drawPathHighlight(GeneralPath path, BasicStroke line)
path
- line
- private void drawPointHighlight(Point p, int size)
public void drawRestriction(Image img, Point pVia, double vx, double vx2, double vy, double vy2, double angle, boolean selected)
public void drawRestriction(Relation r, MapImage icon)
public void drawTextOnPath(Way way, TextElement text)
public void drawWay(Way way, Color color, BasicStroke line, BasicStroke dashes, Color dashedColor, float offset, boolean showOrientation, boolean showHeadArrowOnly, boolean showOneway, boolean onewayReversed)
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 waterwayonewayReversed
- for oneway=-1 and similarpublic double getCircum()
public void getColors()
AbstractMapRenderer
public
, so that
color names in preferences can be displayed even without calling the wireframe display before.getColors
in class AbstractMapRenderer
protected void getSettings(boolean virtual)
AbstractMapRenderer
getSettings
in class AbstractMapRenderer
virtual
- true
if virtual nodes are usedprivate Path2D.Double getPath(Way w)
private boolean isAreaVisible(Path2D.Double area)
public boolean isInactiveMode()
public boolean isShowIcons()
public boolean isShowNames()
public void render(DataSet data, boolean renderVirtualNodes, Bounds bounds)
Rendering
Renders the OSM data in data
data
- the data set to be renderedrenderVirtualNodes
- 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