I just attacked this problem. Here's a modified version of Example.java that shows one way to do this.
Instead of loading data from socialnet.xml , I generate it programmatically (based on Aggregate.java , but without aggregation) and adding one field to each Node and each Edge . The Node field is a simple Boolean flag that controls the color that it displays; the Edge field is a label, but it is not yet displayed. I'm still working on it !:-)
The code for a specific question is in makeGraph() . The main approach is to create a Table (well, one for nodes and edges) and add columns to those tables that define the data form; then when you add your nodes and edges, you can add the corresponding data. One of them is that for edges you should include columns for end nodes / target nodes - for more information see the Graph and Table documentation. There are other ways to do this (for example, involving Schema ), but I have not discussed them yet.
Hope this helps.
import javax.swing.JFrame; import prefuse.Constants; import prefuse.Display; import prefuse.Visualization; import prefuse.action.ActionList; import prefuse.action.RepaintAction; import prefuse.action.assignment.ColorAction; import prefuse.action.assignment.DataColorAction; import prefuse.action.layout.graph.ForceDirectedLayout; import prefuse.activity.Activity; import prefuse.controls.DragControl; import prefuse.controls.PanControl; import prefuse.controls.ZoomControl; import prefuse.data.Edge; import prefuse.data.Graph; import prefuse.data.Node; import prefuse.data.Table; import prefuse.render.DefaultRendererFactory; import prefuse.render.EdgeRenderer; import prefuse.render.Renderer; import prefuse.render.ShapeRenderer; import prefuse.util.ColorLib; import prefuse.visual.VisualItem; public class Example extends Display { private Graph makeGraph() {
source share