/****************************************************************************** * Compilation: javac InteractiveElectionMap.java * Execution: java InteractiveElectionMap usps year * Dependencies: In.java StdDraw.java ElectionMap.java * * Visualzes the presidential election in the given state and year. * When the user clicks a region, it prints out the region and the * vote tallies. * * % java InteractiveElectionMap USA 2004 * * % java InteractiveElectionMap LA 1964 * * % java InteractiveElectionMap NJ 2004 * * % java InteractiveElectionMap USA 1992 * ******************************************************************************/ public class InteractiveElectionMap { public static void main(String[] args) { StdDraw.enableDoubleBuffering(); // name and year of presidential election String name = args[0]; int year = Integer.parseInt(args[1]); // create an election map for the given region and year ElectionMap election = new ElectionMap(name, year); election.show(); election.border(); // print out region that user clicks on StdOut.println(); while (true) { Point p = new Point(StdDraw.mouseX(), StdDraw.mouseY()); if (StdDraw.mousePressed()) election.showRegion(p); StdDraw.show(); StdDraw.pause(50); } } }