Class TextLabel
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.styleelement.TextLabel
-
-
Field Summary
Fields Modifier and Type Field Description static LabelCompositionStrategy
AUTO_LABEL_COMPOSITION_STRATEGY
The default strategy to use when determining the label of a element.java.awt.Color
color
The color to draw the text in, includes alpha.java.awt.Font
font
the font to be used when renderingjava.awt.Color
haloColor
The color of the halo effect.java.lang.Float
haloRadius
The radius of the halo effect.LabelCompositionStrategy
labelCompositionStrategy
The strategy for building the actual label value for a given aOsmPrimitive
.RotationAngle
rotationAngle
The rotation angle to be used when rendering-
Fields inherited from interface org.openstreetmap.josm.gui.mappaint.StyleKeys
COLOR, DASHES, DASHES_BACKGROUND_COLOR, DASHES_BACKGROUND_OPACITY, DASHES_OFFSET, FILL_COLOR, FILL_EXTENT, FILL_EXTENT_THRESHOLD, FILL_IMAGE, FILL_OPACITY, FONT_FAMILY, FONT_SIZE, FONT_STYLE, FONT_WEIGHT, ICON_HEIGHT, ICON_IMAGE, ICON_OFFSET_X, ICON_OFFSET_Y, ICON_OPACITY, ICON_POSITION, ICON_ROTATION, ICON_WIDTH, LINECAP, LINEJOIN, MAJOR_Z_INDEX, MITERLIMIT, MODIFIER, OBJECT_Z_INDEX, OFFSET, OPACITY, REAL_WIDTH, REPEAT_IMAGE, REPEAT_IMAGE_ALIGN, REPEAT_IMAGE_HEIGHT, REPEAT_IMAGE_OFFSET, REPEAT_IMAGE_OPACITY, REPEAT_IMAGE_PHASE, REPEAT_IMAGE_SPACING, REPEAT_IMAGE_WIDTH, TEXT, TEXT_ANCHOR_HORIZONTAL, TEXT_ANCHOR_VERTICAL, TEXT_COLOR, TEXT_HALO_COLOR, TEXT_HALO_OPACITY, TEXT_HALO_RADIUS, TEXT_OFFSET, TEXT_OFFSET_X, TEXT_OFFSET_Y, TEXT_OPACITY, TEXT_POSITION, TEXT_ROTATION, WAY_DIRECTION_ARROWS, WIDTH, Z_INDEX
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TextLabel(LabelCompositionStrategy strategy, java.awt.Font font, RotationAngle rotationAngle, java.awt.Color color, java.lang.Float haloRadius, java.awt.Color haloColor)
Creates a new text elementTextLabel(TextLabel other)
Copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static LabelCompositionStrategy
buildLabelCompositionStrategy(Cascade c, boolean defaultAnnotate)
Derives a suitable label composition strategy from the style properties inc
.static TextLabel
create(Environment env, java.awt.Color defaultTextColor, boolean defaultAnnotate)
Builds a text element from style properties inc
and the default text colordefaultTextColor
boolean
equals(java.lang.Object obj)
java.lang.String
getString(IPrimitive osm)
Replies the label to be rendered for the primitiveosm
.static java.awt.geom.Point2D
getTextOffset(Cascade c)
Gets the text-offset property from a cascadeint
hashCode()
java.lang.String
toString()
protected java.lang.String
toStringImpl()
-
-
-
Field Detail
-
AUTO_LABEL_COMPOSITION_STRATEGY
public static final LabelCompositionStrategy AUTO_LABEL_COMPOSITION_STRATEGY
The default strategy to use when determining the label of a element.
-
labelCompositionStrategy
public LabelCompositionStrategy labelCompositionStrategy
The strategy for building the actual label value for a given aOsmPrimitive
. Check for null before accessing.
-
font
public java.awt.Font font
the font to be used when rendering
-
rotationAngle
public RotationAngle rotationAngle
The rotation angle to be used when rendering
-
color
public java.awt.Color color
The color to draw the text in, includes alpha.
-
haloRadius
public java.lang.Float haloRadius
The radius of the halo effect.
-
haloColor
public java.awt.Color haloColor
The color of the halo effect.
-
-
Constructor Detail
-
TextLabel
protected TextLabel(LabelCompositionStrategy strategy, java.awt.Font font, RotationAngle rotationAngle, java.awt.Color color, java.lang.Float haloRadius, java.awt.Color haloColor)
Creates a new text element- Parameters:
strategy
- the strategy indicating how the text is composed for a specificOsmPrimitive
to be rendered. If null, no label is rendered.font
- the font to be used. Must not be null.rotationAngle
- the rotation angle to be used. Must not be null.color
- the color to be used. Must not be nullhaloRadius
- halo radiushaloColor
- halo color
-
-
Method Detail
-
buildLabelCompositionStrategy
protected static LabelCompositionStrategy buildLabelCompositionStrategy(Cascade c, boolean defaultAnnotate)
Derives a suitable label composition strategy from the style properties inc
.- Parameters:
c
- the style propertiesdefaultAnnotate
- whether to returnAUTO_LABEL_COMPOSITION_STRATEGY
if not strategy is found- Returns:
- the label composition strategy, or
null
-
create
public static TextLabel create(Environment env, java.awt.Color defaultTextColor, boolean defaultAnnotate)
Builds a text element from style properties inc
and the default text colordefaultTextColor
- Parameters:
env
- the environmentdefaultTextColor
- the default text color. Must not be null.defaultAnnotate
- true, if a text label shall be rendered by default, even if the style sheet doesn't include respective style declarations- Returns:
- the text element or null, if the style properties don't include properties for text rendering
- Throws:
java.lang.IllegalArgumentException
- ifdefaultTextColor
is null
-
getTextOffset
public static java.awt.geom.Point2D getTextOffset(Cascade c)
Gets the text-offset property from a cascade- Parameters:
c
- The cascade- Returns:
- The text offset property
-
getString
public java.lang.String getString(IPrimitive osm)
Replies the label to be rendered for the primitiveosm
.- Parameters:
osm
- the OSM object- Returns:
- the label, or null, if
osm
is null or if no label can be derived forosm
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toStringImpl
protected java.lang.String toStringImpl()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-