|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
att.grappa.Attribute
public final class Attribute
A class used for representing attributes associated with the graph elements. An attribute consists of a name-value pair and an element type. Once an attribute is constructed, the name cannot be changed. The element type and the attribute name are used in determining how a string representation of an attribute value is to be converted to an Object and vice versa. The Element class method setUserAttributeType allows users to take advantage of Grappa's built-in converters or to pass a (negative) integer as a conversion indicator to a user-supplied AttributeHandler.
Grappa String Converters | |
BOX_TYPE | att.grappa.GrappaBox |
COLOR_TYPE | java.awt.Color |
DIR_TYPE | java.lang.Integer (restricted) |
DOUBLE_TYPE | java.lang.Double |
FONTSTYLE_TYPE | java.lang.Integer (restricted) |
HASHLIST_TYPE | java.lang.Hashtable |
INTEGER_TYPE | java.lang.Integer |
LINE_TYPE | att.grappa.GrappaLine |
POINT_TYPE | att.grappa.GrappaPoint |
SHAPE_TYPE | java.lang.Integer (restricted) |
SIZE_TYPE | att.grappa.GrappaSize |
STRING_TYPE | java.lang.String (default) |
STYLE_TYPE | att.grappa.GrappaStyle |
AttributeHandler
,
Element.setUserAttributeType(java.lang.String, int)
Field Summary | |
---|---|
private int |
attributeType
|
private int |
elementType
|
private java.lang.String |
name
|
private int |
nameHash
|
private static AttributeHandler |
specialHandler
|
private java.lang.String |
stringValue
|
private java.lang.Object |
value
|
Constructor Summary | |
---|---|
Attribute(Attribute attr)
Constructs a new attribute from an existing one. |
|
Attribute(int elemType,
java.lang.String attrName,
java.lang.Object attrValue)
Constructs a new attribute from a name / value pair. |
Method Summary | |
---|---|
static int |
attributeType(int elemType,
java.lang.String attrName)
Returns the attribute conversion type for the supplied attribute name and element type.. |
void |
clearChanged()
Use to indicate that this object has no longer changed, or that it has already notified all of its observers of its most recent change. |
java.lang.Object |
convertStringValue(int type,
java.lang.String name,
java.lang.String stringValue,
int attrtype)
Convert the supplied string value to the appropriate Object. |
java.lang.String |
convertValue(int type,
java.lang.String name,
java.lang.Object value,
int attrtype)
Convert the supplied value to a string. |
java.lang.Object |
copyValue(int type,
java.lang.String name,
java.lang.Object value,
int attrtype)
Make a copy of the supplied value. |
boolean |
equals(Attribute attr)
Tests for equality with the given attribute. |
boolean |
equalsValue(Attribute attr)
Tests for equality of this attribute's value with the given attribute's value. |
int |
getAttributeType()
Get the attribute value type for this attribute. |
int |
getElementType()
Get the element type for this attribute. |
java.lang.String |
getName()
Get the name of this attribute. |
int |
getNameHash()
Get the hash value for this attributes name. |
java.lang.String |
getStringValue()
Get the value of this attribute converted to a String. |
java.lang.Object |
getValue()
Get the value of this attribute. |
static AttributeHandler |
setAttributeHandler(AttributeHandler newHandler)
Set a custom attribute handler for converting a String value to an Object and vice versa. |
void |
setChanged()
Use to indicate that this object has changed. |
java.lang.Object |
setValue(java.lang.Object attrValue)
Set the value of the attribute. |
java.lang.String |
toString()
Provide a generic string representation of the attribute. |
Methods inherited from class java.util.Observable |
---|
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static AttributeHandler specialHandler
private java.lang.String name
private java.lang.String stringValue
private java.lang.Object value
private int elementType
private int attributeType
private int nameHash
Constructor Detail |
---|
public Attribute(int elemType, java.lang.String attrName, java.lang.Object attrValue)
elemType
- the element type with which the attribute is
or will be associated.attrName
- the name of the attribute.attrValue
- the value of the attribute.GrappaConstants.NODE
,
GrappaConstants.EDGE
,
GrappaConstants.SUBGRAPH
public Attribute(Attribute attr)
attr
- the attribute from which this new one is to be generatedMethod Detail |
---|
public static AttributeHandler setAttributeHandler(AttributeHandler newHandler)
newHandler
- the AttributeHandler to use for conversions
AttributeHandler
public final int getElementType()
GrappaConstants.NODE
,
GrappaConstants.EDGE
,
GrappaConstants.SUBGRAPH
public final int getAttributeType()
public final java.lang.String getName()
public final java.lang.Object getValue()
public final java.lang.String getStringValue()
public final java.lang.Object setValue(java.lang.Object attrValue)
attrValue
- the new attribute value.
public final boolean equals(Attribute attr)
attr
- the attribute with which to compare this attribute.
public final boolean equalsValue(Attribute attr)
attr
- the attribute with which to compare this attribute.
public final int getNameHash()
public final void setChanged()
setChanged
in class java.util.Observable
Observable.setChanged()
public final void clearChanged()
clearChanged
in class java.util.Observable
Observable.clearChanged()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String convertValue(int type, java.lang.String name, java.lang.Object value, int attrtype)
convertValue
in interface AttributeHandler
type
- the element type to which the named attribute appliesname
- the name of the attributevalue
- the object value to be converted to a stringattrtype
- the type of the attribute
public java.lang.Object convertStringValue(int type, java.lang.String name, java.lang.String stringValue, int attrtype)
convertStringValue
in interface AttributeHandler
type
- the element type to which the named attribute appliesname
- the name of the attributevalue
- the string value to be converted to an objectattrtype
- the type of the attribute
public java.lang.Object copyValue(int type, java.lang.String name, java.lang.Object value, int attrtype)
copyValue
in interface AttributeHandler
type
- the element type to which the named attribute appliesname
- the name of the attributevalue
- the attribute value to be copiedattrtype
- the type of the attribute
public static int attributeType(int elemType, java.lang.String attrName)
elemType
- the element typeattrName
- the attribute name
Element.attributeType(java.lang.String)
,
Node.attributeType(java.lang.String)
,
Edge.attributeType(java.lang.String)
,
Subgraph.attributeType(java.lang.String)
,
Graph.attributeType(java.lang.String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |