de.cau.cs.kieler.kiml
Class LayoutOptionData<T>

java.lang.Object
  extended by de.cau.cs.kieler.kiml.LayoutOptionData<T>
Type Parameters:
T - data type for the option data
All Implemented Interfaces:
IProperty<T>, ILayoutData, Comparable<IProperty<?>>

public class LayoutOptionData<T>
extends Object
implements ILayoutData, IProperty<T>, Comparable<IProperty<?>>

Data type used to store information for a layout option.

Rating yellow
(2011-02-01) reviewed by cmot, soh

Nested Class Summary
static class LayoutOptionData.Target
          option target enumeration.
static class LayoutOptionData.Type
          data type enumeration.
 
Field Summary
static String[] BOOLEAN_CHOICES
          choices for boolean type options.
static String BOOLEAN_LITERAL
          literal value constant for booleans.
static String DEFAULT_OPTION_NAME
          default name for layout options for which no name is given.
static String EDGES_LITERAL
          literal value constant for edges target.
static String ENUM_LITERAL
          literal value constant for enumerations.
static String FLOAT_LITERAL
          literal value constant for floating point numbers.
static String INT_LITERAL
          literal value constant for integer numbers.
static String LABELS_LITERAL
          literal value constant for labels target.
static String NODES_LITERAL
          literal value constant for nodes target.
static String OBJECT_LITERAL
          literal value constant for data objects.
static String PARENTS_LITERAL
          literal value constant for diagram target.
static String PORTS_LITERAL
          literal value constant for ports target.
static String REMOTEENUM_LITERAL
          literal value constant for enumeration coming from remote layout.
static String STRING_LITERAL
          literal value constant for strings.
 
Constructor Summary
LayoutOptionData()
           
 
Method Summary
 int compareTo(IProperty<?> other)
          Compares this with another Object.
 boolean equals(Object obj)
          
 String[] getChoices()
          Creates an array of choices that can be selected by the user to set a value for this option.
 T getDefault()
          Returns the default value of this property.
 T getDefaultDefault()
          Creates a default-default value for this layout option.
 String getDescription()
          Returns the description.
 Enum<?> getEnumValue(int intValue)
          Returns the enumeration value for a given index.
 String getId()
          Returns the identifier.
 Comparable<T> getLowerBound()
          Returns the lower bound of this property.
 String getName()
          Returns the name.
 Class<?> getOptionClass()
          Returns the option type class.
 String getTargetsDescription()
          Returns a user friendly description of the active targets of this layout option.
 LayoutOptionData.Type getType()
          Returns the type.
 Comparable<T> getUpperBound()
          Returns the upper bound of this property.
 int hashCode()
          
 boolean hasTarget(LayoutOptionData.Target target)
          Checks whether the given target is active for this layout option.
 boolean isAdvanced()
          Whether the option should be shown in advanced mode only.
 boolean isVisible()
          Returns whether this option is visible to users, e.g.
 void parseRemoteEnumValues(String valueString)
          Parses the possible values for a remote enumeration from a space separated string.
 T parseValue(String valueString)
          Parses a string value for this layout option.
 void setAdvanced(boolean theadvanced)
          Sets the advanced property of the layout option.
 void setDefault(T thedefaultValue)
          Sets the default value.
 void setDescription(String thedescription)
          Sets the description.
 void setId(String theid)
          Sets the identifier.
 void setName(String thename)
          Sets the name.
 void setOptionClass(Class<?> theclazz)
          Sets the option type class.
 void setTargets(String targetsString)
          Sets the targets property of this layout option data.
 void setType(LayoutOptionData.Type thetype)
          Sets the data type.
 void setType(String typeLiteral)
          Sets the type field depending on the given literal.
 void setVisible(boolean thevisible)
          Sets whether this option is visible to users, e.g.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BOOLEAN_LITERAL

public static final String BOOLEAN_LITERAL
literal value constant for booleans.

See Also:
Constant Field Values

INT_LITERAL

public static final String INT_LITERAL
literal value constant for integer numbers.

See Also:
Constant Field Values

STRING_LITERAL

public static final String STRING_LITERAL
literal value constant for strings.

See Also:
Constant Field Values

FLOAT_LITERAL

public static final String FLOAT_LITERAL
literal value constant for floating point numbers.

See Also:
Constant Field Values

ENUM_LITERAL

public static final String ENUM_LITERAL
literal value constant for enumerations.

See Also:
Constant Field Values

OBJECT_LITERAL

public static final String OBJECT_LITERAL
literal value constant for data objects.

See Also:
Constant Field Values

REMOTEENUM_LITERAL

public static final String REMOTEENUM_LITERAL
literal value constant for enumeration coming from remote layout.

See Also:
Constant Field Values

DEFAULT_OPTION_NAME

public static final String DEFAULT_OPTION_NAME
default name for layout options for which no name is given.

See Also:
Constant Field Values

PARENTS_LITERAL

public static final String PARENTS_LITERAL
literal value constant for diagram target.

See Also:
Constant Field Values

NODES_LITERAL

public static final String NODES_LITERAL
literal value constant for nodes target.

See Also:
Constant Field Values

EDGES_LITERAL

public static final String EDGES_LITERAL
literal value constant for edges target.

See Also:
Constant Field Values

PORTS_LITERAL

public static final String PORTS_LITERAL
literal value constant for ports target.

See Also:
Constant Field Values

LABELS_LITERAL

public static final String LABELS_LITERAL
literal value constant for labels target.

See Also:
Constant Field Values

BOOLEAN_CHOICES

public static final String[] BOOLEAN_CHOICES
choices for boolean type options.

Constructor Detail

LayoutOptionData

public LayoutOptionData()
Method Detail

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

compareTo

public int compareTo(IProperty<?> other)
Compares this with another Object. Returns -1 if this object is smaller, 0 if both objects are equal and 1 if this object is bigger.

Specified by:
compareTo in interface Comparable<IProperty<?>>
Parameters:
other - the object to compare with
Returns:
one of the values -1, 0, 1

toString

public String toString()

Overrides:
toString in class Object

setType

public void setType(String typeLiteral)
Sets the type field depending on the given literal.

Parameters:
typeLiteral - a string value that is expected to be equal to one of the predefined literal value constants

parseValue

public T parseValue(String valueString)
Parses a string value for this layout option.

Parameters:
valueString - a serialized value
Returns:
an instance of the corresponding correctly typed value, or null if the given value string is invalid

parseRemoteEnumValues

public void parseRemoteEnumValues(String valueString)
Parses the possible values for a remote enumeration from a space separated string.

Parameters:
valueString - the space separated string containing the possible values

getDefaultDefault

public T getDefaultDefault()
Creates a default-default value for this layout option. In contrast to getDefault(), this never returns null for options with type other than 'object'.

Returns:
a default-default value, depending on the option type

getChoices

public String[] getChoices()
Creates an array of choices that can be selected by the user to set a value for this option. This makes only sense for enumeration type or boolean type options.

Returns:
an array of values to be displayed for the user

getEnumValue

public Enum<?> getEnumValue(int intValue)
Returns the enumeration value for a given index.

Parameters:
intValue - zero-based index of the enumeration value
Returns:
the corresponding enumeration value

setTargets

public void setTargets(String targetsString)
Sets the targets property of this layout option data.

Parameters:
targetsString - comma separated list of targets

hasTarget

public boolean hasTarget(LayoutOptionData.Target target)
Checks whether the given target is active for this layout option.

Parameters:
target - a layout option target
Returns:
true if the target is active

getTargetsDescription

public String getTargetsDescription()
Returns a user friendly description of the active targets of this layout option.

Returns:
a description of the active targets, or null if there are no active targets

setId

public void setId(String theid)
Sets the identifier.

Specified by:
setId in interface ILayoutData
Parameters:
theid - the identifier to set

getId

public String getId()
Returns the identifier.

Specified by:
getId in interface IProperty<T>
Specified by:
getId in interface ILayoutData
Returns:
the identifier

setType

public void setType(LayoutOptionData.Type thetype)
Sets the data type. If the option class can be derived from the class, it is also set.

Parameters:
thetype - the data type to set

getType

public LayoutOptionData.Type getType()
Returns the type.

Returns:
the type

setName

public void setName(String thename)
Sets the name.

Specified by:
setName in interface ILayoutData
Parameters:
thename - the name to set

getName

public String getName()
Returns the name.

Specified by:
getName in interface ILayoutData
Returns:
the name

setDescription

public void setDescription(String thedescription)
Sets the description.

Specified by:
setDescription in interface ILayoutData
Parameters:
thedescription - the description to set

getDescription

public String getDescription()
Returns the description.

Specified by:
getDescription in interface ILayoutData
Returns:
the description

getDefault

public T getDefault()
Returns the default value of this property.

Specified by:
getDefault in interface IProperty<T>
Returns:
the default value, or null if the property has no default value

getLowerBound

public Comparable<T> getLowerBound()
Returns the lower bound of this property. If there is no lower bound, a comparable is returned that is smaller than everything else.

Specified by:
getLowerBound in interface IProperty<T>
Returns:
the lower bound

getUpperBound

public Comparable<T> getUpperBound()
Returns the upper bound of this property. If there is no upper bound, a comparable is returned that is greater than everything else.

Specified by:
getUpperBound in interface IProperty<T>
Returns:
the upper bound

setDefault

public void setDefault(T thedefaultValue)
Sets the default value.

Parameters:
thedefaultValue - the default value

getOptionClass

public Class<?> getOptionClass()
Returns the option type class.

Returns:
the type class

setOptionClass

public void setOptionClass(Class<?> theclazz)
Sets the option type class.

Parameters:
theclazz - the class to set

isAdvanced

public boolean isAdvanced()
Whether the option should be shown in advanced mode only.

Returns:
true if the option is advanced

setAdvanced

public void setAdvanced(boolean theadvanced)
Sets the advanced property of the layout option.

Parameters:
theadvanced - true if the option is advanced

isVisible

public boolean isVisible()
Returns whether this option is visible to users, e.g. should be displayed in GUI elements..

Returns:
true if the option is visible

setVisible

public void setVisible(boolean thevisible)
Sets whether this option is visible to users, e.g. should be displayed in GUI elements.

Parameters:
thevisible - whether this option is visible to users, e.g. should be displayed in GUI elements