javadata-visualizationprefuse

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.


Solution

  • 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);