|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.graphics.AbstractPrimitive
The AbstractPrimitive class contains the shared, reusable
code needed by all of our Primitive implementations. By
deriving from this abstract base class, concrete Primitive
classes are much easier to write and maintain.
It is not possible for the AbstractPrimitive class to
implement all methods defined in the Primitive interface
for the obvious reason that some methods require specialized behavior.
You will not create instances of this abstract class but an instance of derived class.
| Field Summary | |
protected AttributableOnSetListener |
attributableOnSetListener
instance variable that holds the AttributableOnSetListeners
currently registered at the Primitive. |
protected boolean |
doAttributableEvents
instance variable that indicates whether the registered AttributableOnSetListeners should be notified on changes or
not |
protected java.util.HashMap |
infovalueregistry
|
protected InteractionDescriptor |
interactionDescriptor
instance variable for the InteractionDescriptor of this
Primitve |
protected boolean |
selected
instance variable that indicats whether this Primitve
is currently selected or not |
| Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet |
TREE_SUBSET_POSTFIX |
| Constructor Summary | |
AbstractPrimitive()
Default constructor necessary for deserialization. |
|
AbstractPrimitive(boolean hasStroke,
boolean hasPaint,
boolean hasFont)
Constructor specifying whether this Primitve has a default Stroke-, Paint- and FontFormat. |
|
| Method Summary | |
void |
addAttributableOnSetListener(AttributableOnSetListener attributableOnSetListener)
Adds a listener to the attributable on set instance. |
void |
addInfoValue(java.lang.Object key,
java.lang.Object value)
Adds the infovalue given by value with the given
key to the infovalue registry of the Primitive.
|
void |
addOrSetInfoValue(java.lang.Object key,
java.lang.Object value)
Adds the infovalue given by value with the given
key to the infovalue registry of the Primitive.
|
boolean |
areAttributableEventsEnabled()
Returns a boolean that indicates whether generating of
events is enabled or not. |
void |
disableAttributableEvents()
Disables events for the registered listeners. |
void |
enableAttributableEvents()
Enables the transmission of events to registered listeners. |
protected void |
fireAttributableOnSetChangedEvent(AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike)
Fires the attributableonset has changed event internally in order to notify all registered listener that one or many of the attribute of the Primitive instance has/have been changed. |
protected void |
fireAttributableOnSetChangedEvent(AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike,
java.util.Map attribute2oldvalue_tablelike,
java.util.Map attribute2oldvalue_treelike)
Fires the attributableonset has changed event internally in order to notify all registered listener that one or many of the attribute of the Primitive instance has/have been changed.
|
Attribute |
getAttribute(java.lang.String name)
Returns the attribute with the given name or null if there
is no Attribute with the given name. |
AttributeType |
getAttributeType(java.lang.String name)
Returns the AttributeType of the attribute with the given
name. |
java.lang.Object |
getAttributeValue(java.lang.String name)
Return the value of the attribute with the given name. |
FontFormat |
getFont()
Returns the FontFormat that is used by this
Primitive to draw text.
|
java.lang.Object |
getInfoValue(java.lang.Object key)
Returns the infovalue that is stored with the given key
in the infovalue registry of the Primitive. |
InteractionDescriptor |
getInteractionDescriptor()
This method returns the InteractionDescriptor for the
BaseInteractable. |
InteractionItem |
getMoveItem()
Returns the InteractionItem that is used to move the
BaseInteractable. |
PaintFormat |
getPaint()
Returns the PaintFormat that is used by the
Primitive to fill areas.
|
RenderingData |
getRenderingData(Transform2D xform_context)
Returns a RenderingData instance, which are used by a
Renderer implementation to render a Primitive.
|
StrokeFormat |
getStroke()
Returns the StrokeFormat that is used by the
Primitive to draw lines, borders and such.
|
Transform2D |
getTransform()
Returns a Transform2D currently used to transform
the coordinates of the graphical Primitive. |
boolean |
hasInfoValue(java.lang.Object key)
Returns a boolean that indicates whether an infovalue with
the key given by key is already registered or not. |
InteractionItem |
hits(InteractionInfo interactionInfo)
This method is called to check if the given point hits the BaseInteractable object. |
protected abstract InteractionDescriptor |
internalCreateInteractionDescriptor()
This method should return an InteractionDescriptor that
defines the interaction capabilities of a certain Primitive.
|
protected void |
internalDeepCopyInfoValues(java.util.HashMap infovalueregistry)
Deep copies the info values stored in the info-value-registry given by infovalueregistry into the info-value-registry of this
Primitive. |
void |
internalEnableSelection(boolean enabled)
Sets the internal state of selectability for this BaseInteractable instance to the value given by
enabled.
|
InteractionItem |
internalSelect(InteractionInfo interactionInfo)
This method is called by the InteractionContext to select
the BaseInteractable. |
protected boolean |
internalSetFont(FontFormat font,
AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike)
|
protected void |
internalSetPaint(PaintFormat paint,
AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike)
|
void |
internalSetSelected(boolean select)
Sets the state of selection for this BaseInteractable to the
value given by select. |
protected void |
internalSetStroke(StrokeFormat stroke,
java.lang.String attributename)
|
protected void |
internalSetStroke(StrokeFormat stroke,
java.lang.String attributename,
AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike)
|
boolean |
isMovable()
Returns a boolean that indicates whether this
BaseInteractable is movable or not. |
boolean |
isSelectable()
Returns a boolean |
boolean |
isSelected()
Returns a boolean |
void |
mouseClick(InteractionInfo interactionInfo)
This method is called when a mouse button click has been occured upon the BaseInteractable. |
void |
mouseDown(InteractionInfo interactionInfo)
This method is called when a mouse button has been pressed upon the BaseInteractable. |
void |
mouseEnter(InteractionInfo interactionInfo)
This method is called when the mouse cursor has entered the BaseInteractable bounding box. |
void |
mouseExit(InteractionInfo interactionInfo)
This method is called when the mouse cursor has exited the BaseInteractable bounding box. |
void |
mouseUp(InteractionInfo interactionInfo)
This method is called when a mouse button has been released upon the BaseInteractable. |
void |
postActing(InteractionInfo interactionInfo,
int itemspecifier)
This method is called by the InteractionContext while the
interaction takes place. |
boolean |
preActing(InteractionInfo interactionInfo,
int itemspecifier)
This method is called by the InteractionContext while the
interaction takes place. |
protected boolean |
raiseAttributableEvents()
|
void |
removeAttributableOnSetListener(AttributableOnSetListener attributableOnSetListener)
Removes a listener from the attributable on set instance. |
void |
removeInfoValue(java.lang.Object key)
Removes the infovalue that is stored with the given key
in the infovalue registry of the Primitive from the
infovalue registry. |
InteractionItem |
select(InteractionInfo interactionInfo)
This method is called by the InteractionContext to select
the BaseInteractable. |
void |
setAttribute(Attribute attribute)
Sets the value of the attribute with the same name to the value of the given attribute. |
void |
setAttributeValue(java.lang.String name,
java.lang.Object value)
Sets the value of the attribute with the name to the given value. |
void |
setFontFormat(FontFormat font)
Sets the FontFormat for the Primitive. |
void |
setInfoValue(java.lang.Object key,
java.lang.Object newValue)
Sets the value of the infovalue with the key given by key to
the value given by newValue.
|
void |
setMovable(boolean movable)
Sets the state of movability for this BaseInteractable to the
value given by movable. |
void |
setPaint(PaintFormat paint)
Sets the PaintFormat for the Primitive. |
void |
setSelectable(boolean allowSelection)
Sets the state of selectability for this BaseInteractable to the
value given by selectable. |
void |
setSelected(boolean selected)
Sets the state of selection for this BaseInteractable to the
value given by selected. |
void |
setTransform(Transform2D transform)
Sets the Transform2D given by transform as the
new transform for the coordinates of the Primitive. |
boolean |
startAction(InteractionInfo interactionInfo,
int itemspecifier)
This method is called by the InteractionContext before the
interaction takes place. |
void |
stopAction(InteractionInfo interactionInfo,
int itemspecifier)
This method is called by the InteractionContext after the
interaction has taken place. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.tensegrity.graphics.Primitive |
applyState, deepCopy, getBoundingBox, getIllustrator, getState, setStroke |
| Methods inherited from interface com.tensegrity.generic.attribute.AttributableOnSet |
getAttributes, getAttributesTree, setAttributes, setAttributesTree |
| Field Detail |
protected boolean selected
Primitve
is currently selected or not
protected InteractionDescriptor interactionDescriptor
InteractionDescriptor of this
Primitve
protected AttributableOnSetListener attributableOnSetListener
AttributableOnSetListeners
currently registered at the Primitive.
protected boolean doAttributableEvents
AttributableOnSetListeners should be notified on changes or
not
protected java.util.HashMap infovalueregistry
| Constructor Detail |
public AbstractPrimitive()
public AbstractPrimitive(boolean hasStroke,
boolean hasPaint,
boolean hasFont)
Stroke-, Paint- and FontFormat.
hasStroke - true, if this Primitve should have a
default StrokeFormat.hasPaint - true, if this Primitve should have a
default PaintFormat.hasFont - true, if this Primitve should have a
default FontFormat.| Method Detail |
public StrokeFormat getStroke()
PrimitiveStrokeFormat that is used by the
Primitive to draw lines, borders and such.
The returned StrokeFormat can be null for
Primitives that have no lines, borders or such.
getStroke in interface Primitive
protected final void internalSetStroke(StrokeFormat stroke,
java.lang.String attributename)
protected final void internalSetStroke(StrokeFormat stroke,
java.lang.String attributename,
AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike)
public PaintFormat getPaint()
PrimitivePaintFormat that is used by the
Primitive to fill areas.
The returned PaintFormat can be null for
Primitives that have no areas.
getPaint in interface Primitivepublic void setPaint(PaintFormat paint)
PrimitivePaintFormat for the Primitive.
setPaint in interface Primitivepaint - the PaintFormat to use
protected final void internalSetPaint(PaintFormat paint,
AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike)
public FontFormat getFont()
PrimitiveFontFormat that is used by this
Primitive to draw text.
The returned FontFormat can be null for
Primitives that have no text.
getFont in interface Primitivepublic void setFontFormat(FontFormat font)
PrimitiveFontFormat for the Primitive.
setFontFormat in interface Primitivefont - the FontFormat to use
protected final boolean internalSetFont(FontFormat font,
AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike)
public final Transform2D getTransform()
PrimitiveTransform2D currently used to transform
the coordinates of the graphical Primitive.
getTransform in interface PrimitivePrimitivepublic void setTransform(Transform2D transform)
PrimitiveTransform2D given by transform as the
new transform for the coordinates of the Primitive.
setTransform in interface Primitivetransform - the new transform of the Primitive, may not
be null.public boolean hasInfoValue(java.lang.Object key)
Primitiveboolean that indicates whether an infovalue with
the key given by key is already registered or not.
hasInfoValue in interface Primitivekey - the key to check for
public void addInfoValue(java.lang.Object key,
java.lang.Object value)
Primitive
Adds the infovalue given by value with the given
key to the infovalue registry of the Primitive.
If there is already an infovalue registered with the given
key an InvalidArgumentException is thrown.
addInfoValue in interface Primitivekey - the key to store the infovalue withvalue - the infovalue to storepublic void removeInfoValue(java.lang.Object key)
Primitivekey
in the infovalue registry of the Primitive from the
infovalue registry.
removeInfoValue in interface Primitivekey - the key of the infovalue to removepublic java.lang.Object getInfoValue(java.lang.Object key)
Primitivekey
in the infovalue registry of the Primitive. If there is
no infovalue stored for the given key the methods returns
null
getInfoValue in interface Primitivekey - the key to return the infovalue for
key or
null if there is none
public void setInfoValue(java.lang.Object key,
java.lang.Object newValue)
Primitive
Sets the value of the infovalue with the key given by key to
the value given by newValue.
If there is no infovalue registered with the given key an
InvalidArgumentException is thrown.
setInfoValue in interface Primitivekey - the key of the infovalue to set a new value fornewValue - the new value for the infovalue
public void addOrSetInfoValue(java.lang.Object key,
java.lang.Object value)
Primitive
Adds the infovalue given by value with the given
key to the infovalue registry of the Primitive.
If there is already an infovalue registered with the given
key the value given by value is set as the
new value of the infovalue.
addOrSetInfoValue in interface Primitivekey - the key to store the infovalue withvalue - the infovalue to store or setpublic RenderingData getRenderingData(Transform2D xform_context)
PrimitiveRenderingData instance, which are used by a
Renderer implementation to render a Primitive.
RenderingData object see
the class documentation above or the documentation of the
RenderingData class.
Renderer technique see the
class documentation above or the documentation of the
Renderer class.
getRenderingData in interface Primitivexform_context - the transformation of the context the
Primitive lies within. May not be null.
RenderingData instancepublic boolean isSelectable()
BaseInteractableboolean that indicates whether is it allowed to
select the BaseInteractable or not.
- Specified by:
isSelectable in interface BaseInteractable
- Returns:
- boolean that indicates the state of selectability for the
BaseInteractable
public void setSelectable(boolean allowSelection)
BaseInteractableBaseInteractable to the
value given by selectable.
setSelectable in interface BaseInteractableallowSelection - the new state of selectability for the
BaseInteractablepublic void internalEnableSelection(boolean enabled)
BaseInteractableBaseInteractable instance to the value given by
enabled.
internalEnableSelection in interface BaseInteractableenabled - the new state of internal selectability for the
BaseInteractable instancepublic boolean isSelected()
BaseInteractableboolean that indicates whether this
BaseInteractable is selected or not.
- Specified by:
isSelected in interface BaseInteractable
- Returns:
- boolean that indicates the state of selection for this
BaseInteractable
public void setSelected(boolean selected)
BaseInteractableBaseInteractable to the
value given by selected.
setSelected in interface BaseInteractableselected - the new state of selection for this
BaseInteractablepublic void internalSetSelected(boolean select)
BaseInteractableBaseInteractable to the
value given by select.BaseInteractable.setSelected(boolean) method is
that not the complete hierarchy is selected the BaseInteractable
may be belongs to.
internalSetSelected in interface BaseInteractableselect - the new state of selection for this
BaseInteractablepublic boolean isMovable()
BaseInteractableboolean that indicates whether this
BaseInteractable is movable or not.
isMovable in interface BaseInteractableBaseInteractablepublic void setMovable(boolean movable)
BaseInteractableBaseInteractable to the
value given by movable.
setMovable in interface BaseInteractablemovable - the new state of movabilitypublic InteractionItem getMoveItem()
BaseInteractableInteractionItem that is used to move the
BaseInteractable. The returned value can be null if
there is no InteractionItem defined for moving the
BaseInteractable.
getMoveItem in interface BaseInteractableBaseInteractablepublic InteractionDescriptor getInteractionDescriptor()
BaseInteractableInteractionDescriptor for the
BaseInteractable.
getInteractionDescriptor in interface BaseInteractableBaseInteractableInteractionDescriptorpublic void mouseEnter(InteractionInfo interactionInfo)
BaseInteractableBaseInteractable bounding box.
mouseEnter in interface BaseInteractableinteractionInfo - the corresponding InteractionInfo
to the interactionpublic void mouseExit(InteractionInfo interactionInfo)
BaseInteractableBaseInteractable bounding box.
mouseExit in interface BaseInteractableinteractionInfo - the corresponding InteractionInfo
to the interactionpublic void mouseDown(InteractionInfo interactionInfo)
BaseInteractableBaseInteractable.
mouseDown in interface BaseInteractableinteractionInfo - the corresponding InteractionInfo
to the interactionpublic void mouseUp(InteractionInfo interactionInfo)
BaseInteractableBaseInteractable.
mouseUp in interface BaseInteractableinteractionInfo - the corresponding InteractionInfo
to the interactionpublic void mouseClick(InteractionInfo interactionInfo)
BaseInteractableBaseInteractable.
mouseClick in interface BaseInteractableinteractionInfo - the corresponding InteractionInfo
to the interactionpublic InteractionItem hits(InteractionInfo interactionInfo)
BaseInteractableBaseInteractable object. It returns null if the
object is not hit or the responsable InteractionItem.
Notice that it do not influence the state of selected for the
BaseInteractable.
hits in interface BaseInteractableinteractionInfo - the InteractionInfo's to check, may
not be null.
null.public InteractionItem select(InteractionInfo interactionInfo)
BaseInteractableInteractionContext to select
the BaseInteractable. It returns null if the
BaseInteractable is not hit or the responsible
InteractionItem.
select in interface BaseInteractableinteractionInfo - the InteractionInfo's to check, may
not be null.
InteractionItem or
null.public InteractionItem internalSelect(InteractionInfo interactionInfo)
BaseInteractableInteractionContext to select
the BaseInteractable. It returns null if the
BaseInteractable is not hit or the responsable
InteractionItem.BaseInteractable.select(com.tensegrity.graphics.interaction.InteractionInfo) method
is that the flag returned by BaseInteractable.isSelected() will not be changed nor
an event is generated by a call to this method.
internalSelect in interface BaseInteractableinteractionInfo - the InteractionInfo to check, may not
be null.
null
public boolean preActing(InteractionInfo interactionInfo,
int itemspecifier)
BaseInteractableInteractionContext while the
interaction takes place. The prefix pre indicates that it is called
before the InteractionContext calls the
InteractionItem to do his work. The returned
boolean indicates whether it is allowed to interact with the
BaseInteractable or not.
preActing in interface BaseInteractableinteractionInfo - the InteractionInfo instance;
must not be null.itemspecifier - the specifier of the InteractionItem
the InteractionContext will use
BaseInteractable
public void postActing(InteractionInfo interactionInfo,
int itemspecifier)
BaseInteractableInteractionContext while the
interaction takes place. The prefix post indicates that it is called
after the InteractionContext has called the
InteractionItem to do his work, so that the
BaseInteractable can update needed values, fire events and such
postActing in interface BaseInteractableinteractionInfo - the InteractionInfo instance;
must not be null.itemspecifier - the specifier of the InteractionItem
the InteractionContext will use
public boolean startAction(InteractionInfo interactionInfo,
int itemspecifier)
BaseInteractableInteractionContext before the
interaction takes place. It enables the BaseInteractable object
to fire events or to prepare some datas und such. The returned value
indicates that interaction is allowed or not.
startAction in interface BaseInteractableinteractionInfo - the InteractionInfo instance;
must not be null.itemspecifier - the specifier of the InteractionItem
the InteractionContext will use.
public void stopAction(InteractionInfo interactionInfo,
int itemspecifier)
BaseInteractableInteractionContext after the
interaction has taken place. It enabled the BaseInteractable
object to fire events, update some datas and such.
stopAction in interface BaseInteractableinteractionInfo - the InteractionInfo instance;
must not be null.itemspecifier - the specifier of the InteractionItem
the InteractionContext will usepublic Attribute getAttribute(java.lang.String name)
Attributablenull if there
is no Attribute with the given name.
getAttribute in interface Attributablename - name of the attribute to return.
null.public AttributeType getAttributeType(java.lang.String name)
AttributableAttributeType of the attribute with the given
name.
getAttributeType in interface Attributablename - the name of the attribute.
public java.lang.Object getAttributeValue(java.lang.String name)
Attributable
getAttributeValue in interface Attributablename - the name of the attribute to return the value from.
public void setAttribute(Attribute attribute)
throws IllegalValueException,
ConstraintViolationException
AttributableAttributable interface doesn't support an
Attribute with the name of the Attribute given
by attribute, the given attribute is not
handled by nor added to the attributes of the Attributable.
setAttribute in interface Attributableattribute - the attribute to be set.
ConstraintViolationException - is thrown when the value of the
given Attribute violates the constraint of the
Attribute to set.
IllegalValueException - is thrown when the value of the given
Attribute is illegal (for instance when it is null).
public void setAttributeValue(java.lang.String name,
java.lang.Object value)
throws IllegalValueException,
ConstraintViolationException
AttributableAttributable 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.
setAttributeValue in interface Attributablename - the name of the attribute.value - the value to set the attributes value to.
ConstraintViolationException - is thrown when the given
value violates the constraint of the
Attribute to set.
IllegalValueException - is thrown when the given value
is illegal (for instance when it is null).public void addAttributableOnSetListener(AttributableOnSetListener attributableOnSetListener)
AttributableOnSet
addAttributableOnSetListener in interface AttributableOnSetattributableOnSetListener - an AttributableOnSet
listener listening for changespublic void removeAttributableOnSetListener(AttributableOnSetListener attributableOnSetListener)
AttributableOnSet
removeAttributableOnSetListener in interface AttributableOnSetattributableOnSetListener - the AttributableOnSet to
be removed from the list of listeners.public void enableAttributableEvents()
AttributableOnSet
enableAttributableEvents in interface AttributableOnSetpublic void disableAttributableEvents()
AttributableOnSet
disableAttributableEvents in interface AttributableOnSetpublic boolean areAttributableEventsEnabled()
AttributableOnSetboolean that indicates whether generating of
events is enabled or not.
areAttributableEventsEnabled in interface AttributableOnSetprotected abstract InteractionDescriptor internalCreateInteractionDescriptor()
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.
null.
InteractionDescriptor
for the certain Primitive instance
protected void fireAttributableOnSetChangedEvent(AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike)
Primitive instance has/have been changed.
protected void fireAttributableOnSetChangedEvent(AttributeSet attributeschanged_tablelike,
AttributeSet attributeschanged_treelike,
java.util.Map attribute2oldvalue_tablelike,
java.util.Map attribute2oldvalue_treelike)
Primitive instance has/have been changed.
protected final boolean raiseAttributableEvents()
protected final void internalDeepCopyInfoValues(java.util.HashMap infovalueregistry)
infovalueregistry into the info-value-registry of this
Primitive.
infovalueregistry - the info-value-registry to copy the info values
from
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||