Changeset 34 for branches/localSpectral/src/view/Viewer.java
- Timestamp:
- Oct 30, 2010, 8:39:22 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/localSpectral/src/view/Viewer.java
r32 r34 4 4 import clustering.VertexScore; 5 5 import clustering.VertexString; 6 import edu.uci.ics.jung.algorithms.layout.DAGLayout; 6 7 import edu.uci.ics.jung.algorithms.layout.FRLayout; 8 import edu.uci.ics.jung.algorithms.layout.KKLayout; 7 9 import edu.uci.ics.jung.algorithms.layout.Layout; 8 10 import edu.uci.ics.jung.graph.Graph; 9 11 import edu.uci.ics.jung.visualization.BasicVisualizationServer; 12 import java.awt.BorderLayout; 10 13 import java.awt.Color; 11 14 import java.awt.Dimension; 15 import java.awt.FlowLayout; 12 16 import java.awt.LayoutManager; 13 17 import java.awt.Paint; 18 import java.awt.event.ActionEvent; 19 import java.awt.event.ActionListener; 14 20 import java.util.ArrayList; 15 21 import java.util.List; 22 import javax.swing.JButton; 16 23 import javax.swing.JFrame; 24 import javax.swing.JPanel; 25 import javax.swing.JTextArea; 26 import javax.xml.bind.JAXB; 17 27 import org.apache.commons.collections15.Transformer; 18 28 … … 25 35 BasicVisualizationServer<V,E> vv; 26 36 JFrame frame; 37 JButton button; 38 JPanel button_panel; 39 JTextArea text ; 27 40 28 public Viewer(Graph<V,E> graph) { 41 public Viewer(Graph<V,E> graph, ActionListener listerner) { 42 this.button = new JButton("Next"); 43 this.button.addActionListener(listerner); 44 this.button_panel = new JPanel(new BorderLayout(100,100)); 45 this.button_panel.add(button); 46 this.text = new JTextArea(); 47 this.text.setEditable(false); 48 this.text.setBackground(Color.yellow); 49 29 50 this.graph = graph; 30 this.frame = new JFrame("Graph View"); 31 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 32 layout = new FRLayout(graph); 33 layout.setSize(new Dimension(1000,700)); 51 this.frame = new JFrame("Clustering with Google PageRank"); 52 this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 53 KKLayout kklayout = new KKLayout(graph); 54 kklayout.setAdjustForGravity(false); 55 kklayout.setMaxIterations(100); 56 this.layout = kklayout; 57 layout.setSize(new Dimension(1280,700)); 34 58 vv = new BasicVisualizationServer(layout); 35 vv.setPreferredSize(new Dimension(1000,700)); 59 vv.setPreferredSize(new Dimension(1280,700)); 60 vv.add(this.button_panel); 61 vv.add(this.text); 36 62 vv.getRenderContext().setVertexLabelTransformer(new VertexLabelTransformer<V, String>()); 63 37 64 } 38 65 66 public void setText(String text){ 67 this.text.setText(text); 68 } 39 69 public void setGraph(Graph<V, E> graph) { 40 70 this.graph = graph; … … 43 73 } 44 74 45 public void viewGraphRank(List<VertexScore<V>> pagerank, List<V> cluster){46 VertexPaintRankTransformer vertexPaint = new VertexPaintRankTransformer(pagerank, cluster);75 public void viewGraphRank(List<VertexScore<V>> pagerank, V seed_node){ 76 VertexPaintRankTransformer vertexPaint = new VertexPaintRankTransformer(pagerank,seed_node); 47 77 vv.getRenderContext().setVertexFillPaintTransformer((Transformer<V, Paint>) vertexPaint); 48 78 … … 67 97 68 98 } 99 69 100 }
Note: See TracChangeset
for help on using the changeset viewer.