public abstract class CTag extends Tag implements CElement
CTags are labels associated to canvas' shapes. The CTag class has most of the methods of the CShape class.
 Calling one of these CTag's methods calls the CShape method that has the same name on every shape having this tag.
A tag is an object corresponding to a set of CShape shapes that can be browsed (i.e. a collection
 and an iterator on it).
 One example is a CNamedTag which is a set of shapes having a given label attached to them.
 Another example is a CHierarchyTag(CShape s) which is a set composed of s and every shape whose s is an ancestor.
Some tags, CExtensionalTag tags, can be explicitely attached to and detached from a shape, 
 i.e. a shape can be added to or removed from the tag's collection,
 while others can not. For example, a CNamedTag can while a CHierarchyTag can not (it is added by
 setting the parent of a CShape).
A tag can be attached to any number of shapes in the same canvas. A shape in the canvas can have any number of tags attached to it.
Tags are used for two main purposes : grouping and interaction.
ClickOnTag(BUTTON1, movable)
 that will fire only when the user is clicking on an object with tag "movable".
 
  class ColorTag extends CTag {
                Color color;
                ...
  }
 
 Then, in a state machine, one can use transitions like:
 
        Transition onAnyColor = new PressOnTag(ColoredTag.class, BUTTON1) {
                public void action() {
                        System.out.println("This object has a "+((ColoredTag)getTag()).color+" tag");
                }
        };
 
 Tag| Constructor and Description | 
|---|
CTag(Canvas c)
Builds a CTag that can tag the shapes displayed on the canvas c. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
CElement | 
above(CElement before)
Changes the display list order so that every CShape tagged by this tag is right above 
 the top most shape in another CElement. 
 | 
CElement | 
aboveAll()
Calls  
aboveAll() for every CShape contained in this CElement. | 
CTag | 
action()
Calls  
action(CShape s) for every CShape s that has this tag. | 
void | 
action(CShape s)
Method called by  
action(). | 
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. | 
CTag | 
and(CTag t)
Builds a tag corresponding to the set of shapes tagged by this tag and by t. 
 | 
CTag | 
and(java.lang.String t)
Builds a tag corresponding to the set of shapes tagged by this tag and by the  
SMNamedTag t. | 
CElement | 
animate(Animation anim)
Calls  
animate(Animation anim) for every CShape tagged by this CTag. | 
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 tagged by this tag 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. 
 | 
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 that has this tag. 
 | 
CElement | 
fixReferenceShapeToCurrent() | 
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. 
 | 
CShape | 
getTopLeastShape()  | 
CShape | 
getTopMostShape()  | 
boolean | 
hasNext()
Tests if there is other objects tagged by this tag. 
 | 
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 that has this tag. | 
boolean | 
isDrawable()
Returns true if every shape that has this tag 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 that has this tag is outlined. 
 | 
boolean | 
isPickable()
Returns true if every shape that has this tag is pickable. 
 | 
java.lang.Object | 
next() | 
CShape | 
nextShape()  | 
CTag | 
or(CTag t)
Builds a tag corresponding to the set of shapes tagged by this tag or by t. 
 | 
CTag | 
or(java.lang.String t)
Builds a tag corresponding to the set of shapes tagged by this tag or by the  
SMNamedTag t. | 
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 theta)
Calls  
rotateBy(double theta) for every CShape contained in this CElement. | 
CElement | 
rotateTo(double theta)
Calls  
rotateTo(double theta) for every CShape contained in this CElement. | 
CElement | 
scaleBy(double s)
Calls  
scaleBy(double s) for every CShape contained in this CElement. | 
CElement | 
scaleBy(double sx,
       double sy)
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 sx,
       double sy)
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. | 
boolean | 
tagsShape(CShape s)
Tests if the shape s is tagged by this tag. 
 | 
CElement | 
translateBy(double tx,
           double ty)
Calls  
translateBy(double tx, double ty) for every CShape contained in this CElement. | 
CElement | 
translateTo(double tx,
           double ty)
Calls  
translateTo(double tx, double ty) every CShape contained in this CElement. | 
getCollection, remove, reset, sizepublic CTag(Canvas c)
c - The canvas.public Canvas getCanvas()
public boolean hasNext()
public final java.lang.Object next()
public CShape nextShape()
CShape.Iterator.next()public boolean tagsShape(CShape s)
s - The shapepublic CTag and(CTag t)
t - The second tag.CAndTagpublic CTag and(java.lang.String t)
SMNamedTag t.public CTag or(CTag t)
t - The second tag.COrTagpublic CTag or(java.lang.String t)
SMNamedTag t.public void action(CShape s)
action(). This method does nothing.
 Redefine it in a subclass to specify the effect of CTag#action()s - The CShape on which applying specific treatments.public final CTag action()
action(CShape s) for every CShape s that has this tag.public CElement setShape(java.awt.Shape sh)
setShape(Shape sh) for every CShape contained in this CElement.setShape in interface CElementsh - The shapeCElementCShape.setShape(java.awt.Shape)public CElement setParent(CShape parent)
setParent(CShape parent) for every CShape contained in this CElement.setParent in interface CElementparent - The parent shapeCElementCShape.setParent(CShape)public CElement setStroke(java.awt.Stroke str)
setStroke(Shape sh) for every CShape contained in this CElement.setStroke in interface CElementstr - The strokeCElementCShape.setStroke(java.awt.Stroke)public CElement setTransparencyFill(java.awt.AlphaComposite transparencyFill)
setTransparencyFill(AlphaComposite transparencyFill) for every CShape contained in this CElement.setTransparencyFill in interface CElementtransparencyFill - The transparencyCElementCShape.setTransparencyFill(AlphaComposite)public CElement setTransparencyFill(float alpha)
setTransparencyFill(float alpha) for every CShape contained in this CElement.setTransparencyFill in interface CElementalpha - The transparencyCElementCShape.setTransparencyFill(float)public CElement setTransparencyOutline(java.awt.AlphaComposite transparencyOutline)
setTransparencyOutline(AlphaComposite transparencyOutline) for every CShape contained in this CElement.setTransparencyOutline in interface CElementtransparencyOutline - The transparencyCElementCShape.setTransparencyOutline(AlphaComposite)public CElement setTransparencyOutline(float alpha)
setTransparencyOutline(float alpha) for every CShape contained in this CElement.setTransparencyOutline in interface CElementalpha - The transparencyCElementCShape.setTransparencyOutline(float)public CElement setFillPaint(java.awt.Paint fp)
setFillPaint(Paint fp) for every CShape contained in this CElement.setFillPaint in interface CElementfp - The paint valueCElementCShape.setFillPaint(Paint)public CElement setOutlinePaint(java.awt.Paint op)
setOutlinePaint(Paint op) for every CShape contained in this CElement.setOutlinePaint in interface CElementop - The paint valueCElementCShape.setOutlinePaint(Paint)public boolean isAntialiased()
isAntialiased() for every CShape that has this tag.isAntialiased in interface CElementCShape.isAntialiased()public java.util.LinkedList<CShape> getAntialiasedShapes()
getAntialiasedShapes in interface CElementCShape.isAntialiased()public CElement setRenderingHint(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)
setRenderingHint(hintKey, hintValue) for every CShape contained in this CElement.
 See java.awt.RenderingHints for available hint keys and hint values.setRenderingHint in interface CElementhintKey - The hint keyhintValue - The hint valueCElement.public CElement setAntialiased(boolean a)
setAntialiased(boolean) for every CShape contained in this CElement.setAntialiased in interface CElementa - True to activate the antialiasing, false to deactivate it.CElementCShape.setAntialiased(boolean)public boolean isFilled()
isFilled() for every CShape contained in this CElement.isFilled in interface CElementCElement is filled.CShape.isFilled()public java.util.LinkedList<CShape> getFilledShapes()
getFilledShapes in interface CElementCShape.isFilled()public CElement setFilled(boolean f)
setFilled(boolean) for every CShape contained in this CElement.setFilled in interface CElementf - True if the shape must be filled, false otherwise.CElementCShape.setFilled(boolean)public boolean isOutlined()
isOutlined in interface CElementCShape.isOutlined()public java.util.LinkedList<CShape> getOutlinedShapes()
CElementgetOutlinedShapes in interface CElementCShape.isOutlined()public CElement setOutlined(boolean f)
setOutlined(boolean) for every CShape contained in this CElement.setOutlined in interface CElementf - True if the shape must be outlined, false otherwise.CElementCShape.setOutlined(boolean)public boolean isDrawable()
isDrawable in interface CElementCShape.isDrawable()public CElement setDrawable(boolean f)
setDrawable(boolean) for every CShape contained in this CElement.setDrawable in interface CElementf - True if the shape must be drawn, false otherwise.CElementCShape.setDrawable(boolean)public boolean isPickable()
isPickable in interface CElementCShape.isPickable()public CElement setPickable(boolean pick)
setPickable(boolean) for every CShape contained in this CElement.setPickable in interface CElementpick - True if the shape must be pickable, false otherwise.CElementCShape.setOutlined(boolean)public CElement setReferencePoint(double x, double y)
setReferencePoint(double x, double y) for every CShape contained in this CElement.setReferencePoint in interface CElementx - The x coordinate of the new reference point.y - The y coordinate of the new reference point.CElementCShape.setReferencePoint(double, double)public CElement setTransformToIdentity()
setTransformToIdentity() for every CShape contained in this CElement.setTransformToIdentity in interface CElementCElementCShape.setTransformToIdentity()public CElement fixReferenceShapeToCurrent()
fixReferenceShapeToCurrent in interface CElementpublic CElement translateBy(double tx, double ty)
translateBy(double tx, double ty) for every CShape contained in this CElement.translateBy in interface CElementtx - The x offsetty - The y offsetCElementCShape.translateBy(double, double)public CElement translateTo(double tx, double ty)
translateTo(double tx, double ty) every CShape contained in this CElement.translateTo in interface CElementtx - The x coordinatety - The y coordinateCElementCShape.translateTo(double, double)public CElement scaleBy(double sx, double sy)
scale(double sx, double sy) for every CShape contained in this CElement.scaleBy in interface CElementsx - The x scale factorsy - The y scale factorCElementCShape.scaleBy(double, double)public CElement scaleBy(double s)
scaleBy(double s) for every CShape contained in this CElement.scaleBy in interface CElements - The scale factorCElementCShape.scaleBy(double)public CElement scaleTo(double sx, double sy)
scaleTo(double sx, double sy) for every CShape contained in this CElement.scaleTo in interface CElementsx - The x scalesy - The y scaleCElementCShape.scaleTo(double, double)public CElement scaleTo(double s)
scaleTo(double s) for every CShape contained in this CElement.scaleTo in interface CElements - The scale valueCElementCShape.scaleTo(double)public CElement rotateBy(double theta)
rotateBy(double theta) for every CShape contained in this CElement.rotateBy in interface CElementtheta - The angle offsetCElementCShape.rotateBy(double)public CElement rotateTo(double theta)
rotateTo(double theta) for every CShape contained in this CElement.rotateTo in interface CElementtheta - The angleCElementCShape.rotateTo(double)public CShape contains(double x, double y)
contains in interface CElementx - The x-coordinate of the point to test.y - The y-coordinate of the point to test.CShape.contains(double, double)public CShape contains(java.awt.geom.Point2D p)
contains in interface CElementp - The point to test.CShape.contains(Point2D)public CShape contains(double x, double y, double w, double h)
contains in interface CElementx - The x-coordinate of the left corner of the rectangle to test.y - The y-coordinate of the left corner of the rectangle to test.w - The width of the rectangle to test.h - The height of the rectangle to test.CShape.contains(double, double, double, double)public CShape contains(java.awt.Rectangle r)
contains in interface CElementr - The rectangle to test.CShape.contains(Rectangle)public CShape isOnOutline(java.awt.geom.Point2D p)
isOnOutline in interface CElementp - The point to test.CShape.isOnOutline(Point2D)public CShape intersects(CShape s)
CShape that intersects the given CShape s.intersects in interface CElements - The shapeCShape that intersects the given CShape, null if no CShape intersects s.CShape.intersects(CShape)public CPolyLine getIntersection(CShape s)
CShape s intersects this CElement.getIntersection in interface CElements - The shapeCPolyLine if s intersects it, null otherwise.CShape.getIntersection(CShape)public CShape getFirstHavingTag(CTag t)
getFirstHavingTag in interface CElementt - The tag to test.CShape.hasTag(fr.lri.swingstates.canvas.CTag)public boolean hasTag(java.lang.String t)
hasTag in interface CElementt - The name of the tag to testCShape.hasTag(String)public boolean hasTag(CTag t)
public CElement above(CElement before)
before, this method does nothing.above in interface CElementbefore - The shape that must be right below every shape contained in this CElement in the display listCElementCShape.below(CElement)public CElement aboveAll()
aboveAll() for every CShape contained in this CElement.aboveAll in interface CElementCElementCShape.aboveAll()public CShape getTopMostShape()
public CShape getTopLeastShape()
public CElement below(CElement after)
after, this method does nothing.below in interface CElementafter - The shape that must be right above every shape contained in this CElement in the display listCShape.below(CElement)public CElement belowAll()
belowAll() for every CShape contained in this CElement.belowAll in interface CElementCElementCShape.belowAll()public CElement setClip(CShape clip)
setClip(CShape clip) for every CShape contained in this CElement.setClip in interface CElementclip - The clipping shape, or null to reset clipping of this shapeCElementCShape.setClip(CShape)public void addGhost()
CElement.addGhost in interface CElementCShape.addGhost()public void removeGhost()
CElement.removeGhost in interface CElementCShape.removeGhost()public CRectangle getBoundingBox()
getBoundingBox in interface CElementpublic double getMinX()
public double getMaxX()
public double getCenterX()
getCenterX in interface CElementpublic double getMinY()
public double getMaxY()
public double getCenterY()
getCenterY in interface CElementpublic CShape firstShape()
firstShape in interface CElementpublic CShape getFirstAntialiasedShape()
CElement.getFirstAntialiasedShape in interface CElementCElement, null if no CShape is antialiased.CShape.isAntialiased()public CShape getFirstFilledShape()
CElement and that is filled.getFirstFilledShape in interface CElementCElement and that is filled, null if no CShape is filled.CShape.isFilled()public final CShape getFirstOutlinedShape()
CElement and that is outlined.getFirstOutlinedShape in interface CElementCElement and that is outlined, null if no CShape is outlined.CShape.isOutlined()public CElement addTag(CExtensionalTag t)
addTag(Canvas.Tag t) for every CShape contained in this CElement.public CElement addTag(java.lang.String t)
addTag(String t) for every CShape contained in this CElement.addTag in interface CElementt - The name of the tagCElementCShape.addTag(String)public CElement removeTag(CExtensionalTag t)
removeTag(Tag t) for every CShape contained in this CElement only if t is a SMExtensionalTag, 
 does nothing otherwise.removeTag in interface CElementt - The tagCElementCShape.removeTag(CExtensionalTag)public CElement removeTag(java.lang.String t)
removeTag(String t) for every CShape contained in this CElement.removeTag in interface CElementt - The name of the tagCElementCShape.removeTag(String)public void attachSM(CStateMachine sm, boolean reset)
CElement to describe its behavior.public void detachSM(CStateMachine sm)
CElement.public CElement animate(Animation anim)
animate(Animation anim) for every CShape tagged by this CTag.animate in interface CElementanim - The animation to associate to each shape tagged by this CTag.CTag as a CElementCShape.animate(Animation)