Class StyleElement
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement
-
- All Implemented Interfaces:
StyleKeys
- Direct Known Subclasses:
AreaElement
,AreaIconElement
,BoxTextElement
,LineElement
,NodeElement
,RepeatImageElement
,TextElement
public abstract class StyleElement extends Object implements StyleKeys
Class that defines how objects (OsmPrimitive
) should be drawn on the map. Several subclasses of this abstract class implement different drawing features, like icons for a node or area fill. This class and all its subclasses are immutable and tend to get shared when multiple objects have the same style (in order to save memory, seeStyleCache.intern()
).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
StyleElement.FontDescriptor
-
Field Summary
Fields Modifier and Type Field Description private static String
defaultFontName
private static Float
defaultFontSize
boolean
defaultSelectedHandling
A flag indicating that the selection color handling should be done automaticallyprivate static Map<StyleElement.FontDescriptor,Font>
FONT_MAP
protected static int
ICON_HEIGHT_IDX
protected static int
ICON_IMAGE_IDX
protected static int
ICON_OFFSET_X_IDX
protected static int
ICON_OFFSET_Y_IDX
protected static int
ICON_OPACITY_IDX
protected static int
ICON_WIDTH_IDX
boolean
isModifier
false, if style can serve as main style for the primitive; true, if it is a highlight or modifierprivate static Object
lock
float
majorZIndex
The major z index of this style elementfloat
objectZIndex
The object z indexfloat
zIndex
The z index as set by the user-
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
StyleElement(float majorZIndex, float zIndex, float objectZIndex, boolean isModifier, boolean defaultSelectedHandling)
Construct a new StyleElementprotected
StyleElement(Cascade c, float defaultMajorZindex)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
private static Font
getCachedFont(String name, int style, int size)
private static String
getDefaultFontName()
private static Float
getDefaultFontSize()
protected static Font
getFont(Cascade c, String s)
protected static Float
getWidth(Cascade c, String key, Float relativeTo)
Get a property value of type Widthint
hashCode()
boolean
isProperLineStyle()
Check if this is a style that makes the line visible to the userabstract void
paintPrimitive(IPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean outermember, boolean member)
draws a primitiveString
toString()
-
-
-
Field Detail
-
ICON_IMAGE_IDX
protected static final int ICON_IMAGE_IDX
- See Also:
- Constant Field Values
-
ICON_WIDTH_IDX
protected static final int ICON_WIDTH_IDX
- See Also:
- Constant Field Values
-
ICON_HEIGHT_IDX
protected static final int ICON_HEIGHT_IDX
- See Also:
- Constant Field Values
-
ICON_OPACITY_IDX
protected static final int ICON_OPACITY_IDX
- See Also:
- Constant Field Values
-
ICON_OFFSET_X_IDX
protected static final int ICON_OFFSET_X_IDX
- See Also:
- Constant Field Values
-
ICON_OFFSET_Y_IDX
protected static final int ICON_OFFSET_Y_IDX
- See Also:
- Constant Field Values
-
majorZIndex
public float majorZIndex
The major z index of this style element
-
zIndex
public float zIndex
The z index as set by the user
-
objectZIndex
public float objectZIndex
The object z index
-
isModifier
public boolean isModifier
false, if style can serve as main style for the primitive; true, if it is a highlight or modifier
-
defaultSelectedHandling
public boolean defaultSelectedHandling
A flag indicating that the selection color handling should be done automatically
-
defaultFontName
private static volatile String defaultFontName
-
defaultFontSize
private static volatile Float defaultFontSize
-
FONT_MAP
private static final Map<StyleElement.FontDescriptor,Font> FONT_MAP
-
-
Constructor Detail
-
StyleElement
protected StyleElement(float majorZIndex, float zIndex, float objectZIndex, boolean isModifier, boolean defaultSelectedHandling)
Construct a new StyleElement- Parameters:
majorZIndex
- like z-index, but higher priorityzIndex
- order the objects are drawnobjectZIndex
- like z-index, but lower priorityisModifier
- if false, a default line or node symbol is generateddefaultSelectedHandling
- true if default behavior for selected objects is enabled, false if a style for selected state is given explicitly
-
StyleElement
protected StyleElement(Cascade c, float defaultMajorZindex)
-
-
Method Detail
-
paintPrimitive
public abstract void paintPrimitive(IPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean outermember, boolean member)
draws a primitive- Parameters:
primitive
- primitive to drawpaintSettings
- 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- Since:
- 13662 (signature)
-
isProperLineStyle
public boolean isProperLineStyle()
Check if this is a style that makes the line visible to the user- Returns:
true
for line styles
-
getWidth
protected static Float getWidth(Cascade c, String key, Float relativeTo)
Get a property value of type Width- Parameters:
c
- the cascadekey
- property key for the width valuerelativeTo
- reference width. Only needed, when relative width syntax is used, e.g. "+4".- Returns:
- width
-
getDefaultFontSize
private static Float getDefaultFontSize()
-
getDefaultFontName
private static String getDefaultFontName()
-
getCachedFont
private static Font getCachedFont(String name, int style, int size)
-
-