|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.Visualization
public class Visualization
Central data structure representing an interactive Visualization.
This class is responsible for
managing the mappings between source data and onscreen VisualItems,
maintaining a list of Display
instances responsible for rendering
of and interaction with the contents of this visualization, and
providing a collection of named Action instances for performing
data processing such as layout, animation, and size, shape, and color
assignment.
The primary responsibility of the Visualization class is the creation
of visual abstractions of input data. Regardless of the data
structure (i.e., Table
, Graph
,
or Tree
), this class takes source data such as that
loaded from a file (see prefuse.data.io
) or from a relational
database (see prefuse.data.io.sql
) and creates a visual
representation of the data. These visual representations of the data are
data sets in their own right, providing access to the underlying source
data to be visualized while also adding addition data fields specific to a
visualization. These fields include spatial location (x, y
coordinates and item bounds), color (for stroke, fill, and text), size,
shape, and font. For a given input data set of type
Table
, Graph
, or
or Tree
, a corresponding instance of
VisualTable
, VisualGraph
, or
VisualTree
is created and stored in the
visualization. These data types inherit the data values of the source
data (and indeed, manipulate it directly) while additionally providing
the aforementioned visual variables unique to that generated
visual abstraction. Similarly, all Tuple
,
Node
, or Edge
instances used to represent an entry in the source data have a
corresponding VisualItem
,
NodeItem
, or EdgeItem
representing the interactive, visual realization of the backing data.
The mapping of source data to a visual abstraction is accomplished
using add(String, TupleSet)
and the other "add" methods. These
methods will automatically create the visual abstraction, and store it
in this visualization, associating it with a provided data group name
. This group name allows for queries to this visualization that
consider only VisualItem instances from that particular group. This is
quite useful when crafting Action
instances that
process only a particular group of visual data. The Visualization class
provides mechanisms for querying any or all groups within the visualization,
using one or both of the group name or a filtering
Predicate
to determine the items to
include (see items(Predicate)
for an examples). Source data
may be added multiple times to a Visualization under different group
names, allowing for multiple representations of the same backing data.
Additionally, the Visualization class supports VisualItem instances
that are not directly grounded in backing source data. Examples include
DecoratorItem
which "decorates" another pre-existing
VisualItem with a separate interactive visual object, and
AggregateItem
which provides an interactive visual
representation of an aggregated of other VisualItems. Methods for adding
data groups of these kinds include addDecorators(String, String)
and addAggregates(String)
.
All of the examples discussed above are examples of primary, or
visual, data groups of VisualItems. Visualizations also support
secondary, or focus data groups that maintain additional
collections of the VisualItems stored in the primary groups. Examples
include a set of focus items (such as those that have been clicked
by the user), selected items (items selected by a user), or search
items (all matches to a search query). The exact semantics of these
groups and the mechanisms by which they are populated is determined by
application creators, but some defaults are provided. The Visualization
class includes some default group names, namely FOCUS_ITEMS
,
SELECTED_ITEMS
, and SEARCH_ITEMS
for the above
mentioned tasks. By default, both the FOCUS_ITEMS
,
SELECTED_ITEMS
focus groups are included in the Visualization,
represented using DefaultTupleSet
instances.
Also, some of the interactive controls provided by the
prefuse.controls
package populate these sets by default. See
FocusControl
for an example.
Visualizations also maintain references to all the Display
instances providing interactive views of the content of this
visualization. Display
instances registers themselves with
the visualization either in their constructor or through
the Display.setVisualization(Visualization)
method, so they
do not otherwise need to be added manually. Displays can be configured
to show all or only a subset of the data in the Visualization. A
filtering Predicate
can be used to
control what items are drawn by the displaying, including limiting
the Display to particular data groups (for example, using a
InGroupPredicate
). The Visualization's
repaint()
method will trigger a repaint on all Displays
associated with the visualization.
Finally, the Visualization class provides a map of named
Action
instances that can be invoked to perform
processing on the VisualItems contained in the visualization.
Using the putAction(String, Action)
will add a named Action
to the visualization, registering the Action such that a reference
to this Visualization will be available within the scope of the
Action's Action.run(double)
method. Processing
Actions can later be invoked by name using the run(String)
method and other similar methods. This functionality not only
provides a convenient means of organizing a Visualization-specific
collection of processing Actions, it also allows for a layer of indirection
between an Action and its name. This allows Actions to be dynamically
swapped at runtime. For example, an application may make a call to
invoke an Action named "layout", but the actual layout processing maybe
be dynamically swapped by changing the Action that corresponds to that
name. For more information on processing Actions, see the
prefuse.action
packages and the top-level
Action
class.
Field Summary | |
---|---|
static java.lang.String |
ALL_ITEMS
Data group name for indicating all groups |
static java.lang.String |
FOCUS_ITEMS
Default data group name for focus items |
static java.lang.String |
SEARCH_ITEMS
Default data group name for search result items |
static java.lang.String |
SELECTED_ITEMS
Default data group name for selected items |
Constructor Summary | |
---|---|
Visualization()
Create a new, empty Visualization. |
Method Summary | |
---|---|
VisualTupleSet |
add(java.lang.String group,
TupleSet data)
Add a data set to this visualization, using the given data group name. |
VisualTupleSet |
add(java.lang.String group,
TupleSet data,
Predicate filter)
Add a data set to this visualization, using the given data group name. |
AggregateTable |
addAggregates(java.lang.String group)
Add a group of aggregates to this visualization. |
AggregateTable |
addAggregates(java.lang.String group,
Schema schema)
Add a group of aggregates to this visualization. |
protected void |
addDataGroup(java.lang.String group,
VisualTupleSet ts,
TupleSet src)
|
VisualTable |
addDecorators(java.lang.String group,
java.lang.String source)
Add a group of decorators to an existing visual data group. |
VisualTable |
addDecorators(java.lang.String group,
java.lang.String source,
Predicate filter)
Add a group of decorators to an existing visual data group. |
VisualTable |
addDecorators(java.lang.String group,
java.lang.String source,
Predicate filter,
Schema schema)
Add a group of decorators to an existing visual data group. |
VisualTable |
addDecorators(java.lang.String group,
java.lang.String source,
Schema schema)
Add a group of decorators to an existing visual data group. |
VisualTable |
addDerivedTable(java.lang.String group,
java.lang.String source,
Predicate filter,
Schema override)
Add a derived table, a VisualTable that is cascaded from an existing VisualTable. |
void |
addFocusGroup(java.lang.String group)
Add a new secondary, or focus, group to this visualization. |
void |
addFocusGroup(java.lang.String group,
TupleSet tset)
Add a new secondary, or focus, group to this visualization. |
VisualGraph |
addGraph(java.lang.String group,
Graph graph)
Adds a graph to this visualization, using the given data group name. |
VisualGraph |
addGraph(java.lang.String group,
Graph graph,
Predicate filter)
Adds a graph to this visualization, using the given data group name. |
VisualGraph |
addGraph(java.lang.String group,
Graph graph,
Predicate filter,
Schema nodeSchema,
Schema edgeSchema)
Adds a graph to this visualization, using the given data group name. |
VisualTable |
addTable(java.lang.String group)
Add an empty VisualTable to this visualization, using the given data group name. |
VisualTable |
addTable(java.lang.String group,
Schema schema)
Add an empty VisualTable to this visualization, using the given data group name and table schema. |
VisualTable |
addTable(java.lang.String group,
Table table)
Adds a data table to this visualization, using the given data group name. |
VisualTable |
addTable(java.lang.String group,
Table table,
Predicate filter)
Adds a data table to this visualization, using the given data group name. |
VisualTable |
addTable(java.lang.String group,
Table table,
Predicate filter,
Schema schema)
Adds a data table to this visualization, using the given data group name. |
VisualTable |
addTable(java.lang.String group,
Table table,
Schema schema)
Adds a data table to this visualization, using the given data group name. |
VisualTable |
addTable(VisualTable table)
Add a VisualTable to this visualization, using the table's pre-set group name. |
VisualTree |
addTree(java.lang.String group,
Tree tree)
Adds a tree to this visualization, using the given data group name. |
VisualTree |
addTree(java.lang.String group,
Tree tree,
Predicate filter)
Adds a tree to this visualization, using the given data group name. |
VisualTree |
addTree(java.lang.String group,
Tree tree,
Predicate filter,
Schema nodeSchema,
Schema edgeSchema)
Adds a tree to this visualization, using the given data group name. |
Activity |
alwaysRunAfter(java.lang.String before,
java.lang.String after)
Schedule the Action with the given name to always run after another Action finishes running. |
Activity |
cancel(java.lang.String action)
Cancel the Action with the given name, if it has been scheduled. |
protected void |
checkGroupExists(java.lang.String group)
|
void |
damageReport(VisualItem item,
java.awt.geom.Rectangle2D region)
Report damage to associated displays, indicating a region that will need to be redrawn. |
Action |
getAction(java.lang.String name)
Get the data processing Action with the given name. |
java.awt.geom.Rectangle2D |
getBounds(java.lang.String group)
Get the bounding rectangle for all items in the given group. |
java.awt.geom.Rectangle2D |
getBounds(java.lang.String group,
java.awt.geom.Rectangle2D r)
Get the bounding rectangle for all items in the given group. |
Display |
getDisplay(int idx)
Get the display at the given list index. |
int |
getDisplayCount()
Get the number of displays associated with this visualization. |
TupleSet |
getFocusGroup(java.lang.String group)
Retrieve the focus data group of the given group name. |
TupleSet |
getGroup(java.lang.String group)
Get the TupleSet associated with the given data group name. |
Renderer |
getRenderer(VisualItem item)
Get the renderer for the given item. |
RendererFactory |
getRendererFactory()
Get the RendererFactory used by this Visualization. |
TupleSet |
getSourceData(java.lang.String group)
Get the source data TupleSet backing the given visual data group. |
TupleSet |
getSourceData(VisualTupleSet ts)
Get the source data TupleSet backing the given visual tuple set. |
Tuple |
getSourceTuple(VisualItem item)
Get the Tuple from a backing source data set that corresponds most closely to the given VisualItem. |
TupleSet |
getVisualGroup(java.lang.String group)
Retrieve the visual data group of the given group name. |
VisualItem |
getVisualItem(java.lang.String group,
Tuple t)
Get the VisualItem associated with a source data tuple, if it exists. |
void |
invalidate(java.lang.String group)
Invalidate the bounds of all VisualItems in the given group. |
void |
invalidateAll()
Invalidate the bounds of all VisualItems in this visualization. |
boolean |
isInGroup(VisualItem item,
java.lang.String group)
Indicates if a given VisualItem is contained in the given visual data group. |
java.util.Iterator |
items()
Get an iterator over all items, visible or not. |
java.util.Iterator |
items(Predicate filter)
Get an iterator over all items which match the given Predicate filter. |
java.util.Iterator |
items(java.lang.String group)
Get an iterator over all items in the specified group. |
java.util.Iterator |
items(java.lang.String group,
Predicate filter)
Get an iterator over all items in the given group which match the given Predicate filter. |
java.util.Iterator |
items(java.lang.String group,
java.lang.String expr)
Get an iterator over all items in the given group which match the given filter expression. |
Action |
putAction(java.lang.String name,
Action action)
Add a data processing Action to this Visualization. |
Action |
removeAction(java.lang.String name)
Remove a data processing Action registered with this visualization. |
boolean |
removeGroup(java.lang.String group)
Removes a data group from this Visualization. |
void |
repaint()
Issue a repaint request, causing all displays associated with this visualization to be repainted. |
void |
reset()
Reset this visualization, clearing out all visualization tuples. |
Activity |
run(java.lang.String action)
Schedule the Action with the given name to run immediately. |
Activity |
runAfter(java.lang.String action,
long delay)
Schedule the Action with the given name to run after the specified delay. |
Activity |
runAfter(java.lang.String before,
java.lang.String after)
Schedule the Action with the given name to run after another Action finishes running. |
Activity |
runAt(java.lang.String action,
long startTime)
Schedule the Action with the given name to run at the specified time. |
void |
setInteractive(java.lang.String group,
Predicate p,
boolean value)
Sets the interactivity status for all items in a given data group matching a given filter predicate. |
void |
setRendererFactory(RendererFactory rf)
Set the RendererFactory used by this Visualization. |
void |
setValue(java.lang.String group,
Predicate p,
java.lang.String field,
java.lang.Object val)
Set a data field value for all items in a given data group matching a given filter predicate. |
void |
setVisible(java.lang.String group,
Predicate p,
boolean value)
Sets the visbility status for all items in a given data group matching a given filter predicate. |
int |
size(java.lang.String group)
Get the size of the given visual data group. |
java.util.Iterator |
visibleItems()
Get an iterator over all visible items. |
java.util.Iterator |
visibleItems(java.lang.String group)
Get an iterator over all visible items in the specified group. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ALL_ITEMS
public static final java.lang.String FOCUS_ITEMS
public static final java.lang.String SELECTED_ITEMS
public static final java.lang.String SEARCH_ITEMS
Constructor Detail |
---|
public Visualization()
Method Detail |
---|
public VisualTupleSet add(java.lang.String group, TupleSet data)
group
- the data group name for the visualized datadata
- the data to visualize
public VisualTupleSet add(java.lang.String group, TupleSet data, Predicate filter)
group
- the data group name for the visualized datadata
- the data to visualizefilter
- a filter Predicate determining which data Tuples in the
input data set are visualized
protected void checkGroupExists(java.lang.String group)
protected void addDataGroup(java.lang.String group, VisualTupleSet ts, TupleSet src)
public VisualTable addTable(java.lang.String group)
group
- the data group name for the visualized data
public VisualTable addTable(java.lang.String group, Schema schema)
group
- the data group name for the visualized dataschema
- the data schema to use for the VisualTable
public VisualTable addTable(java.lang.String group, Table table)
group
- the data group name for the visualized datatable
- the data table to visualizepublic VisualTable addTable(java.lang.String group, Table table, Predicate filter)
group
- the data group name for the visualized datatable
- the data table to visualizefilter
- a filter Predicate determining which data Tuples in the
input table are visualizedpublic VisualTable addTable(java.lang.String group, Table table, Schema schema)
group
- the data group name for the visualized datatable
- the data table to visualizeschema
- the data schema to use for the created VisualTablepublic VisualTable addTable(java.lang.String group, Table table, Predicate filter, Schema schema)
group
- the data group name for the visualized datatable
- the data table to visualizefilter
- a filter Predicate determining which data Tuples in the
input table are visualizedschema
- the data schema to use for the created VisualTablepublic VisualTable addTable(VisualTable table)
table
- the pre-built VisualTable to add
public VisualGraph addGraph(java.lang.String group, Graph graph)
group
- the data group name for the visualized graph. The nodes
and edges will be available in the "group.nodes" and "group.edges"
subgroups.graph
- the graph to visualizepublic VisualGraph addGraph(java.lang.String group, Graph graph, Predicate filter)
group
- the data group name for the visualized graph. The nodes
and edges will be available in the "group.nodes" and "group.edges"
subgroups.graph
- the graph to visualizefilter
- a filter Predicate determining which data Tuples in the
input graph are visualizedpublic VisualGraph addGraph(java.lang.String group, Graph graph, Predicate filter, Schema nodeSchema, Schema edgeSchema)
group
- the data group name for the visualized graph. The nodes
and edges will be available in the "group.nodes" and "group.edges"
subgroups.graph
- the graph to visualizefilter
- a filter Predicate determining which data Tuples in the
input graph are visualizednodeSchema
- the data schema to use for the visual node tableedgeSchema
- the data schema to use for the visual edge tablepublic VisualTree addTree(java.lang.String group, Tree tree)
group
- the data group name for the visualized tree. The nodes
and edges will be available in the "group.nodes" and "group.edges"
subgroups.tree
- the tree to visualizepublic VisualTree addTree(java.lang.String group, Tree tree, Predicate filter)
group
- the data group name for the visualized tree. The nodes
and edges will be available in the "group.nodes" and "group.edges"
subgroups.tree
- the tree to visualizefilter
- a filter Predicate determining which data Tuples in the
input graph are visualizedpublic VisualTree addTree(java.lang.String group, Tree tree, Predicate filter, Schema nodeSchema, Schema edgeSchema)
group
- the data group name for the visualized tree. The nodes
and edges will be available in the "group.nodes" and "group.edges"
subgroups.tree
- the tree to visualizefilter
- a filter Predicate determining which data Tuples in the
input graph are visualizednodeSchema
- the data schema to use for the visual node tableedgeSchema
- the data schema to use for the visual edge tablepublic AggregateTable addAggregates(java.lang.String group)
group
- the data group name for the aggregates.
AggregateTable
public AggregateTable addAggregates(java.lang.String group, Schema schema)
group
- the data group name for the aggregates.schema
- the data schema to use for the AggregateTable
AggregateTable
public VisualTable addDerivedTable(java.lang.String group, java.lang.String source, Predicate filter, Schema override)
group
- the data group to use for the derived tablesource
- the source data group to derive fromfilter
- a Predicate filter indicating which tuples of the
source group should be inheritable by the new groupoverride
- a data schema indicating which data fields
should not be inherited, but managed locally by the derived group
public VisualTable addDecorators(java.lang.String group, java.lang.String source)
DecoratorItem
instances that provide
access to the decorated item in addition to the standard VisualItem
properties. The generated table is created using the
addDerivedTable(String, String, Predicate, Schema)
method,
but with no VisualItem properties inherited from the source group.
group
- the data group to use for the decoratorssource
- the source data group to decorate
public VisualTable addDecorators(java.lang.String group, java.lang.String source, Schema schema)
DecoratorItem
instances that provide
access to the decorated item in addition to the standard VisualItem
properties.
group
- the data group to use for the decoratorssource
- the source data group to decorateschema
- schema indicating which variables should not be
inherited from the source data group and instead be managed locally
by the generated VisualTable
public VisualTable addDecorators(java.lang.String group, java.lang.String source, Predicate filter)
DecoratorItem
instances that provide
access to the decorated item in addition to the standard VisualItem
properties.
group
- the data group to use for the decoratorssource
- the source data group to decoratefilter
- a Predicate filter indicating which tuples of the
source group should be inheritable by the new group
public VisualTable addDecorators(java.lang.String group, java.lang.String source, Predicate filter, Schema schema)
DecoratorItem
instances that provide
access to the decorated item in addition to the standard VisualItem
properties.
group
- the data group to use for the decoratorssource
- the source data group to decoratefilter
- a Predicate filter indicating which tuples of the
source group should be inheritable by the new groupschema
- schema indicating which variables should not be
inherited from the source data group and instead be managed locally
by the generated VisualTable
public boolean removeGroup(java.lang.String group)
group
- the data group to remove
public void reset()
public TupleSet getSourceData(java.lang.String group)
public TupleSet getSourceData(VisualTupleSet ts)
public Tuple getSourceTuple(VisualItem item)
item
- the VisualItem for which to retreive the source tuple
public VisualItem getVisualItem(java.lang.String group, Tuple t)
group
- the data group from which to lookup the source tuple,
only primary visual groups are valid, focus groups will not workt
- the source data tuple
public TupleSet getGroup(java.lang.String group)
group
- a visual data group name
public boolean isInGroup(VisualItem item, java.lang.String group)
item
- the VisualItem instancegroup
- the data group to check for containment
public void addFocusGroup(java.lang.String group)
DefaultTupleSet
.
group
- the name of the focus group to addpublic void addFocusGroup(java.lang.String group, TupleSet tset)
group
- the name of the focus group to addtset
- the TupleSet for the focus grouppublic int size(java.lang.String group)
group
- the visual data group
public TupleSet getVisualGroup(java.lang.String group)
group
- the visual data group
public TupleSet getFocusGroup(java.lang.String group)
group
- the focus data group
public void invalidate(java.lang.String group)
group
- the visual data group to invalidatepublic void invalidateAll()
public java.util.Iterator visibleItems()
public java.util.Iterator visibleItems(java.lang.String group)
group
- the visual data group name
public java.util.Iterator items()
public java.util.Iterator items(Predicate filter)
filter
- a Predicate indicating which items should be included
in the iteration
public java.util.Iterator items(java.lang.String group)
group
- the visual data group name
public java.util.Iterator items(java.lang.String group, java.lang.String expr)
group
- the visual data group to iterate overexpr
- an expression string that should parse to a Predicate
indicating which items should be included in the iteration. The input
string will be parsed using the
ExpressionParser
class. If a
parse error occurs, an empty iterator is returned.
public java.util.Iterator items(java.lang.String group, Predicate filter)
group
- the visual data group to iterate overfilter
- a Predicate indicating which items should be included in
the iteration.
public void setValue(java.lang.String group, Predicate p, java.lang.String field, java.lang.Object val)
group
- the visual data group namep
- the filter predicate determining which items to modifyfield
- the data field / column name to setval
- the value to setpublic void setVisible(java.lang.String group, Predicate p, boolean value)
group
- the visual data group namep
- the filter predicate determining which items to modifyvalue
- the visibility value to setpublic void setInteractive(java.lang.String group, Predicate p, boolean value)
group
- the visual data group namep
- the filter predicate determining which items to modifyvalue
- the interactivity value to setpublic Action putAction(java.lang.String name, Action action)
name
- the name of the Actionaction
- the Action to addpublic Action getAction(java.lang.String name)
name
- the name of the Action
public Action removeAction(java.lang.String name)
name
- the name of the Action
public Activity run(java.lang.String action)
ActivityManager
, which runs in a dedicated
thread.
action
- the name of the Action to run
public Activity runAfter(java.lang.String action, long delay)
ActivityManager
, which runs in a dedicated
thread.
action
- the name of the Action to rundelay
- the amount of time to wait, in milliseconds, before
running the Action
public Activity runAt(java.lang.String action, long startTime)
ActivityManager
, which runs in a dedicated
thread.
action
- the name of the Action to runstartTime
- the absolute system time, in milliseconds since the
epoch, at which to run the Action.
public Activity runAfter(java.lang.String before, java.lang.String after)
ActivityManager
, which runs
in a dedicated thread.
before
- the name of the Action to wait forafter
- the name of the Action to run after the first one finishes
public Activity alwaysRunAfter(java.lang.String before, java.lang.String after)
ActivityManager
, which runs in a dedicated
thread.
before
- the name of the Action to wait forafter
- the name of the Action to run after the first one finishes
public Activity cancel(java.lang.String action)
action
- the name of the Action to cancel
public void setRendererFactory(RendererFactory rf)
rf
- the RendererFactory to use.public RendererFactory getRendererFactory()
public Renderer getRenderer(VisualItem item)
RendererFactory
and returns the result.
item
- the item to retreive the renderer for
Renderer
for drawing the
given itempublic void repaint()
public java.awt.geom.Rectangle2D getBounds(java.lang.String group)
group
- the visual data group
public java.awt.geom.Rectangle2D getBounds(java.lang.String group, java.awt.geom.Rectangle2D r)
group
- the visual data group namer
- a rectangle in which to store the computed bounding box
public int getDisplayCount()
public Display getDisplay(int idx)
idx
- the list index
public void damageReport(VisualItem item, java.awt.geom.Rectangle2D region)
item
- the item responsible for the damageregion
- the damaged region, in item-space coordinates
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |