Graphics2D Actor API

g2d.glyph
Class Attributable

java.lang.Object
  extended by g2d.glyph.Identifiable
      extended by g2d.glyph.Attributable
Direct Known Subclasses:
ClosureAction, ClosureActionListener, ClosureComponentListener, ClosureItemListener, ClosureMouseListener, ClosureMouseMotionListener, ClosureWindowListener, Glyphish

public class Attributable
extends Identifiable

Those things that have Attributes. Attributes are indexed by a String as a key. They contain an Object as the value.

One can set attributes for each object instance or using static attributes that apply to all things Attributable.

Since:
July 11th, 2004
Author:
Ian A. Mason, Linda (get keys and javadoc)

Field Summary
 
Fields inherited from class g2d.glyph.Identifiable
DEBUG, uid
 
Constructor Summary
Attributable()
           
 
Method Summary
 Object getAttribute(String key)
          Get value of given attribute.
 boolean getAttributeAsBoolean(String key, boolean defaultValue)
           
 byte getAttributeAsByte(String key, byte defaultValue)
           
 char getAttributeAsChar(String key, char defaultValue)
           
 double getAttributeAsDouble(String key, double defaultValue)
           
 float getAttributeAsFloat(String key, float defaultValue)
           
 int getAttributeAsInt(String key, int defaultValue)
           
 short getAttributeAsShort(String key, short defaultValue)
           
 String getAttributeAsString(String key, String defaultValue)
           
 String[] getKeys()
          Obtain all keys of currently set attributes as an array.
 Object getStaticAttribute(String key)
          Get value of given static attribute.
 String[] getStaticKeys()
          Obtain all keys of currently set static attributes as an array.
 boolean isAttribute(String key)
          Test whether given key is a valid attribute.
 boolean isStaticAttribute(String key)
          Test whether given key is a valid static attribute.
 void setAttribute(String key, Object value)
          Set an attribute using the given parameters.
 void setStaticAttribute(String key, Object value)
          Set a static attribute using the given parameters.
 
Methods inherited from class g2d.glyph.Identifiable
getObject, getUID, setUID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attributable

public Attributable()
Method Detail

setAttribute

public void setAttribute(String key,
                         Object value)
Set an attribute using the given parameters.

Parameters:
key - String of key to identify attribute
value - Object that is value of this attribute

isAttribute

public boolean isAttribute(String key)
Test whether given key is a valid attribute. Note, if attribute with given key was set using null as a value, this will still result in true.

Parameters:
key - String of key to test attribute existence
Returns:
true if attribute with given key has been assigned before, false otherwise
See Also:
setAttribute(java.lang.String, java.lang.Object)

getAttribute

public Object getAttribute(String key)
Get value of given attribute. May return null if attribute does not exist.

Parameters:
key - String of key to obtain attribute
Returns:
Object that is value of given attribute (or null if attribute key does not exist)

getKeys

public String[] getKeys()
Obtain all keys of currently set attributes as an array.

Returns:
String[] of currently known keys of attributes

setStaticAttribute

public void setStaticAttribute(String key,
                               Object value)
Set a static attribute using the given parameters.

Parameters:
key - String of key to identify static attribute
value - Object that is value of this static attribute

isStaticAttribute

public boolean isStaticAttribute(String key)
Test whether given key is a valid static attribute. Note, if static attribute with given key was set using null as a value, this will still result in true.

Parameters:
key - String of key to test static attribute existence
Returns:
true if static attribute with given key has been assigned before, false otherwise
See Also:
setStaticAttribute(java.lang.String, java.lang.Object)

getStaticAttribute

public Object getStaticAttribute(String key)
Get value of given static attribute. May return null if static attribute does not exist.

Parameters:
key - String of key to obtain static attribute
Returns:
Object that is value of given static attribute (or null if attribute key does not exist)

getStaticKeys

public String[] getStaticKeys()
Obtain all keys of currently set static attributes as an array.

Returns:
String[] of currently known keys of static attributes

getAttributeAsByte

public byte getAttributeAsByte(String key,
                               byte defaultValue)

getAttributeAsBoolean

public boolean getAttributeAsBoolean(String key,
                                     boolean defaultValue)

getAttributeAsChar

public char getAttributeAsChar(String key,
                               char defaultValue)

getAttributeAsDouble

public double getAttributeAsDouble(String key,
                                   double defaultValue)

getAttributeAsFloat

public float getAttributeAsFloat(String key,
                                 float defaultValue)

getAttributeAsInt

public int getAttributeAsInt(String key,
                             int defaultValue)

getAttributeAsShort

public short getAttributeAsShort(String key,
                                 short defaultValue)

getAttributeAsString

public String getAttributeAsString(String key,
                                   String defaultValue)

Graphics2D Actor API