|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.activity.Activity prefuse.action.Action prefuse.action.GroupAction prefuse.action.ItemAction prefuse.action.EncoderAction prefuse.action.assignment.ColorAction
public class ColorAction
Assignment Action that assigns color values to VisualItems for a given color field (e.g., the stroke, text, or fill color).
By default, a ColorAction simply assigns a single default color value to all items (the initial default color is black). Clients can change this default value to achieve uniform color assignment, or can add any number of additional rules for color assignment. Rules are specified by a Predicate instance which, if returning true, will trigger that rule, causing either the provided color value or the result of a delegate ColorAction to be applied. Rules are evaluated in the order in which they are added to the ColorAction, so earlier rules will have precedence over rules added later.
In addition, subclasses can simply override getColor(VisualItem)
to achieve custom color assignment. In some cases, this may be the simplest
or most flexible approach.
To automatically assign color values based on varying values of a particular data field, consider using the DataColorAction.
Color values are represented using integers, into which 8-bit values for
the red, green, blue, and alpha channels are stored. For more information
and utilities for creating and manipulating color values, see the
ColorLib
class.
ColorLib
,
DataColorAction
Field Summary | |
---|---|
protected int |
m_cidx
|
protected java.lang.String |
m_colorField
|
protected int |
m_defaultColor
|
protected int |
m_eidx
|
protected java.lang.String |
m_endField
|
protected int |
m_sidx
|
protected java.lang.String |
m_startField
|
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 | |
---|---|
ColorAction(java.lang.String group,
Predicate filter,
java.lang.String field)
Constructor, sets the data group, filter predicate and color field for color assignment. |
|
ColorAction(java.lang.String group,
Predicate filter,
java.lang.String field,
int color)
Constructor, sets the data group, filter predicate, color field, and default color value for color assignment. |
|
ColorAction(java.lang.String group,
java.lang.String field)
Constructor, sets the data group and color field for color assignment. |
|
ColorAction(java.lang.String group,
java.lang.String field,
int color)
Constructor, sets the data group, color field, and default color value for color assignment. |
Method Summary | |
---|---|
void |
add(Predicate p,
ColorAction f)
Add a color mapping rule to this ColorAction. |
void |
add(Predicate p,
int color)
Add a color mapping rule to this ColorAction. |
void |
add(java.lang.String expr,
ColorAction f)
Add a color mapping rule to this ColorAction. |
void |
add(java.lang.String expr,
int color)
Add a color mapping rule to this ColorAction. |
int |
getColor(VisualItem item)
Returns a color value for the given item. |
int |
getDefaultColor()
Returns the default color for this ColorAction |
void |
process(VisualItem item,
double frac)
Processes an individual item. |
void |
setDefaultColor(int color)
Sets the default color for this ColorAction. |
void |
setField(java.lang.String field)
Set the color field name that this ColorAction should set. |
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 |
---|
protected java.lang.String m_colorField
protected java.lang.String m_startField
protected java.lang.String m_endField
protected int m_cidx
protected int m_sidx
protected int m_eidx
protected int m_defaultColor
Constructor Detail |
---|
public ColorAction(java.lang.String group, java.lang.String field)
group
- the data group processed by this Actionfield
- the color field assigned by this Actionpublic ColorAction(java.lang.String group, java.lang.String field, int color)
group
- the data group processed by this Actionfield
- the color field assigned by this Actioncolor
- the default color value assigned by this ColorActionpublic ColorAction(java.lang.String group, Predicate filter, java.lang.String field)
group
- the data group processed by this Actionfilter
- the filter predicate
Predicate
field
- the color field assigned by this Actionpublic ColorAction(java.lang.String group, Predicate filter, java.lang.String field, int color)
group
- the data group processed by this Actionfilter
- the filter predicate
Predicate
field
- the color field assigned by this Actioncolor
- the default color value assigned by this ColorActionMethod Detail |
---|
public void setField(java.lang.String field)
field
- public int getDefaultColor()
public void setDefaultColor(int color)
color
- the new default colorpublic void add(Predicate p, int color)
p
- the rule Predicatecolor
- the color valuepublic void add(java.lang.String expr, int color)
expr
- the expression String, should parse to a Predicate.color
- the color value
java.lang.RuntimeException
- if the expression does not parse correctly or
does not result in a Predicate instance.public void add(Predicate p, ColorAction f)
p
- the rule Predicatef
- the delegate ColorAction to usepublic void add(java.lang.String expr, ColorAction f)
expr
- the expression String, should parse to a Predicate.f
- the delegate ColorAction to use
java.lang.RuntimeException
- if the expression does not parse correctly or
does not result in a Predicate instance.public void process(VisualItem item, double frac)
ItemAction
process
in class ItemAction
item
- the VisualItem to processfrac
- the fraction of elapsed duration timeItemAction.process(prefuse.visual.VisualItem, double)
public int getColor(VisualItem item)
item
- the item for which to get the color value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |