public class StyledMapRenderer extends AbstractMapRenderer
Modifier and Type | Class and Description |
---|---|
private class |
StyledMapRenderer.ComputeStyleListWorker |
private class |
StyledMapRenderer.ConcurrentTasksHelper |
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 static class |
StyledMapRenderer.StyleRecord |
Modifier and Type | Field and Description |
---|---|
private java.lang.Object |
antialiasing |
private double |
circum |
private static double |
cosPHI |
private static int |
FLAG_DISABLED
A primitive with
OsmPrimitive.isDisabled() |
private static int |
FLAG_MEMBER_OF_SELECTED
A primitive with
OsmPrimitive.isMemberOfSelected() |
private static int |
FLAG_NORMAL
Flags used to store the primitive state along with the style.
|
private static int |
FLAG_OUTERMEMBER_OF_SELECTED
A primitive with
OsmPrimitive.isOuterMemberOfSelected() |
private static int |
FLAG_SELECTED
A primitive with
OsmPrimitive.isSelected() |
private java.awt.Color |
highlightColorTransparent |
private int |
highlightLineWidth |
private int |
highlightPointRadius |
private int |
highlightStep |
private java.util.Collection<WaySegment> |
highlightWaySegments |
private static java.util.Map<java.awt.Font,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 boolean |
showIcons |
private boolean |
showNames |
private static double |
sinPHI |
private static Pair<java.lang.Integer,java.util.concurrent.ExecutorService> |
THREAD_POOL |
private boolean |
useStrokes |
private boolean |
useWiderHighlight |
private int |
widerHighlight |
backgroundColor, g, highlightColor, inactiveColor, isInactiveMode, nc, nodeColor, relationSelectedColor, segmentNumberSpace, selectedColor, virtualNodeSize, virtualNodeSpace
Constructor and Description |
---|
StyledMapRenderer(java.awt.Graphics2D g,
NavigatableComponent nc,
boolean isInactiveMode)
Constructs a new
StyledMapRenderer . |
Modifier and Type | Method and Description |
---|---|
private java.awt.Polygon |
buildPolygon(java.awt.Point center,
int radius,
int sides) |
private static java.awt.Polygon |
buildPolygon(java.awt.Point center,
int radius,
int sides,
double rotation) |
static int |
computeFlags(OsmPrimitive primitive,
boolean checkOuterMember)
Computes the flags for a given OSM primitive.
|
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) |
private void |
displayText(java.awt.font.GlyphVector gv,
java.lang.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,
java.awt.geom.Path2D.Double path,
java.awt.Color color,
MapImage fillImage,
java.lang.Float extent,
boolean disabled,
TextElement text) |
void |
drawArea(Relation r,
java.awt.Color color,
MapImage fillImage,
java.lang.Float extent,
boolean disabled,
TextElement text)
Draws a multipolygon area.
|
void |
drawArea(Way w,
java.awt.Color color,
MapImage fillImage,
java.lang.Float extent,
boolean disabled,
TextElement text)
Draws an area defined by a way.
|
private void |
drawAreaText(OsmPrimitive osm,
TextElement text,
java.awt.Shape area) |
void |
drawBoxText(Node n,
BoxTextElemStyle bs) |
void |
drawNode(Node n,
java.awt.Color color,
int size,
boolean fill)
Draw the node as small square with the given color.
|
void |
drawNodeIcon(Node n,
MapImage img,
boolean disabled,
boolean selected,
boolean member,
double theta) |
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 |
drawRepeatImage(Way way,
MapImage pattern,
boolean disabled,
double offset,
double spacing,
double phase,
RepeatImageElemStyle.LineImageAlignment align)
Draw an image along a way repeatedly.
|
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,
boolean disabled) |
void |
drawTextOnPath(Way way,
TextElement text)
Draws a text along a given way.
|
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()
Gets the "circum".
|
void |
getColors()
Reads the color definitions from preferences.
|
private static java.awt.geom.Path2D.Double |
getPath(Way w) |
void |
getSettings(boolean virtual)
Reads all the settings from preferences.
|
private boolean |
isAreaVisible(java.awt.geom.Path2D.Double area) |
static boolean |
isGlyphVectorDoubleTranslationBug(java.awt.Font font)
Check, if this System has the GlyphVector double translation bug.
|
boolean |
isInactiveMode() |
boolean |
isShowIcons() |
boolean |
isShowNames() |
private static double[] |
pointAt(double t,
java.awt.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 final Pair<java.lang.Integer,java.util.concurrent.ExecutorService> THREAD_POOL
private static java.util.Map<java.awt.Font,java.lang.Boolean> IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG
private double circum
private MapPaintSettings paintSettings
private java.awt.Color highlightColorTransparent
private static final int FLAG_NORMAL
Not used in any public interfaces.
private static final int FLAG_DISABLED
OsmPrimitive.isDisabled()
private static final int FLAG_MEMBER_OF_SELECTED
OsmPrimitive.isMemberOfSelected()
private static final int FLAG_SELECTED
OsmPrimitive.isSelected()
private static final int FLAG_OUTERMEMBER_OF_SELECTED
OsmPrimitive.isOuterMemberOfSelected()
private static final double PHI
private static final double cosPHI
private static final double sinPHI
private java.util.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 java.awt.Font orderFont
private boolean leftHandTraffic
private java.lang.Object antialiasing
public StyledMapRenderer(java.awt.Graphics2D g, NavigatableComponent nc, boolean isInactiveMode)
StyledMapRenderer
.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.java.lang.IllegalArgumentException
- if g
is nulljava.lang.IllegalArgumentException
- if nc
is nullpublic static boolean isGlyphVectorDoubleTranslationBug(java.awt.Font font)
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.
After switch to Java 7, this test is a false positive on Mac OS X (see #10446),
i.e. it returns true, but the real rendering code does not require any special
handling.
It hasn't been further investigated why the test reports a wrong result in
this case, but the method has been changed to simply return false by default.
(This can be changed with a setting in the advanced preferences.)font
- The font to check.private java.awt.Polygon buildPolygon(java.awt.Point center, int radius, int sides)
private static 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)
private void displayText(java.awt.font.GlyphVector gv, java.lang.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, java.awt.geom.Path2D.Double path, java.awt.Color color, MapImage fillImage, java.lang.Float extent, boolean disabled, TextElement text)
private void drawAreaText(OsmPrimitive osm, TextElement text, java.awt.Shape area)
public void drawArea(Relation r, java.awt.Color color, MapImage fillImage, java.lang.Float extent, boolean disabled, TextElement text)
r
- The multipolygon relationcolor
- The color to fill the area with.fillImage
- The image to fill the area with. Overrides color.extent
- if not null, area will be filled partially; specifies, how
far to fill from the boundary towards the center of the area;
if null, area will be filled completelydisabled
- If this should be drawn with a special disabled style.text
- The text to write on the area.public void drawArea(Way w, java.awt.Color color, MapImage fillImage, java.lang.Float extent, boolean disabled, TextElement text)
w
- The way.color
- The color to fill the area with.fillImage
- The image to fill the area with. Overrides color.extent
- if not null, area will be filled partially; specifies, how
far to fill from the boundary towards the center of the area;
if null, area will be filled completelydisabled
- If this should be drawn with a special disabled style.text
- The text to write on the area.public void drawBoxText(Node n, BoxTextElemStyle bs)
public void drawRepeatImage(Way way, MapImage pattern, boolean disabled, double offset, double spacing, double phase, RepeatImageElemStyle.LineImageAlignment align)
way
- the waypattern
- the imagedisabled
- If this should be drawn with a special disabled style.offset
- 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, java.awt.Color color, int size, boolean fill)
AbstractMapRenderer
drawNode
in class AbstractMapRenderer
n
- The node to draw.color
- The color of the node.size
- size in pixelsfill
- determines if the square mmust be filledpublic void drawNodeIcon(Node n, MapImage img, boolean disabled, boolean selected, boolean member, double theta)
public void drawNodeSymbol(Node n, NodeElemStyle.Symbol s, java.awt.Color fillColor, java.awt.Color strokeColor)
public void drawOrderNumber(Node n1, Node n2, int orderNumber, java.awt.Color clr)
n1
- First node of the way segment.n2
- Second node of the way segment.orderNumber
- The number of the segment in the way.clr
- The color to use for drawing the text.private void drawPathHighlight(java.awt.geom.GeneralPath path, java.awt.BasicStroke line)
path
- path to drawline
- line styleprivate void drawPointHighlight(java.awt.Point p, int size)
public void drawRestriction(java.awt.Image img, java.awt.Point pVia, double vx, double vx2, double vy, double vy2, double angle, boolean selected)
public void drawRestriction(Relation r, MapImage icon, boolean disabled)
public void drawTextOnPath(Way way, TextElement text)
way
- The way to draw the text on.text
- The text definition (font/.../text content) to draw.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)
way
- The way to drawcolor
- The base color to draw the way inline
- The line style to use. This is drawn using color.dashes
- The dash style to use. This is drawn using dashedColor. null
if unused.dashedColor
- The color of the dashes.offset
- The offsetshowOrientation
- show arrows that indicate the technical orientation of
the way (defined by order of nodes)showHeadArrowOnly
- True if only the arrow at the end of the line but not those on the segments should be displayed.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
public void getSettings(boolean virtual)
AbstractMapRenderer
getSettings
in class AbstractMapRenderer
virtual
- true
if virtual nodes are usedprivate boolean isAreaVisible(java.awt.geom.Path2D.Double area)
public boolean isInactiveMode()
public boolean isShowIcons()
public boolean isShowNames()
private static double[] pointAt(double t, java.awt.Polygon poly, double pathLength)
public static int computeFlags(OsmPrimitive primitive, boolean checkOuterMember)
primitive
- The primititve to compute the flags for.checkOuterMember
- true
if we should also add FLAG_OUTERMEMBER_OF_SELECTED
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