com.tensegrity.graphics
Interface Primitive

All Superinterfaces:
Attributable, AttributableOnSet, BaseInteractable
All Known Implementing Classes:
AbstractPrimitive

public interface Primitive
extends AttributableOnSet, BaseInteractable

This interface defines an atomic graphical shape. A Primitive can be implemented as a line, rectangle, polygon, ellipse or text. While the name of this interface might cause some initial confusion, please remember that within the visual graph domain, a basic, atomic drawing unit for a complex visual Node and Edge is simply called a Primitive.

A Primitive must support a StrokeFormat and a PaintFormat for regions. Additionally, a Primitive representing text will also support a FontFormat. A StrokeFormat may be provided by default if the application programmer does not specify one.

The following class diagram illustrates the general dependencies between the classes and interfaces in package com.tensegrity.graphics.primitive: Class Diagram Primitive

A single pixel implementation cannot be represented by this interface because the framework does not handle raster graphics.

A Primitive always provides a bounding box. The method for retrieving it is:

A Primitive can be transformed using a Transform2D component from the Generic package. At the current time, a Primitive can be translated, scaled and rotated. For more help, please read the Transform2D class documentation. The methods for transforming a Primitive are:

A Primitive supports the Illustrator technology. For more information on this, please read the Illustrator interface. An Illustrator can be retrieved with this method:

A Primitive can also be deep copied. This means that a Primitive client does not have to know the implementation class in order to make a copy.

Version:
$Id: Primitive.java,v 1.39 2005/07/14 11:10:24 MichaelKegel Exp $
Author:
M. Kegel,

Field Summary
 
Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
TREE_SUBSET_POSTFIX
 
Method Summary
 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.
 void applyState(PrimitiveState state)
           
 Primitive deepCopy()
          An implementation of this method is responsible for returning a deep- copy of the Primitive instance
 Boundary getBoundingBox()
          Returns a Boundary that describes the bounding box for a graphical object implementing this interface.
 FontFormat getFont()
          Returns the FontFormat that is used by this Primitive to draw text.
 Illustrator getIllustrator(Transform2D xform_context)
          Returns the Primitives illustrator object.
 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.
 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.
 PrimitiveState getState()
           
 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.
 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.
 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 setPaint(PaintFormat paint)
          Sets the PaintFormat for the Primitive.
 void setStroke(StrokeFormat stroke)
          Sets a StrokeFormat for the Primitive.
 void setTransform(Transform2D transform)
          Sets the Transform2D given by transform as the new transform for the coordinates of the Primitive.
 
Methods inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
addAttributableOnSetListener, areAttributableEventsEnabled, disableAttributableEvents, enableAttributableEvents, getAttributes, getAttributesTree, removeAttributableOnSetListener, setAttributes, setAttributesTree
 
Methods inherited from interface com.tensegrity.generic.attribute.Attributable
getAttribute, getAttributeType, getAttributeValue, setAttribute, setAttributeValue
 
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
 

Method Detail

getStroke

public StrokeFormat getStroke()
Returns the StrokeFormat 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.

Returns:
StrokeFormat

Find more information in the class documentation


setStroke

public void setStroke(StrokeFormat stroke)
Sets a StrokeFormat for the Primitive.

Parameters:
stroke - the StrokeFormat to use

Find more information in the class documentation


getPaint

public PaintFormat getPaint()
Returns the PaintFormat that is used by the Primitive to fill areas. The returned PaintFormat can be null for Primitives that have no areas.

Returns:
PaintFormat

Find more information in the class documentation


setPaint

public void setPaint(PaintFormat paint)
Sets the PaintFormat for the Primitive.

Parameters:
paint - the PaintFormat to use

Find more information in the class documentation


getFont

public FontFormat getFont()
Returns the FontFormat that is used by this Primitive to draw text. The returned FontFormat can be null for Primitives that have no text.

Returns:
FontFormat

Find more information in the class documentation


setFontFormat

public void setFontFormat(FontFormat font)
Sets the FontFormat for the Primitive.

Parameters:
font - the FontFormat to use

Find more information in the class documentation


getTransform

public Transform2D getTransform()
Returns a Transform2D currently used to transform the coordinates of the graphical Primitive.

Returns:
Transform2D the current transform of the Primitive

Find more information in the class documentation


setTransform

public void setTransform(Transform2D transform)
Sets the Transform2D given by transform as the new transform for the coordinates of the Primitive.

Parameters:
transform - the new transform of the Primitive, may not be null.

hasInfoValue

public 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.

Parameters:
key - the key to check for
Returns:
boolean a flag that indicates whether the given key is in use or not

addInfoValue

public 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.

If there is already an infovalue registered with the given key an InvalidArgumentException is thrown.

Parameters:
key - the key to store the infovalue with
value - the infovalue to store

removeInfoValue

public 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.

Parameters:
key - the key of the infovalue to remove

getInfoValue

public 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. If there is no infovalue stored for the given key the methods returns null

Parameters:
key - the key to return the infovalue for
Returns:
the info value for the given key or null if there is none

setInfoValue

public 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.

If there is no infovalue registered with the given key an InvalidArgumentException is thrown.

Parameters:
key - the key of the infovalue to set a new value for
newValue - the new value for the infovalue

addOrSetInfoValue

public 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.

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.

Parameters:
key - the key to store the infovalue with
value - the infovalue to store or set

getBoundingBox

public Boundary getBoundingBox()
Returns a Boundary that describes the bounding box for a graphical object implementing this interface.

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

Find more information in the class documentation


getState

public PrimitiveState getState()

applyState

public void applyState(PrimitiveState state)
                throws PrimitiveStateNotApplicableException
Throws:
PrimitiveStateNotApplicableException

getIllustrator

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

Parameters:
xform_context - the transformation of the context the Primitive lies within.
Returns:
Illustrator the illustrator for outputting the Primitive.

Find more information in the class documentation


getRenderingData

public RenderingData getRenderingData(Transform2D xform_context)
Returns a RenderingData instance, which are used by a Renderer implementation to render a Primitive.
To get more informations about the RenderingData object see the class documentation above or the documentation of the RenderingData class.
To get more information about the Renderer technique see the class documentation above or the documentation of the Renderer class.

Parameters:
xform_context - the transformation of the context the Primitive lies within. May not be null.
Returns:
RenderingData the RenderingData instance

deepCopy

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

Returns:
a deep copy of the Primitive.


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