package view; 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.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 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); } }