public abstract class EventOnTag extends EventOnShape
class ColorTag extends CNamedTag { Color color; public ColorTag(String tagName, Color c) { super(n); } } ... CShape ellipse1 = canvas.newEllipse(100, 100, 20, 30); CShape ellipse2 = canvas.newEllipse(200, 200, 20, 30); CShape rectangle = canvas.newRectangle(300, 300, 20, 30); ColorTag red = new ColorTag("red", Color.RED); red.addTo(ellipse1).addTo(rectangle); ColorTag green = new ColorTag("green", Color.GREEN); green.addTo(ellipse2);
// The transition is triggered when an event occurs on ellipse1 or on rectangle. Transition t = new EventOnTag (red, BUTTON1) { public void action() { ... // scale ellipse1 and rectangle getTag().scaleBy(1.5); // set the transparencyFill of the shape on which this transition has been triggered (ellipse1 OR rectangle) getShape().setTransparency(0.5f); } }
// The transition is triggered when an event occurs on ellipse1, ellipse2 or on rectangle (any shape tagged by an instance of ColorTag). Transition t = new EventOnTag (ColorTag.class, BUTTON1) { public void action() { ... getShape().setFillPaint(((ColorTag)getTag()).color)); ... } }
// The transition is triggered when an event occurs on ellipse2 (the only shape tagged by the instance of ColorTag having the name "green"). Transition t = new EventOnTag ("green", BUTTON1) { public void action() { ... System.out.println("This shape is tagged by the color "+((ColorTag)getTag()).color); ... } }
Constructor and Description |
---|
EventOnTag(java.lang.Class<? extends CTag> tagClass,
java.lang.Class eventClass)
Builds a transition with any modifier on a tagged shape that loops on
the current state.
|
EventOnTag(java.lang.Class<? extends CTag> tgClass,
java.lang.Class eventClass,
java.lang.String outState)
Builds a transition with any modifier on a tagged shape.
|
EventOnTag(java.lang.Class<? extends CTag> tagClass,
java.lang.String keyEvent)
Builds a transition with any modifier on a tagged shape that loops on
the current state.
|
EventOnTag(java.lang.Class<? extends CTag> tagClass,
java.lang.String keyEvent,
java.lang.String outState)
Builds a transition with any modifier on a tagged shape.
|
EventOnTag(CTag tag,
java.lang.Class eventClass)
Builds a transition with any modifier on a tagged shape that loops on
the current state.
|
EventOnTag(CTag tag,
java.lang.Class eventClass,
java.lang.String outState)
Builds a transition with any modifier on a tagged shape.
|
EventOnTag(CTag tag,
java.lang.String keyEvent)
Builds a transition with any modifier on a tagged shape that loops on
the current state.
|
EventOnTag(CTag tag,
java.lang.String keyEvent,
java.lang.String outState)
Builds a transition with any modifier on a tagged shape.
|
EventOnTag(java.lang.String tagName,
java.lang.Class eventClass)
Builds a transition with any modifier on a tagged shape that loops on
the current state.
|
EventOnTag(java.lang.String tagName,
java.lang.Class eventClass,
java.lang.String outState)
Builds a transition with any modifier on a tagged shape.
|
EventOnTag(java.lang.String tagName,
java.lang.String keyEvent)
Builds a transition with any modifier on a tagged shape that loops on
the current state.
|
EventOnTag(java.lang.String tagName,
java.lang.String keyEvent,
java.lang.String outState)
Builds a transition with any modifier on a tagged shape.
|
Modifier and Type | Method and Description |
---|---|
CTag |
getTag()
Returns the tag instance hold by the CShape on which the mouse
event firing this transition has occurred.
|
java.lang.String |
getTagName()
Returns the name of the tag hold by the CShape on which the mouse
event firing this transition has occurred.
|
boolean |
matches(java.util.EventObject eventObject)
Tests if an event can trigger that transition.
|
java.lang.String |
toString() |
getPoint, getShape, pickingRequired
getClassEvent
action, getEvent, getInputState, getOutputState, guard, manageEventID, oldToString, setTriggeringEvent
public EventOnTag(CTag tag, java.lang.String keyEvent)
tag
- The tagkeyEvent
- The string describing the events for which this transition
must be triggeredpublic EventOnTag(java.lang.Class<? extends CTag> tagClass, java.lang.String keyEvent)
tagClass
- The class of the tagkeyEvent
- The string describing the events for which this transition
must be triggeredpublic EventOnTag(java.lang.String tagName, java.lang.String keyEvent)
tagName
- The name of the tagkeyEvent
- The string describing the events for which this transition
must be triggeredpublic EventOnTag(CTag tag, java.lang.Class eventClass)
tag
- The tageventClass
- The class of eventspublic EventOnTag(java.lang.Class<? extends CTag> tagClass, java.lang.Class eventClass)
tagClass
- The class of the tageventClass
- The class of eventspublic EventOnTag(java.lang.String tagName, java.lang.Class eventClass)
tagName
- The name of the tageventClass
- The class of eventspublic EventOnTag(java.lang.String tagName, java.lang.String keyEvent, java.lang.String outState)
tagName
- The name of the tagkeyEvent
- The string describing the events for which this transition
must be triggeredoutState
- The name of the output statepublic EventOnTag(java.lang.Class<? extends CTag> tagClass, java.lang.String keyEvent, java.lang.String outState)
tagClass
- The class of the tagkeyEvent
- The string describing the events for which this transition
must be triggeredoutState
- The name of the output statepublic EventOnTag(CTag tag, java.lang.String keyEvent, java.lang.String outState)
tag
- The tagkeyEvent
- The string describing the events for which this transition
must be triggeredoutState
- The name of the output statepublic EventOnTag(java.lang.String tagName, java.lang.Class eventClass, java.lang.String outState)
tagName
- The name of the tageventClass
- The class of eventsoutState
- The name of the output statepublic EventOnTag(java.lang.Class<? extends CTag> tgClass, java.lang.Class eventClass, java.lang.String outState)
tgClass
- The class of the tageventClass
- The class of eventsoutState
- The name of the output statepublic EventOnTag(CTag tag, java.lang.Class eventClass, java.lang.String outState)
tag
- The tageventClass
- The class of events for which that triggers this
transition.outState
- The name of the output statepublic java.lang.String getTagName()
public CTag getTag()
public java.lang.String toString()
toString
in class EventOnShape
public boolean matches(java.util.EventObject eventObject)
matches
in class EventOnShape
eventObject
- The event to testeventObject
can trigger this transition.