-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlotFilter.java
More file actions
39 lines (31 loc) · 1.11 KB
/
PlotFilter.java
File metadata and controls
39 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*************************************************************************
* 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
*
*************************************************************************/
public class PlotFilter {
public static void main(String[] args) {
// read in bounding box and rescale
double x0 = StdIn.readDouble();
double y0 = StdIn.readDouble();
double x1 = StdIn.readDouble();
double y1 = StdIn.readDouble();
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 (!StdIn.isEmpty()) {
double x = StdIn.readDouble();
double y = StdIn.readDouble();
StdDraw.point(x, y);
}
// display all of the points now
// StdDraw.show(0);
}
}