Package dev.avelar.mapnik
Class Symbolizer
java.lang.Object
dev.avelar.mapnik.Symbolizer
One drawing instruction inside a
Rule: how to draw the geometry of a matching feature.
Build one with a factory such as polygon(), then set attributes, using the typed methods
for common ones or attr(String, Object) for any other. Attribute names are the ones in
Mapnik's XML reference, for example stroke-dasharray or halo-radius.
Mapnik silently ignores attributes it does not know. MapnikMap.addStyle(dev.avelar.mapnik.Style) therefore loads
the style in Mapnik's strict mode, which rejects a misspelled attribute, or one that does not
belong on that kind of symbolizer, and says which.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhere labels go relative to the geometry.static enumWhich placements to try for a label, in order, when the first does not fit. -
Method Summary
Modifier and TypeMethodDescriptionallowOverlap(boolean v) Set any attribute.One attribute's value, or empty if it is not set.The attributes set so far, in the order they were set.avoidEdges(boolean v) Text: do not draw labels that would be cut by the edge of the map or tile.body()The text inside the element, such as the expression of a text symbolizer, if it has any.static Symbolizerbuilding()Extrude polygons into simple 3D buildings.Add a nested XML element, for symbolizers that take them, such as the colorizer of a raster symbolizer or a text placement.children()Nested elements as XML text, in order.colorizer(RasterColorizer colorizer) Colour a single-band raster by value.Compositing mode, such asmultiplyorscreen.static Symbolizerdebug()Draw the collision boxes Mapnik computes, for debugging label placement.displacement(double dx, double dy) Text: shift the label by this many pixels.static Symbolizerdot()Draw a dot at each point.element()The element name, for examplePolygonSymbolizer.Text: the font face, for example"DejaVu Sans Book".Fill colour: a name,#rrggbborrgba(r,g,b,a).fillOpacity(double v) fontFeatureSettings(String settings) Text: OpenType features, for example"liga=0, smcp".fontSize(double v) Text: the font size in pixels.static SymbolizerformattedText(TextFormat... formats) Draw text made of several runs, each with its own look.static Symbolizergroup()A group of symbols and labels drawn together for features that share a key, such as a cluster of points.groupColumns(int startColumn, int numColumns, String repeatKey) Which columns of the group layout this symbolizer fills (start-column, 1-based, and how many,num-columns) and the expression that says which features belong together (repeat-key, for example"[id]").Text: outline colour and width.horizontalAlignment(String alignment) Text: horizontal alignment of the label to its position:left,middle,right,autooradjust.ignorePlacement(boolean v) Markers, points and shields (not text): draw without making room for it, so it never blocks later labels.Text: how lines of a wrapped label line up with each other:left,center,rightorauto.labelPlacement(Symbolizer.LabelPlacement placement) Text and shields: where labels go: along a line, at a point, inside a polygon and so on.labelPositionTolerance(double pixels) Text: how far in pixels a label may move along a line to find room.labelSpacing(double pixels) Text on lines: distance between labels along a line, in pixels.largestBoxOnly(boolean v) Text: label only the largest part of a multipart geometry.static Symbolizerline()Stroke lines and polygon outlines:stroke,stroke-width,stroke-dasharray, ...static SymbolizerlinePattern(String file) Stroke lines with a repeating image.margin(double pixels) Text: keep labels this many pixels away from other labels with the same text.static Symbolizermarkers()Draw markers at points, along lines or inside polygons:marker-type,width,fill, ...maxCharAngleDelta(double degrees) Text on lines: the largest angle in degrees between two letters, so labels do not bend sharply.minimumPadding(double pixels) Text: keep labels this many pixels away from the edge of the map or tile.minimumPathLength(double pixels) Text on lines: skip lines shorter than this many pixels.opacity(double v) Opacity, for symbolizers that have it: markers, point, dot, raster, text and the pattern symbolizers.pairLayout(double itemMargin) Lay group members out in pairs side by side.placementList(TextPlacement... placements) Try these alternatives in order until one fits.placementPositions(String positions) Try these positions around a point, for example"E,NE,SE,W"(east, north-east and so on) and use the first that fits.placementSizes(int... sizes) Text: if a label does not fit at any position, try again at these smaller font sizes, in whole pixels and largest first.static SymbolizerDraw an image file at each point.static Symbolizerpolygon()Fill polygons:fill,fill-opacity,gamma,smooth, ...static SymbolizerpolygonPattern(String file) Fill polygons with a repeating image.positions(Symbolizer.Position... positions) Text: try these positions around the point in turn until a label fits, for examplepositions(Position.NORTH_EAST, Position.SOUTH_EAST, Position.EXACT).static Symbolizerraster()Draw raster data.repeatDistance(double pixels) Text on lines: repeat the label every this many pixels along the line.rotation(double degrees) Text: turn the label by this many degrees clockwise.static SymbolizerA text label drawn on top of an image, such as a road shield.simpleLayout(double itemMargin) Lay group members out in a column,itemMarginpixels apart.size(double width, double height) Markers and dots: width and height in pixels.For example"5,3": 5 units on, 3 off.butt,roundorsquare.miter,roundorbevel.strokeOpacity(double v) strokeWidth(double v) static SymbolizerDraw text.textTransform(String transform) Text: change the case of the label:none,uppercase,lowercase,capitalizeorreverse.toString()toXml()Text on lines: which way up the letters stand:auto,auto-down,left,right,left-onlyorright-only.verticalAlignment(String alignment) Text: vertical alignment of the label to its position:top,middle,bottomorauto.wrapBefore(boolean v) Text: wrap before the wrap character instead of after it.wrapCharacter(String character) Text: the character to wrap at, a space by default.wrapWidth(double pixels) Text: wrap lines longer than this many pixels.
-
Method Details
-
polygon
Fill polygons:fill,fill-opacity,gamma,smooth, ... -
line
Stroke lines and polygon outlines:stroke,stroke-width,stroke-dasharray, ... -
markers
Draw markers at points, along lines or inside polygons:marker-type,width,fill, ... -
point
Draw an image file at each point. -
polygonPattern
Fill polygons with a repeating image. -
linePattern
Stroke lines with a repeating image. -
raster
Draw raster data. -
building
Extrude polygons into simple 3D buildings. -
dot
Draw a dot at each point. -
debug
Draw the collision boxes Mapnik computes, for debugging label placement. -
text
Draw text.expressionsays what to write, in Mapnik's expression language, for example"[name]"or"[name] + ' (' + [pop] + ')'". Needs a font: setface-nameand register the fonts withMapnik.registerFonts(java.lang.String). -
formattedText
Draw text made of several runs, each with its own look. The symbolizer itself still needs aface-name(orfontset-name) as the default, which each run may override:Symbolizer.formattedText(TextFormat.of("[name]").fontSize(14), TextFormat.of("' ' + [pop]").fontSize(10).fill("gray")) .faceName("DejaVu Sans Bold"); -
placementList
Try these alternatives in order until one fits. Only forformattedText(dev.avelar.mapnik.TextFormat...). Setsplacement-typetolist. -
placementPositions
Try these positions around a point, for example"E,NE,SE,W"(east, north-east and so on) and use the first that fits. Setsplacement-typetosimple. -
group
A group of symbols and labels drawn together for features that share a key, such as a cluster of points. Add rules withgroupRule(dev.avelar.mapnik.GroupRule)and choose how members are laid out.Mapnik draws nothing for a group unless it has a column range and a key: call
groupColumns(int, int, java.lang.String)too. -
groupRule
-
groupColumns
Which columns of the group layout this symbolizer fills (start-column, 1-based, and how many,num-columns) and the expression that says which features belong together (repeat-key, for example"[id]"). Mapnik draws a group only when all three are set. Only forgroup(). -
simpleLayout
Lay group members out in a column,itemMarginpixels apart. Only forgroup(). -
pairLayout
Lay group members out in pairs side by side. Only forgroup(). -
shield
A text label drawn on top of an image, such as a road shield. -
attr
Set any attribute. The value is written withtoString(), except that numbers have no trailing.0and booleans aretrueorfalse. -
fill
Fill colour: a name,#rrggbborrgba(r,g,b,a). -
fill
-
fillOpacity
-
stroke
-
stroke
-
strokeWidth
-
strokeOpacity
-
strokeDasharray
For example"5,3": 5 units on, 3 off. -
strokeLinejoin
miter,roundorbevel. -
strokeLinecap
butt,roundorsquare. -
opacity
Opacity, for symbolizers that have it: markers, point, dot, raster, text and the pattern symbolizers. Polygons and lines have none; usefillOpacity(double)andstrokeOpacity(double). -
compOp
Compositing mode, such asmultiplyorscreen. -
compOp
-
size
Markers and dots: width and height in pixels. -
allowOverlap
-
faceName
Text: the font face, for example"DejaVu Sans Book". -
fontSize
Text: the font size in pixels. -
labelPlacement
Text and shields: where labels go: along a line, at a point, inside a polygon and so on. -
positions
Text: try these positions around the point in turn until a label fits, for examplepositions(Position.NORTH_EAST, Position.SOUTH_EAST, Position.EXACT). Add smaller font sizes to fall back to withplacementSizes(int...). -
placementSizes
Text: if a label does not fit at any position, try again at these smaller font sizes, in whole pixels and largest first. Mapnik tries every position at each size. Callpositions(dev.avelar.mapnik.Symbolizer.Position...)first. -
margin
Text: keep labels this many pixels away from other labels with the same text. (Mapnik's olderminimum-distanceis deprecated and refuses to combine withrepeatDistance(double).) -
minimumPadding
Text: keep labels this many pixels away from the edge of the map or tile. -
avoidEdges
Text: do not draw labels that would be cut by the edge of the map or tile. -
repeatDistance
Text on lines: repeat the label every this many pixels along the line. -
labelSpacing
Text on lines: distance between labels along a line, in pixels. -
minimumPathLength
Text on lines: skip lines shorter than this many pixels. -
maxCharAngleDelta
Text on lines: the largest angle in degrees between two letters, so labels do not bend sharply. -
labelPositionTolerance
Text: how far in pixels a label may move along a line to find room. -
largestBoxOnly
Text: label only the largest part of a multipart geometry. -
ignorePlacement
Markers, points and shields (not text): draw without making room for it, so it never blocks later labels. -
wrapWidth
Text: wrap lines longer than this many pixels. -
wrapCharacter
Text: the character to wrap at, a space by default. -
wrapBefore
Text: wrap before the wrap character instead of after it. -
justify
Text: how lines of a wrapped label line up with each other:left,center,rightorauto. -
horizontalAlignment
Text: horizontal alignment of the label to its position:left,middle,right,autooradjust. -
verticalAlignment
Text: vertical alignment of the label to its position:top,middle,bottomorauto. -
upright
Text on lines: which way up the letters stand:auto,auto-down,left,right,left-onlyorright-only. -
displacement
Text: shift the label by this many pixels. Positive x is right and positive y is down. -
rotation
Text: turn the label by this many degrees clockwise. -
textTransform
Text: change the case of the label:none,uppercase,lowercase,capitalizeorreverse. -
fontFeatureSettings
Text: OpenType features, for example"liga=0, smcp". -
halo
Text: outline colour and width. -
halo
-
child
Add a nested XML element, for symbolizers that take them, such as the colorizer of a raster symbolizer or a text placement. Typed builders such asRasterColorizeruse this; write raw XML only for elements that have no builder. A symbolizer made withtext(java.lang.String)keeps its expression as body text, so it cannot also have children. -
colorizer
Colour a single-band raster by value. Only forraster(). -
attribute
One attribute's value, or empty if it is not set. -
body
The text inside the element, such as the expression of a text symbolizer, if it has any. -
children
Nested elements as XML text, in order. -
element
The element name, for examplePolygonSymbolizer. -
attributes
The attributes set so far, in the order they were set. -
toXml
-
toString
-