com.tensegrity.gui.swing.customattribute
Class FormatAttribute

java.lang.Object
  extended bycom.tensegrity.gui.swing.customattribute.FormatAttribute
All Implemented Interfaces:
Attribute, java.lang.Cloneable, CustomAttribute, Restrictable

public class FormatAttribute
extends java.lang.Object
implements CustomAttribute

The FormatAttribute class represents an Attribute encapsulating a Format instance. Use this Attribute implementation whenever you need Format instances as Attribute.

Version:
$Id: FormatAttribute.java,v 1.8 2005/03/23 15:02:42 BurkhardWick Exp $
Author:
GillesIachelini

Field Summary
static int FONT
          Identifier for the four available Format types.
static java.lang.String FONT_GENERATOR
          String identifier for the generators.
static int MARKER
          Identifier for the four available Format types.
static java.lang.String MARKER_GENERATOR
          String identifier for the generators.
static int PAINT
          Identifier for the four available Format types.
static java.lang.String PAINT_GENERATOR
          String identifier for the generators.
static int STROKE
          Identifier for the four available Format types.
static java.lang.String STROKE_GENERATOR
          String identifier for the generators.
 
Constructor Summary
FormatAttribute(int type)
          Creates a new FormatAttribute based on the given type.
FormatAttribute(java.lang.String name, int type)
          Creates a new FormatAttribute based on the given type.
 
Method Summary
 java.lang.Object clone()
          Clones this attribute.
 java.lang.Object cloneValue()
          Clones this attribute's value.
 Constraint getConstraint()
          Returns the root of the constraint tree.
 CustomAttributeEditor getEditor()
          Method getEditor returns an instance of a CustomAttributeEditor which the AttributeTree will use to allow users to edit this attribute.
static int getFormatType(Format format)
          Utility method to dynamically identify the proper type identifier for a given Format instance.
 java.lang.String getGeneratorKey()
          Returns a proper Generatorkey depending on the current value type.
 java.lang.String getName()
          Returns the Attribute name.
 CustomAttributeRenderer getRenderer()
          Returns an instance of a CustomAttributeRenderer which the AttributeTree uses to render values of this attribute.
 java.lang.String getStringRepresentation()
          Returns a String representation for the value of this attribute, which will be used to create an instance of this attribute via the CustomAttributeGenerator.
 AttributeType getType()
          Returns the current value's type.
 java.lang.Object getValue()
          Returns the Attribute value.
 boolean isMutable()
          Returns the mutable flag that indicates whether the attribute is mutable or immutable.
 java.lang.Object newValueInstance()
          Creates a new instance of the value part of the CustomAttribute.
 void setConstraint(Constraint constraint)
          Sets the root of the constraint tree.
 void setMutable(boolean mutable)
          Sets the mutable flag that indicates whether the attribute is mutable or immutable.
 void setName(java.lang.String name)
          Sets the name of this attribute.
 void setValue(java.lang.Object value)
          Sets the Attribute value.
 boolean useDefaultEditor()
          If the CustomAttribute does not implement its own editor, it can use the default editors if the value is one of the recognized types (e.g.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAINT

public static final int PAINT
Identifier for the four available Format types.

See Also:
Constant Field Values

STROKE

public static final int STROKE
Identifier for the four available Format types.

See Also:
Constant Field Values

FONT

public static final int FONT
Identifier for the four available Format types.

See Also:
Constant Field Values

MARKER

public static final int MARKER
Identifier for the four available Format types.

See Also:
Constant Field Values

PAINT_GENERATOR

public static final java.lang.String PAINT_GENERATOR
String identifier for the generators.

See Also:
Constant Field Values

STROKE_GENERATOR

public static final java.lang.String STROKE_GENERATOR
String identifier for the generators.

See Also:
Constant Field Values

FONT_GENERATOR

public static final java.lang.String FONT_GENERATOR
String identifier for the generators.

See Also:
Constant Field Values

MARKER_GENERATOR

public static final java.lang.String MARKER_GENERATOR
String identifier for the generators.

See Also:
Constant Field Values
Constructor Detail

FormatAttribute

public FormatAttribute(int type)
Creates a new FormatAttribute based on the given type. The name will be generated depending on the type.

Parameters:
type - identifier of the target format type.
See Also:
PAINT, STROKE, MARKER, FONT

FormatAttribute

public FormatAttribute(java.lang.String name,
                       int type)
Creates a new FormatAttribute based on the given type.

Parameters:
name - the name for this instance
type - identifier of the target format type.
See Also:
PAINT, STROKE, MARKER, FONT
Method Detail

getEditor

public CustomAttributeEditor getEditor()
Description copied from interface: CustomAttribute
Method getEditor returns an instance of a CustomAttributeEditor which the AttributeTree will use to allow users to edit this attribute. The method returns null if no such editor exists and the attribute is not editable or the default editor should be used.

Specified by:
getEditor in interface CustomAttribute
Returns:
a CustomAttributeEditor for this attribute.

getRenderer

public CustomAttributeRenderer getRenderer()
Description copied from interface: CustomAttribute
Returns an instance of a CustomAttributeRenderer which the AttributeTree uses to render values of this attribute. The method returns null if no such renderer exists and the default renderer should be used. A renderer is required if the Attribute cannot be rendered by the standard renderer of the Table.

Specified by:
getRenderer in interface CustomAttribute
Returns:
a CustomAttributeRenderer for this attribute.

getStringRepresentation

public java.lang.String getStringRepresentation()
Description copied from interface: CustomAttribute
Returns a String representation for the value of this attribute, which will be used to create an instance of this attribute via the CustomAttributeGenerator.

Specified by:
getStringRepresentation in interface CustomAttribute
Returns:
a String representation of this attribute.

newValueInstance

public java.lang.Object newValueInstance()
Description copied from interface: CustomAttribute
Creates a new instance of the value part of the CustomAttribute. This is needed when instances of this Attribute need to be added and an instance of the value part is required.

Specified by:
newValueInstance in interface CustomAttribute
Returns:
an Object for the value part of this attribute.

getGeneratorKey

public java.lang.String getGeneratorKey()
Returns a proper Generatorkey depending on the current value type.

Specified by:
getGeneratorKey in interface CustomAttribute
Returns:
a String usable as a key for this attribute.
See Also:
CustomAttribute.getGeneratorKey()

getType

public AttributeType getType()
Description copied from interface: Attribute
Returns the current value's type.

Specified by:
getType in interface Attribute
Returns:
the type of the current value.

getName

public java.lang.String getName()
Description copied from interface: Attribute
Returns the Attribute name.

Specified by:
getName in interface Attribute
Returns:
the name of the attribute.

getValue

public java.lang.Object getValue()
Description copied from interface: Attribute
Returns the Attribute value.

Specified by:
getValue in interface Attribute
Returns:
the value of this attribute.

setValue

public void setValue(java.lang.Object value)
              throws IllegalValueException,
                     ConstraintViolationException
Description copied from interface: Attribute
Sets the Attribute value.

Specified by:
setValue in interface Attribute
Parameters:
value - the new value of the attribute.
Throws:
IllegalValueException - if the attribute value is invalid.
ConstraintViolationException - thrown if the constraint of this attribute does not permit setting the new value.

setName

public void setName(java.lang.String name)
Description copied from interface: CustomAttribute
Sets the name of this attribute.

Specified by:
setName in interface CustomAttribute
Parameters:
name - String for the new name.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: Attribute
Clones this attribute. The name of the attribute is not deep-copied, as String instances are immutable. The value of the attribute is copied by means of the clone method of Object.

Specified by:
clone in interface Attribute
Throws:
java.lang.CloneNotSupportedException

isMutable

public boolean isMutable()
Description copied from interface: Attribute
Returns the mutable flag that indicates whether the attribute is mutable or immutable.

Specified by:
isMutable in interface Attribute
Returns:
true, if it is mutable; false, if it is immutable.

setMutable

public void setMutable(boolean mutable)
Description copied from interface: Attribute
Sets the mutable flag that indicates whether the attribute is mutable or immutable.

Specified by:
setMutable in interface Attribute
Parameters:
mutable - the new value of the mutable flag.

setConstraint

public void setConstraint(Constraint constraint)
Description copied from interface: Restrictable
Sets the root of the constraint tree.

Specified by:
setConstraint in interface Restrictable
Parameters:
constraint - the root of the constraint tree

getConstraint

public Constraint getConstraint()
Description copied from interface: Restrictable
Returns the root of the constraint tree.

Specified by:
getConstraint in interface Restrictable
Returns:
the root of the constraint tree

getFormatType

public static int getFormatType(Format format)
Utility method to dynamically identify the proper type identifier for a given Format instance.

Parameters:
format - the format instance you wish to receive the aprobriate type identifier to.
Returns:
the type identifier for the given Format instance.

cloneValue

public java.lang.Object cloneValue()
                            throws java.lang.CloneNotSupportedException
Description copied from interface: Attribute
Clones this attribute's value. Usually a deep copy is returned. The value object itself can decide what is to be considered a deep-copy. Sometimes in case of (nested) references to immutable objects a deep-copy may be the same as a shallow-copy.

Specified by:
cloneValue in interface Attribute
Returns:
a deep copy of this attribute's value.
Throws:
java.lang.CloneNotSupportedException - may be thrown if invoking this method on the value is not allowed or supported.

useDefaultEditor

public boolean useDefaultEditor()
Description copied from interface: CustomAttribute
If the CustomAttribute does not implement its own editor, it can use the default editors if the value is one of the recognized types (e.g. String, Integer, etc.)

Specified by:
useDefaultEditor in interface CustomAttribute
Returns:
true to use the default editors if the method CustomAttribute.getEditor() returns null


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.