|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprefuse.activity.Activity
prefuse.action.Action
prefuse.action.GroupAction
prefuse.action.ItemAction
prefuse.action.EncoderAction
prefuse.action.assignment.ColorAction
prefuse.action.assignment.DataColorAction
public class DataColorAction
Assignment Action that assigns color values for a group of items based upon a data field. The type of color encoding used is dependent upon the reported data type. Nominal (categorical) data is encoded using a different hue for each unique data value. Ordinal (ordered) and Numerical (quantitative) data is shown using a grayscale color ramp. In all cases, the default color palette used by this Action can be replaced with a client-specified palette provided to the DataColorAction constructor.
The color spectra for numerical data is continuous by default, but can also
be binned into a few discrete steps (see setBinCount(int)
).
Quantitative data can also be colored on different numerical scales. The
default scale is a linear scale (specified by
Scale.LINEAR
), but logarithmic and square root scales can
be used (specified by Scale.LOG
and
Scale.SQRT
respectively. Finally, the scale can be broken
into quantiles, reflecting the statistical distribution of the values rather
than just the total data value range, using the
Scale.QUANTILE
value. For the quantile scale to work, you
also need to specify the number of bins to use (see
setBinCount(int)
). This value will determine the number of
quantiles that the data should be divided into.
Field Summary |
---|
Fields inherited from class prefuse.action.assignment.ColorAction |
---|
m_cidx, m_colorField, m_defaultColor, m_eidx, m_endField, m_sidx, 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 | |
---|---|
DataColorAction(java.lang.String group,
java.lang.String dataField,
DataType dataType,
java.lang.String colorField)
Create a new DataColorAction |
|
DataColorAction(java.lang.String group,
java.lang.String dataField,
DataType dataType,
java.lang.String colorField,
int[] palette)
Create a new DataColorAction |
Method Summary | |
---|---|
protected int[] |
createPalette(int size)
Create a color palette of the requested type and size. |
protected void |
finish()
Perform any necessary clean-up after this encoder can be used. |
int |
getBinCount()
Returns the number of "bins" or discrete steps of color. |
int |
getColor(VisualItem<?> item)
Returns a color value for the given item. |
java.lang.String |
getDataField()
Returns the data field used to encode size values. |
DataType |
getDataType()
|
protected double[] |
getDistribution()
Computes the distribution (either min/max or quantile values) used to help assign colors to data values. |
Scale |
getScale()
Returns the scale type used for encoding color values from the data. |
void |
setBinCount(int count)
Sets the number of "bins" or or discrete steps of color. |
void |
setDataField(java.lang.String field)
Set the data field used to encode size values. |
void |
setDataType(DataType type)
|
void |
setDefaultColor(int color)
This operation is not supported by the DataColorAction type. |
void |
setOrdinalMap(java.lang.Object[] values)
Manually sets the ordered list of values to use for color assignment. |
void |
setScale(Scale scale)
Set the scale (linear, square root, or log) to use for encoding color values from the data. |
protected void |
setup()
Set up the state of this encoding Action. |
Methods inherited from class prefuse.action.assignment.ColorAction |
---|
add, add, add, add, getDefaultColor, process, setField |
Methods inherited from class prefuse.action.EncoderAction |
---|
add, clear, 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 |
Constructor Detail |
---|
public DataColorAction(java.lang.String group, java.lang.String dataField, DataType dataType, java.lang.String colorField)
group
- the data group to processdataField
- the data field to base size assignments ondataType
- the data type to use for the data field.colorField
- the color field to assignpublic DataColorAction(java.lang.String group, java.lang.String dataField, DataType dataType, java.lang.String colorField, int[] palette)
group
- the data group to processdataField
- the data field to base size assignments ondataType
- the data type to use for the data fieldcolorField
- the color field to assignpalette
- the color palette to use. See
ColorLib
for color palette generators.Method Detail |
---|
public java.lang.String getDataField()
public void setDataField(java.lang.String field)
field
- the data field to map to size valuespublic DataType getDataType()
public void setDataType(DataType type)
type
- the data type used by this actionpublic Scale getScale()
DataType.NUMERICAL
data.
public void setScale(Scale scale)
DataType.NUMERICAL
data.
scale
- the scale type to use.
If Scale.QUANTILE
is used, the number of
bins to use must also be specified to a value greater than zero using
the setBinCount(int)
method.public int getBinCount()
public void setBinCount(int count)
count
- the number of bins to set. The value
BinConstants.CONTINUOUS
indicates not to use any binning. If the
scale type set using the setScale(Scale)
method is
Scale.QUANTILE
, the bin count must
be greater than zero.public void setDefaultColor(int color)
setDefaultColor
in class ColorAction
color
- the new default color
java.lang.UnsupportedOperationException
ColorAction.setDefaultColor(int)
public void setOrdinalMap(java.lang.Object[] values)
DataLib
class. This method allows you to set your
own custom ordering. This ordering corresponds to the ordering of
colors in this action's color palette. If the provided array of values
is missing a value contained within the data, an exception will result
during execution of this action.
values
- the ordered list of values. If this array is missing a
value contained within data processed by this action, an exception
will be thrown when this action is run.protected void setup()
setup
in class EncoderAction
EncoderAction.setup()
protected void finish()
EncoderAction
finish
in class EncoderAction
protected double[] getDistribution()
protected int[] createPalette(int size)
public int getColor(VisualItem<?> item)
ColorAction
getColor
in class ColorAction
item
- the item for which to get the color value
ColorAction.getColor(prefuse.visual.VisualItem)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |