简体   繁体   中英

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 .
  2. prefuse.action.assignment.DataColorAction assigns color based on a data field. For more advanced scenarios you can use ColorAction with predicates or extend the class 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); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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