Rev | Line | |
---|
[33] | 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; |
---|
[34] | 15 | V seed_node; |
---|
[36] | 16 | List<V> cluster; |
---|
[33] | 17 | |
---|
[34] | 18 | public VertexPaintRankTransformer(List<VertexScore<V>> ranking, V seed_node){ |
---|
[33] | 19 | this.pagerank = ranking; |
---|
[34] | 20 | this.seed_node = seed_node; |
---|
[36] | 21 | this.cluster = null; |
---|
[33] | 22 | } |
---|
| 23 | |
---|
[36] | 24 | public VertexPaintRankTransformer(List<VertexScore<V>> ranking, V seed_node, List<V> cluster){ |
---|
| 25 | this.pagerank = ranking; |
---|
| 26 | this.seed_node = seed_node; |
---|
| 27 | this.cluster = cluster; |
---|
| 28 | } |
---|
| 29 | |
---|
[33] | 30 | public Paint transform(V node) { |
---|
| 31 | |
---|
[34] | 32 | if(seed_node != null){ |
---|
| 33 | if (seed_node.equals(node)){ |
---|
[33] | 34 | return (Paint) Color.GREEN; |
---|
| 35 | } |
---|
| 36 | } |
---|
[36] | 37 | if(cluster != null){ |
---|
| 38 | if (!cluster.contains(node)){ |
---|
| 39 | return (Paint) Color.WHITE; |
---|
| 40 | } |
---|
| 41 | } |
---|
[33] | 42 | double score = 0; |
---|
| 43 | for(VertexScore s : pagerank){ |
---|
| 44 | if(s.getVertex().equals(node)) |
---|
| 45 | score = s.getScore(); |
---|
| 46 | } |
---|
| 47 | int rgb = (int)((255 * score) / pagerank.get(0).getScore()); |
---|
| 48 | return (Paint) new Color(rgb,0,0); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.