📄 visualization.java
字号:
String group, Table table, Schema schema)
{
return addTable(group, table, null, schema);
}
/**
* Adds a data table to this visualization, using the given data group
* name. A visual abstraction of the data will be created and registered
* with the visualization. An exception will be thrown if the group name
* is already in use.
* @param group the data group name for the visualized data
* @param table the data table to visualize
* @param filter a filter Predicate determining which data Tuples in the
* input table are visualized
* @param schema the data schema to use for the created VisualTable
*/
public synchronized VisualTable addTable(
String group, Table table, Predicate filter, Schema schema)
{
VisualTable vt = new VisualTable(table, this, group, filter, schema);
addDataGroup(group, vt, table);
return vt;
}
/**
* Add a VisualTable to this visualization, using the table's
* pre-set group name. An exception will be thrown if the group
* name is already in use. This method allows you to insert custom
* implementations of VisualTable into a Visualization. It is intended
* for advanced users and should <b>NOT</b> be used if you do not know
* what you are doing. In almost all cases, one of the other add methods
* is preferred.
* @param table the pre-built VisualTable to add
* @return the added VisualTable
*/
public synchronized VisualTable addTable(VisualTable table) {
addDataGroup(table.getGroup(), table, table.getParentTable());
table.setVisualization(this);
return table;
}
// -- Graphs and Trees ----------------------------------------------------
/**
* Adds a graph to this visualization, using the given data group
* name. A visual abstraction of the data will be created and registered
* with the visualization. An exception will be thrown if the group name
* is already in use.
* @param group the data group name for the visualized graph. The nodes
* and edges will be available in the "group.nodes" and "group.edges"
* subgroups.
* @param graph the graph to visualize
*/
public synchronized VisualGraph addGraph(String group, Graph graph) {
return addGraph(group, graph, null);
}
/**
* Adds a graph to this visualization, using the given data group
* name. A visual abstraction of the data will be created and registered
* with the visualization. An exception will be thrown if the group name
* is already in use.
* @param group the data group name for the visualized graph. The nodes
* and edges will be available in the "group.nodes" and "group.edges"
* subgroups.
* @param graph the graph to visualize
* @param filter a filter Predicate determining which data Tuples in the
* input graph are visualized
*/
public synchronized VisualGraph addGraph(
String group, Graph graph, Predicate filter)
{
return addGraph(group, graph, filter, VisualItem.SCHEMA, VisualItem.SCHEMA);
}
/**
* Adds a graph to this visualization, using the given data group
* name. A visual abstraction of the data will be created and registered
* with the visualization. An exception will be thrown if the group name
* is already in use.
* @param group the data group name for the visualized graph. The nodes
* and edges will be available in the "group.nodes" and "group.edges"
* subgroups.
* @param graph the graph to visualize
* @param filter a filter Predicate determining which data Tuples in the
* input graph are visualized
* @param nodeSchema the data schema to use for the visual node table
* @param edgeSchema the data schema to use for the visual edge table
*/
public synchronized VisualGraph addGraph(String group, Graph graph,
Predicate filter, Schema nodeSchema, Schema edgeSchema)
{
checkGroupExists(group); // check before adding sub-tables
String ngroup = PrefuseLib.getGroupName(group, Graph.NODES);
String egroup = PrefuseLib.getGroupName(group, Graph.EDGES);
VisualTable nt, et;
nt = addTable(ngroup, graph.getNodeTable(), filter, nodeSchema);
et = addTable(egroup, graph.getEdgeTable(), filter, edgeSchema);
VisualGraph vg = new VisualGraph(nt, et,
graph.isDirected(), graph.getNodeKeyField(),
graph.getEdgeSourceField(), graph.getEdgeTargetField());
vg.setVisualization(this);
vg.setGroup(group);
addDataGroup(group, vg, graph);
TupleManager ntm = new TupleManager(nt, vg, TableNodeItem.class);
TupleManager etm = new TupleManager(et, vg, TableEdgeItem.class);
nt.setTupleManager(ntm);
et.setTupleManager(etm);
vg.setTupleManagers(ntm, etm);
return vg;
}
/**
* Adds a tree to this visualization, using the given data group
* name. A visual abstraction of the data will be created and registered
* with the visualization. An exception will be thrown if the group name
* is already in use.
* @param group the data group name for the visualized tree. The nodes
* and edges will be available in the "group.nodes" and "group.edges"
* subgroups.
* @param tree the tree to visualize
*/
public synchronized VisualTree addTree(String group, Tree tree) {
return addTree(group, tree, null);
}
/**
* Adds a tree to this visualization, using the given data group
* name. A visual abstraction of the data will be created and registered
* with the visualization. An exception will be thrown if the group name
* is already in use.
* @param group the data group name for the visualized tree. The nodes
* and edges will be available in the "group.nodes" and "group.edges"
* subgroups.
* @param tree the tree to visualize
* @param filter a filter Predicate determining which data Tuples in the
* input graph are visualized
*/
public synchronized VisualTree addTree(
String group, Tree tree, Predicate filter)
{
return addTree(group, tree, filter, VisualItem.SCHEMA, VisualItem.SCHEMA);
}
/**
* Adds a tree to this visualization, using the given data group
* name. A visual abstraction of the data will be created and registered
* with the visualization. An exception will be thrown if the group name
* is already in use.
* @param group the data group name for the visualized tree. The nodes
* and edges will be available in the "group.nodes" and "group.edges"
* subgroups.
* @param tree the tree to visualize
* @param filter a filter Predicate determining which data Tuples in the
* input graph are visualized
* @param nodeSchema the data schema to use for the visual node table
* @param edgeSchema the data schema to use for the visual edge table
*/
public synchronized VisualTree addTree(String group, Tree tree,
Predicate filter, Schema nodeSchema, Schema edgeSchema)
{
checkGroupExists(group); // check before adding sub-tables
String ngroup = PrefuseLib.getGroupName(group, Graph.NODES);
String egroup = PrefuseLib.getGroupName(group, Graph.EDGES);
VisualTable nt, et;
nt = addTable(ngroup, tree.getNodeTable(), filter, nodeSchema);
et = addTable(egroup, tree.getEdgeTable(), filter, edgeSchema);
VisualTree vt = new VisualTree(nt, et, tree.getNodeKeyField(),
tree.getEdgeSourceField(), tree.getEdgeTargetField());
vt.setVisualization(this);
vt.setGroup(group);
addDataGroup(group, vt, tree);
TupleManager ntm = new TupleManager(nt, vt, TableNodeItem.class);
TupleManager etm = new TupleManager(et, vt, TableEdgeItem.class);
nt.setTupleManager(ntm);
et.setTupleManager(etm);
vt.setTupleManagers(ntm, etm);
return vt;
}
// -- Aggregates ----------------------------------------------------------
/**
* Add a group of aggregates to this visualization. Aggregates are
* used to visually represent groups of VisualItems.
* @param group the data group name for the aggregates.
* @return the generated AggregateTable
* @see prefuse.visual.AggregateTable
*/
public synchronized AggregateTable addAggregates(String group) {
return addAggregates(group, VisualItem.SCHEMA);
}
/**
* Add a group of aggregates to this visualization. Aggregates are
* used to visually represent groups of VisualItems.
* @param group the data group name for the aggregates.
* @param schema the data schema to use for the AggregateTable
* @return the generated AggregateTable
* @see prefuse.visual.AggregateTable
*/
public synchronized AggregateTable addAggregates(String group,
Schema schema)
{
AggregateTable vat = new AggregateTable(this, group, schema);
addDataGroup(group, vat, null);
return vat;
}
// -- Derived Tables and Decorators ---------------------------------------
/**
* Add a derived table, a VisualTable that is cascaded from an
* existing VisualTable. This is useful for creating VisualItems
* that inherit a set of visual properties from another group of
* VisualItems. This might be used, for example, in the creation
* of small multiples where only a few visual attributes vary
* across the multiples.
* @param group the data group to use for the derived table
* @param source the source data group to derive from
* @param filter a Predicate filter indicating which tuples of the
* source group should be inheritable by the new group
* @param override a data schema indicating which data fields
* should not be inherited, but managed locally by the derived group
* @return the derived VisualTable
*/
public synchronized VisualTable addDerivedTable(
String group, String source, Predicate filter, Schema override)
{
VisualTable src = (VisualTable)getGroup(source);
VisualTable vt = new VisualTable(src, this, group, filter, override);
addDataGroup(group, vt, getSourceData(source));
return vt;
}
/**
* Add a group of decorators to an existing visual data group. Decorators
* are VisualItem instances intended to "decorate" another VisualItem,
* such as providing a label or dedicated interactive control, and are
* realizeed as {@link prefuse.visual.DecoratorItem} instances that provide
* access to the decorated item in addition to the standard VisualItem
* properties. The generated table is created using the
* {@link #addDerivedTable(String, String, Predicate, Schema)} method,
* but with no VisualItem properties inherited from the source group.
* @param group the data group to use for the decorators
* @param source the source data group to decorate
* @return the generated VisualTable of DecoratorItem instances
*/
public synchronized VisualTable addDecorators(String group,String source) {
return addDecorators(group, source, (Predicate)null);
}
/**
* Add a group of decorators to an existing visual data group. Decorators
* are VisualItem instances intended to "decorate" another VisualItem,
* such as providing a label or dedicated interactive control, and are
* realizeed as {@link prefuse.visual.DecoratorItem} instances that provide
* access to the decorated item in addition to the standard VisualItem
* properties.
* @param group the data group to use for the decorators
* @param source the source data group to decorate
* @param schema schema indicating which variables should <b>not</b> be
* inherited from the source data group and instead be managed locally
* by the generated VisualTable
* @return the generated VisualTable of DecoratorItem instances
*/
public synchronized VisualTable addDecorators(
String group, String source, Schema schema)
{
return addDecorators(group, source, null, schema);
}
/**
* Add a group of decorators to an existing visual data group. Decorators
* are VisualItem instances intended to "decorate" another VisualItem,
* such as providing a label or dedicated interactive control, and are
* realizeed as {@link prefuse.visual.DecoratorItem} instances that provide
* access to the decorated item in addition to the standard VisualItem
* properties.
* @param group the data group to use for the decorators
* @param source the source data group to decorate
* @param filter a Predicate filter indicating which tuples of the
* source group should be inheritable by the new group
* @return the generated VisualTable of DecoratorItem instances
*/
public synchronized VisualTable addDecorators(
String group, String source, Predicate filter)
{
VisualTable t = addDerivedTable(group,source,filter,VisualItem.SCHEMA);
t.setTupleManager(new TupleManager(t, null, TableDecoratorItem.class));
return t;
}
/**
* Add a group of decorators to an existing visual data group. Decorators
* are VisualItem instances intended to "decorate" another VisualItem,
* such as providing a label or dedicated interactive control, and are
* realizeed as {@link prefuse.visual.DecoratorItem} instances that provide
* access to the decorated item in addition to the standard VisualItem
* properties.
* @param group the data group to use for the decorators
* @param source the source data group to decorate
* @param filter a Predicate filter indicating which tuples of the
* source group should be inheritable by the new group
* @param schema schema indicating which variables should <b>not</b> be
* inherited from the source data group and instead be managed locally
* by the generated VisualTable
* @return the generated VisualTable of DecoratorItem instances
*/
public synchronized VisualTable addDecorators(
String group, String source, Predicate filter, Schema schema)
{
VisualTable t = addDerivedTable(group, source, filter, schema);
t.setTupleManager(new TupleManager(t, null, TableDecoratorItem.class));
return t;
}
// -- Data Removal --------------------------------------------------------
/**
* Removes a data group from this Visualization. If the group is a focus
* group, the group will simply be removed, and any subsequent attempts to
* retrieve the group will return null. If the group is a primary group, it
* will be removed, and any members of the group will also be removed
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -