This repository has been archived by the owner on Nov 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
85 lines (68 loc) · 1.75 KB
/
Main.java
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
74
75
76
77
78
79
80
81
82
83
84
85
/*
* Name: Adam Kaplan
*
* NetID: akaplan6
*
* Project: #4
*
* Lab Section: TR 4:50PM - 6:05PM (I switched my lab section)
*
* TA: Charlie Kelman
*
* I affirm that I have not given or received any unauthorized help on this assignment, and that this work is my own.
*/
import javax.swing.JFrame;
import javax.swing.Timer;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
public class Main extends JFrame{
boolean switching = false;
public Main(Graph g, boolean directions, boolean meridianmap, String i1, String i2){
setTitle("Map");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(640, 480);
Canvas c = new Canvas(g, directions, meridianmap, i1, i2);
new Timer(500, new ActionListener(){
public void actionPerformed(ActionEvent e){
c.brush = Color.GREEN;
if(switching){
c.brush = Color.BLUE;
switching = false;
}
else{
c.brush = Color.GREEN;
switching = true;
}
repaint();
}
}).start();
add(c);
}
public static void main(String[] args) {
IO io = new IO();
String filename = args[0];
Graph g = io.getGraph(filename);
boolean showMap = false;
boolean showDirections = false;
boolean showMeridianMap = false;
String i1 = "", i2 = "";
for(int i = 1; i < args.length; i++){
if(args[i].equals("-show"))
showMap = true;
if(args[i].equals("-directions")){
showDirections = true;
i1 = args[++i];
i2 = args[++i];
}
if(args[i].equals("-meridianmap"))
showMeridianMap = true;
}
if(showDirections)
g.getShortestPath(i1, i2);
if(showMeridianMap)
g.getMeridianMap();
if(showMap)
new Main(g, showDirections, showMeridianMap, i1, i2).setVisible(true);
}
}