prefuse.action.assignment
Class DataShapeAction

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.ShapeAction
                          extended by prefuse.action.assignment.DataShapeAction

public class DataShapeAction
extends ShapeAction

Assignment Action that assigns shape values for a group of items based upon a data field. Shape values are simple integer codes that indicate to appropriate renderer instances what shape should be drawn. The default list of shape values is included in the Constants class, all beginning with the prefix SHAPE. Of course, clients can always create their own shape codes that are handled by a custom Renderer.

The data field will be assumed to be nominal, and shapes will be assigned to unique values in the order they are encountered. Note that if the number of unique values is greater than Constants.SHAPE_COUNT (when no palette is given) or the length of a specified palette, then duplicate shapes will start being assigned.

This Action only sets the shape field of the VisualItem. For this value to have an effect, a renderer instance that takes this shape value into account must be used (e.g., ShapeRenderer).

Author:
jeffrey heer

Field Summary
protected  java.lang.String m_dataField
           
protected  java.util.Map m_ordinalMap
           
protected  int[] m_palette
           
protected static int NO_SHAPE
           
 
Fields inherited from class prefuse.action.assignment.ShapeAction
m_defaultShape
 
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
DataShapeAction(java.lang.String group, java.lang.String field)
          Create a new DataShapeAction.
DataShapeAction(java.lang.String group, java.lang.String field, int[] palette)
          Create a new DataShapeAction.
 
Method Summary
 java.lang.String getDataField()
          Returns the data field used to encode shape values.
 int getShape(VisualItem item)
          Returns a shape value for the given item.
 void setDataField(java.lang.String field)
          Set the data field used to encode shape values.
 void setDefaultShape(int defaultShape)
          This operation is not supported by the DataShapeAction type.
protected  void setup()
          Perform any necessary setup before this encoder can be used.
 
Methods inherited from class prefuse.action.assignment.ShapeAction
add, add, add, add, getDefaultSize, process
 
Methods inherited from class prefuse.action.EncoderAction
add, clear, finish, lookup, remove, run, 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

NO_SHAPE

protected static final int NO_SHAPE
See Also:
Constant Field Values

m_dataField

protected java.lang.String m_dataField

m_palette

protected int[] m_palette

m_ordinalMap

protected java.util.Map m_ordinalMap
Constructor Detail

DataShapeAction

public DataShapeAction(java.lang.String group,
                       java.lang.String field)
Create a new DataShapeAction.

Parameters:
group - the data group to process
field - the data field to base shape assignments on

DataShapeAction

public DataShapeAction(java.lang.String group,
                       java.lang.String field,
                       int[] palette)
Create a new DataShapeAction.

Parameters:
group - the data group to process
field - the data field to base shape assignments on
palette - a palette of shape values to use for the encoding. By default, shape values are assumed to be one of the integer SHAPE codes included in the Constants class.
Method Detail

getDataField

public java.lang.String getDataField()
Returns the data field used to encode shape values.

Returns:
the data field that is mapped to shape values

setDataField

public void setDataField(java.lang.String field)
Set the data field used to encode shape values.

Parameters:
field - the data field to map to shape values

setDefaultShape

public void setDefaultShape(int defaultShape)
This operation is not supported by the DataShapeAction type. Calling this method will result in a thrown exception.

Overrides:
setDefaultShape in class ShapeAction
Parameters:
defaultShape - the new default shape value
Throws:
java.lang.UnsupportedOperationException
See Also:
ShapeAction.setDefaultShape(int)

setup

protected void setup()
Description copied from class: EncoderAction
Perform any necessary setup before this encoder can be used. By default does nothing. Subclasses can override this method to perform custom setup before the Action is used.

Overrides:
setup in class EncoderAction
See Also:
EncoderAction.setup()

getShape

public int getShape(VisualItem item)
Description copied from class: ShapeAction
Returns a shape value for the given item.

Overrides:
getShape in class ShapeAction
Parameters:
item - the item for which to get the shape value
Returns:
the shape value for the item
See Also:
ShapeAction.getShape(prefuse.visual.VisualItem)


Copyright © 2007 Regents of the University of California