rendered paste bodyimport javax.swing.JFrame;import java.util.Iterator;import java.util.HashMap;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.action.layout.GridLayout;import prefuse.activity.Activity;import prefuse.controls.DragControl;import prefuse.controls.PanControl;import prefuse.controls.ZoomControl;import prefuse.data.Graph;import prefuse.data.Node;import prefuse.data.io.DataIOException;import prefuse.data.io.GraphMLReader;import prefuse.render.DefaultRendererFactory;import prefuse.render.PolygonRenderer;import prefuse.render.Renderer;import prefuse.render.ShapeRenderer;import prefuse.util.ColorLib;import prefuse.util.GraphicsLib;import prefuse.visual.AggregateItem;import prefuse.visual.AggregateTable;import prefuse.visual.VisualGraph;import prefuse.visual.VisualItem;public class Satisfaction extends Display { public static final String GRAPH = "graph"; public static final String NODES = "graph.nodes"; public static final String EDGES = "graph.edges"; public static final String AGGRS = "aggregates"; private HashMap<String,AggregateItem> regions; public Satisfaction() { super(new Visualization()); initDataGroups(); Renderer node_renderer = new ShapeRenderer(10); Renderer aggr_renderer = new ShapeRenderer(60); DefaultRendererFactory default_renderer_factory = new DefaultRendererFactory(); default_renderer_factory.setDefaultRenderer(node_renderer); default_renderer_factory.add("ingroup('aggregates')", aggr_renderer); m_vis.setRendererFactory(default_renderer_factory); // set up the visual operators // first set up all the color actions ColorAction nStroke = new ColorAction(NODES, VisualItem.STROKECOLOR); nStroke.setDefaultColor(ColorLib.gray(100)); nStroke.add("_hover", ColorLib.gray(50)); ColorAction nFill = new ColorAction(NODES, VisualItem.FILLCOLOR); nFill.setDefaultColor(ColorLib.gray(255)); nFill.add("_hover", ColorLib.gray(200)); ColorAction nEdges = new ColorAction(EDGES, VisualItem.STROKECOLOR); nEdges.setDefaultColor(ColorLib.gray(100)); ColorAction aStroke = new ColorAction(AGGRS, VisualItem.STROKECOLOR); aStroke.setDefaultColor(ColorLib.gray(200)); aStroke.add("_hover", ColorLib.rgb(255,100,100)); int[] palette = new int[] { ColorLib.rgba(255,200,200,150), ColorLib.rgba(200,255,200,150), ColorLib.rgba(200,200,255,150) }; ColorAction aFill = new DataColorAction(AGGRS, "region", Constants.NOMINAL, VisualItem.FILLCOLOR, palette); // bundle the color actions ActionList colors = new ActionList(); colors.add(nStroke); colors.add(nFill); colors.add(nEdges); colors.add(aStroke); colors.add(aFill); // now create the main layout routine ActionList layout = new ActionList(Activity.INFINITY); layout.add(colors); layout.add(new ForceDirectedLayout(GRAPH, true)); layout.add(new ForceDirectedLayout(AGGRS)); layout.add(new RepaintAction()); m_vis.putAction("layout", layout); // set up the display setSize(500,500); pan(250, 250); setHighQuality(true);// addControlListener(new AggregateDragControl()); addControlListener(new ZoomControl()); addControlListener(new PanControl()); // set things running m_vis.run("layout"); } private void initDataGroups() { Graph graph = null; try { graph = new GraphMLReader().readGraph("/satisfaction.xml"); } catch ( DataIOException e ) { e.printStackTrace(); System.err.println("Error loading graph. Exiting..."); System.exit(1); } VisualGraph visual_graph = m_vis.addGraph(GRAPH, graph); m_vis.setInteractive(EDGES, null, false); m_vis.setValue(NODES, null, VisualItem.SHAPE, new Integer(Constants.SHAPE_ELLIPSE)); AggregateTable aggr_table = m_vis.addAggregates(AGGRS); aggr_table.addColumn(VisualItem.POLYGON, float[].class); aggr_table.addColumn("region", String.class); regions = new HashMap<String,AggregateItem>(); AggregateItem aggr_item; Iterator<VisualItem> node_iterator = (Iterator<VisualItem>)visual_graph.nodes(); while (node_iterator.hasNext()) { VisualItem node = (VisualItem)node_iterator.next(); String region = (String)node.get("region"); String gender = (String)node.get("gender"); String age = (String)node.get("age"); if (!regions.containsKey(region)) { aggr_item = (AggregateItem)aggr_table.addItem(); aggr_item.setString("region", region); regions.put(region,aggr_item); } else { aggr_item = (AggregateItem)regions.get(region); } aggr_item.addItem((VisualItem)node); } } public static void main(String[] argv) { JFrame frame = satisfaction(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public static JFrame satisfaction() { Satisfaction sat = new Satisfaction(); JFrame frame = new JFrame("s a t i s f a c t i o n"); frame.getContentPane().add(sat); frame.pack(); return frame; }}/*class AggregateLayout extends Layout { private double[] points; public AggregateLayout(String aggr_group) { super(aggr_group); } public void run(double frac) { Iterator<AggregateItem> aggr_iterator; AggregateItem aggr_item; VisualItem visual_item; AggregateTable aggr_table = (AggregateTable)m_vis.getGroup(m_group); if (aggr_table.getTupleCount() == 0) return; int max_size = 0; aggr_iterator = aggr_table.tuples(); while (aggr_iterator.hasNext()) { aggr_item = (AggregateItem)aggr_iterator.next(); max_size = Math.max(max_size, 4*2*aggr_item.getAggregateSize()); } points = new double[max_size]; aggr_iterator = m_vis.visibleItems(m_group); while (aggr_iterator.hasNext()) { aggr_item = (AggregateItem)aggr_iterator.next(); if (aggr_item.getAggregateSize() == 0) continue; Iterator<VisualItem> visual_iterator*/