package view; import clustering.VertexScore; import java.awt.Color; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.apache.commons.collections15.Transformer; public class VertexPaintRankTransformer implements Transformer{ List> pagerank; V seed_node; List cluster; public VertexPaintRankTransformer(List> ranking, V seed_node){ this.pagerank = ranking; this.seed_node = seed_node; this.cluster = null; } public VertexPaintRankTransformer(List> ranking, V seed_node, List cluster){ this.pagerank = ranking; this.seed_node = seed_node; this.cluster = cluster; } public Paint transform(V node) { if(seed_node != null){ if (seed_node.equals(node)){ return (Paint) Color.GREEN; } } if(cluster != null){ if (!cluster.contains(node)){ return (Paint) Color.WHITE; } } double score = 0; for(VertexScore s : pagerank){ if(s.getVertex().equals(node)) score = s.getScore(); } int rgb = (int)((255 * score) / pagerank.get(0).getScore()); return (Paint) new Color(rgb,0,0); } }