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

Last change on this file since 33 was 33, checked in by toshi, 14 years ago
File size: 958 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    List<V> cluster;
16
17    public VertexPaintRankTransformer(List<VertexScore<V>> ranking, List<V> cluster){
18        this.pagerank = ranking;
19        this.cluster = cluster;
20    }
21
22    public Paint transform(V node) {
23
24        if(cluster != null){
25            if (cluster.contains(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.