package view; import clustering.VertexScore; import clustering.VertexString; import edu.uci.ics.jung.algorithms.layout.FRLayout; import edu.uci.ics.jung.algorithms.layout.Layout; import edu.uci.ics.jung.graph.Graph; import edu.uci.ics.jung.visualization.BasicVisualizationServer; import java.awt.Color; import java.awt.Dimension; import java.awt.LayoutManager; import java.awt.Paint; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import org.apache.commons.collections15.Transformer; public class Viewer { Graph graph; Layout layout; BasicVisualizationServer vv; JFrame frame; public Viewer(Graph graph) { this.graph = graph; this.frame = new JFrame("Graph View"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); layout = new FRLayout(graph); layout.setSize(new Dimension(1000,700)); vv = new BasicVisualizationServer(layout); vv.setPreferredSize(new Dimension(1000,700)); vv.getRenderContext().setVertexLabelTransformer(new VertexLabelTransformer()); } public void setGraph(Graph graph) { this.graph = graph; layout.setGraph(graph); frame.repaint(); } public void viewGraphRank(List> pagerank, List cluster){ VertexPaintRankTransformer vertexPaint = new VertexPaintRankTransformer(pagerank,cluster); vv.getRenderContext().setVertexFillPaintTransformer((Transformer) vertexPaint); frame.getContentPane().add(vv); frame.pack(); frame.repaint(); frame.setVisible(true); } public void viewGraph(List cut){ if(cut != null){ VertexPaintTransformer vertexPaint = new VertexPaintTransformer(cut); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); } frame.getContentPane().add(vv); frame.pack(); frame.repaint(); frame.setVisible(true); } }