package uk.ac.leeds.ccg.geotools; import uk.ac.leeds.ccg.geotools.*; import uk.ac.leeds.ccg.geotools.classification.*; import java.util.*; import java.awt.Color; public class FirstPastPostShader extends uk.ac.leeds.ccg.geotools.DiscreteShader { Vector groups = new Vector(); boolean markAsMinority = false; // protected Vector keys = new Vector(); //the value passed in should be an id public Color getColor(double id){ int groupID =-1; if(id <0){ return ((Group)groups.elementAt((int)Math.abs(id)-1)).color; } // System.out.println("Finding winner for "+id); double max = Double.MIN_VALUE; for(int i=0;i max){ max = value; groupID = i; } } if(groupID>=0){ Color c = ((Group)groups.elementAt(groupID)).color; if(markAsMinority && isMinority(groupID,(int)id)){ c = c.darker(); } return c; } return this.missingColor; } public void setMarkMinorites(boolean flag){ if(flag!=markAsMinority){ markAsMinority = flag; this.notifyShaderChangedListeners(); } } /** * Gets a descriptive name for this shader type */ public String getName(){ return "First Past the Post Shader"; } public boolean isMinority(int group,int id){ double total = 0; for(int i=0;i