-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.java
More file actions
73 lines (52 loc) · 1.6 KB
/
Copy pathProgram.java
File metadata and controls
73 lines (52 loc) · 1.6 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
70
71
72
73
package orbit;
import java.awt.Component;
import java.awt.EventQueue;
public class Program {
// private JPanelView jpView;
// private CanvasView canvas;
private Component painter;
private SpaceLogic space;
private PaintHandler paintHandler;
private Input input;
private static String painterMode = "JPanel";
// private static int initStateArg;
public static void main(String[] args) {
System.setProperty("sun.java2d.opengl", "true");
if (args.length > 0) {
for (int i = 0; i < args.length; i++) {
System.out.println(args[i]);
if (args[i].equals("canvas")) {
painterMode = "Canvas";
}
}
}
//System.out.println("Drawing on " + painterMode);
TextOutput textOutput = new TextOutput();
textOutput.addMessage("Drawing on " + painterMode);
new Program();
}
public Program() {
space = new SpaceLogic();
input = new Input(space);
paintHandler = new PaintHandler(space, input);
space.addPaintHandler(paintHandler);
space.addInput(input);
input.addPaintHandler(paintHandler);
InitState.initState(1, false, space, paintHandler);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
if (painterMode == "JPanel") {
painter = new JPanelView(paintHandler); // chose either one, JPanel
} else if (painterMode == "Canvas") {
painter = new CanvasView(paintHandler); // or canvas
painter.addKeyListener(input); // which needs key input
}
paintHandler.addPainter(painter);
new MainWindow("PlaneSpace", painter, input);
space.start(); // start the math
paintHandler.startDisplay();
}
});
}
}