sm
Class SMTag

java.lang.Object
  extended bysm.SMTag
All Implemented Interfaces:
InteractiveObject, java.util.Iterator
Direct Known Subclasses:
SMAndTag, SMExtensionalTag, SMHierarchyTag, SMOrTag

public abstract class SMTag
extends java.lang.Object
implements java.util.Iterator, InteractiveObject

Tags are labels associated to canvas' shapes. The SMTag class has most of the methods of the SMShape class. Calling one of these SMTag's methods calls the SMShape method that has the same name on every shape having this tag.

A tag is an object corresponding to a set of SMShape shapes that can be browsed (i.e. a collection and an iterator on it). One example is a SMNamedTag which is a set of shapes having a given label attached to them. Another example is a SMHierarchyTag(SMShape s) which is a set composed of s and every shape whose s is an ancestor.

Some tags, SMVolatileTag 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 SMNamedTag can while a SMHierarchyTag can not (it is added by setting the parent of a SMShape).

A tag can be attached to any number of objects in the same canvas. An object in the canvas can have any number of tags attached to it.

Tags are used for two main purposes : grouping and interaction.

Author:
Caroline Appert

Constructor Summary
SMTag(SMCanvas c)
          Builds a SMTag that can tag the shapes displayed on the canvas c.
 
Method Summary
 SMTag above(SMShape before)
          Calls above(SMShape before) for every SMShape that has this tag.
 SMTag aboveAll()
          Calls aboveAll() for every SMShape that has this tag.
 SMTag action()
          Calls action(SMShape s) for every SMShape s that has this tag.
 void action(SMShape s)
          Method called by action().
 java.util.LinkedList addGhost()
          Calls addGhost() on every SMShape that has this tag
 SMTag addTag(SMExtensionalTag t)
          Calls addTag(SMCanvas.Tag t) for every SMShape that has this tag.
 SMTag addTag(java.lang.String t)
          Calls addTag(String t) for every SMShape that has this tag.
 SMTag and(SMTag t)
          Builds a tag corresponding to the set of shapes tagged by this tag and by t.
 SMTag and(java.lang.String t)
          Builds a tag corresponding to the set of shapes tagged by this tag and by the SMNamedTag t.
 void attachSM(StateMachine sm, boolean reset)
          Attaches a state machine to this interactive object to describe its behavior.
 SMTag below(SMShape after)
          Calls below(SMShape after) for every SMShape that has this tag.
 SMTag belowAll()
          Calls belowAll() for every SMShape that has this tag.
 SMShape contains(double x, double y)
          Returns the topmost SMShape containing the point (x, y).
 SMShape contains(double x, double y, double w, double h)
          Returns the topmost SMShape containing a given rectangle.
 SMShape contains(java.awt.geom.Point2D p)
          Returns the topmost SMShape containing the point p.
 SMShape contains(java.awt.geom.Rectangle2D r)
          Returns the topmost SMShape containing a given rectangle.
 boolean containsPoint(double x, double y)
          Tests if a point is in this interactive object.
 boolean containsPoint(java.awt.geom.Point2D point)
          Tests if a point is in this interactive object.
 void detachSM(StateMachine sm)
          Detaches a state machine from this interactive object.
 SMShape firstShape()
          Returns the first shape that has this tag.
 java.util.LinkedList getAntialiasedShapes()
          Returns the list of SMShape that have this tag and that are antialiased.
 SMCanvas getCanvas()
          Returns the canvas in which this interactive object is displayed.
 java.util.Collection getCollection()
          Returns a collection containing all the shapes tagged by this tag.
 java.util.LinkedList getFilledShapes()
          Returns the list of SMShape that have this tag and that are filled.
 SMShape getFirstAntialiasedShape()
          Returns the first antialiased SMShape that has this tag.
 SMShape getFirstFilledShape()
          Returns the first SMShape that has this tag and that is filled.
 SMShape getFirstHavingTag(SMTag t)
          Returns the topmost SMShape that has tag t.
 SMShape getFirstOutlinedShape()
          Returns the first SMShape that has this tag and that is outlined.
 SMRectangle getGlobalBoundingBox()
           
 java.util.LinkedList getOutlinedShapes()
          Returns the list of SMShape that have this tag and that are outlined.
abstract  boolean hasNext()
          Tests if there is other shapes tagged by this tag.
 boolean hasTag(SMTag 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.
 SMShape intersects(double x, double y, double w, double h)
          Returns the topmost SMShape that intersects the given rectangle.
 SMShape intersects(java.awt.geom.Rectangle2D r)
          Returns the topmost SMShape that intersects the given rectangle.
 boolean isAntialiased()
          Calls isAntialiased() for every SMShape that has this tag.
 boolean isDrawable()
          Returns true if every shape that has this tag is drawable.
 boolean isFilled()
          Calls isFilled() for every SMShape that has this tag.
 SMShape isOnOutline(java.awt.geom.Point2D p)
          Returns the topmost SMShape 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()
          Returns the next shape tagged by this tag.
abstract  SMShape nextShape()
           
 SMTag or(SMTag t)
          Builds a tag corresponding to the set of shapes tagged by this tag or by t.
 SMTag or(java.lang.String t)
          Builds a tag corresponding to the set of shapes tagged by this tag or by the SMNamedTag t.
 void remove()
          This methods is not supported by a SMTag.
 SMTag removeGhost()
          Calls removeGhost() on every SMShape that has this tag
 SMTag removeTag(SMTag t)
          Calls removeTag(SMTag t) for every SMShape that has this tag only if t is a SMVolatileTag, does nothing otherwise.
 SMTag removeTag(java.lang.String t)
          Calls removeTag(String t) for every SMShape that has this tag.
abstract  void reset()
          Inits the tag's iterator.
 SMTag rotateBy(double theta)
          Calls rotateBy(double theta) for every SMShape that has this tag
 SMTag rotateTo(double theta)
          Calls rotateTo(double theta) for every SMShape that has this tag
 SMTag scaleBy(double s)
          Calls scaleBy(double s) for every SMShape that has this tag
 SMTag scaleBy(double sx, double sy)
          Calls scale(double sx, double sy) for every SMShape that has this tag
 SMTag scaleTo(double s)
          Calls scaleTo(double s) for every SMShape that has this tag
 SMTag scaleTo(double sx, double sy)
          Calls scaleTo(double sx, double sy) for every SMShape that has this tag
 SMTag setAntialiased(boolean a)
          Calls setAntialiased(boolean) for every SMShape that has this tag.
 SMTag setClip(SMShape clip)
          Calls setClip(SMShape clip) for every SMShape that has this tag.
 SMTag setDrawable(boolean f)
          Calls setDrawable(boolean) for every SMShape that has this tag
 SMTag setFilled(boolean f)
          Calls setFilled(boolean) for every SMShape that has this tag
 SMTag setFillPaint(java.awt.Paint fp)
          Calls setFillPaint(Paint fp) for every SMShape that has this tag.
 SMTag setOutlined(boolean f)
          Calls setOutlined(boolean) for every SMShape that has this tag
 SMTag setOutlinePaint(java.awt.Paint op)
          Calls setOutlinePaint(Paint op) for every SMShape that has this tag.
 SMTag setParent(SMShape parent)
          Calls setParent(SMShape parent) for every SMShape that has this tag.
 SMTag setPickable(boolean pick)
          Calls setPickable(boolean) for every SMShape that has this tag.
 SMTag setReferencePoint(double x, double y)
          Calls setReferencePoint(double x, double y) for every SMShape that has this tag.
 SMTag setShape(java.awt.Shape sh)
          Calls setShape(Shape sh) for every SMShape that has this tag.
 SMTag setStroke(java.awt.Stroke str)
          Calls setStroke(Shape sh) for every SMShape that has this tag.
 SMTag setTransparency(float alpha)
          Calls setTransparency(float alpha) for every SMShape that has this tag.
 int size()
          Counts how many shapes are tagged by this tag.
 boolean tagsShape(SMShape s)
          Tests if the shape s is tagged by this tag.
 SMTag translateBy(double tx, double ty)
          Calls translateBy(double tx, double ty) for every SMShape that has this tag.
 SMTag translateTo(double tx, double ty)
          Calls translateTo(double tx, double ty) every SMShape that has this tag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMTag

public SMTag(SMCanvas c)
Builds a SMTag that can tag the shapes displayed on the canvas c. This tag can be explicitely removed to any shape displayed on c.

Parameters:
c - The canvas.
Method Detail

getCollection

public java.util.Collection getCollection()
Returns a collection containing all the shapes tagged by this tag.

Returns:
Returns a collection containing all the shapes tagged by this tag.

reset

public abstract void reset()
Inits the tag's iterator.


hasNext

public abstract boolean hasNext()
Tests if there is other shapes tagged by this tag.

Specified by:
hasNext in interface java.util.Iterator
Returns:
Returns true if there is other shapes tagged by this tag, false otherwise.
See Also:
Iterator.hasNext()

next

public final java.lang.Object next()
Returns the next shape tagged by this tag.

Specified by:
next in interface java.util.Iterator
See Also:
Iterator.next()

nextShape

public abstract SMShape nextShape()

remove

public final void remove()
This methods is not supported by a SMTag. To remove a tag of a shape, take a look at removeFrom

Specified by:
remove in interface java.util.Iterator
See Also:
SMExtensionalTag.removeFrom(sm.SMShape)

size

public int size()
Counts how many shapes are tagged by this tag.

Returns:
Returns the number of shapes that are tagged by this tag.

tagsShape

public boolean tagsShape(SMShape s)
Tests if the shape s is tagged by this tag.

Parameters:
s - The shape
Returns:
Returns true if s is tagged by this tag, false otherwise.

and

public SMTag and(SMTag t)
Builds a tag corresponding to the set of shapes tagged by this tag and by t.

Parameters:
t - The second tag.
Returns:
Returns a new SMTag to access shapes tagged by this tag and t.
See Also:
SMAndTag

and

public SMTag and(java.lang.String t)
Builds a tag corresponding to the set of shapes tagged by this tag and by the SMNamedTag t.

Parameters:
t - The name of the second tag.
Returns:
Returns a new SMTag to access shapes tagged by this tag and the tag named by t.
See Also:
SMNamedTag, SMAndTag

or

public SMTag or(SMTag t)
Builds a tag corresponding to the set of shapes tagged by this tag or by t.

Parameters:
t - The second tag.
Returns:
Returns a new SMTag to access shapes tagged by this tag or t.
See Also:
SMOrTag

or

public SMTag or(java.lang.String t)
Builds a tag corresponding to the set of shapes tagged by this tag or by the SMNamedTag t.

Parameters:
t - The name of the second tag.
Returns:
Returns a new SMTag to access shapes tagged by this tag or the tag named by t.
See Also:
SMNamedTag, SMOrTag

action

public void action(SMShape s)
Method called by action(). This method does nothing. Redefine it in a subclass to specify the effect of Tag#action()

Parameters:
s - The SMShape on which applying specific treatments.

action

public final SMTag action()
Calls action(SMShape s) for every SMShape s that has this tag.

Returns:
Returns this tag

setShape

public SMTag setShape(java.awt.Shape sh)
Calls setShape(Shape sh) for every SMShape that has this tag.

See Also:
SMShape.setShape(java.awt.Shape)

setParent

public SMTag setParent(SMShape parent)
                throws ImpossibleOperationOnDifferentCanvasException
Calls setParent(SMShape parent) for every SMShape that has this tag.

Throws:
ImpossibleOperationOnDifferentCanvasException
See Also:
SMShape.setParent(SMShape)

setStroke

public SMTag setStroke(java.awt.Stroke str)
Calls setStroke(Shape sh) for every SMShape that has this tag.

See Also:
SMShape.setStroke(java.awt.Stroke)

setTransparency

public SMTag setTransparency(float alpha)
Calls setTransparency(float alpha) for every SMShape that has this tag.

See Also:
SMShape.setTransparency(float)

setFillPaint

public SMTag setFillPaint(java.awt.Paint fp)
Calls setFillPaint(Paint fp) for every SMShape that has this tag.

See Also:
SMShape.setFillPaint(Paint)

setOutlinePaint

public SMTag setOutlinePaint(java.awt.Paint op)
Calls setOutlinePaint(Paint op) for every SMShape that has this tag.

See Also:
SMShape.setOutlinePaint(Paint)

isAntialiased

public boolean isAntialiased()
Calls isAntialiased() for every SMShape that has this tag.

Returns:
Returns true if every shape that has this tag is antialiased.
See Also:
SMShape.isAntialiased()

getAntialiasedShapes

public final java.util.LinkedList getAntialiasedShapes()
Returns the list of SMShape that have this tag and that are antialiased.

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

setAntialiased

public SMTag setAntialiased(boolean a)
Calls setAntialiased(boolean) for every SMShape that has this tag.

See Also:
SMShape.setAntialiased(boolean)

isFilled

public boolean isFilled()
Calls isFilled() for every SMShape that has this tag.

Returns:
Returns true if every shape that has this tag is filled.
See Also:
SMShape.isFilled()

getFilledShapes

public java.util.LinkedList getFilledShapes()
Returns the list of SMShape that have this tag and that are filled.

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

setFilled

public SMTag setFilled(boolean f)
Calls setFilled(boolean) for every SMShape that has this tag

See Also:
SMShape.setFilled(boolean)

isOutlined

public boolean isOutlined()
Returns true if every shape that has this tag is outlined.

Returns:
Returns true if every shape that has this tag is outlined.
See Also:
SMShape.isOutlined()

getOutlinedShapes

public java.util.LinkedList getOutlinedShapes()
Returns the list of SMShape that have this tag and that are outlined.

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

setOutlined

public SMTag setOutlined(boolean f)
Calls setOutlined(boolean) for every SMShape that has this tag

See Also:
SMShape.setOutlined(boolean)

isDrawable

public boolean isDrawable()
Returns true if every shape that has this tag is drawable.

Returns:
Returns true if every shape that has this tag is drawable.
See Also:
SMShape.isDrawable()

setDrawable

public SMTag setDrawable(boolean f)
Calls setDrawable(boolean) for every SMShape that has this tag

See Also:
SMShape.setDrawable(boolean)

isPickable

public boolean isPickable()
Returns true if every shape that has this tag is pickable.

Returns:
Returns true if every shape that has this tag is pickable.
See Also:
SMShape.isPickable()

setPickable

public SMTag setPickable(boolean pick)
Calls setPickable(boolean) for every SMShape that has this tag.

See Also:
SMShape.setOutlined(boolean)

setReferencePoint

public SMTag setReferencePoint(double x,
                               double y)
Calls setReferencePoint(double x, double y) for every SMShape that has this tag.

See Also:
SMShape.setReferencePoint(double, double)

translateBy

public SMTag translateBy(double tx,
                         double ty)
Calls translateBy(double tx, double ty) for every SMShape that has this tag.

See Also:
SMShape.translateBy(double, double)

translateTo

public SMTag translateTo(double tx,
                         double ty)
Calls translateTo(double tx, double ty) every SMShape that has this tag

See Also:
SMShape.translateTo(double, double)

scaleBy

public SMTag scaleBy(double sx,
                     double sy)
Calls scale(double sx, double sy) for every SMShape that has this tag

See Also:
SMShape.scaleBy(double, double)

scaleBy

public SMTag scaleBy(double s)
Calls scaleBy(double s) for every SMShape that has this tag

See Also:
SMShape.scaleBy(double)

scaleTo

public SMTag scaleTo(double sx,
                     double sy)
Calls scaleTo(double sx, double sy) for every SMShape that has this tag

See Also:
SMShape.scaleTo(double, double)

scaleTo

public SMTag scaleTo(double s)
Calls scaleTo(double s) for every SMShape that has this tag

See Also:
SMShape.scaleTo(double)

rotateBy

public SMTag rotateBy(double theta)
Calls rotateBy(double theta) for every SMShape that has this tag

See Also:
SMShape.rotateBy(double)

rotateTo

public final SMTag rotateTo(double theta)
Calls rotateTo(double theta) for every SMShape that has this tag

See Also:
SMShape.rotateTo(double)

contains

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

Returns:
Returns the topmost SMShape containing the point (x, y), null if no SMShape contains the point (x, y).
See Also:
SMShape.contains(double, double)

contains

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

Returns:
Returns the topmost SMShape containing the point p, null if no SMShape contains the point p.
See Also:
SMShape.contains(Point2D)

contains

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

Returns:
Returns the topmost SMShape containing the rectangle defined by the upper left corner (x, y), the width w and the height h, null if no SMShape contains the rectangle.
See Also:
SMShape.contains(double, double, double, double)

contains

public SMShape contains(java.awt.geom.Rectangle2D r)
Returns the topmost SMShape containing a given rectangle.

Returns:
Returns the topmost SMShape containing the rectangle r, null if no SMShape contains r.
See Also:
SMShape.contains(Rectangle2D)

isOnOutline

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

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

intersects

public SMShape intersects(double x,
                          double y,
                          double w,
                          double h)
Returns the topmost SMShape that intersects the given rectangle.

Returns:
Returns the topmost SMShape that intersects the given rectangle, null if no SMShape intersects the rectangle.
See Also:
SMShape.intersects(double, double, double, double)

intersects

public SMShape intersects(java.awt.geom.Rectangle2D r)
Returns the topmost SMShape that intersects the given rectangle.

Returns:
Returns the topmost SMShape that intersects the given rectangle, null if no SMShape intersects the rectangle.
See Also:
SMShape.intersects(Rectangle2D)

getFirstHavingTag

public SMShape getFirstHavingTag(SMTag t)
Returns the topmost SMShape that has tag t.

Returns:
Returns the topmost SMShape that has tag t, null if no SMShape has tag t.
See Also:
SMShape.hasTag(sm.SMTag)

hasTag

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

Returns:
Returns true if every shape with this tag also has tag t, false otherwise.
See Also:
SMShape.hasTag(String)

hasTag

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

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

above

public SMTag above(SMShape before)
Calls above(SMShape before) for every SMShape that has this tag.

See Also:
SMShape.above(SMShape)

aboveAll

public SMTag aboveAll()
Calls aboveAll() for every SMShape that has this tag.

See Also:
SMShape.aboveAll()

below

public SMTag below(SMShape after)
Calls below(SMShape after) for every SMShape that has this tag.

See Also:
SMShape.below(SMShape)

belowAll

public SMTag belowAll()
Calls belowAll() for every SMShape that has this tag.

See Also:
SMShape.belowAll()

setClip

public SMTag setClip(SMShape clip)
Calls setClip(SMShape clip) for every SMShape that has this tag.

See Also:
SMShape.setClip(SMShape)

addGhost

public java.util.LinkedList addGhost()
Calls addGhost() on every SMShape that has this tag

Returns:
The list of built ghosts.
See Also:
SMShape.addGhost()

removeGhost

public SMTag removeGhost()
Calls removeGhost() on every SMShape that has this tag

See Also:
SMShape.removeGhost()

getGlobalBoundingBox

public SMRectangle getGlobalBoundingBox()
Returns:
Returns the rectangle that is the bounding box of the group of SMShapes that has this tag.

firstShape

public SMShape firstShape()
Returns the first shape that has this tag.

Returns:
Returns the first shape that has this tag, null if no shape has this tag.

getFirstAntialiasedShape

public SMShape getFirstAntialiasedShape()
Returns the first antialiased SMShape that has this tag. return Returns the first antialiased SMShape that has this tag, null if no SMShape is antialiased.

See Also:
SMShape.isAntialiased()

getFirstFilledShape

public SMShape getFirstFilledShape()
Returns the first SMShape that has this tag and that is filled. return Returns the first SMShape that has this tag and that is filled, null if no SMShape is filled.

See Also:
SMShape.isFilled()

getFirstOutlinedShape

public final SMShape getFirstOutlinedShape()
Returns the first SMShape that has this tag and that is outlined. return Returns the first SMShape that has this tag and that is outlined, null if no SMShape is outlined.

See Also:
SMShape.isOutlined()

addTag

public SMTag addTag(SMExtensionalTag t)
Calls addTag(SMCanvas.Tag t) for every SMShape that has this tag.

Returns:
Returns this tag

addTag

public SMTag addTag(java.lang.String t)
Calls addTag(String t) for every SMShape that has this tag.

Returns:
Returns this tag
See Also:
SMShape.addTag(String)

removeTag

public SMTag removeTag(SMTag t)
Calls removeTag(SMTag t) for every SMShape that has this tag only if t is a SMVolatileTag, does nothing otherwise.

Returns:
Returns this tag
See Also:
SMShape.removeTag(SMTag)

removeTag

public SMTag removeTag(java.lang.String t)
Calls removeTag(String t) for every SMShape that has this tag.

Returns:
Returns this tag
See Also:
SMShape.removeTag(String)

attachSM

public void attachSM(StateMachine sm,
                     boolean reset)
Description copied from interface: InteractiveObject
Attaches a state machine to this interactive object to describe its behavior.

Specified by:
attachSM in interface InteractiveObject
Parameters:
sm - The State machine that describes the behavior of this interactive object.
reset - True if the machine must be reset, false otherwise.

containsPoint

public boolean containsPoint(double x,
                             double y)
Description copied from interface: InteractiveObject
Tests if a point is in this interactive object.

Specified by:
containsPoint in interface InteractiveObject
Parameters:
x - The x-coordinate of the point to test.
y - The y-coordinate of the point to test.
Returns:
Returns true if (x, y) is in this interactive object, false otherwise.

containsPoint

public boolean containsPoint(java.awt.geom.Point2D point)
Description copied from interface: InteractiveObject
Tests if a point is in this interactive object.

Specified by:
containsPoint in interface InteractiveObject
Parameters:
point - The point to test.
Returns:
Returns true if point is in this interactive object, false otherwise.

detachSM

public void detachSM(StateMachine sm)
Description copied from interface: InteractiveObject
Detaches a state machine from this interactive object.

Specified by:
detachSM in interface InteractiveObject
Parameters:
sm - The State machine to detach.

getCanvas

public SMCanvas getCanvas()
Description copied from interface: InteractiveObject
Returns the canvas in which this interactive object is displayed.

Specified by:
getCanvas in interface InteractiveObject
Returns:
Returns the canvas.