public class PreviewProperties extends Object
PreviewProperty attached to a PreviewModel.
This class holds all preview properties defined in the model. Each property has a unique name, a type and a value and can be configured by users.
Properties should be added using the addProperty() method before
calling putValue() to properly register properties.
Besides holding well-defined properties this class acts also as a map
and can store arbitrary (key,value) pairs. All (key,value) pairs are stored
when calling the putValue() method but only properties added with
the addProperty() method are returned when calling the
getProperties() methods. Therefore this class can both be used
for fixed properties and temporary variables.
To batch put a set of property values the best way is to create a PreviewPreset
and call the applyPreset() method.
PreviewPreset| Constructor and Description |
|---|
PreviewProperties() |
| Modifier and Type | Method and Description |
|---|---|
void |
addProperty(PreviewProperty property)
Add
property to the properties. |
void |
applyPreset(PreviewPreset previewPreset)
Sets all preset's property values to this properties.
|
boolean |
getBooleanValue(String property)
Returns the property value as a boolean.
|
PreviewProperty[] |
getChildProperties(PreviewProperty property)
Returns all properties which defined
property as a dependency. |
Color |
getColorValue(String property)
Returns an the property value as a
Color. |
double |
getDoubleValue(String property)
Returns the property value as a double.
|
float |
getFloatValue(String property)
Returns the property value as a float.
|
Font |
getFontValue(String property)
Returns an the property value as a
Font. |
int |
getIntValue(String property)
Returns the property value as an int.
|
Number |
getNumberValue(String property,
Number defaultValue)
Returns the property value as a
Number. |
PreviewProperty[] |
getParentProperties(PreviewProperty property)
Returns all properties
property defined as dependencies. |
PreviewProperty[] |
getProperties()
Returns all properties.
|
PreviewProperty[] |
getProperties(Object source)
Returns all properties with
source as source. |
PreviewProperty[] |
getProperties(String category)
Returns all properties with
category as category. |
PreviewProperty |
getProperty(String name)
Returns the property defined as
name. |
Set<Map.Entry<String,Object>> |
getSimpleValues()
Return all simple values.
|
String |
getStringValue(String property)
Returns the property value as an string.
|
<T> T |
getValue(String property)
Returns the property value and cast it to the
T type. |
<T> T |
getValue(String property,
T defaultValue)
Returns the property value and cast it to the
T type. |
static String |
getValueAsText(Object value)
Converts any value to a serialized String.
|
boolean |
hasProperty(String name)
Returns
true if a property name exists. |
void |
putValue(String name,
Object value)
Puts the property's value.
|
static Object |
readValueFromText(String valueStr,
Class valueClass)
Deserializes a serialized String of the given class.
|
void |
removeProperty(PreviewProperty property) |
void |
removeSimpleValue(String name)
Removes a simple value if existing
|
public void addProperty(PreviewProperty property)
property to the properties.
The property should have a unique name and the method will throw an exception if not.
property - the property to add to the propertiesIllegalArgumentException - if property already existspublic void removeProperty(PreviewProperty property)
public boolean hasProperty(String name)
true if a property name exists.name - the name of the property to lookuptrue if the property exists, false otherwisepublic void putValue(String name, Object value)
name - the name of the propertyvalue - the valuepublic void removeSimpleValue(String name)
name - Simple value namepublic int getIntValue(String property)
property - the property's name0 if not foundClassCastException - if the property can't be cast to Numberpublic float getFloatValue(String property)
property - the property's name0 if not foundClassCastException - if the property can't be cast to Numberpublic double getDoubleValue(String property)
property - the property's name0.0 if not foundClassCastException - if the property can't be cast to Numberpublic String getStringValue(String property)
String
it calls the toString() method.property - the property's name"" if not foundpublic Color getColorValue(String property)
Color.property - the property's namenull if not foundClassCastException - if the property can't be cast to Colorpublic Font getFontValue(String property)
Font.property - the property's namenull if not foundClassCastException - if the property can't be cast to Fontpublic boolean getBooleanValue(String property)
property - the property's namefalse if not foundClassCastException - if the property can't be cast to Booleanpublic <T> T getValue(String property)
T type.T - the type to cast the property value toproperty - the property's namenull if not foundClassCastException - if the property can't be cast to Tpublic <T> T getValue(String property, T defaultValue)
T type.T - the type to cast the property value toproperty - the property's namedefaultValue - the default value if not founddefaultValue if not foundClassCastException - if the property can't be cast to Tpublic Number getNumberValue(String property, Number defaultValue)
Number.property - the property's namedefaultValue - the default value if not founddefaultValue if not foundClassCastException - if the property can't be cast to Numberpublic Set<Map.Entry<String,Object>> getSimpleValues()
public PreviewProperty[] getProperties()
public PreviewProperty[] getProperties(String category)
category as category. A property
can belong to only one category. Default categories names are defined in
PreviewProperty.category - the category properties belong tocategorypublic PreviewProperty getProperty(String name)
name.name - the property's namenull if not foundpublic PreviewProperty[] getProperties(Object source)
source as source. A property
can belong to only one source.source - the source properties belong tosourcepublic PreviewProperty[] getChildProperties(PreviewProperty property)
property as a dependency.property - the parent propertyproperty as a parent propertypublic PreviewProperty[] getParentProperties(PreviewProperty property)
property defined as dependencies.property - the property to find parent properties fromproperty depends onpublic void applyPreset(PreviewPreset previewPreset)
previewPreset - the preset to get values frompublic static String getValueAsText(Object value)
PropertyEditor for serialization except for values of Font class.
Note: Method moved to Utils module (org.gephi.utils.Serialization).value - Value to serialize as StringPropertyEditorpublic static Object readValueFromText(String valueStr, Class valueClass)
PropertyEditor for serialization except for values of Font class.
Note: Method moved to Utils module (org.gephi.utils.Serialization).valueStr - String to deserializevalueClass - Class of the serialized valuePropertyEditorCopyright © 2007–2015 Gephi Consortium. All rights reserved.