Line | |
---|
1 | |
---|
2 | package view; |
---|
3 | |
---|
4 | import clustering.VertexScore; |
---|
5 | import java.awt.Color; |
---|
6 | import java.util.ArrayList; |
---|
7 | import java.util.Collection; |
---|
8 | import java.util.List; |
---|
9 | import org.apache.commons.collections15.Transformer; |
---|
10 | |
---|
11 | |
---|
12 | public 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.