Package org.geotools.api.style
Interface TextSymbolizer
-
- All Superinterfaces:
Symbolizer
- All Known Implementing Classes:
TextSymbolizerImpl
public interface TextSymbolizer extends Symbolizer
Indicates how text will be drawn.- Since:
- GeoAPI 2.2
- Author:
- Open Geospatial Consortium, Johann Sorel (Geomatys), Chris Dillard (SYS Technologies)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classTextSymbolizer.DisplacementModeDisplacementMode associates an angle with each enum valuestatic classTextSymbolizer.GraphicPlacementGraphicPlacemnts controls the position of the Graphic associated with the labelstatic classTextSymbolizer.PolygonAlignOptionsEnumerated options that can be used with polygonAlign.
-
Field Summary
Fields Modifier and Type Field Description static StringALLOW_OVERRUNS_KEYWhen false does not allow labels on lines to get beyond the beginning/end of the line.static StringAUTO_WRAP_KEYNumber of pixels are which a long label should be split into multiple lines.static StringCHAR_SPACING_KEYOption expand/shrink character spacing, expressed as a value in pixels.static StringCONFLICT_RESOLUTION_KEYEnables conflict resolution (default, true) meaning no two labels will be allowed to overlap.static booleanDEFAULT_ALLOW_OVERRUNSWe allow labels that are longer than the line to appear by defaultstatic intDEFAULT_AUTO_WRAPAuto wrapping long labels defaultstatic doubleDEFAULT_CHAR_SPACINGDefault extra char spacing (no extra)static booleanDEFAULT_CONFLICT_RESOLUTIONBy default, put each label in the conflict resolution mapstatic booleanDEFAULT_FOLLOW_LINEIf labels with a line placement should follow the line shape or be just tangentstatic intDEFAULT_FONT_SHRINK_SIZE_MINDefault font shrink sizestatic booleanDEFAULT_FORCE_LEFT_TO_RIGHTForce labels to a readable orientation (so that they don't look "upside down")static doubleDEFAULT_GOODNESS_OF_FITDefault value for the goodness of fit thresholdstatic booleanDEFAULT_GROUPDefault grouping value, falsestatic booleanDEFAULT_KERNINGDefault behaviour is to perform kerningstatic booleanDEFAULT_LABEL_ALL_GROUPIf in case of grouping all resulting lines have to be labelledstatic intDEFAULT_LABEL_REPEATDefault repetition distance for labels (<= 0 -> no repetition)static doubleDEFAULT_MAX_ANGLE_DELTAWhen label follows line, the max angle change between two subsequent characters, keeping it low avoids chars overlaps.static intDEFAULT_MAX_DISPLACEMENTDefault max displacementstatic intDEFAULT_MIN_GROUP_DISTANCEDefault min distance between labels in the same group (-1 means no min distance)static booleanDEFAULT_PARTIALSDefault behaviour is to not truncate labels on the border of the display area.static TextSymbolizer.PolygonAlignOptionsDEFAULT_POLYGONALIGNDefault value for the polygonAlignstatic booleanDEFAULT_REMOVE_OVERLAPSDefault value for REMOVE_OVERLAPS_KEYstatic intDEFAULT_SPACE_AROUNDBy default, don't add space around labelsstatic booleanDEFAULT_STRIKETHROUGH_TEXTIf labels text should be stroke through or not.static booleanDEFAULT_UNDERLINE_TEXTIf labels text should be underline or not.static doubleDEFAULT_WORD_SPACINGDefault extra word spacing (no extra)static StringDISPLACEMENT_MODE_KEYOption to control displacement of labels.static StringFOLLOW_LINE_KEYWhen true activates curved labels on linear geometries.static StringFONT_SHRINK_SIZE_MINOption expressed in value of pixels.static StringFORCE_LEFT_TO_RIGHT_KEYWhen true forces labels to a readable orientation, when false they make follow the line orientation even if that means the label will look upside down (useful when using TTF symbol fonts to add direction markers along a line)static StringGOODNESS_OF_FIT_KEYSets the percentage of the label that must sit inside the geometry to allow drawing the label.static StringGRAPHIC_MARGIN_KEYPixels between the stretched graphic and the text, applies when graphic stretching is in usestatic StringGRAPHIC_PLACEMENT_KEYPlacement of the graphic element, see GraphicPlacement enumeration for possible valuestatic StringGRAPHIC_RESIZE_KEYStretches the graphic below a label to fit the label size.static StringGROUP_KEYIf true, geometries with the same labels are grouped and considered a single entity to be labeled.static StringKERNING_KEYOption to enable automatic adjustment of the space between charactersstatic StringLABEL_ALL_GROUP_KEYWhen false, only the biggest geometry in a group is labelled (the biggest is obtained by merging, when possible, the original geometries).static StringLABEL_REPEAT_KEYWhen positive it's the desired distance between two subsequent labels on a "big" geometry.static StringMAX_ANGLE_DELTA_KEYWhen drawing curved labels, max allowed angle between two subsequent characters.static StringMAX_DISPLACEMENT_KEYThe distance, in pixel, a label can be displaced from its natural position in an attempt to find a position that does not conflict with already drawn labels.static StringMIN_GROUP_DISTANCE_KEYMinimum distance between two labels in the same label group.static StringPARTIALS_KEYOption to truncate labels placed on the border of the displayArea (display partial labels).static StringPOLYGONALIGN_KEYOption overriding manual rotation to align label rotation automatically for polygons.static StringREMOVE_OVERLAPS_KEYIf, in case of grouping, self overlaps have to be taken into account and removed (expensive!)static StringSPACE_AROUND_KEYThe minimum distance between two labels, in pixelsstatic StringSTRIKETHROUGH_TEXT_KEYWhen TRUE labels text will be stroked through, the line will have the same color of the text.static StringUNDERLINE_TEXT_KEYWhen TRUE labels text will be underline, the underline will have the same color of the text.static StringWORD_SPACING_KEYOption expand word spacing, expressed as a value in pixels.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Objectaccept(TraversingStyleVisitor visitor, Object extraData)calls the visit method of a StyleVisitorList<Font>fonts()Direct access to device independent Fonts used to render the label.ExpressiongetFeatureDescription()Description is used by text oriented renders such as KML and RSS to specify a feature's descriptionFillgetFill()Returns the object that indicates how the text will be filled.FontgetFont()Returns the Font to apply on the text.GraphicgetGraphic()The nonstandard-SLD graphic element supports putting little graphical-bits onto labels.HalogetHalo()A halo fills an extended area outside the glyphs of a rendered text label to make the label easier to read over a background.ExpressiongetLabel()Returns the expression that will be evaluated to determine what text is displayed.LabelPlacementgetLabelPlacement()A LabelPlacement specifies how a text element should be rendered relative to its geometric point or line.Map<String,String>getOptions()return the map of optionOtherTextgetOtherText()Other text can be used to allow open ended extensions on text oriented output formatsExpressiongetPriority()Priority -- null = use the default labeling priority Expression = an expression that evaluates to a number (ie.ExpressiongetSnippet()Abstract is used by text oriented renderers such as KML and RSS to specify an abstract (RSS) or a snippet (KML)voidsetFeatureDescription(Expression description)voidsetFill(Fill fill)Sets the object that indicates how the text will be filled.voidsetFont(Font font)Set initial font used to render label.voidsetGraphic(Graphic graphic)The nonstandard-SLD graphic element supports putting little graphical-bits onto labels.voidsetHalo(Halo halo)A halo fills an extended area outside the glyphs of a rendered text label to make the label easier to read over a background.voidsetLabel(Expression label)Sets the expression that will be evaluated to determine what text is displayed.voidsetLabelPlacement(LabelPlacement labelPlacement)A LabelPlacement specifies how a text element should be rendered relative to its geometric point or line.voidsetOtherText(OtherText otherText)voidsetPriority(Expression e)Priority -- null = use the default labeling priority Expression = an expression that evaluates to a number (ie.voidsetSnippet(Expression expression)-
Methods inherited from interface Symbolizer
accept, getDescription, getGeometry, getGeometryPropertyName, getName, getUnitOfMeasure, hasOption, setDescription, setGeometry, setGeometryPropertyName, setName, setUnitOfMeasure
-
-
-
-
Field Detail
-
GROUP_KEY
static final String GROUP_KEY
If true, geometries with the same labels are grouped and considered a single entity to be labeled. This allows to avoid or control repeated labels- See Also:
- Constant Field Values
-
DEFAULT_GROUP
static final boolean DEFAULT_GROUP
Default grouping value, false- See Also:
- Constant Field Values
-
SPACE_AROUND_KEY
static final String SPACE_AROUND_KEY
The minimum distance between two labels, in pixels- See Also:
- Constant Field Values
-
DEFAULT_SPACE_AROUND
static final int DEFAULT_SPACE_AROUND
By default, don't add space around labels- See Also:
- Constant Field Values
-
MAX_DISPLACEMENT_KEY
static final String MAX_DISPLACEMENT_KEY
The distance, in pixel, a label can be displaced from its natural position in an attempt to find a position that does not conflict with already drawn labels.- See Also:
- Constant Field Values
-
DEFAULT_MAX_DISPLACEMENT
static final int DEFAULT_MAX_DISPLACEMENT
Default max displacement- See Also:
- Constant Field Values
-
MIN_GROUP_DISTANCE_KEY
static final String MIN_GROUP_DISTANCE_KEY
Minimum distance between two labels in the same label group. To be used when both displacement and repeat are used to avoid having two labels too close to each other- See Also:
- Constant Field Values
-
DEFAULT_MIN_GROUP_DISTANCE
static final int DEFAULT_MIN_GROUP_DISTANCE
Default min distance between labels in the same group (-1 means no min distance)- See Also:
- Constant Field Values
-
LABEL_REPEAT_KEY
static final String LABEL_REPEAT_KEY
When positive it's the desired distance between two subsequent labels on a "big" geometry. Works only on lines at the moment. If zero only one label is drawn no matter how big the geometry is- See Also:
- Constant Field Values
-
DEFAULT_LABEL_REPEAT
static final int DEFAULT_LABEL_REPEAT
Default repetition distance for labels (<= 0 -> no repetition)- See Also:
- Constant Field Values
-
LABEL_ALL_GROUP_KEY
static final String LABEL_ALL_GROUP_KEY
When false, only the biggest geometry in a group is labelled (the biggest is obtained by merging, when possible, the original geometries). When true, also the smaller items in the group are labeled. Works only on lines at the moment.- See Also:
- Constant Field Values
-
DEFAULT_LABEL_ALL_GROUP
static final boolean DEFAULT_LABEL_ALL_GROUP
If in case of grouping all resulting lines have to be labelled- See Also:
- Constant Field Values
-
ALLOW_OVERRUNS_KEY
static final String ALLOW_OVERRUNS_KEY
When false does not allow labels on lines to get beyond the beginning/end of the line. By default a partial overrun is tolerated, set to false to disallow it.- See Also:
- Constant Field Values
-
DEFAULT_ALLOW_OVERRUNS
static final boolean DEFAULT_ALLOW_OVERRUNS
We allow labels that are longer than the line to appear by default- See Also:
- Constant Field Values
-
REMOVE_OVERLAPS_KEY
static final String REMOVE_OVERLAPS_KEY
If, in case of grouping, self overlaps have to be taken into account and removed (expensive!)- See Also:
- Constant Field Values
-
DEFAULT_REMOVE_OVERLAPS
static final boolean DEFAULT_REMOVE_OVERLAPS
Default value for REMOVE_OVERLAPS_KEY- See Also:
- Constant Field Values
-
FOLLOW_LINE_KEY
static final String FOLLOW_LINE_KEY
When true activates curved labels on linear geometries. The label will follow the shape of the current line, as opposed to being drawn a tangent straight line- See Also:
- Constant Field Values
-
DEFAULT_FOLLOW_LINE
static final boolean DEFAULT_FOLLOW_LINE
If labels with a line placement should follow the line shape or be just tangent- See Also:
- Constant Field Values
-
UNDERLINE_TEXT_KEY
static final String UNDERLINE_TEXT_KEY
When TRUE labels text will be underline, the underline will have the same color of the text.- See Also:
- Constant Field Values
-
DEFAULT_UNDERLINE_TEXT
static final boolean DEFAULT_UNDERLINE_TEXT
If labels text should be underline or not.- See Also:
- Constant Field Values
-
STRIKETHROUGH_TEXT_KEY
static final String STRIKETHROUGH_TEXT_KEY
When TRUE labels text will be stroked through, the line will have the same color of the text.- See Also:
- Constant Field Values
-
DEFAULT_STRIKETHROUGH_TEXT
static final boolean DEFAULT_STRIKETHROUGH_TEXT
If labels text should be stroke through or not.- See Also:
- Constant Field Values
-
MAX_ANGLE_DELTA_KEY
static final String MAX_ANGLE_DELTA_KEY
When drawing curved labels, max allowed angle between two subsequent characters. Higher angles may cause disconnected words or overlapping characters- See Also:
- Constant Field Values
-
DEFAULT_MAX_ANGLE_DELTA
static final double DEFAULT_MAX_ANGLE_DELTA
When label follows line, the max angle change between two subsequent characters, keeping it low avoids chars overlaps. When the angle is exceeded the label placement will fail.- See Also:
- Constant Field Values
-
AUTO_WRAP_KEY
static final String AUTO_WRAP_KEY
Number of pixels are which a long label should be split into multiple lines. Works on all geometries, on lines it is mutually exclusive with the followLine option- See Also:
- Constant Field Values
-
DEFAULT_AUTO_WRAP
static final int DEFAULT_AUTO_WRAP
Auto wrapping long labels default- See Also:
- Constant Field Values
-
FORCE_LEFT_TO_RIGHT_KEY
static final String FORCE_LEFT_TO_RIGHT_KEY
When true forces labels to a readable orientation, when false they make follow the line orientation even if that means the label will look upside down (useful when using TTF symbol fonts to add direction markers along a line)- See Also:
- Constant Field Values
-
DEFAULT_FORCE_LEFT_TO_RIGHT
static final boolean DEFAULT_FORCE_LEFT_TO_RIGHT
Force labels to a readable orientation (so that they don't look "upside down")- See Also:
- Constant Field Values
-
CONFLICT_RESOLUTION_KEY
static final String CONFLICT_RESOLUTION_KEY
Enables conflict resolution (default, true) meaning no two labels will be allowed to overlap. Symbolizers with conflict resolution off are considered outside of the conflict resolution game, they don't reserve area and can overlap with other labels.- See Also:
- Constant Field Values
-
DEFAULT_CONFLICT_RESOLUTION
static final boolean DEFAULT_CONFLICT_RESOLUTION
By default, put each label in the conflict resolution map- See Also:
- Constant Field Values
-
GOODNESS_OF_FIT_KEY
static final String GOODNESS_OF_FIT_KEY
Sets the percentage of the label that must sit inside the geometry to allow drawing the label. Works only on polygons.- See Also:
- Constant Field Values
-
DEFAULT_GOODNESS_OF_FIT
static final double DEFAULT_GOODNESS_OF_FIT
Default value for the goodness of fit threshold- See Also:
- Constant Field Values
-
POLYGONALIGN_KEY
static final String POLYGONALIGN_KEY
Option overriding manual rotation to align label rotation automatically for polygons.- See Also:
- Constant Field Values
-
GRAPHIC_MARGIN_KEY
static final String GRAPHIC_MARGIN_KEY
Pixels between the stretched graphic and the text, applies when graphic stretching is in use- See Also:
- Constant Field Values
-
GRAPHIC_RESIZE_KEY
static final String GRAPHIC_RESIZE_KEY
Stretches the graphic below a label to fit the label size. Possible values are 'stretch', 'proportional'.- See Also:
- Constant Field Values
-
DEFAULT_POLYGONALIGN
static final TextSymbolizer.PolygonAlignOptions DEFAULT_POLYGONALIGN
Default value for the polygonAlign
-
PARTIALS_KEY
static final String PARTIALS_KEY
Option to truncate labels placed on the border of the displayArea (display partial labels).- See Also:
- Constant Field Values
-
DEFAULT_PARTIALS
static final boolean DEFAULT_PARTIALS
Default behaviour is to not truncate labels on the border of the display area. Instead, labels are hidden or moved to be fully displayed inside the area.- See Also:
- Constant Field Values
-
KERNING_KEY
static final String KERNING_KEY
Option to enable automatic adjustment of the space between characters- See Also:
- Constant Field Values
-
DEFAULT_KERNING
static final boolean DEFAULT_KERNING
Default behaviour is to perform kerning- See Also:
- Constant Field Values
-
CHAR_SPACING_KEY
static final String CHAR_SPACING_KEY
Option expand/shrink character spacing, expressed as a value in pixels. A negative value will shrink spacing, making character eventually overlap.- See Also:
- Constant Field Values
-
DEFAULT_CHAR_SPACING
static final double DEFAULT_CHAR_SPACING
Default extra char spacing (no extra)- See Also:
- Constant Field Values
-
WORD_SPACING_KEY
static final String WORD_SPACING_KEY
Option expand word spacing, expressed as a value in pixels. This option does not support negative values- See Also:
- Constant Field Values
-
DEFAULT_WORD_SPACING
static final double DEFAULT_WORD_SPACING
Default extra word spacing (no extra)- See Also:
- Constant Field Values
-
FONT_SHRINK_SIZE_MIN
static final String FONT_SHRINK_SIZE_MIN
Option expressed in value of pixels. This option does not support negative values. Works only on polygons.- See Also:
- Constant Field Values
-
DEFAULT_FONT_SHRINK_SIZE_MIN
static final int DEFAULT_FONT_SHRINK_SIZE_MIN
Default font shrink size- See Also:
- Constant Field Values
-
DISPLACEMENT_MODE_KEY
static final String DISPLACEMENT_MODE_KEY
Option to control displacement of labels. Available values are defined as enum values @seeTextSymbolizer.DisplacementMode- See Also:
- Constant Field Values
-
GRAPHIC_PLACEMENT_KEY
static final String GRAPHIC_PLACEMENT_KEY
Placement of the graphic element, see GraphicPlacement enumeration for possible value- See Also:
- Constant Field Values
-
-
Method Detail
-
getLabel
Expression getLabel()
Returns the expression that will be evaluated to determine what text is displayed. If a Label element is not provided in a TextSymbolizer, then no text shall be rendered.- Returns:
- Expression
-
setLabel
void setLabel(Expression label)
Sets the expression that will be evaluated to determine what text is displayed. SeegetLabel()for details.
-
fonts
List<Font> fonts()
Direct access to device independent Fonts used to render the label. Fonts are used in order of priority given.- Returns:
- device independent Font used to render the label.
-
getFont
Font getFont()
Returns the Font to apply on the text.- Returns:
- Font
-
getLabelPlacement
LabelPlacement getLabelPlacement()
A LabelPlacement specifies how a text element should be rendered relative to its geometric point or line.
-
setLabelPlacement
void setLabelPlacement(LabelPlacement labelPlacement)
A LabelPlacement specifies how a text element should be rendered relative to its geometric point or line.
-
getHalo
Halo getHalo()
A halo fills an extended area outside the glyphs of a rendered text label to make the label easier to read over a background.
-
setHalo
void setHalo(Halo halo)
A halo fills an extended area outside the glyphs of a rendered text label to make the label easier to read over a background.
-
getFill
Fill getFill()
Returns the object that indicates how the text will be filled.
-
accept
Object accept(TraversingStyleVisitor visitor, Object extraData)
calls the visit method of a StyleVisitor- Specified by:
acceptin interfaceSymbolizer- Parameters:
visitor- the style visitor- Returns:
- value produced
-
setFill
void setFill(Fill fill)
Sets the object that indicates how the text will be filled. SeegetFill()for details.
-
setPriority
void setPriority(Expression e)
Priority -- null = use the default labeling priority Expression = an expression that evaluates to a number (ie. Integer, Long, Double...) Larger = more likely to be rendered
-
getPriority
Expression getPriority()
Priority -- null = use the default labeling priority Expression = an expression that evaluates to a number (ie. Integer, Long, Double...) Larger = more likely to be rendered
-
getOptions
Map<String,String> getOptions()
return the map of option- Specified by:
getOptionsin interfaceSymbolizer- Returns:
- null - no options set
-
setFont
void setFont(Font font)
Set initial font used to render label. This will replace the initial entry in thefonts()list.
-
getGraphic
Graphic getGraphic()
The nonstandard-SLD graphic element supports putting little graphical-bits onto labels. Useful for things like interstate road shields or labeled logos- Returns:
- - the Graphic object to be rendered under the label text
-
setGraphic
void setGraphic(Graphic graphic)
The nonstandard-SLD graphic element supports putting little graphical-bits onto labels. Useful for things like interstate road shields or labeled logos- Parameters:
graphic- - the Graphic object which will be rendered under the label text
-
getSnippet
Expression getSnippet()
Abstract is used by text oriented renderers such as KML and RSS to specify an abstract (RSS) or a snippet (KML)
-
setSnippet
void setSnippet(Expression expression)
-
getFeatureDescription
Expression getFeatureDescription()
Description is used by text oriented renders such as KML and RSS to specify a feature's description
-
setFeatureDescription
void setFeatureDescription(Expression description)
-
getOtherText
OtherText getOtherText()
Other text can be used to allow open ended extensions on text oriented output formats
-
setOtherText
void setOtherText(OtherText otherText)
-
-