/************************************************************************* * Compilation: javac PlotFilter.java * Execution: java PlotFilter input.txt * Dependencies: StdDraw.java StdIn.java * * % java PlotFilter USA.txt * * Datafiles: http://www.cs.princeton.edu/IntroProgramming/15inout/USA.txt * *************************************************************************/ import java.io.*; import java.util.*; public class PlotFilter { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(new File(args[0])); // read in bounding box and rescale double x0 = sc.nextDouble(); double y0 = sc.nextDouble(); double x1 = sc.nextDouble(); double y1 = sc.nextDouble(); StdDraw.setXscale(x0, x1); StdDraw.setYscale(y0, y1); // turn on animation mode to defer displaying all of the points // StdDraw.show(0); // plot points, one at a time while (sc.hasNext()){ double x = sc.nextDouble(); double y = sc.nextDouble(); StdDraw.point(x, y); } // display all of the points now // StdDraw.show(0); } }