fr.lri.swingstates.sm
Class JNamedTag

java.lang.Object
  extended by fr.lri.swingstates.sm.Tag
      extended by fr.lri.swingstates.sm.JTag
          extended by fr.lri.swingstates.sm.JExtensionalTag
              extended by fr.lri.swingstates.sm.JNamedTag
All Implemented Interfaces:
java.util.Iterator

public class JNamedTag
extends JExtensionalTag

A JNamedTag tag is a JExtensionalTag. A JNamedTag tag is a set of components having the same label.

One can create a CNamedTag named "colorable":

 CNamedTag tag = new CNamedTag("colorable");
 
and use transitions in state machine like:
 Transition onAnyColor = new Press("colorable", BUTTON1) {
                public void action() {
                        ...
                }
 };
 

Author:
Caroline Appert
See Also:
JExtensionalTag

Constructor Summary
JNamedTag(java.lang.String n)
          Builds a JNamedTag tag.
 
Method Summary
static void clear()
          Clear all registered tags.
 java.lang.String getName()
          Returns the name of this tag.
static JNamedTag getTag(java.lang.String t)
          Returns the tag object given its name.
static java.util.LinkedList getTaggedComponents(java.lang.String t)
          Returns the list of components that have a given tag.
 boolean setName(java.lang.String n)
          Sets the name of this tag.
 
Methods inherited from class fr.lri.swingstates.sm.JExtensionalTag
added, addTo, removed, removeFrom, reset
 
Methods inherited from class fr.lri.swingstates.sm.JTag
action, action, getTaggedComponents, hasNext, next, nextComponent, setBackground, tagsComponent, tagsComponent
 
Methods inherited from class fr.lri.swingstates.sm.Tag
getCollection, remove, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNamedTag

public JNamedTag(java.lang.String n)
Builds a JNamedTag tag. Note that if a tag with the same name already exists, this new tag is not registered and the results are undefined. This constructor is left public and does not throw an exception in order to make it possible to create anonymous classes derived from JNamedTag.

Parameters:
n - The name of the tag
Method Detail

clear

public static void clear()
Clear all registered tags.


getTaggedComponents

public static java.util.LinkedList getTaggedComponents(java.lang.String t)
Returns the list of components that have a given tag.

Parameters:
t - The name of the tag
Returns:
The list of shapes.

getTag

public static JNamedTag getTag(java.lang.String t)
Returns the tag object given its name.

Parameters:
t - The name of the tag
Returns:
The tag, or null if no such tag exists.

getName

public java.lang.String getName()
Returns the name of this tag.

Returns:
the name of this tag.

setName

public boolean setName(java.lang.String n)
Sets the name of this tag. The name can only be changed if no existing tag by this name already exists.

Parameters:
n - The name.
Returns:
true if the name could be change, false otherwise.