public class ATag extends Tag
ATag
s are labels associated to canvas' animations. ATag
class has most of the methods of the Animation
class.
Calling one of these ATag
's methods calls the method for each tagged Animation
.
A tag is an object corresponding to a set of Animation
s that can be browsed:
aTag.reset(); while(aTag.hasNext()) Animation a = aTag.nextAnimation();
Tags can be used to in Animation* transitions in a CStateMachine
to know when an animation
has been started, stopped, suspended or resumed.
class MyTag extends ATag { ... } ... Transition anAnimationStopped = new AnimationStopped(MyTag.class) { public void action() { System.out.println(anAnimationStopped+" has just stopped."); // start a new animation for example } };
A tag can be attached to any number of animations. An animation can have any number of tags attached to it.
Some tags, AExtensionalTag
tags, can be explicitely attached to and detached from an animation,
i.e. an animation can be added to or removed from the tag's collection,
while others can not. ANamedTag
are special extensional tags that can be referenced by their key string.
Tags are used for grouping animations.
for example, one can decide to start several animations at the same time.
For example, to animate two rectangles that move towards two opposite directions
(we use a ANamedTag
):
Animation onePart = new AnimationTranslateBy(-2, 0); onePart.setAnimatedElement(canvas.newRectangle(100, 100, 20, 20).addTag("part")); Animation anotherPart = new AnimationTranslateBy(2, 0); anotherPart.setAnimatedElement(canvas.newRectangle(120, 120, 20, 20).addTag("part")); ... ANamedTag.getTag("part").start();
Tag
Constructor and Description |
---|
ATag()
Builds a
ATag that can tag animations. |
Modifier and Type | Method and Description |
---|---|
ATag |
action()
Calls
action(Animation s) for every Animation a that has this tag. |
void |
action(Animation a)
Method called by
action() . |
ATag |
addTag(AExtensionalTag t)
Calls
addTag(animations.AExtensionalTag t) for every animation that has this tag. |
ATag |
addTag(java.lang.String t)
Calls
addTag(String t) for every animation that has this tag. |
boolean |
hasNext()
Tests if there is other objects tagged by this tag.
|
java.lang.Object |
next() |
Animation |
nextAnimation() |
ATag |
removeTag(AExtensionalTag t)
Calls
removeTag(animations.ATag t) for every animation that has this tag only if t is a AExtensionalTag ,
does nothing otherwise. |
ATag |
removeTag(java.lang.String t)
Calls
removeTag(String t) for every animation that has this tag. |
void |
reset()
Inits the tag's iterator.
|
ATag |
resume()
Calls
resume() for every Animation that has this tag. |
ATag |
setAnimatedElement(CElement ce)
Calls
setAnimatedElement(CElement ce) for every Animation that has this tag. |
ATag |
setDelay(int d)
Calls
setDelay(int d) for every Animation that has this tag. |
ATag |
setDurationLap(long d)
Calls
setDurationLap(long d) for every Animation that has this tag. |
ATag |
setFunction(short t)
Calls
setFunction(int t) for every Animation that has this tag. |
ATag |
setNbLaps(int laps)
Calls
setNbLaps(int laps) for every Animation that has this tag. |
ATag |
start()
Calls
start() for every Animation that has this tag. |
ATag |
stop()
Calls
stop() for every Animation that has this tag. |
ATag |
suspend()
Calls
suspend() for every Animation that has this tag. |
boolean |
tagsAnimation(Animation a)
Tests if the animation
a is tagged by this tag. |
getCollection, remove, size
public final java.lang.Object next()
Tag
public boolean tagsAnimation(Animation a)
a
is tagged by this tag.a
- The animationa
is tagged by this tag, false otherwise.public void action(Animation a)
action()
. This method does nothing.
Redefine it in a subclass to specify the effect of ATag#action()
a
- The Animation
on which applying specific treatments.public final ATag action()
action(Animation s)
for every Animation
a
that has this tag.public ATag setDelay(int d)
setDelay(int d)
for every Animation
that has this tag.d
- The delay in milliseconds.Animation.setDelay(int)
public ATag setDurationLap(long d)
setDurationLap(long d)
for every Animation
that has this tag.d
- The duration in milliseconds.Animation.setLapDuration(long)
public ATag setFunction(short t)
setFunction(int t)
for every Animation
that has this tag.t
- The type of the pacing function.Animation.setFunction(short)
public ATag setNbLaps(int laps)
setNbLaps(int laps)
for every Animation
that has this tag.laps
- The number of laps.Animation.setNbLaps(int)
public ATag setAnimatedElement(CElement ce)
setAnimatedElement(CElement ce)
for every Animation
that has this tag.ce
- The CElement
to animate.Animation.setAnimatedElement(CElement)
public final ATag start()
start()
for every Animation
that has this tag.Animation.start()
public final ATag stop()
stop()
for every Animation
that has this tag.Animation.stop()
public final ATag suspend()
suspend()
for every Animation
that has this tag.Animation.suspend()
public final ATag resume()
resume()
for every Animation
that has this tag.Animation.resume()
public ATag addTag(AExtensionalTag t)
addTag(animations.AExtensionalTag t)
for every animation that has this tag.t
- The tag to add.Animation.addTag(fr.lri.swingstates.animations.AExtensionalTag)
public ATag addTag(java.lang.String t)
addTag(String t)
for every animation that has this tag.t
- The name of the tag to add.Animation.addTag(fr.lri.swingstates.animations.AExtensionalTag)
public ATag removeTag(AExtensionalTag t)
removeTag(animations.ATag t)
for every animation that has this tag only if t is a AExtensionalTag
,
does nothing otherwise.t
- The tag to remove.Animation.removeTag(fr.lri.swingstates.animations.AExtensionalTag)
public ATag removeTag(java.lang.String t)
removeTag(String t)
for every animation that has this tag.t
- The name of the tag to remove.Animation.removeTag(String)
public Animation nextAnimation()
Animation
.Iterator.next()
public boolean hasNext()