org.openstreetmap.josm.gui.mappaint
Class TextElement

java.lang.Object
  extended by org.openstreetmap.josm.gui.mappaint.TextElement
All Implemented Interfaces:
StyleKeys

public class TextElement
extends java.lang.Object
implements StyleKeys

Represents the rendering style for a textual label placed somewhere on the map.


Field Summary
static LabelCompositionStrategy AUTO_LABEL_COMPOSITION_STRATEGY
           
 java.awt.Color color
           
 java.awt.Font font
          the font to be used when rendering
 java.awt.Color haloColor
           
 java.lang.Float haloRadius
           
 LabelCompositionStrategy labelCompositionStrategy
          the strategy for building the actual label value for a given a OsmPrimitive.
 int xOffset
           
 int yOffset
           
 
Fields inherited from interface org.openstreetmap.josm.gui.mappaint.StyleKeys
COLOR, DASHES, DASHES_BACKGROUND_COLOR, DASHES_BACKGROUND_OPACITY, DASHES_OFFSET, FILL_COLOR, FILL_IMAGE, FILL_OPACITY, ICON_IMAGE, MODIFIER, OBJECT_Z_INDEX, OFFSET, OPACITY, REAL_WIDTH, TEXT, TEXT_POSITION, WIDTH, Z_INDEX
 
Constructor Summary
TextElement(LabelCompositionStrategy strategy, java.awt.Font font, int xOffset, int yOffset, java.awt.Color color, java.lang.Float haloRadius, java.awt.Color haloColor)
          Creates a new text element
TextElement(TextElement other)
          Copy constructor
 
Method Summary
protected static LabelCompositionStrategy buildLabelCompositionStrategy(Cascade c, boolean defaultAnnotate)
          Derives a suitable label composition strategy from the style properties in c.
static TextElement create(Cascade c, java.awt.Color defaultTextColor, boolean defaultAnnotate)
          Builds a text element from style properties in c and the default text color defaultTextColor
 boolean equals(java.lang.Object obj)
           
 java.lang.String getString(OsmPrimitive osm)
          Replies the label to be rendered for the primitive osm.
 int hashCode()
           
 java.lang.String toString()
           
protected  java.lang.String toStringImpl()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

AUTO_LABEL_COMPOSITION_STRATEGY

public static final LabelCompositionStrategy AUTO_LABEL_COMPOSITION_STRATEGY

labelCompositionStrategy

public LabelCompositionStrategy labelCompositionStrategy
the strategy for building the actual label value for a given a OsmPrimitive. Check for null before accessing.


font

public java.awt.Font font
the font to be used when rendering


xOffset

public int xOffset

yOffset

public int yOffset

color

public java.awt.Color color

haloRadius

public java.lang.Float haloRadius

haloColor

public java.awt.Color haloColor
Constructor Detail

TextElement

public TextElement(LabelCompositionStrategy strategy,
                   java.awt.Font font,
                   int xOffset,
                   int yOffset,
                   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 specific OsmPrimitive to be rendered. If null, no label is rendered.
font - the font to be used. Must not be null.
xOffset -
yOffset -
color - the color to be used. Must not be null
haloRadius -
haloColor -

TextElement

public TextElement(TextElement other)
Copy constructor

Parameters:
other - the other element.
Method Detail

buildLabelCompositionStrategy

protected static LabelCompositionStrategy buildLabelCompositionStrategy(Cascade c,
                                                                        boolean defaultAnnotate)
Derives a suitable label composition strategy from the style properties in c.

Parameters:
c - the style properties
Returns:
the label composition strategy

create

public static TextElement create(Cascade c,
                                 java.awt.Color defaultTextColor,
                                 boolean defaultAnnotate)
                          throws java.lang.IllegalArgumentException
Builds a text element from style properties in c and the default text color defaultTextColor

Parameters:
c - the style properties
defaultTextColor - 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 - thrown if defaultTextColor is null

getString

public java.lang.String getString(OsmPrimitive osm)
Replies the label to be rendered for the primitive osm.

Parameters:
osm - the OSM object
Returns:
the label, or null, if osm is null or if no label can be derived for osm

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringImpl

protected java.lang.String toStringImpl()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


JOSM