prefuse.action.assignment
Class StrokeAction

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.StrokeAction

public class StrokeAction
extends EncoderAction

Assignment Action that assigns Stroke values to VisualItems. The Stroke instance determines how lines and shape outlines are drawn, including the base size of the line, the line endings and line join types, and whether the line is solid or dashed. By default, a StrokeAction simply sets each VisualItem to use a default 1-pixel wide solid line. Clients can change this default value to achieve uniform Stroke assignment, or can add any number of additional rules for Stroke assignment. Rules are specified by a Predicate instance which, if returning true, will trigger that rule, causing either the provided Stroke value or the result of a delegate StrokeAction to be applied. Rules are evaluated in the order in which they are added to the StrokeAction, so earlier rules will have precedence over rules added later.

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

Author:
jeffrey heer

Field Summary
protected  java.awt.BasicStroke defaultStroke
           
 
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
StrokeAction()
          Create a new StrokeAction that processes all data groups.
StrokeAction(java.lang.String group)
          Create a new StrokeAction that processes the specified group.
StrokeAction(java.lang.String group, java.awt.BasicStroke defaultStroke)
          Create a new StrokeAction that processes the specified group.
 
Method Summary
 void add(Predicate p, java.awt.BasicStroke stroke)
          Add a mapping rule to this StrokeAction.
 void add(Predicate p, StrokeAction f)
          Add a mapping rule to this StrokeAction.
 void add(java.lang.String expr, java.awt.BasicStroke stroke)
          Add a mapping rule to this StrokeAction.
 void add(java.lang.String expr, StrokeAction f)
          Add a mapping rule to this StrokeAction.
 java.awt.BasicStroke getDefaultStroke()
          Get the default BasicStroke assigned to items.
 java.awt.BasicStroke getStroke(VisualItem item)
          Returns the stroke to use for a given VisualItem.
 void process(VisualItem item, double frac)
          Processes an individual item.
 void setDefaultStroke(java.awt.BasicStroke f)
          Set the default BasicStroke to be 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

defaultStroke

protected java.awt.BasicStroke defaultStroke
Constructor Detail

StrokeAction

public StrokeAction()
Create a new StrokeAction that processes all data groups.


StrokeAction

public StrokeAction(java.lang.String group)
Create a new StrokeAction that processes the specified group.

Parameters:
group - the data group to process

StrokeAction

public StrokeAction(java.lang.String group,
                    java.awt.BasicStroke defaultStroke)
Create a new StrokeAction that processes the specified group.

Parameters:
group - the data group to process
defaultStroke - the default Stroke to assign
Method Detail

setDefaultStroke

public void setDefaultStroke(java.awt.BasicStroke f)
Set the default BasicStroke to be assigned to items. Items will be assigned the default Stroke if they do not match any registered rules.

Parameters:
f - the default BasicStroke to use

getDefaultStroke

public java.awt.BasicStroke getDefaultStroke()
Get the default BasicStroke assigned to items.

Returns:
the default BasicStroke

add

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

Parameters:
p - the rule Predicate
stroke - the BasicStroke

add

public void add(java.lang.String expr,
                java.awt.BasicStroke stroke)
Add a mapping rule to this StrokeAction. VisualItems that match the provided expression will be assigned the given BasicStroke 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.
stroke - the BasicStroke
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,
                StrokeAction f)
Add a mapping rule to this StrokeAction. VisualItems that match the provided predicate will be assigned the BasicStroke value returned by the given StrokeAction's getStroke() method.

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

add

public void add(java.lang.String expr,
                StrokeAction f)
Add a mapping rule to this StrokeAction. VisualItems that match the provided expression will be assigned the given BasicStroke 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 StrokeAction 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)

getStroke

public java.awt.BasicStroke getStroke(VisualItem item)
Returns the stroke to use for a given VisualItem. Subclasses should override this method to perform customized Stroke assignment.

Parameters:
item - the VisualItem for which to get the Stroke
Returns:
the BasicStroke for the given item


Copyright © 2007 Regents of the University of California