prefuse.action.assignment
Class SizeAction

java.lang.Object
  extended by prefuse.activity.Activity
      extended by prefuse.action.Action
          extended by prefuse.action.GroupAction
              extended by prefuse.action.ItemAction
                  extended by prefuse.action.EncoderAction
                      extended by prefuse.action.assignment.SizeAction
Direct Known Subclasses:
DataSizeAction

public class SizeAction
extends EncoderAction

Assignment Action that assigns size values to VisualItems.

By default, a SizeAction simply assigns a single default size value to all items (the initial default size is 1.0). Clients can change this default value to achieve uniform size assignment, or can add any number of additional rules for size assignment. Rules are specified by a Predicate instance which, if returning true, will trigger that rule, causing either the provided size value or the result of a delegate SizeAction to be applied. Rules are evaluated in the order in which they are added to the SizeAction, so earlier rules will have precedence over rules added later.

In addition, subclasses can simply override getSize(VisualItem) to achieve custom size assignment. In some cases, this may be the simplest or most flexible approach.

To automatically assign size values based on varying values of a particular data field, consider using the DataSizeAction.

Author:
jeffrey heer

Field Summary
protected  double m_defaultSize
           
 
Fields inherited from class prefuse.action.ItemAction
m_predicate
 
Fields inherited from class prefuse.action.GroupAction
m_group
 
Fields inherited from class prefuse.action.Action
m_vis
 
Fields inherited from class prefuse.activity.Activity
DEFAULT_STEP_TIME, INFINITY
 
Constructor Summary
SizeAction()
          Constructor.
SizeAction(java.lang.String group)
          Constructor.
SizeAction(java.lang.String group, double size)
          Constructor which specified a default size value.
 
Method Summary
 void add(Predicate p, double size)
          Add a size mapping rule to this SizeAction.
 void add(Predicate p, SizeAction f)
          Add a size mapping rule to this SizeAction.
 void add(java.lang.String expr, double size)
          Add a size mapping rule to this SizeAction.
 void add(java.lang.String expr, SizeAction f)
          Add a size mapping rule to this SizeAction.
 double getDefaultSize()
          Returns the default size value assigned to items.
 double getSize(VisualItem item)
          Returns a size value for the given item.
 void process(VisualItem item, double frac)
          Processes an individual item.
 void setDefaultSize(double defaultSize)
          Sets the default size value assigned to items.
 
Methods inherited from class prefuse.action.EncoderAction
add, clear, finish, lookup, remove, run, setup, setVisualization
 
Methods inherited from class prefuse.action.ItemAction
getFilterPredicate, setFilterPredicate
 
Methods inherited from class prefuse.action.GroupAction
getGroup, setGroup
 
Methods inherited from class prefuse.action.Action
getVisualization, run
 
Methods inherited from class prefuse.activity.Activity
addActivityListener, alwaysRunAfter, cancel, fireActivityCancelled, fireActivityFinished, fireActivityScheduled, fireActivityStarted, fireActivityStepped, getDuration, getNextTime, getPace, getPacingFunction, getStartTime, getStepTime, getStopTime, isEnabled, isRunning, isScheduled, removeActivityListener, run, runAfter, runAt, setDuration, setEnabled, setPacingFunction, setStartTime, setStepTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_defaultSize

protected double m_defaultSize
Constructor Detail

SizeAction

public SizeAction()
Constructor. A default size value of 1.0 will be used.


SizeAction

public SizeAction(java.lang.String group)
Constructor. A default size value of 1.0 will be used.

Parameters:
group - the data group processed by this Action.

SizeAction

public SizeAction(java.lang.String group,
                  double size)
Constructor which specified a default size value.

Parameters:
group - the data group processed by this Action.
size - the default size to use
Method Detail

getDefaultSize

public double getDefaultSize()
Returns the default size value assigned to items.

Returns:
the default size value

setDefaultSize

public void setDefaultSize(double defaultSize)
Sets the default size value assigned to items. Items will be assigned the default size if they do not match any registered rules.

Parameters:
defaultSize - the new default size value

add

public void add(Predicate p,
                double size)
Add a size mapping rule to this SizeAction. VisualItems that match the provided predicate will be assigned the given size value (assuming they do not match an earlier rule).

Parameters:
p - the rule Predicate
size - the size value

add

public void add(java.lang.String expr,
                double size)
Add a size mapping rule to this SizeAction. VisualItems that match the provided expression will be assigned the given size value (assuming they do not match an earlier rule). The provided expression String will be parsed to generate the needed rule Predicate.

Parameters:
expr - the expression String, should parse to a Predicate.
size - the size value
Throws:
java.lang.RuntimeException - if the expression does not parse correctly or does not result in a Predicate instance.

add

public void add(Predicate p,
                SizeAction f)
Add a size mapping rule to this SizeAction. VisualItems that match the provided predicate will be assigned the size value returned by the given SizeAction's getSize() method.

Parameters:
p - the rule Predicate
f - the delegate SizeAction to use

add

public void add(java.lang.String expr,
                SizeAction f)
Add a size mapping rule to this SizeAction. VisualItems that match the provided expression will be assigned the given size value (assuming they do not match an earlier rule). The provided expression String will be parsed to generate the needed rule Predicate.

Parameters:
expr - the expression String, should parse to a Predicate.
f - the delegate SizeAction to use
Throws:
java.lang.RuntimeException - if the expression does not parse correctly or does not result in a Predicate instance.

process

public void process(VisualItem item,
                    double frac)
Description copied from class: ItemAction
Processes an individual item.

Specified by:
process in class ItemAction
Parameters:
item - the VisualItem to process
frac - the fraction of elapsed duration time
See Also:
ItemAction.process(prefuse.visual.VisualItem, double)

getSize

public double getSize(VisualItem item)
Returns a size value for the given item.

Parameters:
item - the item for which to get the size value
Returns:
the size value for the item


Copyright © 2007 Regents of the University of California