-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTest.java
More file actions
69 lines (62 loc) · 2.08 KB
/
Test.java
File metadata and controls
69 lines (62 loc) · 2.08 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import javax.swing.*;
import java.util.*;
import java.io.*;
import java.awt.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Test {
//private static final String FILE = new File(args[0]);
private static Point[] points;
public static void main(final String[] args){
try{
File FILE = new File(args[0]);
//final BufferedReader br = new BufferedReader(new FileReader(new File(FILE)));
points = new Point[Integer.parseInt(args[1])];
Scanner input = new Scanner(FILE);
int i = 0;
int xMax = 0;
int yMax = 0;
while(input.hasNext())
{
//line = input.nextLine();
//System.out.println(line);
final int x = Integer.parseInt(input.next());
final int y = Integer.parseInt(input.next());
xMax = Math.max(x, xMax);
yMax = Math.max(y, yMax);
System.out.println("x="+x+", y="+y);
points[i++] = new Point(x, y);
}
input.close();
/*
while(br.ready()){
final String[] split = br.readLine().split("\u0009");
final int x = Integer.parseInt(split[0]);
final int y = Integer.parseInt(split[1]);
xMax = Math.max(x, xMax);
yMax = Math.max(y, yMax);
points[i++] = new Point(x, y);
}
*/
final JFrame frame = new JFrame("Point Data Rendering");
final Panel panel = new Panel();
panel.setPreferredSize(new Dimension(xMax + 10, yMax + 10));
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
frame.repaint();
} catch (final Exception e){
e.printStackTrace();
}
}
public static class Panel extends JPanel {
@Override
public void paintComponent(final Graphics g){
g.setColor(Color.RED);
for(final Point p : points){
g.fillRect((int) p.getX(), (int) p.getY(), 2, 2);
}
}
}
}