|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.gui2.PropertyStatusReader
Help class for easily reading properties from a given DrawAtom
with different prefixes depending on a given state.
The properties to read with this class should have the following
structure:
<prefix>[.<subtype>][.<style>][.<layout>].<key>
getProperty(java.lang.String, java.lang.Object)
) will be expanded like
this using the set prefix strings and the set layout state.
The actual layout state must be set actively by the code using this
PropertyStatusReader
. Only DisplayInteractiveObjects
manage setting the layout state automatically. In this case, the layout state will be composed
by the state of the DisplayInteractiveObject
and the state of the
Painter
that uses the PropertyStatusReader
.
The set layout state determines not only the according part of the property key, but
also determines, how this part should be switched through the layouts, if
the property was not found. If a property was not found, first the given style
will be ignored (so if the property "xsegment.point.round.active.color" was not found,
the PropertyStatusReader
tries "xsegment.point.active.color" instead).
If still no value was found, the layout will be lowered, meaning the elemination
of the highest bit in the layout mask. Assume, the layout state is set to
. The highest layout (bit) defines
the prefix according to the global prefix table; the highest layout is
LAYOUT_1
| LAYOUT_2
LAYOUT_2
, the according entry is "active". If no property with this
layout prefix is found, the highest bit in the layout state mask will be
eleminated; thus LAYOUT_1
is remaining. The according prefix of the
highest layout (bit) is "selected", so e.g. "xsegment.point.round.selected.color"
will be read. This continues until all layout state bits are cleared and the normal
prefix ("") was read (e.g. "xsegment.point.round.color"/"xsegment.point.color").
If a value is found, the PropertyStatusReader
can cache the found value,
to accelerate the retrieval of this property next time. The caching can be disabled
by calling disableCaching()
. This will cost performance but save memory.
Per default, caching is enabled. Caching assumes static properties. If properties do
change dynamically, clearCache()
must be called to ensure reading of correct
properties.
Field Summary | |
static byte |
LAYOUT_0
Layout constant: normal layout (no prefix). |
static byte |
LAYOUT_1
Layout constant: layout 1 (prefix according prefix table). |
static byte |
LAYOUT_2
Layout constant: layout 2 (prefix according prefix table). |
static byte |
LAYOUT_3
Layout constant: layout 3 (prefix according prefix table). |
static byte |
LAYOUT_4
Layout constant: layout 4 (prefix according prefix table). |
static byte |
LAYOUT_5
Layout constant: layout 5 (prefix according prefix table). |
static byte |
LAYOUT_6
Layout constant: layout 6 (prefix according prefix table). |
static byte |
LAYOUT_7
Layout constant: layout 7 (prefix according prefix table). |
static byte |
LAYOUT_8
Layout constant: layout 8 (prefix according prefix table). |
static java.lang.String |
STYLE_PROPERTY_NAME
The property name for a style property. |
Constructor Summary | |
PropertyStatusReader(java.lang.String prefix,
DrawAtom dob)
Constructs a new PropertyStatusReader object with the specified properties prefix and source DrawAtom . |
|
PropertyStatusReader(java.lang.String prefix,
DrawAtom drw,
byte state)
Constructs a new PropertyStatusReader object with the specified properties prefix, source DrawAtom and state. |
Method Summary | |
void |
addPrefix(java.lang.String prefix)
Adds a prefix for reading properties. |
void |
clearCache()
Clears the Cache of this PropertyStatusReader . |
void |
clearPropertyAdapterSource()
Clears the source object for SourcePropertyAdapter entries. |
void |
disableCaching()
Disables the caching of properties. |
void |
enableCaching()
Enables the caching of properties. |
boolean |
getBoolProperty(java.lang.String key,
boolean default_value)
Returns a property value which must be an boolean value. |
java.awt.Color |
getColorProperty(java.lang.String key,
java.awt.Color default_color)
Returns a property value which must be a color. |
double |
getDoubleProperty(java.lang.String key,
double default_value)
Returns a property value which must be an double number. |
java.awt.Font |
getFontProperty(java.lang.String key,
java.awt.Font default_font)
Returns a property value which must be a java.awt.Font object.
|
int |
getIntProperty(java.lang.String key,
int default_value)
Returns a property value which must be an integer number. |
Painter |
getPainterFromStyle(java.lang.String name,
java.lang.String subtype)
Returns a Painter created by a Style stored at the
style property of the given subtype. |
java.awt.Point |
getPointProperty(java.lang.String key,
java.awt.Point default_point)
Returns a property value which must be a java.awt.Point object.
|
java.lang.Object |
getProperty(java.lang.String key)
Returns property with the given key of the connected DrawAtom .
|
java.lang.Object |
getProperty(java.lang.String key,
java.lang.Object default_value)
Returns property with the given key of the connected DrawAtom .
with a given default value if the property is not set.
|
java.lang.Object |
getSpecialProperty(java.lang.String key,
java.lang.Object default_value,
java.lang.Object source,
DrawAtom atom)
Reads the property with this PropertyStatusReader from
another DrawAtom in the drawing hierachy.
|
java.lang.String |
getStringProperty(java.lang.String key,
java.lang.String default_string)
Returns a property value which must be a string. |
Style |
getStyleProperty(java.lang.String subtype)
Reads a Style property value for a given subtype. |
java.lang.Object |
getSubTypeProperty(java.lang.String subtype,
java.lang.String key)
Returns property with the given key of the connected DrawAtom
using the specified subtype string instead of the one already set
on this PropertyStatusReader.
|
java.lang.Object |
getSubTypeProperty(java.lang.String subtype,
java.lang.String key,
java.lang.Object default_value)
Returns property with the given key of the connected DrawAtom .
(with a given default value if the property is not set)
using the specified subtype string instead of the one already set
on this PropertyStatusReader.
|
boolean |
hasProperty(java.lang.String key)
Returns true , if the specified property is set. |
java.lang.String |
prefix()
Returns the properties prefix of the PropertyStatusReader. |
java.lang.Object |
propertyAdapterSource()
Returns the source object for SourcePropertyAdapter entries. |
java.lang.String |
removeLastPrefix()
Removes the last added prefix (to the last point). |
void |
setPrefixTo(java.lang.String prefix)
Sets the properties prefix for reading properties. |
void |
setPropertyAdapterSource(java.lang.Object source)
Sets a source object for SourcePropertyAdapter entries. |
void |
setState(byte state)
Sets the layout state. |
void |
setStyle(java.lang.String style)
Sets the style prefix to the given String (may be empty). |
void |
setSubType(java.lang.String subtype)
Sets the subtype prefix to the given String (may be empty). |
byte |
state()
Returns the layout state of the PropertyReader . |
java.lang.String |
style()
Returns the style prefix for properties (may be empty). |
java.lang.String |
subtype()
Returns the subtype prefix for properties (may be empty). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String STYLE_PROPERTY_NAME
public static final byte LAYOUT_0
public static final byte LAYOUT_1
public static final byte LAYOUT_2
public static final byte LAYOUT_3
public static final byte LAYOUT_4
public static final byte LAYOUT_5
public static final byte LAYOUT_6
public static final byte LAYOUT_7
public static final byte LAYOUT_8
Constructor Detail |
public PropertyStatusReader(java.lang.String prefix, DrawAtom drw, byte state)
DrawAtom
and state.prefix
- the prefix for all propertiesdrw
- the DrawAtom to read properties fromstate
- the state of the elementpublic PropertyStatusReader(java.lang.String prefix, DrawAtom dob)
DrawAtom
. The state will
be determined through the state of the DrawAtom
(if it is
an instance of DisplayInteractiveObject).prefix
- the prefix for all propertiesdrw
- the DrawAtom to read properties fromstate
- the state of the elementMethod Detail |
public byte state()
PropertyReader
.PropertyReader
.public void setState(byte state)
state
- the new statepublic void enableCaching()
public void disableCaching()
public void clearCache()
this
PropertyStatusReader
.public java.lang.String prefix()
public void setPrefixTo(java.lang.String prefix)
prefix
- new prefix stringaddPrefix(java.lang.String)
public void addPrefix(java.lang.String prefix)
prefix
- new prefix to addpublic java.lang.String removeLastPrefix()
addPrefix(java.lang.String)
public java.lang.String subtype()
public void setSubType(java.lang.String subtype)
subtype
- the subtype stringpublic java.lang.String style()
public void setStyle(java.lang.String style)
style
- the style stringpublic void setPropertyAdapterSource(java.lang.Object source)
SourcePropertyAdapter
entries.source
- the source object to usepublic java.lang.Object propertyAdapterSource()
SourcePropertyAdapter
entries.SourcePropertyAdapter
entries.public void clearPropertyAdapterSource()
SourcePropertyAdapter
entries.public final java.lang.Object getSpecialProperty(java.lang.String key, java.lang.Object default_value, java.lang.Object source, DrawAtom atom)
this
PropertyStatusReader
from
another DrawAtom
in the drawing hierachy.
Use this method with caution!key
- property keydefault_value
- the default valuesource
- the source object to useatom
- the DrawAtom
to usepublic final java.lang.Object getProperty(java.lang.String key, java.lang.Object default_value)
DrawAtom
.
with a given default value if the property is not set.
The read property depends on the actual state. The key will be expanded
by the given prefix, the subtype and style and the prefixes "selected",
"active", "active1", "active2",... dependend on the current state.key
- a key in the properties listdefault_value
- the default value of that propertynull
if the key
is not mapped to any value
in the properties lists of the connected DrawAtom
and parent
object(s).public java.lang.Object getProperty(java.lang.String key)
DrawAtom
.
The read property depends on the actual state. The key will be expanded
by the given prefix, the subtype and style and the prefixes "selected",
"active", "active1", "active2",... dependend on the current state.key
- a key in the properties listnull
if the key
is not mapped to any value
in the properties lists of the connected DrawAtom
and parent
object(s).public final boolean hasProperty(java.lang.String key)
true
, if the specified property is set.key
- the key for the propertytrue
, if the specified property is set.public java.lang.Object getSubTypeProperty(java.lang.String subtype, java.lang.String key)
DrawAtom
using the specified subtype string instead of the one already set
on this
PropertyStatusReader.
The read property depends on the actual state. The key will be expanded
by the given prefix and subtype and the style and the prefixes "selected",
"active", "active1", "active2",... dependend on the current state.subtype
- the subtype string to usekey
- a key in the properties listnull
if the key
is not mapped to any value
in the properties lists of the connected DrawAtom
and parent
object(s).public java.lang.Object getSubTypeProperty(java.lang.String subtype, java.lang.String key, java.lang.Object default_value)
DrawAtom
.
(with a given default value if the property is not set)
using the specified subtype string instead of the one already set
on this
PropertyStatusReader.
The read property depends on the actual state. The key will be expanded
by the given prefix, the subtype and style and the prefixes "selected",
"active", "active1", "active2",... dependend on the current state.subtype
- the subtype string to usekey
- a key in the properties listnull
if the key
is not mapped to any value
in the properties lists of the connected DrawAtom
and parent
object(s).public int getIntProperty(java.lang.String key, int default_value)
Number
. If the property is not
set or is not of the type Number
, the specified default
value will be returned.key
- a key in the properties listdefault_value
- the default value if the property is not set or
invalid.public double getDoubleProperty(java.lang.String key, double default_value)
Number
. If the property is not
set or is not of the type Number
, the specified default
value will be returned.key
- a key in the properties listdefault_value
- the default value if the property is not set or
invalid.public java.lang.String getStringProperty(java.lang.String key, java.lang.String default_string)
String
. If the property is not
set or is not of the type String
, the specified default
string will be returned.key
- a key in the properties listdefault_string
- the default string if the property is not set or
invalid.public java.awt.Color getColorProperty(java.lang.String key, java.awt.Color default_color)
Color
. If the property is not
set or is not of the type Color
, the specified default
color will be returned.key
- a key in the properties listdefault_color
- the default color if the property is not set or
invalid.public boolean getBoolProperty(java.lang.String key, boolean default_value)
Boolean
. If the property is not
set or is not of the type Boolean
, the specified default
value will be returned.key
- a key in the properties listdefault_value
- the default value if the property is not set or
invalid.public java.awt.Point getPointProperty(java.lang.String key, java.awt.Point default_point)
java.awt.Point
object.
If the property is not set or is not of the type java.awt.Point
,
the specified default point will be returned.key
- a key in the properties listdefault_point
- the default java.awt.Point
if the
property is not set or invalid.java.awt.Point
property.public java.awt.Font getFontProperty(java.lang.String key, java.awt.Font default_font)
java.awt.Font
object.
If the property is not set or is not of the type java.awt.Font
,
the specified default font will be returned.key
- a key in the properties listdefault_font
- the default java.awt.Font
if the
property is not set or invalid.java.awt.Font
property.public Style getStyleProperty(java.lang.String subtype)
Style
property value for a given subtype. The Style
property is a required property. The property name that is
used is defined via STYLE_PROPERTY_NAME
.subtype
- the subtype string to useStyle
property.public Painter getPainterFromStyle(java.lang.String name, java.lang.String subtype)
Painter
created by a Style
stored at the
style property of the given subtype. The created Painter
will have the same subtype string.name
- the name of the created Painter
subtype
- where to create a Painter
fromPainter
created by the Style
that is stored
at the style property of the given subtype
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |