quicktime.app.actions
Class TickleList

java.lang.Object
  |
  +--quicktime.app.actions.TickleList
All Implemented Interfaces:
Collection, CollectionController, Controller, Ticklish, TicklishController
Direct Known Subclasses:
SimpleActionList

public class TickleList
extends java.lang.Object
implements TicklishController, CollectionController

An TickleList is a list that contains Ticklish members. Each time the TickleList is tickled (it itself implements the Ticklish interface and can be a member of a TickleList) it will tickle all of its members. If the member's tickle method returns true the Ticklish member is kept active. If the tickle method returns false the member must be re-enabled for it to be tickled. A TickleList's tickle method will return false if the list is empty.

Members of a TickleList are kept in a TickleNode object which is where the active state of the node is kept. This information is only relevant for the list itself. When a Ticklish member is added to a TickleList the addMember method calls the makeTickleNode method. A subclass can define this method to make a subclass of TickleNode to store extra information about Ticklish members in a TickleList.

A singly-linked list is used to implement the TickleList. A list is used for fast iteration through the list whenever the tickle method is called. Insertion and Removal of members is of course a more expensive operation.

The TickleList also implements the TicklishController interface thus enabling it to be added to a Space as a controller for objects in that space. It implements the Collection interface to indicate that it contains a collection of objects. The TicklishController aspect of the TickleList is generally used to schedule PeriodicActions that control required aspects of the Space's members.


Field Summary
protected  TickleNode list
          This TickleNode is the head of the singly-linked list.
 
Fields inherited from interface quicktime.app.time.Ticklish
kScale
 
Constructor Summary
TickleList()
          Construct an empty TickleList.
 
Method Summary
 void addedToSpace(Space s)
          This method is called by the Space when a Controller is being addedTo the Space s.
 boolean addMember(java.lang.Object member)
          Adds an object to the collection.
 TickleNode findNode(java.lang.Object object)
          This method returns the TickleNode that corresponds to the member object.
 boolean hasMember(java.lang.Object object)
          Returns true if the provided object is a member of the collection.
 boolean isAppropriate(java.lang.Object object)
          Returns true if the provided object is an appropriate candidate for membership in a collection.
 boolean isEmpty()
          Returns true if the collection contains no members, or false if it has one or more members.
 boolean isMemberActive(Ticklish member)
          Returns the current active state of the supplied member.
 boolean isWholespace()
          Returns the current setting of the wholespace flag.
protected  TickleNode makeTickleNode(Ticklish t)
          Used by the addMember method to make a TickleNode that holds the supplied Ticklish object in the TickleList.
 java.util.Enumeration members()
          Return an Enumeration that is capable of enumerating through the actions that have been added to the action list.
 java.util.Enumeration nodes()
          Returns an Enumeration that is capable of enumerating over the nodes of a list.
 void removedFromSpace()
          Called by the Space when a Controller is being removed from a Space.
 void removeMember(java.lang.Object member)
          If the object is a member of the collection it is removed.
 void setMemberActive(Ticklish member, boolean flag)
          Sets the active state of a member of the Ticklish list.
 void setWholespace(boolean flag)
          This sets the wholespace characteristic.
 int size()
          Returns the number of members in the collection, ie.
 boolean tickle(float effectiveRate, int currentTime)
          The Timer invokes the tickle method when the invocation constraints of the Timer are reached.
 void timeChanged(int newTime)
          Invoked by the timer when a time condition of its time base has changed.
 java.lang.String toString()
          Returns a string representation of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

list

protected TickleNode list
This TickleNode is the head of the singly-linked list. If this member is null then the list is empty.
Constructor Detail

TickleList

public TickleList()
Construct an empty TickleList.
Method Detail

addedToSpace

public void addedToSpace(Space s)
This method is called by the Space when a Controller is being addedTo the Space s. If the Controller is not an appropriate controller for that kind of Space this method can throw an exception and the controller won't be added to the Space.
Specified by:
addedToSpace in interface Controller
Parameters:
s - the Space being added to

removedFromSpace

public void removedFromSpace()
Called by the Space when a Controller is being removed from a Space. This is only called by the Space on controllers that have previously been added, thus the space they are being removed from is the space they were added to.
Specified by:
removedFromSpace in interface Controller

timeChanged

public void timeChanged(int newTime)
                 throws QTException
Invoked by the timer when a time condition of its time base has changed.
Specified by:
timeChanged in interface Ticklish
Parameters:
the - newTime of the time base resulting from the changed time line of the timer

tickle

public boolean tickle(float effectiveRate,
                      int currentTime)
               throws QTException
The Timer invokes the tickle method when the invocation constraints of the Timer are reached.
Specified by:
tickle in interface Ticklish
Parameters:
er - the effective rate of the Timer when the time condition matches
time - the time that the Timer invoked the tickle method.

members

public java.util.Enumeration members()
Return an Enumeration that is capable of enumerating through the actions that have been added to the action list. The objects of this enumeration are the Ticklish members.
Specified by:
members in interface Collection
Returns:
an Enumeration object

isEmpty

public boolean isEmpty()
Returns true if the collection contains no members, or false if it has one or more members.
Specified by:
isEmpty in interface Collection
Returns:
a boolean

size

public int size()
Returns the number of members in the collection, ie. the collection's size.
Specified by:
size in interface Collection
Returns:
the size of the collection.

addMember

public boolean addMember(java.lang.Object member)
                  throws QTException
Adds an object to the collection. Returns true if the object is appropriate member of the collection (and thus added) and false if not. The candidate member must implement the Ticklish interface.
Specified by:
addMember in interface Collection
Parameters:
member - the object that should be added as a member to the collection
Returns:
a boolean.

makeTickleNode

protected TickleNode makeTickleNode(Ticklish t)
Used by the addMember method to make a TickleNode that holds the supplied Ticklish object in the TickleList. Subclasses can subclass the TickleNode and return their subclass if required.
Parameters:
t - the new Ticklish member of the list.
Returns:
the TickleNode that is used to hold the Ticklish member in the list

setMemberActive

public void setMemberActive(Ticklish member,
                            boolean flag)
Sets the active state of a member of the Ticklish list. This state is only viable whilst the supplied member is a member of the list.
Parameters:
member - the member of the list.
flag - if true the member is active and will be tickled, if false it is inactive and it won't be tickled when the list is tickled.

isMemberActive

public boolean isMemberActive(Ticklish member)
Returns the current active state of the supplied member. If the member is not a member of the list this call returns false.
Parameters:
member - a Ticklish member of this list
Returns:
a boolean indicative the active state of the member

hasMember

public boolean hasMember(java.lang.Object object)
Returns true if the provided object is a member of the collection.
Specified by:
hasMember in interface Collection
Parameters:
member - the object to test for membership
Returns:
a boolean

findNode

public TickleNode findNode(java.lang.Object object)
This method returns the TickleNode that corresponds to the member object. If the object is not a member this returns null.
Returns:
a TickleNode

nodes

public java.util.Enumeration nodes()
Returns an Enumeration that is capable of enumerating over the nodes of a list.
Returns:
an Enumeration

removeMember

public void removeMember(java.lang.Object member)
If the object is a member of the collection it is removed.
Specified by:
removeMember in interface Collection
Parameters:
member - the object to remove from the collection

isAppropriate

public boolean isAppropriate(java.lang.Object object)
Returns true if the provided object is an appropriate candidate for membership in a collection. The object must implement the Ticklish interface. Subclasses can refine this test to ensure a specialized type of Ticklish interface.
Specified by:
isAppropriate in interface Collection
Parameters:
object - the object to test
Returns:
true if the supplied object implements the Ticklish interface.

isWholespace

public boolean isWholespace()
Returns the current setting of the wholespace flag.
Specified by:
isWholespace in interface CollectionController
Returns:
true if any member of the Space is a candidate for being controlled by this controller. If false then objects must be explicitly added to the space.

setWholespace

public void setWholespace(boolean flag)
This sets the wholespace characteristic. If the TickleList is added to a Space and wholspace is true, then the Space will query the list with existing and new members, and if appropriate, they will be added as members to this Controller.
Parameters:
flag - the wholespace flag
See Also:
CollectionController

toString

public java.lang.String toString()
Returns a string representation of this class.
Overrides:
toString in class java.lang.Object
Returns:
a String