Ignore:
Timestamp:
Oct 30, 2010, 8:39:22 PM (14 years ago)
Author:
toshi
Message:
 
Location:
branches/localSpectral/src/view
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/localSpectral/src/view/VertexPaintRankTransformer.java

    r33 r34  
    1313
    1414    List<VertexScore<V>> pagerank;
    15     List<V> cluster;
     15    V seed_node;
    1616
    17     public VertexPaintRankTransformer(List<VertexScore<V>> ranking, List<V> cluster){
     17    public VertexPaintRankTransformer(List<VertexScore<V>> ranking, V seed_node){
    1818        this.pagerank = ranking;
    19         this.cluster = cluster;
     19        this.seed_node = seed_node;
    2020    }
    2121
    2222    public Paint transform(V node) {
    2323
    24         if(cluster != null){
    25             if (cluster.contains(node)){
     24        if(seed_node != null){
     25            if (seed_node.equals(node)){
    2626                return (Paint) Color.GREEN;
    2727            }
  • branches/localSpectral/src/view/Viewer.java

    r32 r34  
    44import clustering.VertexScore;
    55import clustering.VertexString;
     6import edu.uci.ics.jung.algorithms.layout.DAGLayout;
    67import edu.uci.ics.jung.algorithms.layout.FRLayout;
     8import edu.uci.ics.jung.algorithms.layout.KKLayout;
    79import edu.uci.ics.jung.algorithms.layout.Layout;
    810import edu.uci.ics.jung.graph.Graph;
    911import edu.uci.ics.jung.visualization.BasicVisualizationServer;
     12import java.awt.BorderLayout;
    1013import java.awt.Color;
    1114import java.awt.Dimension;
     15import java.awt.FlowLayout;
    1216import java.awt.LayoutManager;
    1317import java.awt.Paint;
     18import java.awt.event.ActionEvent;
     19import java.awt.event.ActionListener;
    1420import java.util.ArrayList;
    1521import java.util.List;
     22import javax.swing.JButton;
    1623import javax.swing.JFrame;
     24import javax.swing.JPanel;
     25import javax.swing.JTextArea;
     26import javax.xml.bind.JAXB;
    1727import org.apache.commons.collections15.Transformer;
    1828
     
    2535    BasicVisualizationServer<V,E> vv;
    2636    JFrame frame;
     37    JButton button;
     38    JPanel button_panel;
     39    JTextArea text ;
    2740
    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
    2950        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));
    3458        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);
    3662        vv.getRenderContext().setVertexLabelTransformer(new VertexLabelTransformer<V, String>());
     63       
    3764    }
    3865
     66    public void setText(String text){
     67        this.text.setText(text);
     68    }
    3969    public void setGraph(Graph<V, E> graph) {
    4070        this.graph = graph;
     
    4373    }
    4474   
    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);
    4777         vv.getRenderContext().setVertexFillPaintTransformer((Transformer<V, Paint>) vertexPaint);
    4878         
     
    6797
    6898     }
     99
    69100}
Note: See TracChangeset for help on using the changeset viewer.