简体   繁体   English

预熔为每个节点组设置不同的颜色

[英]Prefuse set different color to every nodes group

I am new to prefuse and don't understand several things regarding nodes. 我是新手,不了解关于节点的几件事。

  1. How can I get an event raised whenever a node clicked? 每当节点单击时如何引发事件?
  2. How can I group similar nodes with the same color? 如何将具有相同颜色的相似节点分组?
  3. How can I keep an extra meta-data on every node? 如何在每个节点上保留额外的元数据?

Its important to say that I build the graph in real-time and not loading it from any file. 重要的是要说我是实时构建图形,而不是从任何文件加载图形。

Thanks, Ozrad. 谢谢,奥兹拉德。

Three answers to your three questions: 您的三个问题的三个答案:

  1. The best way to react on node clicks is to extend prefuse.controls.ControlAdapter and add it to the Display . 响应节点单击的最佳方法是扩展prefuse.controls.ControlAdapter并将其添加到Display
  2. prefuse.action.assignment.DataColorAction assigns color based on a data field. prefuse.action.assignment.DataColorAction根据数据字段分配颜色。 For more advanced scenarios you can use ColorAction with predicates or extend the class DataColorAction . 对于更高级的方案,可以将ColorAction与谓词ColorAction使用或扩展DataColorAction类。
  3. You can add columns to the node table to store metadata. 您可以将列添加到节点表中以存储元数据。 A column can also store objects if you need it: 如果需要,列还可以存储对象:

     vg.getNodeTable().addColumn("meta", MyMetaData.class); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM