This repository was archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexFrame.java
More file actions
299 lines (252 loc) · 9.37 KB
/
IndexFrame.java
File metadata and controls
299 lines (252 loc) · 9.37 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
public class IndexFrame extends JFrame implements ActionListener{
/**
*
*/
private static final long serialVersionUID = 1L;
String teamNumberRawData;
static JButton backButton;
static JButton robotTypeButton;
static JButton Pointranking;
static JButton notesButton;
static JButton visualButton;
static JTextField rawDatatextfield;
static JLabel rawDataLabel;
static JLabel visualLabel;
static JLabel robotTypeLabel;
static JLabel pointRankingLabel;
static JLabel notesLabel;
public JFrame IndexFrames;
public static JLabel FRClogo;
public IndexFrame(JFrame frame) {
IndexFrames = frame;
//back
backButton = new JButton();
backButton.setBounds(20, 20, 100, 25);
backButton.setText("Back");
backButton.addActionListener(this);
backButton.setFocusable(false);
//raw data label
rawDataLabel = new JLabel();
rawDataLabel.setBounds(200, 200-75, 400, 50);
rawDataLabel.setText("Input Team#:");
rawDataLabel.setFocusable(false);
rawDataLabel.setHorizontalAlignment(JLabel.CENTER);
rawDataLabel.setFont(new Font("MV Boli", Font.PLAIN,20));
rawDataLabel.setForeground(new Color(0xFFFFFF));
//raw data text field
rawDatatextfield = new JTextField();
rawDatatextfield.setBounds(650, 200-75, 200, 50);
//line 2: robot Type button
robotTypeButton = new JButton();
robotTypeButton.setBounds(650, 275-75, 200, 50);
robotTypeButton.setText("Robot Analyzer ");
robotTypeButton.addActionListener(this);
robotTypeButton.setFocusable(false);
//robot type label
robotTypeLabel = new JLabel();
robotTypeLabel.setBounds(200, 275-75, 400, 50);
robotTypeLabel.setText("Analysis of a Robot: ");
robotTypeLabel.setFocusable(false);
robotTypeLabel.setHorizontalAlignment(JLabel.CENTER);
robotTypeLabel.setFont(new Font("MV Boli", Font.PLAIN,20));
robotTypeLabel.setForeground(new Color(0xFFFFFF));
//line 3: point ranking
Pointranking = new JButton();
Pointranking.setBounds(650, 350-75, 200, 50);
Pointranking.setText("Rankings");
Pointranking.addActionListener(this);
Pointranking.setFocusable(false);
//
pointRankingLabel = new JLabel();
pointRankingLabel.setBounds(200, 350-75, 400, 50);
pointRankingLabel.setText("General Point Rankings: ");
pointRankingLabel.setFocusable(false);
pointRankingLabel.setHorizontalAlignment(JLabel.CENTER);
pointRankingLabel.setFont(new Font("MV Boli", Font.PLAIN,20));
pointRankingLabel.setForeground(new Color(0xFFFFFF));
//notes button
notesButton = new JButton();
notesButton.setBounds(650, 425, 200, 50);
notesButton.setText("Notes");
notesButton.addActionListener(this);
notesButton.setFocusable(false);
//notes Label
notesLabel = new JLabel();
notesLabel.setBounds(200, 425, 400, 50);
notesLabel.setText("Notes on a Robot: ");
notesLabel.setFocusable(false);
notesLabel.setHorizontalAlignment(JLabel.CENTER);
notesLabel.setFont(new Font("MV Boli", Font.PLAIN,20));
notesLabel.setForeground(new Color(0xFFFFFF));
visualButton = new JButton();
visualButton.setBounds(650, 425-75, 200, 50);
visualButton.setText("Visual Data");
visualButton.addActionListener(this);
visualButton.setFocusable(false);
//notes Label
visualLabel = new JLabel();
visualLabel.setBounds(200, 425-75, 400, 50);
visualLabel.setText("Visualised Data on Robot: ");
visualLabel.setFocusable(false);
visualLabel.setHorizontalAlignment(JLabel.CENTER);
visualLabel.setFont(new Font("MV Boli", Font.PLAIN,20));
visualLabel.setForeground(new Color(0xFFFFFF));
ImageIcon FRCicon = new ImageIcon(new ImageIcon("1200px-FRC_Logo.svg.png").getImage().getScaledInstance(120, 80, Image.SCALE_DEFAULT));
FRClogo = new JLabel();
FRClogo.setIcon(FRCicon);
FRClogo.setBounds(1030, 50, 120, 80);
FRClogo.setFocusable(false);
FRClogo.setHorizontalAlignment(JLabel.CENTER);
FRClogo.setForeground(new Color(0xFFFFFF));
FRClogo.setVerticalAlignment(JLabel.CENTER);
IndexFrames.add(FRClogo);
IndexFrames.add(backButton);
IndexFrames.add(visualLabel);
IndexFrames.add(visualButton);
IndexFrames.add(rawDatatextfield);
IndexFrames.add(robotTypeButton);
//IndexFrames.add(robotTypetextfield);
IndexFrames.add(Pointranking);
IndexFrames.add(notesButton);
IndexFrames.add(rawDataLabel);
IndexFrames.add(notesLabel);
IndexFrames.add(pointRankingLabel);
IndexFrames.add(rawDataLabel);
IndexFrames.add(robotTypeLabel);
IndexFrames.setTitle("WVR Scouting App: Index Frame 2020"); // Titles the Window
IndexFrames.setResizable(false); // Keeps a consistent window size.
IndexFrames.setLayout(null);
IndexFrames.setVisible(false); // Makes the frame visible
IndexFrames.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
Boolean a = true;
try {
Double.parseDouble(rawDatatextfield.getText());
} catch (NumberFormatException e1){
a = false;
}
if(a || e.getSource()==Pointranking || e.getSource()==backButton) {
if (e.getSource()==backButton) {
//please copy and paste this chunk outside the if statements in the final verision for more efficieny
backButton.setVisible(false);
rawDataLabel.setVisible(false);
rawDatatextfield.setVisible(false);
robotTypeLabel.setVisible(false);
robotTypeButton.setVisible(false);
visualLabel.setVisible(false);
visualButton.setVisible(false);
Pointranking.setVisible(false);
notesButton.setVisible(false);
notesLabel.setVisible(false);
pointRankingLabel.setVisible(false);
rawDataLabel.setVisible(false);
FRClogo.setVisible(false);
new MainFrame(IndexFrames, 0);
} else if (e.getSource()==robotTypeButton) {
backButton.setVisible(false);
rawDataLabel.setVisible(false);
rawDatatextfield.setVisible(false);
robotTypeLabel.setVisible(false);
robotTypeButton.setVisible(false);
visualLabel.setVisible(false);
visualButton.setVisible(false);
Pointranking.setVisible(false);
notesButton.setVisible(false);
notesLabel.setVisible(false);
pointRankingLabel.setVisible(false);
rawDataLabel.setVisible(false);
FRClogo.setVisible(false);
try {
new DetailFrame(IndexFrames, Integer.parseInt(rawDatatextfield.getText()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else if (e.getSource()==notesButton) {
backButton.setVisible(false);
rawDataLabel.setVisible(false);
rawDatatextfield.setVisible(false);
robotTypeLabel.setVisible(false);
robotTypeButton.setVisible(false);
visualLabel.setVisible(false);
visualButton.setVisible(false);
Pointranking.setVisible(false);
notesButton.setVisible(false);
notesLabel.setVisible(false);
pointRankingLabel.setVisible(false);
rawDataLabel.setVisible(false);
FRClogo.setVisible(false);
try {
new Notes(IndexFrames, Integer.parseInt(rawDatatextfield.getText()));
} catch (NumberFormatException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InvalidFormatException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else if (e.getSource()==Pointranking) {
backButton.setVisible(false);
rawDataLabel.setVisible(false);
rawDatatextfield.setVisible(false);
robotTypeLabel.setVisible(false);
robotTypeButton.setVisible(false);
visualLabel.setVisible(false);
visualButton.setVisible(false);
Pointranking.setVisible(false);
notesButton.setVisible(false);
notesLabel.setVisible(false);
pointRankingLabel.setVisible(false);
rawDataLabel.setVisible(false);
FRClogo.setVisible(false);
try {
new Ranking(IndexFrames);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else if(e.getSource()==visualButton) {
backButton.setVisible(false);
rawDataLabel.setVisible(false);
rawDatatextfield.setVisible(false);
robotTypeLabel.setVisible(false);
robotTypeButton.setVisible(false);
visualLabel.setVisible(false);
visualButton.setVisible(false);
Pointranking.setVisible(false);
notesButton.setVisible(false);
notesLabel.setVisible(false);
pointRankingLabel.setVisible(false);
rawDataLabel.setVisible(false);
FRClogo.setVisible(false);
try {
new VisualFrame(IndexFrames, Integer.parseInt(rawDatatextfield.getText()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
else {
JOptionPane.showMessageDialog(null, "We do not have that team number", "InfoBox: " + "Error", JOptionPane.INFORMATION_MESSAGE);
}
}
}