fr.lri.swingstates.canvas
Interface CElement

All Known Implementing Classes:
CAndTag, Canvas, CDynamicWidget, CEllipse, CExtensionalTag, CHierarchyTag, CImage, CIntentionalTag, ClassTag, CNamedTag, COrTag, CPolyLine, CRectangle, CRectangularShape, CSegment, CShape, CTag, CText, CWidget, StateMachineVisualization

public interface CElement

A CElement is a graphical object: a Canvas, a Tag or a CShape. It can be linked to a state machine.

Author:
Caroline Appert

Method Summary
 CElement above(CElement before)
          Changes the display list order so that every CShape contained in this CElement is right above the top most shape in another CElement.
 CElement aboveAll()
          Calls aboveAll() for every CShape contained in this CElement.
 void addGhost()
          Calls addGhost() on every CShape contained in this CElement.
 CElement addTag(CExtensionalTag t)
          Calls addTag(Canvas.Tag t) for every CShape contained in this CElement.
 CElement addTag(java.lang.String t)
          Calls addTag(String t) for every CShape contained in this CElement.
 CElement animate(Animation anim)
          Calls animate(Animation animTagScale) for every CShape contained in this CElement.
 void attachSM(CStateMachine sm, boolean reset)
          Attaches a state machine to this CElement to describe its behavior.
 CElement below(CElement after)
          Changes the display list order so that every CShape contained in this CElement is right below the top least shape in another CElement.
 CElement belowAll()
          Calls belowAll() for every CShape contained in this CElement.
 CShape contains(double x, double y)
          Returns the topmost CShape containing the point (x, y).
 CShape contains(double x, double y, double w, double h)
          Returns the topmost CShape containing a given rectangle R.
 CShape contains(java.awt.geom.Point2D p)
          Returns the topmost CShape containing the point p.
 CShape contains(java.awt.Rectangle r)
          Returns the topmost CShape containing a given rectangle.
 void detachSM(CStateMachine sm)
          Detaches a state machine from this CElement.
 CShape firstShape()
          Returns the first shape contained in this CElement.
 java.util.LinkedList<CShape> getAntialiasedShapes()
          Returns the list of CShape that have this tag and that are antialiased.
 CRectangle getBoundingBox()
           
 Canvas getCanvas()
          Returns the canvas in which this CElement is displayed.
 double getCenterX()
           
 double getCenterY()
           
 java.util.LinkedList<CShape> getFilledShapes()
          Returns the list of CShape that have this tag and that are filled.
 CShape getFirstAntialiasedShape()
          Returns the first antialiased CShape contained in this CElement.
 CShape getFirstFilledShape()
          Returns the first CShape contained in this CElement and that is filled.
 CShape getFirstHavingTag(CTag t)
          Returns the topmost CShape that has tag t.
 CShape getFirstOutlinedShape()
          Returns the first CShape contained in this CElement and that is outlined.
 CPolyLine getIntersection(CShape s)
          Tests whether a CShape s intersects this CElement.
 double getMaxX()
           
 double getMaxY()
           
 double getMinX()
           
 double getMinY()
           
 java.util.LinkedList<CShape> getOutlinedShapes()
          Returns the list of CShape that have this tag and that are outlined.
 boolean hasTag(CTag t)
          Returns true if every shape with this tag also has tag t.
 boolean hasTag(java.lang.String t)
          Returns true if every shape with this tag also has tag t.
 CShape intersects(CShape s)
          Returns the topmost CShape that intersects the given CShape s.
 boolean isAntialiased()
          Calls isAntialiased() for every CShape contained in this CElement.
 boolean isDrawable()
          Returns true if every shape contained in this CElement is drawable.
 boolean isFilled()
          Calls isFilled() for every CShape contained in this CElement.
 CShape isOnOutline(java.awt.geom.Point2D p)
          Returns the topmost CShape whose outline contains the point p.
 boolean isOutlined()
          Returns true if every shape contained in this CElement is outlined.
 boolean isPickable()
          Returns true if every shape contained in this CElement is pickable.
 void removeGhost()
          Calls removeGhost() on every CShape contained in this CElement.
 CElement removeTag(CExtensionalTag t)
          Calls removeTag(Tag t) for every CShape contained in this CElement only if t is a SMExtensionalTag, does nothing otherwise.
 CElement removeTag(java.lang.String t)
          Calls removeTag(String t) for every CShape contained in this CElement.
 CElement rotateBy(double dt)
          Calls rotateBy(double theta) for every CShape contained in this CElement.
 CElement rotateTo(double t)
          Calls rotateTo(double theta) for every CShape contained in this CElement.
 CElement scaleBy(double ds)
          Calls scaleBy(double s) for every CShape contained in this CElement.
 CElement scaleBy(double x, double y)
          Calls scale(double sx, double sy) for every CShape contained in this CElement.
 CElement scaleTo(double s)
          Calls scaleTo(double s) for every CShape contained in this CElement.
 CElement scaleTo(double x, double y)
          Calls scaleTo(double sx, double sy) for every CShape contained in this CElement.
 CElement setAntialiased(boolean a)
          Calls setAntialiased(boolean) for every CShape contained in this CElement.
 CElement setClip(CShape clip)
          Calls setClip(CShape clip) for every CShape contained in this CElement.
 CElement setDrawable(boolean f)
          Calls setDrawable(boolean) for every CShape contained in this CElement.
 CElement setFilled(boolean f)
          Calls setFilled(boolean) for every CShape contained in this CElement.
 CElement setFillPaint(java.awt.Paint fp)
          Calls setFillPaint(Paint fp) for every CShape contained in this CElement.
 CElement setOutlined(boolean f)
          Calls setOutlined(boolean) for every CShape contained in this CElement.
 CElement setOutlinePaint(java.awt.Paint op)
          Calls setOutlinePaint(Paint op) for every CShape contained in this CElement.
 CElement setParent(CShape parent)
          Calls setParent(CShape parent) for every CShape contained in this CElement.
 CElement setPickable(boolean pick)
          Calls setPickable(boolean) for every CShape contained in this CElement.
 CElement setReferencePoint(double x, double y)
          Calls setReferencePoint(double x, double y) for every CShape contained in this CElement.
 CElement setRenderingHint(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)
          Calls setRenderingHint(hintKey, hintValue) for every CShape contained in this CElement.
 CElement setShape(java.awt.Shape sh)
          Calls setShape(Shape sh) for every CShape contained in this CElement.
 CElement setStroke(java.awt.Stroke str)
          Calls setStroke(Shape sh) for every CShape contained in this CElement.
 CElement setTransformToIdentity()
          Calls setTransformToIdentity() for every CShape contained in this CElement.
 CElement setTransparencyFill(java.awt.AlphaComposite transparencyFill)
          Calls setTransparencyFill(AlphaComposite transparencyFill) for every CShape contained in this CElement.
 CElement setTransparencyFill(float alpha)
          Calls setTransparencyFill(float alpha) for every CShape contained in this CElement.
 CElement setTransparencyOutline(java.awt.AlphaComposite transparencyOutline)
          Calls setTransparencyOutline(AlphaComposite transparencyOutline) for every CShape contained in this CElement.
 CElement setTransparencyOutline(float alpha)
          Calls setTransparencyOutline(float alpha) for every CShape contained in this CElement.
 CElement translateBy(double dx, double dy)
          Calls translateBy(double tx, double ty) for every CShape contained in this CElement.
 CElement translateTo(double x, double y)
          Calls translateTo(double tx, double ty) every CShape contained in this CElement.
 

Method Detail

attachSM

void attachSM(CStateMachine sm,
              boolean reset)
Attaches a state machine to this CElement to describe its behavior.

Parameters:
sm - The State machine that describes the behavior of this CElement.
reset - True if the machine must be reset, false otherwise.

detachSM

void detachSM(CStateMachine sm)
Detaches a state machine from this CElement.

Parameters:
sm - The State machine to detach.

getCanvas

Canvas getCanvas()
Returns the canvas in which this CElement is displayed. This method is required because the global handler that dispatches all the events to all the state machines attached to this CElement is the canvas in which this CElement is displayed.

Returns:
the canvas.

setShape

CElement setShape(java.awt.Shape sh)
Calls setShape(Shape sh) for every CShape contained in this CElement.

Parameters:
sh - The shape
Returns:
this CElement
See Also:
CShape.setShape(java.awt.Shape)

setParent

CElement setParent(CShape parent)
Calls setParent(CShape parent) for every CShape contained in this CElement.

Parameters:
parent - The parent shape
Returns:
this CElement
See Also:
CShape.setParent(CShape)

setStroke

CElement setStroke(java.awt.Stroke str)
Calls setStroke(Shape sh) for every CShape contained in this CElement.

Parameters:
str - The stroke
Returns:
this CElement
See Also:
CShape.setStroke(java.awt.Stroke)

setTransparencyFill

CElement setTransparencyFill(java.awt.AlphaComposite transparencyFill)
Calls setTransparencyFill(AlphaComposite transparencyFill) for every CShape contained in this CElement.

Parameters:
transparencyFill - The transparency
Returns:
this CElement
See Also:
CShape.setTransparencyFill(AlphaComposite)

setTransparencyFill

CElement setTransparencyFill(float alpha)
Calls setTransparencyFill(float alpha) for every CShape contained in this CElement.

Parameters:
alpha - The transparency
Returns:
this CElement
See Also:
CShape.setTransparencyFill(float)

setTransparencyOutline

CElement setTransparencyOutline(java.awt.AlphaComposite transparencyOutline)
Calls setTransparencyOutline(AlphaComposite transparencyOutline) for every CShape contained in this CElement.

Parameters:
transparencyOutline - The transparency
Returns:
this CElement
See Also:
CShape.setTransparencyOutline(AlphaComposite)

setTransparencyOutline

CElement setTransparencyOutline(float alpha)
Calls setTransparencyOutline(float alpha) for every CShape contained in this CElement.

Parameters:
alpha - The transparency
Returns:
this CElement
See Also:
CShape.setTransparencyOutline(float)

setFillPaint

CElement setFillPaint(java.awt.Paint fp)
Calls setFillPaint(Paint fp) for every CShape contained in this CElement.

Parameters:
fp - The paint value
Returns:
this CElement
See Also:
CShape.setFillPaint(Paint)

setOutlinePaint

CElement setOutlinePaint(java.awt.Paint op)
Calls setOutlinePaint(Paint op) for every CShape contained in this CElement.

Parameters:
op - The paint value
Returns:
this CElement
See Also:
CShape.setOutlinePaint(Paint)

isAntialiased

boolean isAntialiased()
Calls isAntialiased() for every CShape contained in this CElement.

Returns:
true if every shape contained in this CElement is antialiased.
See Also:
CShape.isAntialiased()

getAntialiasedShapes

java.util.LinkedList<CShape> getAntialiasedShapes()
Returns the list of CShape that have this tag and that are antialiased.

Returns:
the list of CShape that have this tag and that are antialiased.
See Also:
CShape.isAntialiased()

setAntialiased

CElement setAntialiased(boolean a)
Calls setAntialiased(boolean) for every CShape contained in this CElement.

Parameters:
a - True to activate the antialiasing, false to deactivate it.
Returns:
this CElement
See Also:
CShape.setAntialiased(boolean)

setRenderingHint

CElement setRenderingHint(java.awt.RenderingHints.Key hintKey,
                          java.lang.Object hintValue)
Calls setRenderingHint(hintKey, hintValue) for every CShape contained in this CElement. See java.awt.RenderingHints for available hint keys and hint values.

Parameters:
hintKey - The hint key
hintValue - The hint value
Returns:
this CElement.

isFilled

boolean isFilled()
Calls isFilled() for every CShape contained in this CElement.

Returns:
true if every shape contained in this CElement is filled.
See Also:
CShape.isFilled()

getFilledShapes

java.util.LinkedList<CShape> getFilledShapes()
Returns the list of CShape that have this tag and that are filled.

Returns:
the list of CShape that have this tag and that are filled.
See Also:
CShape.isFilled()

setFilled

CElement setFilled(boolean f)
Calls setFilled(boolean) for every CShape contained in this CElement.

Parameters:
f - True if the shape must be filled, false otherwise.
Returns:
this CElement
See Also:
CShape.setFilled(boolean)

isOutlined

boolean isOutlined()
Returns true if every shape contained in this CElement is outlined.

Returns:
true if every shape contained in this CElement is outlined.
See Also:
CShape.isOutlined()

getOutlinedShapes

java.util.LinkedList<CShape> getOutlinedShapes()
Returns the list of CShape that have this tag and that are outlined.

Returns:
the list of CShape that have this tag and that are outlined.
See Also:
CShape.isOutlined()

setOutlined

CElement setOutlined(boolean f)
Calls setOutlined(boolean) for every CShape contained in this CElement.

Parameters:
f - True if the shape must be outlined, false otherwise.
Returns:
this CElement
See Also:
CShape.setOutlined(boolean)

isDrawable

boolean isDrawable()
Returns true if every shape contained in this CElement is drawable.

Returns:
true if every shape contained in this CElement is drawable.
See Also:
CShape.isDrawable()

setDrawable

CElement setDrawable(boolean f)
Calls setDrawable(boolean) for every CShape contained in this CElement.

Parameters:
f - True if the shape must be drawn, false otherwise.
Returns:
this CElement
See Also:
CShape.setDrawable(boolean)

isPickable

boolean isPickable()
Returns true if every shape contained in this CElement is pickable.

Returns:
true if every shape contained in this CElement is pickable.
See Also:
CShape.isPickable()

setPickable

CElement setPickable(boolean pick)
Calls setPickable(boolean) for every CShape contained in this CElement.

Parameters:
pick - True if the shape must be pickable, false otherwise.
Returns:
this CElement
See Also:
CShape.setOutlined(boolean)

setReferencePoint

CElement setReferencePoint(double x,
                           double y)
Calls setReferencePoint(double x, double y) for every CShape contained in this CElement.

Parameters:
x - The x coordinate of the new reference point.
y - The y coordinate of the new reference point.
Returns:
this CElement
See Also:
CShape.setReferencePoint(double, double)

setTransformToIdentity

CElement setTransformToIdentity()
Calls setTransformToIdentity() for every CShape contained in this CElement.

Returns:
this CElement
See Also:
CShape.setTransformToIdentity()

translateBy

CElement translateBy(double dx,
                     double dy)
Calls translateBy(double tx, double ty) for every CShape contained in this CElement.

Parameters:
dx - The x offset
dy - The y offset
Returns:
this CElement
See Also:
CShape.translateBy(double, double)

translateTo

CElement translateTo(double x,
                     double y)
Calls translateTo(double tx, double ty) every CShape contained in this CElement.

Parameters:
x - The x coordinate
y - The y coordinate
Returns:
this CElement
See Also:
CShape.translateTo(double, double)

scaleBy

CElement scaleBy(double x,
                 double y)
Calls scale(double sx, double sy) for every CShape contained in this CElement.

Parameters:
x - The x scale factor
y - The y scale factor
Returns:
this CElement
See Also:
CShape.scaleBy(double, double)

scaleBy

CElement scaleBy(double ds)
Calls scaleBy(double s) for every CShape contained in this CElement.

Parameters:
ds - The scale factor
Returns:
this CElement
See Also:
CShape.scaleBy(double)

scaleTo

CElement scaleTo(double x,
                 double y)
Calls scaleTo(double sx, double sy) for every CShape contained in this CElement.

Parameters:
x - The x scale
y - The y scale
Returns:
this CElement
See Also:
CShape.scaleTo(double, double)

scaleTo

CElement scaleTo(double s)
Calls scaleTo(double s) for every CShape contained in this CElement.

Parameters:
s - The scale value
Returns:
this CElement
See Also:
CShape.scaleTo(double)

rotateBy

CElement rotateBy(double dt)
Calls rotateBy(double theta) for every CShape contained in this CElement.

Parameters:
dt - The angle offset
Returns:
this CElement
See Also:
CShape.rotateBy(double)

rotateTo

CElement rotateTo(double t)
Calls rotateTo(double theta) for every CShape contained in this CElement.

Parameters:
t - The angle
Returns:
this CElement
See Also:
CShape.rotateTo(double)

contains

CShape contains(double x,
                double y)
Returns the topmost CShape containing the point (x, y).

Parameters:
x - The x coordinate
y - The y coordinate
Returns:
the topmost CShape containing the point (x, y), null if no CShape contains the point (x, y).
See Also:
CShape.contains(double, double)

contains

CShape contains(java.awt.geom.Point2D p)
Returns the topmost CShape containing the point p.

Parameters:
p - The point.
Returns:
the topmost CShape containing the point p, null if no CShape contains the point p.
See Also:
CShape.contains(Point2D)

contains

CShape contains(double x,
                double y,
                double w,
                double h)
Returns the topmost CShape containing a given rectangle R.

Parameters:
x - The x coordinate of the upper left corner of R
y - The y coordinate of the upper left corner of R
w - The width of R
h - The height of R
Returns:
the topmost CShape containing the rectangle defined by the upper left corner (x, y), the width w and the height h, null if no CShape contains the rectangle.
See Also:
CShape.contains(double, double, double, double)

contains

CShape contains(java.awt.Rectangle r)
Returns the topmost CShape containing a given rectangle.

Parameters:
r - The rectangle
Returns:
the topmost CShape containing the rectangle r, null if no CShape contains r.
See Also:
CShape.contains(Rectangle)

isOnOutline

CShape isOnOutline(java.awt.geom.Point2D p)
Returns the topmost CShape whose outline contains the point p.

Parameters:
p - The point
Returns:
the topmost CShape whose outline contains the point p, null if no CShape's outline contains p.
See Also:
CShape.isOnOutline(Point2D)

intersects

CShape intersects(CShape s)
Returns the topmost CShape that intersects the given CShape s.

Parameters:
s - The shape
Returns:
the topmost CShape that intersects the given CShape, null if no CShape intersects s.
See Also:
CShape.intersects(CShape)

getIntersection

CPolyLine getIntersection(CShape s)
Tests whether a CShape s intersects this CElement.

Parameters:
s - The shape
Returns:
the intersection as a CPolyLine if s intersects it, null otherwise.
See Also:
CShape.getIntersection(CShape)

getFirstHavingTag

CShape getFirstHavingTag(CTag t)
Returns the topmost CShape that has tag t.

Parameters:
t - The tag
Returns:
the topmost CShape that has tag t, null if no CShape has tag t.
See Also:
CShape.hasTag(fr.lri.swingstates.canvas.CTag)

hasTag

boolean hasTag(java.lang.String t)
Returns true if every shape with this tag also has tag t.

Parameters:
t - The name of the tag
Returns:
true if every shape with this tag also has tag t, false otherwise.
See Also:
CShape.hasTag(String)

hasTag

boolean hasTag(CTag t)
Returns true if every shape with this tag also has tag t.

Parameters:
t - The tag
Returns:
true if every shape with this tag also has tag t, false otherwise.

above

CElement above(CElement before)
Changes the display list order so that every CShape contained in this CElement is right above the top most shape in another CElement. The relative display order between shapes contained in this CElement is unchanged. WARNING: If this CElement also contains one of the elements contained in before, this method does nothing.

Parameters:
before - The element that must be right below every shape contained in this CElement in the display list
Returns:
This CElement
See Also:
CShape.below(CElement)

aboveAll

CElement aboveAll()
Calls aboveAll() for every CShape contained in this CElement.

Returns:
This CElement
See Also:
CShape.aboveAll()

below

CElement below(CElement after)
Changes the display list order so that every CShape contained in this CElement is right below the top least shape in another CElement. The relative display order between shapes contained in this CElement is unchanged. WARNING: If this CElement also contains one of the elements contained in after, this method does nothing.

Parameters:
after - The element that must be right above every shape contained in this CElement in the display list
Returns:
This tag
See Also:
CShape.below(CElement)

belowAll

CElement belowAll()
Calls belowAll() for every CShape contained in this CElement.

Returns:
This CElement
See Also:
CShape.belowAll()

setClip

CElement setClip(CShape clip)
Calls setClip(CShape clip) for every CShape contained in this CElement.

Parameters:
clip - The clipping shape, or null to reset clipping of this shape
Returns:
This CElement
See Also:
CShape.setClip(CShape)

addGhost

void addGhost()
Calls addGhost() on every CShape contained in this CElement.

See Also:
CShape.addGhost()

removeGhost

void removeGhost()
Calls removeGhost() on every CShape contained in this CElement.

See Also:
CShape.removeGhost()

getBoundingBox

CRectangle getBoundingBox()
Returns:
the rectangle that is the bounding box of the group of SMShapes contained in this CElement.

getMinX

double getMinX()
Returns:
the minimum x-coordinate of the rectangle that is the bounding box of the group of CShapes contained in this CElement.

getMaxX

double getMaxX()
Returns:
the maximum x-coordinate of the rectangle that is the bounding box of the group of CShapes contained in this CElement.

getCenterX

double getCenterX()
Returns:
center x-coordinate of the rectangle that is the bounding box of the group of CShapes contained in this CElement.

getMinY

double getMinY()
Returns:
the minimum y-coordinate of the rectangle that is the bounding box of the group of CShapes contained in this CElement.

getMaxY

double getMaxY()
Returns:
the maximum y-coordinate of the rectangle that is the bounding box of the group of CShapes contained in this CElement.

getCenterY

double getCenterY()
Returns:
center y-coordinate of the rectangle that is the bounding box of the group of CShapes contained in this CElement.

firstShape

CShape firstShape()
Returns the first shape contained in this CElement.

Returns:
the first shape contained in this CElement, null if no shape is contained.

getFirstAntialiasedShape

CShape getFirstAntialiasedShape()
Returns the first antialiased CShape contained in this CElement.

Returns:
the first antialiased CShape contained in this CElement, null if no CShape is antialiased.
See Also:
CShape.isAntialiased()

getFirstFilledShape

CShape getFirstFilledShape()
Returns the first CShape contained in this CElement and that is filled.

Returns:
the first CShape contained in this CElement and that is filled, null if no CShape is filled.
See Also:
CShape.isFilled()

getFirstOutlinedShape

CShape getFirstOutlinedShape()
Returns the first CShape contained in this CElement and that is outlined.

Returns:
the first CShape contained in this CElement and that is outlined, null if no CShape is outlined.
See Also:
CShape.isOutlined()

addTag

CElement addTag(CExtensionalTag t)
Calls addTag(Canvas.Tag t) for every CShape contained in this CElement.

Parameters:
t - The tag
Returns:
this CElement

addTag

CElement addTag(java.lang.String t)
Calls addTag(String t) for every CShape contained in this CElement.

Parameters:
t - The name of the tag
Returns:
this CElement
See Also:
CShape.addTag(String)

removeTag

CElement removeTag(CExtensionalTag t)
Calls removeTag(Tag t) for every CShape contained in this CElement only if t is a SMExtensionalTag, does nothing otherwise.

Parameters:
t - The tag
Returns:
this CElement
See Also:
CShape.removeTag(CExtensionalTag)

removeTag

CElement removeTag(java.lang.String t)
Calls removeTag(String t) for every CShape contained in this CElement.

Parameters:
t - The name of the tag
Returns:
this CElement
See Also:
CShape.removeTag(String)

animate

CElement animate(Animation anim)
Calls animate(Animation animTagScale) for every CShape contained in this CElement.

Parameters:
anim - The animation to associate to each shape.
Returns:
this CElement
See Also:
CShape.animate(Animation)