|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsm.SMTag
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.
SMShape
) are also available for a tag.
For example, one can translate, rotate, change the color, etc. of all the shapes that have a given tag by
calling the corresponding method in this Tag
class.
ClickOnTag("movable")
that will fire only when the user is clicking on a shape with tag "movable".
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 |
public SMTag(SMCanvas c)
c
- The canvas.Method Detail |
public java.util.Collection getCollection()
public abstract void reset()
public abstract boolean hasNext()
hasNext
in interface java.util.Iterator
Iterator.hasNext()
public final java.lang.Object next()
next
in interface java.util.Iterator
Iterator.next()
public abstract SMShape nextShape()
public final void remove()
removeFrom
remove
in interface java.util.Iterator
SMExtensionalTag.removeFrom(sm.SMShape)
public int size()
public boolean tagsShape(SMShape s)
s
- The shape
public SMTag and(SMTag t)
t
- The second tag.
SMAndTag
public SMTag and(java.lang.String t)
SMNamedTag
t.
t
- The name of the second tag.
SMNamedTag
,
SMAndTag
public SMTag or(SMTag t)
t
- The second tag.
SMOrTag
public SMTag or(java.lang.String t)
SMNamedTag
t.
t
- The name of the second tag.
SMNamedTag
,
SMOrTag
public void action(SMShape s)
action()
. This method does nothing.
Redefine it in a subclass to specify the effect of Tag#action()
s
- The SMShape on which applying specific treatments.public final SMTag action()
action(SMShape s)
for every SMShape s that has this tag.
public SMTag setShape(java.awt.Shape sh)
setShape(Shape sh)
for every SMShape that has this tag.
SMShape.setShape(java.awt.Shape)
public SMTag setParent(SMShape parent) throws ImpossibleOperationOnDifferentCanvasException
setParent(SMShape parent)
for every SMShape that has this tag.
ImpossibleOperationOnDifferentCanvasException
SMShape.setParent(SMShape)
public SMTag setStroke(java.awt.Stroke str)
setStroke(Shape sh)
for every SMShape that has this tag.
SMShape.setStroke(java.awt.Stroke)
public SMTag setTransparency(float alpha)
setTransparency(float alpha)
for every SMShape that has this tag.
SMShape.setTransparency(float)
public SMTag setFillPaint(java.awt.Paint fp)
setFillPaint(Paint fp)
for every SMShape that has this tag.
SMShape.setFillPaint(Paint)
public SMTag setOutlinePaint(java.awt.Paint op)
setOutlinePaint(Paint op)
for every SMShape that has this tag.
SMShape.setOutlinePaint(Paint)
public boolean isAntialiased()
isAntialiased()
for every SMShape that has this tag.
SMShape.isAntialiased()
public final java.util.LinkedList getAntialiasedShapes()
SMShape.isAntialiased()
public SMTag setAntialiased(boolean a)
setAntialiased(boolean)
for every SMShape that has this tag.
SMShape.setAntialiased(boolean)
public boolean isFilled()
isFilled()
for every SMShape that has this tag.
SMShape.isFilled()
public java.util.LinkedList getFilledShapes()
SMShape.isFilled()
public SMTag setFilled(boolean f)
setFilled(boolean)
for every SMShape that has this tag
SMShape.setFilled(boolean)
public boolean isOutlined()
SMShape.isOutlined()
public java.util.LinkedList getOutlinedShapes()
SMShape.isOutlined()
public SMTag setOutlined(boolean f)
setOutlined(boolean)
for every SMShape that has this tag
SMShape.setOutlined(boolean)
public boolean isDrawable()
SMShape.isDrawable()
public SMTag setDrawable(boolean f)
setDrawable(boolean)
for every SMShape that has this tag
SMShape.setDrawable(boolean)
public boolean isPickable()
SMShape.isPickable()
public SMTag setPickable(boolean pick)
setPickable(boolean)
for every SMShape that has this tag.
SMShape.setOutlined(boolean)
public SMTag setReferencePoint(double x, double y)
setReferencePoint(double x, double y)
for every SMShape that has this tag.
SMShape.setReferencePoint(double, double)
public SMTag translateBy(double tx, double ty)
translateBy(double tx, double ty)
for every SMShape that has this tag.
SMShape.translateBy(double, double)
public SMTag translateTo(double tx, double ty)
translateTo(double tx, double ty)
every SMShape that has this tag
SMShape.translateTo(double, double)
public SMTag scaleBy(double sx, double sy)
scale(double sx, double sy)
for every SMShape that has this tag
SMShape.scaleBy(double, double)
public SMTag scaleBy(double s)
scaleBy(double s)
for every SMShape that has this tag
SMShape.scaleBy(double)
public SMTag scaleTo(double sx, double sy)
scaleTo(double sx, double sy)
for every SMShape that has this tag
SMShape.scaleTo(double, double)
public SMTag scaleTo(double s)
scaleTo(double s)
for every SMShape that has this tag
SMShape.scaleTo(double)
public SMTag rotateBy(double theta)
rotateBy(double theta)
for every SMShape that has this tag
SMShape.rotateBy(double)
public final SMTag rotateTo(double theta)
rotateTo(double theta)
for every SMShape that has this tag
SMShape.rotateTo(double)
public SMShape contains(double x, double y)
SMShape.contains(double, double)
public SMShape contains(java.awt.geom.Point2D p)
SMShape.contains(Point2D)
public SMShape contains(double x, double y, double w, double h)
SMShape.contains(double, double, double, double)
public SMShape contains(java.awt.geom.Rectangle2D r)
SMShape.contains(Rectangle2D)
public SMShape isOnOutline(java.awt.geom.Point2D p)
SMShape.isOnOutline(Point2D)
public SMShape intersects(double x, double y, double w, double h)
SMShape.intersects(double, double, double, double)
public SMShape intersects(java.awt.geom.Rectangle2D r)
SMShape.intersects(Rectangle2D)
public SMShape getFirstHavingTag(SMTag t)
SMShape.hasTag(sm.SMTag)
public boolean hasTag(java.lang.String t)
SMShape.hasTag(String)
public boolean hasTag(SMTag t)
public SMTag above(SMShape before)
above(SMShape before)
for every SMShape that has this tag.
SMShape.above(SMShape)
public SMTag aboveAll()
aboveAll()
for every SMShape that has this tag.
SMShape.aboveAll()
public SMTag below(SMShape after)
below(SMShape after)
for every SMShape that has this tag.
SMShape.below(SMShape)
public SMTag belowAll()
belowAll()
for every SMShape that has this tag.
SMShape.belowAll()
public SMTag setClip(SMShape clip)
setClip(SMShape clip)
for every SMShape that has this tag.
SMShape.setClip(SMShape)
public java.util.LinkedList addGhost()
SMShape.addGhost()
public SMTag removeGhost()
SMShape.removeGhost()
public SMRectangle getGlobalBoundingBox()
public SMShape firstShape()
public SMShape getFirstAntialiasedShape()
SMShape.isAntialiased()
public SMShape getFirstFilledShape()
SMShape.isFilled()
public final SMShape getFirstOutlinedShape()
SMShape.isOutlined()
public SMTag addTag(SMExtensionalTag t)
addTag(SMCanvas.Tag t)
for every SMShape that has this tag.
public SMTag addTag(java.lang.String t)
addTag(String t)
for every SMShape that has this tag.
SMShape.addTag(String)
public SMTag removeTag(SMTag t)
removeTag(SMTag t)
for every SMShape that has this tag only if t is a SMVolatileTag
,
does nothing otherwise.
SMShape.removeTag(SMTag)
public SMTag removeTag(java.lang.String t)
removeTag(String t)
for every SMShape that has this tag.
SMShape.removeTag(String)
public void attachSM(StateMachine sm, boolean reset)
InteractiveObject
attachSM
in interface InteractiveObject
sm
- The State machine that describes the behavior of this interactive object.reset
- True if the machine must be reset, false otherwise.public boolean containsPoint(double x, double y)
InteractiveObject
containsPoint
in interface InteractiveObject
x
- The x-coordinate of the point to test.y
- The y-coordinate of the point to test.
public boolean containsPoint(java.awt.geom.Point2D point)
InteractiveObject
containsPoint
in interface InteractiveObject
point
- The point to test.
public void detachSM(StateMachine sm)
InteractiveObject
detachSM
in interface InteractiveObject
sm
- The State machine to detach.public SMCanvas getCanvas()
InteractiveObject
getCanvas
in interface InteractiveObject
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |