package uk.ac.leeds.ccg.widgets; import java.awt.*; import java.util.*; import uk.ac.leeds.ccg.geotools.*; /** * BarGraph.java - A simple bar graph that can listen to a highlight manager * * If you have a map with multiple values per region, showing for example, the number of people who * voted for each party in an election then this BarGraph may be of interest.

* * @author James Macgill */ public class BarGraph extends java.awt.Component implements HighlightChangedListener { Vector groups = new Vector(); int id=0; double maxValue; public void paint(Graphics g){ int height = getBounds().height; int width = getBounds().width; int count = groups.size(); int barWidth = width/count; double scale = (double)height/(double)maxValue; for(int i=0;imaxValue){maxValue = value;} } this.repaint(); } public void update(Graphics g){ paint(g); } public void addGroup(GeoData data,Color color){ groups.addElement(new Group(data,color)); } class Group{ public Group(GeoData d,Color c){ data = d; color = c; } public GeoData data; public Color color; } }