com.tensegrity.graphics.primitive2D
Class Rect2D

java.lang.Object
  extended bycom.tensegrity.graphics.AbstractPrimitive
      extended bycom.tensegrity.graphics.primitive2D.Rect2D
All Implemented Interfaces:
Attributable, AttributableOnSet, BaseInteractable, Interactable, Primitive

public class Rect2D
extends AbstractPrimitive
implements Interactable

An object of class Rect2D represents a 2-dimensional rectangular shape. The main properties are its location and size.

This class has three constructors to choose from.

Version:
$Id: Rect2D.java,v 1.84 2006/03/21 14:26:11 MichaelKegel Exp $
Author:
MichaelKegel

Field Summary
protected static double[] tmpCoords
          instance variable that is used to transform the coordinates of the rectangle
protected static int[] tmpPtX
          instance variable that is used to transform the coordinates of the rectangle
protected static int[] tmpPtY
          instance variable that is used to transform the coordinates of the rectangle
 
Fields inherited from class com.tensegrity.graphics.AbstractPrimitive
attributableOnSetListener, doAttributableEvents, infovalueregistry, interactionDescriptor, selected
 
Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
TREE_SUBSET_POSTFIX
 
Constructor Summary
Rect2D()
          Constructor that creates an empty Rect2D.
Rect2D(int left, int top, int right, int bottom)
          Constructor that creates a Rect2D with the coordinates given by left, top, right and bottom.
Rect2D(Rect2D rect)
          Copy constructor for Rect2D.
 
Method Summary
protected  void addSpecificAttributes(AttributeFactory factory, AttributeSet attributes)
          Add the specific attributes of a Rect2D to the AttributeSet given by attributes.
 void applyState(PrimitiveState state)
           
 BoundingBox calculateBoundingBox(InteractionInfo interactionInfo)
           
 Primitive deepCopy()
          An implementation of this method is responsible for returning a deep- copy of the Primitive instance
 int getArcHeight()
          Returns the height of the arc of the rounded edges.
 int getArcWidth()
          Returns the width of the arc of the rounded edges.
 Attribute getAttribute(java.lang.String name)
          Returns the attribute with the given name or null if there is no Attribute with the given name.
 AttributeSet getAttributes()
          Returns an AttributeSet consisting of all attributes of this AttributableOnSet.
 AttributeSet getAttributesTree()
          Returns an AttributeSet containing all Attributes of this AttributableOnSet in a treelike structure.
 int getBottom()
          Returns the y-coordinate of the bottom bounding.
 Boundary getBoundingBox()
          Returns the bounding box of the BaseInteractable.
 boolean getEdgesRounded()
          Returns indicates whether rounded edges are enabled for this Rect2D.
 int getHeight()
          Returns the height of the bounding Rect2D.
 Illustrator getIllustrator(Transform2D xform_context)
          Returns the Primitives illustrator object.
 int getLeft()
          Returns the x-coordinate of the left bounding.
 int getRight()
          Returns the x-coordinate of the right bounding.
 PrimitiveState getState()
           
 int getTop()
          Returns the y-coordinate of the top bounding.
 int getWidth()
          Returns the width of the bounding Rect2D.
protected  InteractionDescriptor internalCreateInteractionDescriptor()
          This method should return an InteractionDescriptor that defines the interaction capabilities of a certain Primitive.
 boolean isResizable()
          Returns a boolean that indicates whether the Interactable is resizable or not.
 void set(int left, int top, int right, int bottom)
          Sets the bounds of this Rect2D to the given left, top and right, bottom coordinates.
 void setArcHeight(int arcHeight)
          Sets the height of the arc of the rounded edges.
 void setArcWidth(int arcWidth)
          Sets the width of the arc of the rounded edges.
 void setAttributes(AttributeSet attributes)
          Searches within the AttributeSet given by attributes for attributes that have the same name as the attributes of this AttributableOnSet holds.
 void setAttributesTree(AttributeSet attributes)
          Performs the same operation as the setAttributes(com.tensegrity.generic.attribute.AttributeSet) method with the difference that the AttributeSet given to this method must provide the treelike structure mentioned in the documentation of the getAttributesTree().
 void setAttributeValue(java.lang.String name, java.lang.Object value)
          Sets the value of the attribute with the name to the given value.
 void setBottom(int bottom)
          Sets the y-coordinate of the bottom bounding.
 void setEdgesRounded(boolean roundEdges)
          If the parameter is true, this rectangle will have rounded edges.
 void setHeight(int height)
          Sets the height of this Rect2D to the given height.
 void setLeft(int left)
          Sets the x-coordinate of the left bounding.
 void setResizable(boolean resizable)
          Sets the state of resizability for the Interactable to the value given by resizable.
 void setRight(int right)
          Sets the x-coordinate of the right bounding.
protected  void setSpecificAttributes(AttributeFactory aFac, AttributeSet attributes, AttributeSet attributeschanged_tablelike, AttributeSet attributeschanged_treelike)
          Set the specific attributes of a Rect2D located in the AttributeSet given by attributes to the Rect2D's properties.
 void setStroke(StrokeFormat stroke)
          Sets a StrokeFormat for the Primitive.
 void setTop(int top)
          Sets the y-coordinate of the top bounding.
 void setWidth(int width)
          Sets the width of this Rect2D to the given width.
 java.lang.String toString()
           
 
Methods inherited from class com.tensegrity.graphics.AbstractPrimitive
addAttributableOnSetListener, addInfoValue, addOrSetInfoValue, areAttributableEventsEnabled, disableAttributableEvents, enableAttributableEvents, fireAttributableOnSetChangedEvent, fireAttributableOnSetChangedEvent, getAttributeType, getAttributeValue, getFont, getInfoValue, getInteractionDescriptor, getMoveItem, getPaint, getRenderingData, getStroke, getTransform, hasInfoValue, hits, internalDeepCopyInfoValues, internalEnableSelection, internalSelect, internalSetFont, internalSetPaint, internalSetSelected, internalSetStroke, internalSetStroke, isMovable, isSelectable, isSelected, mouseClick, mouseDown, mouseEnter, mouseExit, mouseUp, postActing, preActing, raiseAttributableEvents, removeAttributableOnSetListener, removeInfoValue, select, setAttribute, setFontFormat, setInfoValue, setMovable, setPaint, setSelectable, setSelected, setTransform, startAction, stopAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.tensegrity.graphics.interaction.BaseInteractable
getInteractionDescriptor, getMoveItem, hits, internalEnableSelection, internalSelect, internalSetSelected, isMovable, isSelectable, isSelected, mouseClick, mouseDown, mouseEnter, mouseExit, mouseUp, postActing, preActing, select, setMovable, setSelectable, setSelected, startAction, stopAction
 

Field Detail

tmpCoords

protected static final double[] tmpCoords
instance variable that is used to transform the coordinates of the rectangle


tmpPtX

protected static final int[] tmpPtX
instance variable that is used to transform the coordinates of the rectangle


tmpPtY

protected static final int[] tmpPtY
instance variable that is used to transform the coordinates of the rectangle

Constructor Detail

Rect2D

public Rect2D()
Constructor that creates an empty Rect2D.


Rect2D

public Rect2D(int left,
              int top,
              int right,
              int bottom)
Constructor that creates a Rect2D with the coordinates given by left, top, right and bottom.

Parameters:
left - the left bounding
top - the top bounding
right - the right bounding
bottom - the bottom bounding

Rect2D

public Rect2D(Rect2D rect)
Copy constructor for Rect2D.

Parameters:
rect - the Rect2D to copy
Method Detail

getLeft

public final int getLeft()
Returns the x-coordinate of the left bounding.

Returns:
the x-coordinate of the left bounding.

setLeft

public final void setLeft(int left)
Sets the x-coordinate of the left bounding.

Parameters:
left - the left-bounding to set.

getTop

public final int getTop()
Returns the y-coordinate of the top bounding.

Returns:
the y-coordinate of the top bounding.

setTop

public final void setTop(int top)
Sets the y-coordinate of the top bounding.

Parameters:
top - the top-bounding to set.

getRight

public final int getRight()
Returns the x-coordinate of the right bounding.

Returns:
the x-coordinate of the right bounding.

setRight

public final void setRight(int right)
Sets the x-coordinate of the right bounding.

Parameters:
right - the right-bounding to set.

getBottom

public final int getBottom()
Returns the y-coordinate of the bottom bounding.

Returns:
the y-coordinate of the bottom bounding.

setBottom

public final void setBottom(int bottom)
Sets the y-coordinate of the bottom bounding.

Parameters:
bottom - the bottom-bounding to set.

getWidth

public final int getWidth()
Returns the width of the bounding Rect2D.

Returns:
the width of the bounding Rect2D.

setWidth

public final void setWidth(int width)
Sets the width of this Rect2D to the given width.

Parameters:
width - the new width for this rectangle.

Find more information in the class documentation


getHeight

public final int getHeight()
Returns the height of the bounding Rect2D.

Returns:
the height of the bounding Rect2D.

setHeight

public final void setHeight(int height)
Sets the height of this Rect2D to the given height.

Parameters:
height - the new height for this rectangle.

Find more information in the class documentation


getArcWidth

public final int getArcWidth()
Returns the width of the arc of the rounded edges.

Returns:
the width of the arc of the rounded edges.

setArcWidth

public final void setArcWidth(int arcWidth)
Sets the width of the arc of the rounded edges. Only visible, if rounded edges are enabled.

Parameters:
arcWidth - the new width of the arc of the rounded edges.
See Also:
setEdgesRounded(boolean)

Find more information in the class documentation


getArcHeight

public final int getArcHeight()
Returns the height of the arc of the rounded edges.

Returns:
the height of the arc of the rounded edges.

setArcHeight

public final void setArcHeight(int arcHeight)
Sets the height of the arc of the rounded edges. Only visible, if rounded edges are enabled.

Parameters:
arcHeight - the new height of the arc of the rounded edges.
See Also:
setEdgesRounded(boolean)

Find more information in the class documentation


setEdgesRounded

public final void setEdgesRounded(boolean roundEdges)
If the parameter is true, this rectangle will have rounded edges.

Parameters:
roundEdges - true for rounded edges.
See Also:
setArcHeight(int), setArcWidth(int)

Find more information in the class documentation


getEdgesRounded

public final boolean getEdgesRounded()
Returns indicates whether rounded edges are enabled for this Rect2D.

Returns:
true, if rounded edges are enabled.

set

public final void set(int left,
                      int top,
                      int right,
                      int bottom)
Sets the bounds of this Rect2D to the given left, top and right, bottom coordinates.

Parameters:
left - the x-coordinate of the left bounding.
top - the y-coordinate of the top bounding.
right - the x-coordinate of the right bounding.
bottom - the y-coordinate of the bottom bounding.

Find more information in the class documentation


setStroke

public void setStroke(StrokeFormat stroke)
Description copied from interface: Primitive
Sets a StrokeFormat for the Primitive.

Specified by:
setStroke in interface Primitive
Parameters:
stroke - the StrokeFormat to use

getBoundingBox

public Boundary getBoundingBox()
Description copied from interface: BaseInteractable
Returns the bounding box of the BaseInteractable.

Specified by:
getBoundingBox in interface BaseInteractable
Returns:
Boundary the bounding box of the BaseInteractable

getState

public PrimitiveState getState()
Specified by:
getState in interface Primitive

applyState

public void applyState(PrimitiveState state)
                throws PrimitiveStateNotApplicableException
Specified by:
applyState in interface Primitive
Throws:
PrimitiveStateNotApplicableException

getIllustrator

public Illustrator getIllustrator(Transform2D xform_context)
Description copied from interface: Primitive
Returns the Primitives illustrator object. To get more informations about the illustrator object see the class above or the documentation of the Illustrator class.

Specified by:
getIllustrator in interface Primitive
Parameters:
xform_context - the transformation of the context the Primitive lies within.
Returns:
Illustrator the illustrator for outputting the Primitive.

deepCopy

public Primitive deepCopy()
Description copied from interface: Primitive
An implementation of this method is responsible for returning a deep- copy of the Primitive instance

Specified by:
deepCopy in interface Primitive
Returns:
a deep copy of the Primitive.

isResizable

public boolean isResizable()
Description copied from interface: Interactable
Returns a boolean that indicates whether the Interactable is resizable or not.

Specified by:
isResizable in interface Interactable
Returns:
boolean that indicates the state of resizability of the Interactable

setResizable

public void setResizable(boolean resizable)
Description copied from interface: Interactable
Sets the state of resizability for the Interactable to the value given by resizable.

Specified by:
setResizable in interface Interactable
Parameters:
resizable - the new state of resizability for the Interactable

calculateBoundingBox

public BoundingBox calculateBoundingBox(InteractionInfo interactionInfo)
Specified by:
calculateBoundingBox in interface Interactable

setAttributeValue

public void setAttributeValue(java.lang.String name,
                              java.lang.Object value)
                       throws IllegalValueException,
                              ConstraintViolationException
Description copied from interface: Attributable
Sets the value of the attribute with the name to the given value.
Notice: If the specific implementor of the Attributable interface doesn't support an Attribute with the name given by name, the attribute given through name and value is not handled nor created by Attributable.

Specified by:
setAttributeValue in interface Attributable
Overrides:
setAttributeValue in class AbstractPrimitive
Throws:
IllegalValueException
ConstraintViolationException

getAttribute

public Attribute getAttribute(java.lang.String name)
Description copied from interface: Attributable
Returns the attribute with the given name or null if there is no Attribute with the given name.

Specified by:
getAttribute in interface Attributable
Overrides:
getAttribute in class AbstractPrimitive

getAttributes

public AttributeSet getAttributes()
Description copied from interface: AttributableOnSet
Returns an AttributeSet consisting of all attributes of this AttributableOnSet.

Specified by:
getAttributes in interface AttributableOnSet
Returns:
AttributeSet an AttributeSet with all attributes.

setAttributes

public void setAttributes(AttributeSet attributes)
Description copied from interface: AttributableOnSet
Searches within the AttributeSet given by attributes for attributes that have the same name as the attributes of this AttributableOnSet holds. The value of every attribute that has the same name is used as the new value for the corresponding attribute of this AttributableOnSet. An Attribute within the given AttributeSet that is not an attribute of the object that implements the AttributableOnSet interface is not handled by nor added to the specific implementor of the AttributableOnSet interface.

Specified by:
setAttributes in interface AttributableOnSet
Parameters:
attributes - the AttributeSet consisting of the attributes whose values to set.

getAttributesTree

public AttributeSet getAttributesTree()
Description copied from interface: AttributableOnSet
Returns an AttributeSet containing all Attributes of this AttributableOnSet in a treelike structure.
Treelike means that each attribute can have a subset that contains subsequent Attributes for an Attribute of this AttributableOnSet.
Since an Attribute can only have one value (in this case an object or the Attributes for an object) the subsequent attributes are plugged into the returned AttributeSet as a new Attribute with the same name and the AttributableOnSet.TREE_SUBSET_POSTFIX.

Specified by:
getAttributesTree in interface AttributableOnSet
Returns:
AttributeSet an AttributeSet with the attributes in a treelike structure

setAttributesTree

public void setAttributesTree(AttributeSet attributes)
Description copied from interface: AttributableOnSet
Performs the same operation as the AttributableOnSet.setAttributes(com.tensegrity.generic.attribute.AttributeSet) method with the difference that the AttributeSet given to this method must provide the treelike structure mentioned in the documentation of the AttributableOnSet.getAttributesTree().

Specified by:
setAttributesTree in interface AttributableOnSet
Parameters:
attributes - the AttributeSet containing the attributes whose values to set.

addSpecificAttributes

protected void addSpecificAttributes(AttributeFactory factory,
                                     AttributeSet attributes)
Add the specific attributes of a Rect2D to the AttributeSet given by attributes.

Parameters:
factory - an instance of AttributeFactory needed to create new a new attribute
attributes - the AttributeSet to add the attributes to

setSpecificAttributes

protected void setSpecificAttributes(AttributeFactory aFac,
                                     AttributeSet attributes,
                                     AttributeSet attributeschanged_tablelike,
                                     AttributeSet attributeschanged_treelike)
Set the specific attributes of a Rect2D located in the AttributeSet given by attributes to the Rect2D's properties.

Parameters:
attributes - the AttributeSet that contains the attributes to set

internalCreateInteractionDescriptor

protected InteractionDescriptor internalCreateInteractionDescriptor()
Description copied from class: AbstractPrimitive
This method should return an InteractionDescriptor that defines the interaction capabilities of a certain Primitive. Since the InteractionDescriptor varies for different kinds of primitives this method is declared as abstract and must be implemented for each Primitive that is based on the AbstractPrimitive class.
NOTICE: The return value must not be null.

Specified by:
internalCreateInteractionDescriptor in class AbstractPrimitive
Returns:
InteractionDescriptor the InteractionDescriptor for the certain Primitive instance

toString

public java.lang.String toString()


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