att.grappa
Class Attribute

java.lang.Object
  extended by att.grappa.Attribute
All Implemented Interfaces:
AttributeHandler, GrappaConstants

public final class Attribute
extends java.lang.Object
implements AttributeHandler, GrappaConstants

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_TYPEatt.grappa.GrappaBox
COLOR_TYPEjava.awt.Color
DIR_TYPEjava.lang.Integer (restricted)
DOUBLE_TYPEjava.lang.Double
FONTSTYLE_TYPEjava.lang.Integer (restricted)
HASHLIST_TYPEjava.lang.Hashtable
INTEGER_TYPEjava.lang.Integer
LINE_TYPEatt.grappa.GrappaLine
POINT_TYPEatt.grappa.GrappaPoint
SHAPE_TYPEjava.lang.Integer (restricted)
SIZE_TYPEatt.grappa.GrappaSize
STRING_TYPEjava.lang.String (default)
STYLE_TYPEatt.grappa.GrappaStyle

Version:
1.2, ; Copyright 1996 - 2010 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs
See Also:
AttributeHandler, Element.setUserAttributeType(java.lang.String, int)

Field Summary
 
Fields inherited from interface att.grappa.GrappaConstants
_NO_TYPE, ANONYMOUS_PREFIX, BBOX_ATTR, BBOX_HASH, BOX_SHAPE, BOX_TYPE, CLUSTERRANK_ATTR, COLOR_ATTR, COLOR_HASH, COLOR_TYPE, CUSTOM_ATTR, CUSTOM_HASH, CUSTOM_SHAPE, DELETION_MASK, DIAMOND_SHAPE, DIR_ATTR, DIR_HASH, DIR_TYPE, DISTORTION_ATTR, DISTORTION_HASH, DOUBLE_TYPE, DOUBLECIRCLE_SHAPE, DOUBLEOCTAGON_SHAPE, EDGE, EGG_SHAPE, FILLCOLOR_ATTR, FILLCOLOR_HASH, FONTCOLOR_ATTR, FONTCOLOR_HASH, FONTNAME_ATTR, FONTNAME_HASH, FONTSIZE_ATTR, FONTSIZE_HASH, FONTSTYLE_ATTR, FONTSTYLE_HASH, FONTSTYLE_TYPE, GRAPPA_BACKGROUND_COLOR_ATTR, GRAPPA_BACKGROUND_COLOR_HASH, GRAPPA_DELETION_STYLE_ATTR, GRAPPA_DELETION_STYLE_HASH, GRAPPA_FONTSIZE_ADJUSTMENT_ATTR, GRAPPA_FONTSIZE_ADJUSTMENT_HASH, GRAPPA_SELECTION_STYLE_ATTR, GRAPPA_SELECTION_STYLE_HASH, GRAPPA_SHAPE, HASHMAP_TYPE, HEADLABEL_ATTR, HEADLABEL_HASH, HEADLP_ATTR, HEADLP_HASH, HEIGHT_ATTR, HEIGHT_HASH, HEXAGON_SHAPE, HIGHLIGHT_MASK, HIGHLIGHT_OFF, HIGHLIGHT_ON, HIGHLIGHT_TOGGLE, HOUSE_SHAPE, IDENTXFRM, IMAGE_ATTR, IMAGE_HASH, INTEGER_TYPE, INVERTEDHOUSE_SHAPE, INVERTEDTRAPEZIUM_SHAPE, INVERTEDTRIANGLE_SHAPE, LABEL_ATTR, LABEL_HASH, LINE_SHAPE, LINE_TYPE, LOG10, LP_ATTR, LP_HASH, MARGIN_ATTR, MARGIN_HASH, MCIRCLE_SHAPE, MCLIMIT_ATTR, MCLIMIT_HASH, MDIAMOND_SHAPE, MINBOX_ATTR, MINBOX_HASH, MINLEN_ATTR, MINLEN_HASH, MINSIZE_ATTR, MINSIZE_HASH, MRECORD_SHAPE, MSQUARE_SHAPE, NBSP, NEW_LINE, NO_SHAPE, NODE, NODESEP_ATTR, NODESEP_HASH, OCTAGON_SHAPE, ORIENTATION_ATTR, ORIENTATION_HASH, OVAL_SHAPE, PACKAGE_PREFIX, PARALLELOGRAM_SHAPE, PATCH_ATTR, PATCH_HASH, PENTAGON_SHAPE, PERIPHERIES_ATTR, PERIPHERIES_HASH, PERIPHERY_GAP, PKG_LOWER, PKG_UPLOW, PKG_UPPER, PLAINTEXT_SHAPE, POINT_SHAPE, POINT_TYPE, PointsPerInch, POLYGON_SHAPE, POS_ATTR, POS_HASH, PRINTLIST_ATTR, PRINTLIST_HASH, RANKDIR_ATTR, RANKDIR_HASH, RANKSEP_ATTR, RANKSEP_HASH, RECORD_SHAPE, RECTS_ATTR, RECTS_HASH, ROTATION_ATTR, ROTATION_HASH, ROUNDEDBOX_SHAPE, SELECTION_MASK, SHAPE_ATTR, SHAPE_HASH, SHAPE_MASK, SHAPE_TYPE, SIDES_ATTR, SIDES_HASH, SIZE_ATTR, SIZE_HASH, SIZE_TYPE, SKEW_ATTR, SKEW_HASH, STRING_TYPE, STYLE_ATTR, STYLE_HASH, STYLE_TYPE, SUBGRAPH, SYSTEM, TAG_ATTR, TAG_HASH, TAILLABEL_ATTR, TAILLABEL_HASH, TAILLP_ATTR, TAILLP_HASH, TIP_ATTR, TIP_HASH, TRAPEZIUM_SHAPE, TRIANGLE_SHAPE, TRIPLEOCTAGON_SHAPE, TYPES_SHIFT, WEIGHT_ATTR, WEIGHT_HASH, WIDTH_ATTR, WIDTH_HASH
 
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
 void addListener(IGrappaObjectListener listener)
           
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.
 boolean hasChanged()
           
 void notifyListeners(java.lang.Object args)
           
 void removeListener(IGrappaObjectListener listener)
           
 void removeListeners()
           
static AttributeHandler setAttributeHandler(AttributeHandler newHandler)
          Set a custom attribute handler for converting a String value to an Object and vice versa.
 void setChanged()
           
 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.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(int elemType,
                 java.lang.String attrName,
                 java.lang.Object attrValue)
Constructs a new attribute from a name / value pair.

Parameters:
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.
See Also:
GrappaConstants.NODE, GrappaConstants.EDGE, GrappaConstants.SUBGRAPH

Attribute

public Attribute(Attribute attr)
Constructs a new attribute from an existing one.

Parameters:
attr - the attribute from which this new one is to be generated
Method Detail

setAttributeHandler

public static AttributeHandler setAttributeHandler(AttributeHandler newHandler)
Set a custom attribute handler for converting a String value to an Object and vice versa.

Parameters:
newHandler - the AttributeHandler to use for conversions
Returns:
the previously set AttributeHandler or null
See Also:
AttributeHandler

addListener

public void addListener(IGrappaObjectListener listener)

removeListener

public void removeListener(IGrappaObjectListener listener)

removeListeners

public void removeListeners()

notifyListeners

public void notifyListeners(java.lang.Object args)

getElementType

public final int getElementType()
Get the element type for this attribute.

Returns:
the element type for this attribute
See Also:
GrappaConstants.NODE, GrappaConstants.EDGE, GrappaConstants.SUBGRAPH

getAttributeType

public final int getAttributeType()
Get the attribute value type for this attribute.

Returns:
the attribute value type for this attribute.

getName

public final java.lang.String getName()
Get the name of this attribute.

Returns:
the name of this attribute.

getValue

public final java.lang.Object getValue()
Get the value of this attribute.

Returns:
the value of the attribute.

getStringValue

public final java.lang.String getStringValue()
Get the value of this attribute converted to a String.

Returns:
the value of the attribute as a String.

setValue

public final java.lang.Object setValue(java.lang.Object attrValue)
Set the value of the attribute. If the value is different than the current value, the Observable changed indicator is set.

Parameters:
attrValue - the new attribute value.
Returns:
the old attribute value.

equals

public final boolean equals(Attribute attr)
Tests for equality with the given attribute.

Parameters:
attr - the attribute with which to compare this attribute.
Returns:
true if the two attributes are equal, false otherwise.

equalsValue

public final boolean equalsValue(Attribute attr)
Tests for equality of this attribute's value with the given attribute's value. The attribute names are not compated.

Parameters:
attr - the attribute with which to compare this attribute.
Returns:
true if the two attribute values are equal, false otherwise.

getNameHash

public final int getNameHash()
Get the hash value for this attributes name.

Returns:
the hash code for the name portion of this attribute

setChanged

public final void setChanged()

hasChanged

public boolean hasChanged()

clearChanged

public final 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. This method is a convenience method that calls the corresponding protected method of the Observable class.

See Also:
Observable.clearChanged()

toString

public java.lang.String toString()
Provide a generic string representation of the attribute.

Overrides:
toString in class java.lang.Object

convertValue

public java.lang.String convertValue(int type,
                                     java.lang.String name,
                                     java.lang.Object value,
                                     int attrtype)
Convert the supplied value to a string. How to convert the value is based on the type, name and attrtype information supplied. Note: this method really could be declared static except that it hides the instance method declared in the AttributeHandler interface and a class method cannot hide an instance method.

Specified by:
convertValue in interface AttributeHandler
Parameters:
type - the element type to which the named attribute applies
name - the name of the attribute
value - the object value to be converted to a string
attrtype - the type of the attribute
Returns:
a string representation of the supplied value

convertStringValue

public 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. How to convert the value is based on the type, name and attrtype information supplied. Note: this method really could be declared static except that it hides the instance method declared in the AttributeHandler interface and a class method cannot hide an instance method.

Specified by:
convertStringValue in interface AttributeHandler
Parameters:
type - the element type to which the named attribute applies
name - the name of the attribute
value - the string value to be converted to an object
attrtype - the type of the attribute
Returns:
an object representation of the supplied value

copyValue

public java.lang.Object copyValue(int type,
                                  java.lang.String name,
                                  java.lang.Object value,
                                  int attrtype)
Make a copy of the supplied value. How to copy the value is based on the type, name and attrtype information supplied. Note: this method really could be declared static except that it hides the instance method declared in the AttributeHandler interface and a class method cannot hide an instance method.

Specified by:
copyValue in interface AttributeHandler
Parameters:
type - the element type to which the named attribute applies
name - the name of the attribute
value - the attribute value to be copied
attrtype - the type of the attribute
Returns:
a copy of the supplied value

attributeType

public static int attributeType(int elemType,
                                java.lang.String attrName)
Returns the attribute conversion type for the supplied attribute name and element type..

Parameters:
elemType - the element type
attrName - the attribute name
Returns:
the currently associated attribute type
See Also:
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)


Grappa 1.2