Class Cascade
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.Cascade
-
public final class Cascade extends java.lang.Object
Simple map of properties with dynamic typing.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
defaultSelectedHandling
private static GenericParser<java.lang.Object>
GENERIC_PARSER
private static java.util.regex.Pattern
HEX_COLOR_PATTERN
private java.util.Map<java.lang.String,java.lang.Object>
prop
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.String key)
Checks if this cascade has a value for given keystatic <T> T
convertTo(java.lang.Object o, java.lang.Class<T> klass)
Converts an object to a given other class.java.lang.Object
get(java.lang.String key)
Gets a property for the given key (like stroke, ...)<T> T
get(java.lang.String key, T def, java.lang.Class<T> klass)
Gets the value for a given key with the given type<T> T
get(java.lang.String key, T def, java.lang.Class<T> klass, boolean suppressWarnings)
Get value for the given keyboolean
isDefaultSelectedHandling()
Get if the default selection drawing should be used for the object this cascade applies tovoid
put(java.lang.String key, java.lang.Object val)
Sets the property for the given keyvoid
putOrClear(java.lang.String key, java.lang.Object val)
Sets the property for the given key, removes it if the value isnull
void
remove(java.lang.String key)
Removes the property with the given keyvoid
setDefaultSelectedHandling(boolean defaultSelectedHandling)
Set that the default selection drawing should be used for the object this cascade applies toprivate static java.lang.Boolean
toBool(java.lang.Object o)
private static java.awt.Color
toColor(java.lang.Object o)
private static java.lang.Double
toDouble(java.lang.Object o)
private static java.lang.Float
toFloat(java.lang.Object o)
private static float[]
toFloatArray(java.lang.Object o)
java.lang.String
toString()
private static java.lang.String
toString(java.lang.Object o)
-
-
-
Field Detail
-
prop
private final java.util.Map<java.lang.String,java.lang.Object> prop
-
defaultSelectedHandling
private boolean defaultSelectedHandling
-
HEX_COLOR_PATTERN
private static final java.util.regex.Pattern HEX_COLOR_PATTERN
-
GENERIC_PARSER
private static final GenericParser<java.lang.Object> GENERIC_PARSER
-
-
Method Detail
-
get
public <T> T get(java.lang.String key, T def, java.lang.Class<T> klass)
Gets the value for a given key with the given type- Type Parameters:
T
- the expected type- Parameters:
key
- the keydef
- default value, can be nullklass
- the same as T- Returns:
- if a value that can be converted to class klass has been mapped to key, returns this value, def otherwise
-
get
public <T> T get(java.lang.String key, T def, java.lang.Class<T> klass, boolean suppressWarnings)
Get value for the given key- Type Parameters:
T
- the expected type- Parameters:
key
- the keydef
- default value, can be nullklass
- the same as TsuppressWarnings
- show or don't show a warning when some value is found, but cannot be converted to the requested type- Returns:
- if a value that can be converted to class klass has been mapped to key, returns this value, def otherwise
-
get
public java.lang.Object get(java.lang.String key)
Gets a property for the given key (like stroke, ...)- Parameters:
key
- The key of the property- Returns:
- The value or
null
if it is not set. May be of any type
-
put
public void put(java.lang.String key, java.lang.Object val)
Sets the property for the given key- Parameters:
key
- The keyval
- The value
-
putOrClear
public void putOrClear(java.lang.String key, java.lang.Object val)
Sets the property for the given key, removes it if the value isnull
- Parameters:
key
- The keyval
- The value, may benull
-
remove
public void remove(java.lang.String key)
Removes the property with the given key- Parameters:
key
- The key
-
convertTo
public static <T> T convertTo(java.lang.Object o, java.lang.Class<T> klass)
Converts an object to a given other class. Only conversions that are useful for MapCSS are supported- Type Parameters:
T
- The class type- Parameters:
o
- The object to convertklass
- The class- Returns:
- The converted object or
null
if the conversion failed
-
toString
private static java.lang.String toString(java.lang.Object o)
-
toFloat
private static java.lang.Float toFloat(java.lang.Object o)
-
toDouble
private static java.lang.Double toDouble(java.lang.Object o)
-
toBool
private static java.lang.Boolean toBool(java.lang.Object o)
-
toFloatArray
private static float[] toFloatArray(java.lang.Object o)
-
toColor
private static java.awt.Color toColor(java.lang.Object o)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
containsKey
public boolean containsKey(java.lang.String key)
Checks if this cascade has a value for given key- Parameters:
key
- The key to check- Returns:
true
if there is a value
-
isDefaultSelectedHandling
public boolean isDefaultSelectedHandling()
Get if the default selection drawing should be used for the object this cascade applies to- Returns:
true
to use the default selection drawing
-
setDefaultSelectedHandling
public void setDefaultSelectedHandling(boolean defaultSelectedHandling)
Set that the default selection drawing should be used for the object this cascade applies to- Parameters:
defaultSelectedHandling
-true
to use the default selection drawing
-
-