ubc.cs.JLog.Animation
Class aAnimationShape

java.lang.Object
  extended by ubc.cs.JLog.Animation.aAttributeTranslation
      extended by ubc.cs.JLog.Animation.aAnimationShape
All Implemented Interfaces:
iAttributes
Direct Known Subclasses:
aAnimationShape_image, aAnimationShape_line, aAnimationShape_polygon, aAnimationShape_text

public abstract class aAnimationShape
extends aAttributeTranslation

This abstract class represents a simple graphical shape. A shape belongs to an AnimationObject, and the position and rotation of this shape is given as offset from position and rotation of the enclosing object.

Author:
Glendon Holst

Field Summary
protected  java.lang.String name
           
static java.lang.String NAME_ATTR_KEY
           
protected  aAnimationObject object
           
static java.lang.String OBJECT_ATTR_KEY
           
static java.lang.String ROTATION_ATTR_KEY
           
protected  float rotation_offset
           
static java.lang.String TYPE_ATTR_KEY
           
static java.lang.String X_ATTR_KEY
           
protected  float x_offset
           
static java.lang.String Y_ATTR_KEY
           
protected  float y_offset
           
 
Constructor Summary
aAnimationShape(aAnimationObject ao, java.lang.String n)
          The constructor.
 
Method Summary
abstract  void draw(java.awt.Graphics g)
          Draw the shape in the Graphics environment provided.
 java.util.Hashtable getAttributes()
          Returns a hashtable of every attribute associated with this object.
abstract  java.awt.Rectangle getBounds()
          Returns the bounding rectangle for this shape, given in global coordinates.
 aAnimationObject getEnclosingObject()
          Returns the parent, enclosing object.
 java.lang.String getName()
           
 jTermTranslation getTermTranslation()
          Get the current translation unit for this object.
abstract  java.lang.String getType()
          Sub-classes should return their type value (i.e., the value used to specify the shape type to create in the animation<addshape> predicate command).
 void setAttributes(java.util.Hashtable attributes)
          Set the attributes of the object to those in the given Hashtable.
static void setDefaultsForTranslation(jTermTranslation t)
           
 void setLocalPosition(float x, float y)
          Set the new location of the shape to the given offset values.
 void setLocalRotation(float r)
          Set the object relative rotation of the shape to the given angle in radians.
 void setName(java.lang.String n)
           
 void updateMagnification()
          Update notification.
 void updatePosition()
          Update notification.
 void updateRotation()
          Update notification.
 
Methods inherited from class ubc.cs.JLog.Animation.aAttributeTranslation
convertFromColor, convertFromFont, convertFromPolygon, convertFromRectangle, convertToAnimationObject, convertToAnimationShape, convertToAttributesObject, convertToBoolean, convertToColor, convertToFloat, convertToFont, convertToInt, convertToList, convertToPolygon, convertToRectangle, convertToString, convertToTerms, convertToTerms, setObjectDefaults, setStringKeysForTranslation, setTermDefaults
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_ATTR_KEY

public static final java.lang.String X_ATTR_KEY
See Also:
Constant Field Values

Y_ATTR_KEY

public static final java.lang.String Y_ATTR_KEY
See Also:
Constant Field Values

ROTATION_ATTR_KEY

public static final java.lang.String ROTATION_ATTR_KEY
See Also:
Constant Field Values

TYPE_ATTR_KEY

public static final java.lang.String TYPE_ATTR_KEY
See Also:
Constant Field Values

NAME_ATTR_KEY

public static final java.lang.String NAME_ATTR_KEY
See Also:
Constant Field Values

OBJECT_ATTR_KEY

public static final java.lang.String OBJECT_ATTR_KEY
See Also:
Constant Field Values

object

protected aAnimationObject object

name

protected java.lang.String name

x_offset

protected float x_offset

y_offset

protected float y_offset

rotation_offset

protected float rotation_offset
Constructor Detail

aAnimationShape

public aAnimationShape(aAnimationObject ao,
                       java.lang.String n)
The constructor. Requires the owning aAnimationObject, and a name.

Parameters:
ao - The graphical object composed from this shape. Animation shapes can only belong to one object.
n - The name of the shape.
Method Detail

draw

public abstract void draw(java.awt.Graphics g)
Draw the shape in the Graphics environment provided.

Parameters:
g - The Graphics environment to draw into.

getName

public java.lang.String getName()

setName

public void setName(java.lang.String n)

getType

public abstract java.lang.String getType()
Sub-classes should return their type value (i.e., the value used to specify the shape type to create in the animation<addshape> predicate command).

Returns:
The type string for the class.

getEnclosingObject

public aAnimationObject getEnclosingObject()
Returns the parent, enclosing object.

Returns:
The aAnimationObject containing this shape.

getBounds

public abstract java.awt.Rectangle getBounds()
Returns the bounding rectangle for this shape, given in global coordinates.

Returns:
The Rectangle bounding this shape.

setLocalPosition

public void setLocalPosition(float x,
                             float y)
Set the new location of the shape to the given offset values.

Parameters:
x - The new x position component, relative to enclosing object.
y - The new y position component, relative to enclosing object.

setLocalRotation

public void setLocalRotation(float r)
Set the object relative rotation of the shape to the given angle in radians.

Parameters:
r - The new angle of the shape in radians.

setDefaultsForTranslation

public static void setDefaultsForTranslation(jTermTranslation t)

getTermTranslation

public jTermTranslation getTermTranslation()
Description copied from class: aAttributeTranslation
Get the current translation unit for this object. Usually, it will get a translation unit for the class. The returned unit should not be modified (since it belongs to the class).

Overrides:
getTermTranslation in class aAttributeTranslation
Returns:
The jTermTranslation translation unit.

getAttributes

public java.util.Hashtable getAttributes()
Description copied from interface: iAttributes
Returns a hashtable of every attribute associated with this object. Each attribute must have a String name key, and its associated value (non-null).

Returns:
The Hashtable of attribute name-value pairings.

setAttributes

public void setAttributes(java.util.Hashtable attributes)
Description copied from interface: iAttributes
Set the attributes of the object to those in the given Hashtable. Errors such as Non-applicable attributes, or invalid values can be handled as the receiving object prefers (e.g., silently ignore, or throw exception).

Parameters:
attributes - The Hashtable of attribute name-value pairings.

updatePosition

public void updatePosition()
Update notification. The enclosing object position has changed.


updateRotation

public void updateRotation()
Update notification. The enclosing object rotation has changed.


updateMagnification

public void updateMagnification()
Update notification. The environment magnification value changed.