在 Prefuse 中创建数据
我是 Prefuse 的新手。演示示例都是从文件/数据库加载的数据。有没有办法动态创建数据而不是从文件加载。例如,我想创建一个树数据结构并将其可视化。任何简单的工作示例都会对我很有帮助。
I am new to Prefuse. The demo examples are all loaded data from a file/database. Is there any way to create the data dynamically instead of loading from file. For example, I want to create a tree data structure and visualize this. Any simple working example would be really helpful for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚一直在解决这个问题。这是
Example.java
的调整版本,它展示了实现这一目标的一种方法。我不是从
socialnet.xml
加载数据,而是以编程方式生成数据(基于Aggregate.java
但没有聚合内容)并向每个添加一个字段节点
和每个边
。Node
字段是一个简单的布尔标志,用于控制其渲染的颜色;Edge
字段是一个标签 - 但它还没有被渲染。我还在研究那个! :-)特定于问题的代码位于
makeGraph()
中。基本方法是创建一个表(节点和边各一个),并向这些表中添加列来定义数据的形状;然后当您添加节点和边时,您可以添加相应的数据。一个问题是,对于边,您必须包含边的源/目标节点的列 - 有关更多详细信息,请参阅Graph
和Table
文档。还有其他方法可以做到这一点(例如涉及Schema
),但我还没有弄清楚它们。希望这有帮助。
I've just been attacking this problem. Here's a tweaked version of
Example.java
which shows one way to make it happen.Instead of loading data from
socialnet.xml
, I'm generating it programatically (based onAggregate.java
but without the aggregation stuff) and adding one field to eachNode
and eachEdge
. TheNode
field is a simple boolean flag which controls the colour it's rendered; theEdge
field is a label - but it's not being rendered yet. I'm still working on that one! :-)The question-specific code is in
makeGraph()
. The basic approach is to create aTable
(well, one each for nodes and edges), and add columns to those tables defining the shape of the data; then when you add your nodes and edges, you can add the corresponding data. One gotcha is that for edges you must include columns for the edge's source/target nodes - see theGraph
andTable
documentation for more details. There are other ways to do this (e.g. involvingSchema
) but I haven't sussed them out yet.Hope this helps.