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

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