source: branches/localSpectral/src/view/VertexPaintRankTransformer.java @ 34

Last change on this file since 34 was 34, checked in by toshi, 14 years ago
File size: 956 bytes
Line 
1
2package view;
3
4import clustering.VertexScore;
5import java.awt.Color;
6import java.util.ArrayList;
7import java.util.Collection;
8import java.util.List;
9import org.apache.commons.collections15.Transformer;
10
11
12public class VertexPaintRankTransformer<V,Paint> implements Transformer<V,Paint>{
13
14    List<VertexScore<V>> pagerank;
15    V seed_node;
16
17    public VertexPaintRankTransformer(List<VertexScore<V>> ranking, V seed_node){
18        this.pagerank = ranking;
19        this.seed_node = seed_node;
20    }
21
22    public Paint transform(V node) {
23
24        if(seed_node != null){
25            if (seed_node.equals(node)){
26                return (Paint) Color.GREEN;
27            }
28        }
29        double score = 0;
30        for(VertexScore s : pagerank){
31            if(s.getVertex().equals(node))
32                score = s.getScore();
33        }
34        int rgb = (int)((255 * score) / pagerank.get(0).getScore());
35        return (Paint) new Color(rgb,0,0);
36     }
37
38
39}
Note: See TracBrowser for help on using the repository browser.