prefuse.activity
Class ActivityMap

java.lang.Object
  extended by prefuse.activity.ActivityMap

public class ActivityMap
extends java.lang.Object

Maps between Activity instances and user-defined keys. Can be used to maintain and schedule Activity instances through a layer of indirection.

For example, an Activity could be stored in the map using the method call put("activity", activityRef). The Activity pointed to by activityRef could then be subsequently scheduled using the method call run("activity"). Furthermore, the Activity referred to by the key "activity" could be changed later by another call to put(), changing a visualization's behavior without modifying any other application code.

Author:
jeffrey heer

Constructor Summary
ActivityMap()
          Creates a new ActivityMap instance.
ActivityMap(ActivityMap parent)
          Creates a new ActivityMap instance with the specified parent map.
 
Method Summary
 java.lang.Object[] allKeys()
          Returns all keys in this ActivityMap, and in the parent map, and the parent's parent, etc.
 Activity alwaysRunAfter(java.lang.String beforeKey, java.lang.String afterKey)
          Schedules the Activity corresponding to the afterKey to always be run immediately after the completion of the Activity corresponding to the beforeKey.
 Activity cancel(java.lang.String key)
          Cancels the Activity corresponding to the given key.
 void clear()
          Clears the contents of this ActivityMap.
 Activity get(java.lang.String key)
          Returns the Activity associated with the given key.
 ActivityMap getParent()
          Returns this ActivityMap's parent map.
 java.lang.Object[] keys()
          Returns an array consisting of all the keys associated with this map.
 Activity put(java.lang.String key, Activity activity)
          Associates the given key with the given Activity
 void remove(java.lang.Object key)
          Removes a mapping from this ActivityMap.
 Activity run(java.lang.String key)
          Schedules the Activity corresponding to the given key to be run immediately by the ActivityManager.
 Activity runAfter(java.lang.String beforeKey, java.lang.String afterKey)
          Schedules the Activity corresponding to the afterKey to be run immediately after the completion of the Activity corresponding to the beforeKey.
 Activity runAt(java.lang.String key, long time)
          Runs the Activity corresponding to the given key with the ActivityManager to begin at the specified time.
 void setParent(ActivityMap parent)
          Sets this ActivityMap's parent. null values are legal, and indicate this map has no parent.
 int size()
          Returns the number of mappings in this ActivityMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActivityMap

public ActivityMap()
Creates a new ActivityMap instance.


ActivityMap

public ActivityMap(ActivityMap parent)
Creates a new ActivityMap instance with the specified parent map.

Parameters:
parent - The parent map to use. This map is referred to to resolve keys that are not found within this, the child map.
Method Detail

clear

public void clear()
Clears the contents of this ActivityMap. Does not affect the parent map.


size

public int size()
Returns the number of mappings in this ActivityMap. Does not include mappings stored in the parent map.

Returns:
the number of mappings in this ActivityMap

get

public Activity get(java.lang.String key)
Returns the Activity associated with the given key. If the key is not found in this map, the parent map is consulted. If no result is found, null is returned.

Parameters:
key - the key corresponding to a requested Activity instance
Returns:
the requested Activity instance, or null if not found by this map or the parent map.

runAt

public Activity runAt(java.lang.String key,
                      long time)
Runs the Activity corresponding to the given key with the ActivityManager to begin at the specified time.

Parameters:
key - the key corresponding to the Activity to run
time - the start time at which to begin the Activity
Returns:
the scheduled Activity, or null if not found

run

public Activity run(java.lang.String key)
Schedules the Activity corresponding to the given key to be run immediately by the ActivityManager.

Parameters:
key - the key corresponding to the Activity to run
Returns:
the scheduled Activity, or null if not found

runAfter

public Activity runAfter(java.lang.String beforeKey,
                         java.lang.String afterKey)
Schedules the Activity corresponding to the afterKey to be run immediately after the completion of the Activity corresponding to the beforeKey. This method has no scheduling effect on the Activity corresponding to the before key.

Parameters:
beforeKey - the key corresponding to the first Activity
afterKey - the key corresponding to the Activity to be scheduled after the completion of the first.
Returns:
the second, newly scheduled Activity, or null if either of the keys are not found

alwaysRunAfter

public Activity alwaysRunAfter(java.lang.String beforeKey,
                               java.lang.String afterKey)
Schedules the Activity corresponding to the afterKey to always be run immediately after the completion of the Activity corresponding to the beforeKey. This method has no scheduling effect on the Activity corresponding to the before key.

Parameters:
beforeKey - the key corresponding to the first Activity
afterKey - the key corresponding to the Activity to be scheduled after the completion of the first.
Returns:
the second, newly scheduled Activity, or null if either of the keys are not found

cancel

public Activity cancel(java.lang.String key)
Cancels the Activity corresponding to the given key.

Parameters:
key - the lookup key for the Activity to cancel
Returns:
the cancelled Activity, or null if no Activity was found for the given key.

put

public Activity put(java.lang.String key,
                    Activity activity)
Associates the given key with the given Activity

Parameters:
key - the key to associate with the Activity
activity - an Activity instance
Returns:
the Activity previously mapped to by the key, or null if none

remove

public void remove(java.lang.Object key)
Removes a mapping from this ActivityMap. The parent map, if any, is not effected by this method.

Parameters:
key - the key of the mapping to remove

keys

public java.lang.Object[] keys()
Returns an array consisting of all the keys associated with this map. This does not include any mappings in the parent map.

Returns:
an array of all keys in this ActivityMap

allKeys

public java.lang.Object[] allKeys()
Returns all keys in this ActivityMap, and in the parent map, and the parent's parent, etc.

Returns:
an array of all keys in this ActivityMap and its parents

setParent

public void setParent(ActivityMap parent)
Sets this ActivityMap's parent. null values are legal, and indicate this map has no parent.

Parameters:
parent - the new parent for this map, or null for no parent

getParent

public ActivityMap getParent()
Returns this ActivityMap's parent map. This method return null if this map has no parent.

Returns:
this map's parent map


Copyright © 2007 Regents of the University of California