通过用于Java的PREFUSE库显示节点时出现问题? [英] Problem in displaying nodes through PREFUSE library for Java?

查看:53
本文介绍了通过用于Java的PREFUSE库显示节点时出现问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PREFUSE 库开发图形化的数据视图.

I am developing a graphical view of data using PREFUSE library.

我的图中有3种节点:

  1. 应用
  2. 数据库
  3. 界面

下面是我的包含图表的.xml文件的摘录

Below are some excerpts from my .xml file containing graph

<node id="AP-1">
<data key="name">Application1</data>
<data key="type">APPLICATION</data>
</node>

<node id="DB-1">
<data key="name">Database1</data>
<data key="type">DATABASE</data>
</node>

<node id="IT-1">
<data key="name">Interface1</data>
<data key="type">INTERFACE</data>
</node>

我想显示以上3个差异.具有3个差异的各种节点.形状如下:

I want to show the above 3 diff. kinds of nodes with 3 diff. kinds of shapes as follows:

  1. 按矩形应用
  2. 自定义形状(圆柱形状,通常用于表示数据库)的数据库
  3. 按界面圈

我首先阅读了.xml文件,

I have first read the .xml file in a

图g

Q1.现在如何区分数据组中的这三种节点.我认为我应该写谓词.我已经阅读了完整的谓词和表达式手册,以了解它们的用法,但无法编写谓词来区分它们.那么谓词是什么?

Q1. Now how can I distinguish these 3 kinds of nodes in a datagroup. I think I should write predicates. I have read the whole predicates and expressions manuals for prefuse but couldn't write a predicate to distinguish them. So what will be the predicate for that?

Q2.如何指定我的自定义形状以及如何设置可以渲染我开发的自定义形状的渲染器?

Q2. How to specify my custom shape and how to set a renderer that can render the custom shape developed by me?

推荐答案

为节点分配不同形状的范例是使用DataShapeAction

The paradigm for assigning different shapes to nodes is with a DataShapeAction

例如在会议"演示中(同样适用于表节点)

E.g. in the "Congress" demo (the same applies to Nodes as Tables):

int[] shapes = new int[]
            { Constants.SHAPE_RECTANGLE, Constants.SHAPE_DIAMOND };
DataShapeAction shape = new DataShapeAction(group, "Senate", shapes);

这会根据参议院"数据字段中的值为数据点分配不同的形状,即参议员是一种形状,议员是另一种形状(按某种顺序排列(API中对此有多种控件,请参见常量)..ORDINAL(例如).

This assigns different shapes to data points based on the value in the "Senate" data field, i.e. senators are one shape, and congressmen are another shape, in some order (there are various controls for this in the API, see Constants.ORDINAL for an example).

因此,换句话说,您可能会使用类型"数据字段来指示节点属于哪种节点,然后使用DataShapeAction分配不同的形状.

So, in other words, you would probably use your "type" data field to indicate what kind of node the node was, and then use a DataShapeAction to assign different shapes.

当然可以定义新的形状,但是还需要进行一些修改.我会尝试给您一个更好的答案,但是我想最直接的方法是编写自己的noderenderer子类,该子类能够绘制所需的形状,然后扩展DataShapeAction来处理一些问题.新数据类型的标志.希望以后能有更多的了解.

Defining a new shape is certainly possible, but will require some more tinkering. I'll try to get back to you with a better answer, but I'm guessing the most straightforward way would be to write your own subclass of the noderenderer that was capable of drawing your desired shape, and then perhaps extending DataShapeAction to handle some flag for your new data type. More on that later, though, hopefully.

这篇关于通过用于Java的PREFUSE库显示节点时出现问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆