prefuse.Visualization类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(17.0k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中prefuse.Visualization类的一些代码示例,展示了Visualization类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Visualization类的具体详情如下:
包路径:prefuse.Visualization
类名称:Visualization

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., prefuse.data.Table, prefuse.data.Graph, or prefuse.data.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 prefuse.data.Table, prefuse.data.Graph, or or prefuse.data.Tree, a corresponding instance of prefuse.visual.VisualTable, prefuse.visual.VisualGraph, or prefuse.visual.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 prefuse.data.Tuple, prefuse.data.Node, or prefuse.data.Edgeinstances used to represent an entry in the source data have a corresponding prefuse.visual.VisualItem, prefuse.visual.NodeItem, or prefuse.visual.EdgeItemrepresenting 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 prefuse.action.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 prefuse.data.expression.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 prefuse.visual.DecoratorItem which "decorates" another pre-existing VisualItem with a separate interactive visual object, and prefuse.visual.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 prefuse.data.tuple.DefaultTupleSet instances. Also, some of the interactive controls provided by the prefuse.controls package populate these sets by default. See prefuse.controls.FocusControl for an example.

Visualizations also maintain references to all the Displayinstances 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 prefuse.data.expression.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 prefuse.visual.expression.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 prefuse.action.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 prefuse.action.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 prefuse.action.Action class.
[中]表示交互式可视化的中心数据结构。此类负责管理源数据和屏幕上的VisualItems之间的映射,维护一个显示实例列表,该列表负责呈现该可视化内容并与之交互,并提供一个命名动作实例集合,用于执行数据处理,如布局、动画和大小,形状和颜色分配。
可视化类的主要职责是创建输入数据的可视化抽象。无论数据结构如何(即prefuse.data.Table、prefuse.data.Graph或prefuse.data.Tree),此类都会获取源数据,例如从文件(请参见prefuse.data.io)或关系数据库(请参见prefuse.data.io.sql)加载的数据,并创建数据的可视化表示。这些数据的可视化表示本身就是数据集,提供了对要可视化的底层源数据的访问,同时还添加了特定于可视化的附加数据字段。这些字段包括空间位置(x、y坐标和项目边界)、颜色(笔划、填充和文本)、大小、形状和字体。对于prefuse类型的给定输入数据集。数据桌子,预备使用。数据图形,或预使用。数据树,预使用的对应实例。视力的可视的,预先使用的。视力的VisualGraph,或prefuse。视力的VisualTree创建并存储在visualization中。这些数据类型继承源数据的数据值(实际上,直接操作它),同时还提供了生成的视觉抽象所特有的上述视觉变量。同样,所有的预使用。数据元组,预使用。数据节点,或预使用。数据用于表示源数据中的条目的EdgeInstance具有相应的预使用。视力的VisualItem,使用前。视力的NodeItem,或prefuse。视力的EdgeItem表示支持数据的交互式可视化实现。
源数据到可视化抽象的映射是使用#add(String,TupleSet)和其他“add”方法完成的。这些方法将自动创建可视化抽象,并将其存储在此可视化中,并将其与提供的数据组名称相关联。这个组名称允许对该可视化的查询,该视图只考虑来自该特定组的VisualItabor实例。这在制作prefuse时非常有用。行动仅处理一组特定可视数据的操作实例。Visualization类提供了使用组名或过滤预使用中的一个或两个来查询可视化中的任何或所有组的机制。数据表示谓词以确定要包含的项(有关示例,请参见#items(谓词))。源数据可以在不同的组名下多次添加到可视化中,从而允许对同一支持数据进行多个表示。
此外,Visualization类支持不直接基于支持源数据的VisualItem实例。例如预使用。视力的DecoratorItem,它用一个单独的交互式视觉对象“装饰”另一个预先存在的VisualItem,并预使用。视力的AggregateItem,它提供了一个交互式的可视化表示,表示其他可视化元素的聚合。添加这类数据组的方法包括#addDecorators(String,String)和#addAggregates(String)。
上面讨论的所有示例都是VisualItems的主要或可视数据组的示例。可视化还支持辅助数据组或焦点数据组,这些数据组维护存储在主组中的VisualItems的其他集合。示例包括一组焦点项目(例如用户已单击的项目)、选定项目(用户选择的项目)或搜索项目(与搜索查询的所有匹配项)。这些组的确切语义及其填充机制由应用程序创建者决定,但提供了一些默认值。Visualization类包括一些默认组名,即上述任务的#焦点#项、#选定#项和#搜索#项。默认情况下,#FOCUS_项和#SELECTED_项焦点组都包含在可视化中,使用prefuse表示。数据元组。DefaultTupleSet实例。此外,prefuse还提供了一些交互式控件。默认情况下,控件包填充这些集合。参见预使用。控制。例如FocusControl。
Visualizations还维护对所有DisplayInstance的引用,这些DisplayInstance提供了该可视化内容的交互视图。显示实例在其构造函数中或通过Display#setVisualization(visualization)方法向可视化注册,因此不需要手动添加它们。显示器可以配置为显示可视化中的所有数据或仅显示数据的一个子集。过滤预使用。数据表示谓词可用于控制显示所绘制的项目,包括将显示限制为特定的数据组(例如,使用prefuse.visual.expression.InGroupPredicate)。可视化的#repaint()方法将在与可视化相关的所有显示上触发重新绘制。
最后,Visualization类提供了一个命名预使用的映射。行动可以调用的操作实例,以对可视化中包含的VisualItems执行处理。使用#putAction(String,Action)将向可视化添加一个命名的操作,并注册该操作,以便在该操作的预使用范围内提供对该可视化的引用。行动动作#跑(双)法。以后可以使用#run(String)方法和其他类似方法按名称调用处理操作。此功能不仅提供了一种方便的方式来组织特定于可视化的处理动作集合,还允许在动作及其名称之间设置一层间接层。这允许在运行时动态交换操作。例如,应用程序可能会调用名为“layout”的操作,但实际的布局处理可能会通过更改与该名称对应的操作来动态交换。有关处理操作的更多信息,请参阅预使用。操作包和顶级预使用。行动动作课。

代码示例

代码示例来源:origin: es.ucm.fdi.gaia/jCOLIBRI

/**
 *  Updating the graph
 */
public void setGraph(Graph g){
 vis.cancel("layout");
 vis.removeGroup(GRAPH);
 vis.getGroup(Visualization.SEARCH_ITEMS).clear();
 this.remove(spanel);
 vis.addGraph(GRAPH, g);
 addSearchPanel();
 vis.setInteractive(EDGES, null, false);
 setFocus(0);
 stop.setText("Stop");
 vis.run("layout");
 
}

代码示例来源:origin: org.qi4j.tool/org.qi4j.tool.envisage

@Override
public void run( Graph graph )
{
  m_vis.add( GRAPH, graph );
  run();
  m_vis.run( AUTO_ZOOM_ACTION );
  // disable edges interactive
  m_vis.setInteractive( GRAPH_EDGES, null, false );
}

代码示例来源:origin: de.sciss/prefuse-core

/**
 * Get the TupleSet associated with the given data group name. 
 * @param group a visual data group name
 * @return the data group TupleSet
 */
public TupleSet getGroup(String group) {
  TupleSet ts = getVisualGroup(group);
  if ( ts == null )
    ts = getFocusGroup(group);
  return ts;
}

代码示例来源:origin: nz.ac.waikato.cms.weka/prefuseTree

public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) {
 m_vis.cancel("animatePaint");
 m_vis.run("fullPaint");
 m_vis.run("animatePaint");
}
 });

代码示例来源:origin: es.ucm.fdi.gaia/jCOLIBRI

public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) {
   vis.run("draw");
   vis.repaint();
 }
});

代码示例来源:origin: es.ucm.fdi.gaia/jCOLIBRI

vis = new Visualization();
vg = vis.addGraph(GRAPH, graph);
vis.setInteractive(EDGES, null, false);
drf.add("ingroup('aggregates')", polyR);
vis.setRendererFactory(drf);
TupleSet focusGroup = vis.getGroup(Visualization.FOCUS_ITEMS); 
focusGroup.addTupleSetListener(new TupleSetListener() {
  public void tupleSetChanged(TupleSet ts, Tuple[] add, Tuple[] rem)
vis.putAction("draw", draw);
vis.putAction("layout", layout);
vis.runAfter("draw", "layout");
 vis.addFocusGroup(Visualization.SEARCH_ITEMS, search);
 search.addTupleSetListener(new TupleSetListener() {
  public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) {
vis.run("draw");
vis.run("layout");

代码示例来源:origin: nz.ac.waikato.cms.weka/prefuseGraph

super(new BorderLayout());
m_vis = new Visualization();
m_vis.setRendererFactory(new DefaultRendererFactory(tr));
m_vis.getRendererFactory();
((LabelRenderer)drf.getDefaultRenderer()).setTextField(LABEL);
m_vis.putAction(DRAW, draw);
m_vis.putAction(LAYOUT, animate);
m_vis.runAfter(DRAW, LAYOUT);
m_vis.removeGroup(GRAPH);
VisualGraph vg = m_vis.addGraph(GRAPH, graph);
m_vis.setValue(GRAPH_EDGES, null, VisualItem.INTERACTIVE, Boolean.FALSE);
VisualItem f = (VisualItem)vg.getNode(0);
m_vis.getGroup(Visualization.FOCUS_ITEMS).setTuple(f);
f.setFixed(false);
TupleSet focusGroup = m_vis.getGroup(Visualization.FOCUS_ITEMS); 
focusGroup.addTupleSetListener(new TupleSetListener() {
 public void tupleSetChanged(TupleSet ts, Tuple[] add, Tuple[] rem)
m_vis.run(DRAW);

代码示例来源:origin: nz.ac.waikato.cms.weka/prefuseTree

super(new Visualization());
m_vis.add(tree, t);
m_vis.setRendererFactory(rf);
ItemAction textColor = new ColorAction(treeNodes,
VisualItem.TEXTCOLOR, ColorLib.rgb(0,0,0));
m_vis.putAction("textColor", textColor);
repaint.add(nodeColor);
repaint.add(new RepaintAction());
m_vis.putAction("repaint", repaint);
m_vis.putAction("fullPaint", fullPaint);
animatePaint.add(new ColorAnimator(treeNodes));
animatePaint.add(new RepaintAction());
m_vis.putAction("animatePaint", animatePaint);
m_orientation, 50, 0, 8);
treeLayout.setLayoutAnchor(new Point2D.Double(25,300));
m_vis.putAction("treeLayout", treeLayout);
m_vis.putAction("subLayout", subLayout);
filter.add(nodeColor);
filter.add(edgeColor);
m_vis.putAction("filter", filter);

代码示例来源:origin: neueda/jetbrains-plugin-graph-database-support

public GraphDisplay(LookAndFeelService lookAndFeel) {
  super(new Visualization());
  graph.addColumn(TITLE, String.class);
  m_vis.addGraph(GRAPH, graph, null, SchemaProvider.provideNodeSchema(), SchemaProvider.provideEdgeSchema());
  m_vis.setInteractive(EDGES, null, false);
  m_vis.setValue(NODES, null, VisualItem.SHAPE, SHAPE_ELLIPSE);
  m_vis.addDecorators(NODE_LABEL, NODES, SchemaProvider.provideFontSchema());
  m_vis.setRendererFactory(setupRenderer());
  m_vis.putAction(LAYOUT, LayoutProvider.forceLayout(m_vis, this, lookAndFeel));
  m_vis.putAction(REPAINT, LayoutProvider.repaintLayout(lookAndFeel));

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-xml-nbprefuse

protected void runActivity(Visualization vis) {
  if ( activity != null ) {
    vis.run(activity);
  }
}

代码示例来源:origin: org.qi4j.tool/org.qi4j.tool.envisage

super( new Visualization() );
rf.add( edgesPredicate, edgeRenderer );
rf.add( usesPredicate, usesRenderer );
m_vis.setRendererFactory( rf );
m_vis.putAction( "textColor", textColor );
repaint.add( nodeColor );
repaint.add( new RepaintAction() );
m_vis.putAction( REPAINT_ACTION, repaint );
m_vis.putAction( FULL_PAINT_ACTION, fullPaint );
animatePaint.add( new ColorAnimator( GRAPH_NODES ) );
animatePaint.add( new RepaintAction() );
m_vis.putAction( ANIMATE_PAINT_ACTION, animatePaint );
m_vis.putAction( LAYOUT_ACTION, treeLayout );
m_vis.putAction( SUB_LAYOUT_ACTION, subLayout );
filter.add( usesColor );
filter.add( usesArrow );
m_vis.putAction( FILTER_ACTION, filter );
animate.add( new ColorAnimator( GRAPH_NODES ) );
animate.add( new RepaintAction() );
m_vis.putAction( ANIMATE_ACTION, animate );

代码示例来源:origin: apache/chukwa

this.viz = new Visualization();
this.setupRenderer();
 this.viz.putAction("xlabels",xlabels);
 AxisLabelLayout ylabels = new AxisLabelLayout("ylab", yaxis, ylabBound);
 this.viz.putAction("ylabels",ylabels);
 ActionList labeldraw = new ActionList();
 labeldraw.add(sl);
 this.viz.putAction(labelgroup, labeldraw);
 this.viz.putAction(legendshapegroup, legenddraw);
 ActionList legendlabelsdraw = new ActionList();
 legendlabelsdraw.add(legendlabels_sl);
 this.viz.putAction(legendgroup,legendlabelsdraw);
this.viz.putAction("draw",draw);
this.viz.run("draw");
this.viz.run("xlabels");
this.viz.run("ylabels");

代码示例来源:origin: org.qi4j.tool/org.qi4j.tool.envisage

Iterator iter = m_vis.items( GRAPH_NODES );
while( iter.hasNext() )
  TupleSet ts = m_vis.getFocusGroup( Visualization.FOCUS_ITEMS );
  ts.setTuple( item );
  m_vis.run( FILTER_ACTION );

代码示例来源:origin: org.qi4j.tool/org.qi4j.tool.envisage

super( new Visualization() );
rf.add( new InGroupPredicate( LABELS ), labelRenderer );
rf.add( usesPredicate, usesRenderer );
m_vis.setRendererFactory( rf );
colors.add( usesColor );
colors.add( usesArrow );
m_vis.putAction( COLORS_ACTION, colors );
autoPan.add( new AutoPanAction() );
autoPan.add( new RepaintAction() );
m_vis.putAction( AUTO_PAN_ACTION, autoPan );
layout.add( new LabelLayout( LABELS ) );
layout.add( autoPan );
m_vis.putAction( LAYOUT_ACTION, layout );

代码示例来源:origin: apache/chukwa

this.viz = new Visualization();
VisualTable data_tab_viz = viz.addTable(maingroup, hd.agg_tab);
setupHeatmap(data_tab_viz, hd);
 ActionList legenddraw = new ActionList();
 legenddraw.add(legend_sa1);
 this.viz.putAction(legendshapegroup, legenddraw);
 ActionList legendlabelsdraw = new ActionList();
 legendlabelsdraw.add(legendlabels_sl1);
 this.viz.putAction(legendgroup,legendlabelsdraw);
 ActionList legenddraw = new ActionList();
 legenddraw.add(legend_sa2);
 this.viz.putAction(addinfoshapegroup, legenddraw);
 ActionList legendlabelsdraw = new ActionList();
 legendlabelsdraw.add(legendlabels_sl2);
 this.viz.putAction(addinfogroup,legendlabelsdraw);

代码示例来源:origin: com.googlecode.obvious/obvious-prefuse

/**
 * Inits a standard prefuse visualization.
 * @param param param of the visualization.
 */
protected void initVisualization(Map<String, Object> param) {
 groupName = "tupleset";
 if (param != null) {
  if (param.containsKey(GROUP_NAME)) {
   groupName = (String) param.get(GROUP_NAME);
  }
  if (param.containsKey(DIRECTED)) {
   directed = (Boolean) param.get(DIRECTED);
  }
  if (param.containsKey(NODE_KEY)) {
   nodeKey = (String) param.get(NODE_KEY);
  }
 }
 vis = new prefuse.Visualization();
 if (this.getData() instanceof Table) {
  vis.addTable(groupName, getPrefuseTable());
 } else if (this.getData() instanceof Network) {
  vis.addGraph(groupName, getPrefuseNetwork());
 }
}

代码示例来源:origin: de.sciss/prefuse-core

/**
 * Get an iterator over all visible items.
 * @return an iterator over all visible items.
 */
public Iterator visibleItems() {
  return items(VisiblePredicate.TRUE);
}

代码示例来源:origin: apache/chukwa

ActionList gl_list = new ActionList();
gl_list.add(gl);
this.viz.putAction("gridlayout",gl_list);
this.viz.run("gridlayout");

代码示例来源:origin: com.googlecode.obvious/obvious-prefuse

@Override
protected void initVisualization(Map<String, Object> param) {
 prefuse.Visualization prefVis = new prefuse.Visualization();
 this.setPrefVisualization(prefVis);
 groupName = DEF_NAME;
 this.getPrefVisualization().add(groupName, getPrefuseTable());
 ShapeRenderer mShapeR = new ShapeRenderer(2);
 DefaultRendererFactory rf = new DefaultRendererFactory(mShapeR);

代码示例来源:origin: org.qi4j.tool/org.qi4j.tool.envisage

@Override
public void run( Graph graph )
{
  // add the GRAPH to the visualization
  m_vis.add( GRAPH, graph );
  // hide edges
  Predicate edgesPredicate = (Predicate) ExpressionParser.parse( "ingroup('graph.edges') AND [" + USES_EDGES + "]==false", true );
  m_vis.setVisible( GRAPH_EDGES, edgesPredicate, false );
  m_vis.setInteractive( GRAPH_EDGES, null, false );
  // make node interactive
  m_vis.setInteractive( GRAPH_NODES, null, true );
  // add LABELS to the visualization
  Predicate labelP = (Predicate) ExpressionParser.parse( "VISIBLE()" );
  m_vis.addDecorators( LABELS, GRAPH_NODES, labelP, LABEL_SCHEMA );
  run();
}

相关文章