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.
Constructor and Description |
---|
ActivityMap()
Creates a new ActivityMap instance.
|
ActivityMap(ActivityMap parent)
Creates a new ActivityMap instance with the specified parent map.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public ActivityMap()
public ActivityMap(ActivityMap parent)
parent
- The parent map to use. This map is referred to to resolve
keys that are not found within this, the child map.public void clear()
public int size()
public Activity get(java.lang.String key)
key
- the key corresponding to a requested Activity instancepublic Activity runAt(java.lang.String key, long time)
key
- the key corresponding to the Activity to runtime
- the start time at which to begin the Activitypublic Activity run(java.lang.String key)
key
- the key corresponding to the Activity to runpublic Activity runAfter(java.lang.String beforeKey, java.lang.String afterKey)
beforeKey
- the key corresponding to the first ActivityafterKey
- the key corresponding to the Activity to be scheduled
after the completion of the first.public Activity alwaysRunAfter(java.lang.String beforeKey, java.lang.String afterKey)
beforeKey
- the key corresponding to the first ActivityafterKey
- the key corresponding to the Activity to be scheduled
after the completion of the first.public Activity cancel(java.lang.String key)
key
- the lookup key for the Activity to cancelpublic Activity put(java.lang.String key, Activity activity)
key
- the key to associate with the Activityactivity
- an Activity instancepublic void remove(java.lang.Object key)
key
- the key of the mapping to removepublic java.lang.Object[] keys()
public java.lang.Object[] allKeys()
public void setParent(ActivityMap parent)
parent
- the new parent for this map, or null for no parentpublic ActivityMap getParent()
Copyright ? 2013 Regents of the University of California