Class BoxTextElement
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement
-
- org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement
-
- All Implemented Interfaces:
StyleKeys
public class BoxTextElement extends StyleElement
Text style attached to a style with a bounding box, like an icon or a symbol.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BoxTextElement.BoxProvider
Something that provides us with aBoxTextElement.BoxProviderResult
static class
BoxTextElement.BoxProviderResult
A box rectangle with a flag if it is temporary.static class
BoxTextElement.HorizontalTextAlignment
MapCSS text-anchor-horizontalstatic class
BoxTextElement.SimpleBoxProvider
ABoxTextElement.BoxProvider
that always returns the same non-temporary rectanglestatic class
BoxTextElement.VerticalTextAlignment
MapCSS text-anchor-vertical
-
Field Summary
Fields Modifier and Type Field Description protected BoxTextElement.BoxProvider
boxProvider
private static java.awt.Color
defaultTextColorCache
Caches the default text color from the preferences.BoxTextElement.HorizontalTextAlignment
hAlign
TheBoxTextElement.HorizontalTextAlignment
for this text.TextLabel
text
The text this element should display.BoxTextElement.VerticalTextAlignment
vAlign
TheBoxTextElement.VerticalTextAlignment
for this text.int
xOffset
The x offset of the text.int
yOffset
The y offset of the text.-
Fields inherited from class org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement
defaultSelectedHandling, ICON_HEIGHT_IDX, ICON_IMAGE_IDX, ICON_OFFSET_X_IDX, ICON_OFFSET_Y_IDX, ICON_OPACITY_IDX, ICON_WIDTH_IDX, isModifier, majorZIndex, objectZIndex, zIndex
-
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 Constructor Description BoxTextElement(Cascade c, TextLabel text, BoxTextElement.BoxProvider boxProvider, int offsetX, int offsetY, BoxTextElement.HorizontalTextAlignment hAlign, BoxTextElement.VerticalTextAlignment vAlign)
Create a newBoxTextElement
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BoxTextElement
create(Environment env, BoxTextElement.BoxProvider boxProvider)
Create a newBoxTextElement
with a boxprovider and a box.boolean
equals(java.lang.Object obj)
java.awt.Rectangle
getBox()
Get the box in which the content should be drawn.int
hashCode()
private static void
initDefaultParameters()
void
paintPrimitive(IPrimitive osm, MapPaintSettings settings, StyledMapRenderer painter, boolean selected, boolean outermember, boolean member)
draws a primitivejava.lang.String
toString()
-
Methods inherited from class org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement
getFont, getWidth, isProperLineStyle
-
-
-
-
Field Detail
-
defaultTextColorCache
private static volatile java.awt.Color defaultTextColorCache
Caches the default text color from the preferences. FIXME: the cache isn't updated if the user changes the preference during a JOSM session. There should be preference listener updating this cache.
-
xOffset
public int xOffset
The x offset of the text.
-
yOffset
public int yOffset
The y offset of the text. In screen space (inverted to user space)
-
hAlign
public BoxTextElement.HorizontalTextAlignment hAlign
TheBoxTextElement.HorizontalTextAlignment
for this text.
-
vAlign
public BoxTextElement.VerticalTextAlignment vAlign
TheBoxTextElement.VerticalTextAlignment
for this text.
-
boxProvider
protected BoxTextElement.BoxProvider boxProvider
-
-
Constructor Detail
-
BoxTextElement
public BoxTextElement(Cascade c, TextLabel text, BoxTextElement.BoxProvider boxProvider, int offsetX, int offsetY, BoxTextElement.HorizontalTextAlignment hAlign, BoxTextElement.VerticalTextAlignment vAlign)
Create a newBoxTextElement
- Parameters:
c
- The current cascadetext
- The text to displayboxProvider
- The box provider to useoffsetX
- x offset, in screen spaceoffsetY
- y offset, in screen spacehAlign
- TheBoxTextElement.HorizontalTextAlignment
vAlign
- TheBoxTextElement.VerticalTextAlignment
-
-
Method Detail
-
create
public static BoxTextElement create(Environment env, BoxTextElement.BoxProvider boxProvider)
Create a newBoxTextElement
with a boxprovider and a box.- Parameters:
env
- The MapCSS environmentboxProvider
- The box provider.- Returns:
- A new
BoxTextElement
ornull
if the creation failed.
-
getBox
public java.awt.Rectangle getBox()
Get the box in which the content should be drawn.- Returns:
- The box.
-
initDefaultParameters
private static void initDefaultParameters()
-
paintPrimitive
public void paintPrimitive(IPrimitive osm, MapPaintSettings settings, StyledMapRenderer painter, boolean selected, boolean outermember, boolean member)
Description copied from class:StyleElement
draws a primitive- Specified by:
paintPrimitive
in classStyleElement
- Parameters:
osm
- primitive to drawsettings
- paint settingspainter
- painterselected
- true, if primitive is selectedoutermember
- true, if primitive is not selected and outer member of a selected multipolygon relationmember
- true, if primitive is not selected and member of a selected relation
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classStyleElement
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classStyleElement
-
toString
public java.lang.String toString()
- Overrides:
toString
in classStyleElement
-
-