-
Notifications
You must be signed in to change notification settings - Fork 0
/
radarCruise.java
367 lines (313 loc) · 11.7 KB
/
radarCruise.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
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
import javafx.application.*;
import javafx.event.*;
import javafx.geometry.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.image.*;
import javafx.scene.layout.*;
import javafx.stage.*;
import javafx.beans.value.*;
import javafx.util.*;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import javafx.scene.text.*;
import javafx.animation.*;
import javafx.scene.media.*;
import javafx.beans.value.*;
import javafx.collections.*;
import javafx.event.*;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.beans.property.*;
import javafx.scene.media.*;
import javafx.scene.control.cell.*;
import java.io.File;
import java.io.FilenameFilter;
import java.util.*;
import javafx.scene.control.TabPane.*;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.lang.*;
import javafx.beans.property.*;
/**
* radarCruise
*
* contains the active safety systems settings:
* Radar Adaptive Cruise Control, Lane Departure Warning, Pre-Collision System
*
*/
public class radarCruise extends TabPane
{
// instance variables - replace the example below with your own
/**
* Constructor for objects of class bv
*/
public radarCruise()
{
// initialise instance variables
radar();
}
public void radar()
{
Stage s = new Stage();
s.setTitle("Active Safety Systems");
TabPane tp = new TabPane();
tp.setStyle("-fx-background-color: black;");
tp.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
BorderPane borderPane = new BorderPane();
// Radar Cruise Control
String[] array = {"radarfar.png", "radarmid.png", "radarmid2.png", "radarmid3.png", "radarnear.png"};
ImageView radarDistance = new ImageView();
Image distance = new Image(array[0]);
radarDistance.setImage(distance);
radarDistance.setTranslateX(65);
radarDistance.setTranslateY(100);
// Pre Collision System
String[] array1 = {"PCSfar.png", "PCSmid.png", "PCSmid2.png", "PCSmid3.png", "PCSnear.png"};
ImageView preCollisionDistance = new ImageView();
Image PCS = new Image(array1[0]);
preCollisionDistance.setImage(PCS);
Button upPCS = new Button("Close");
upPCS.setMinWidth(45);
upPCS.setMaxWidth(45);
Button downPCS = new Button("Far");
downPCS.setMinWidth(45);
downPCS.setMaxWidth(45);
upPCS.setOnAction(new EventHandler<ActionEvent>()
{
public void handle(ActionEvent e)
{
settings s = settings.theInstance();
preCollisionDistance.setImage(new Image(array1[s.getI()]));
if(s.getI() >= 4)
{
s.setI(4);
preCollisionDistance.setImage(new Image(array1[s.getI()]));
//System.out.println("Index " + i);
}
else
{
int x = (int)s.getI();
x++;
s.setI(x);
//System.out.println("Index " + i);
preCollisionDistance.setImage(new Image(array1[s.getI()]));
}
}
}
);
upPCS.setTranslateX(110);
upPCS.setTranslateY(70);
downPCS.setOnAction(new EventHandler<ActionEvent>()
{
public void handle(ActionEvent e)
{
settings s = settings.theInstance();
preCollisionDistance.setImage(new Image(array1[s.getI()]));
if(s.getI() <= 0)
{
s.setI(0);
preCollisionDistance.setImage(new Image(array1[s.getI()]));
}
else
{
int x = s.getI();
x--;
s.setI(x);
preCollisionDistance.setImage(new Image(array1[s.getI()]));
}
if(downPCS.isPressed() && (s.getI() == 4))
{
int x = s.getI();
x--;
s.setI(x);
preCollisionDistance.setImage(new Image(array1[s.getI()]));
}
}
}
);
downPCS.setTranslateX(110);
downPCS.setTranslateY(195);
// Buttons for Radar Cruise Control Following Distance
Button upRadar = new Button("Close");
upRadar.setMinWidth(45);
upRadar.setMaxWidth(45);
Button downRadar = new Button("Far");
downRadar.setMinWidth(45);
downRadar.setMaxWidth(45);
upRadar.setOnAction(new EventHandler<ActionEvent>()
{
public void handle(ActionEvent e)
{
settings s = settings.theInstance();
radarDistance.setImage(new Image(array[s.getI()]));
if(s.getI() >= 4)
{
s.setI(4);
radarDistance.setImage(new Image(array[s.getI()]));
}
else
{
int x = (int)s.getI();
x++;
s.setI(x);
radarDistance.setImage(new Image(array[s.getI()]));
}
}
}
);
upRadar.setTranslateX(110);
upRadar.setTranslateY(70);
downRadar.setOnAction(new EventHandler<ActionEvent>()
{
//int i = 4;
public void handle(ActionEvent e)
{
settings s = settings.theInstance();
if(s.getI() <= 0)
{
s.setI(0);
radarDistance.setImage(new Image(array[s.getI()]));
}
else
{
int x = s.getI();
x--;
s.setI(x);
//System.out.println("Index " + s.getI());
radarDistance.setImage(new Image(array[s.getI()]));
}
if(downRadar.isPressed() && (s.getI() == 4))
{
int x = s.getI();
x--;
s.setI(x);
//System.out.println("Index " + i);
radarDistance.setImage(new Image(array[s.getI()]));
}
//System.out.println("index is " + s.getI());
}
}
);
downRadar.setTranslateX(110);
downRadar.setTranslateY(195);
Label radar1 = new Label();
radar1.setText("Radar Adaptive Cruise Control");
radar1.setTextFill(Color.WHITE);
radar1.setFont(new Font("Arial", 15));
radar1.setTranslateX(25);
radar1.setTranslateY(230);
Label pcs = new Label();
pcs.setText("Pre-Collision System");
pcs.setTextFill(Color.WHITE);
pcs.setFont(new Font("Arial", 15));
pcs.setTranslateX(65);
pcs.setTranslateY(230);
Label st = new Label();
st.setText("Active Steering Assist");
st.setFont(new Font("Arial", 15));
st.setTextFill(Color.WHITE);
st.setTranslateX(-150);
st.setTranslateY(125);
Group root = new Group();
Scene scene = new Scene(root, 250, 250, Color.WHITE);
//(t, l1, l2, st, t1, ld)
Tab tab1 = new Tab();
HBox group = new HBox();
tab1.setGraphic(new ImageView(new Image("radar.png")));
tab1.setOnSelectionChanged(new EventHandler<Event>()
{
public void handle(Event t)
{
if (tab1.isSelected())
{
radarDistance.setVisible(true);
preCollisionDistance.setVisible(false);
upPCS.setVisible(false);
downPCS.setVisible(false);
upRadar.setVisible(true);
downRadar.setVisible(true);
group.setVisible(false);
pcs.setVisible(false);
radar1.setVisible(true);
}
}
}
);
Group root1 = new Group(group);
// Lane Departure Warning
Tab tab2 = new Tab();
tab2.setGraphic(new ImageView(new Image("lanedeparture.png")));
toggle t = new toggle();
t.setTranslateX(0);
t.setTranslateY(150);
t.setMinWidth(150);
t.setMaxWidth(150);
Label ld = new Label();
ld.setText("Lane Departure Warning");
ld.setTextFill(Color.WHITE);
ld.setFont(new Font("Arial", 15));
ld.setTranslateX(-450);
ld.setTranslateY(50);
toggle t1 = new toggle();
t1.setMinWidth(150);
t1.setMaxWidth(150);
t1.setTranslateX(-296);
t1.setTranslateY(75);
root1.getChildren().addAll(radar1, pcs);
group.setTranslateX(50);
group.setTranslateY(50);
group.getChildren().addAll(t, st, t1, ld);
tab2.setOnSelectionChanged(new EventHandler<Event>()
{
public void handle(Event t)
{
if (tab2.isSelected())
{
radarDistance.setVisible(false);
upRadar.setVisible(false);
downRadar.setVisible(false);
preCollisionDistance.setVisible(false);
upPCS.setVisible(false);
downPCS.setVisible(false);
group.setVisible(true);
radar1.setVisible(false);
st.setVisible(true);
ld.setVisible(true);
pcs.setVisible(false);
}
}
}
);
Tab tab3 = new Tab();
tab3.setGraphic(new ImageView(new Image("collision.png")));
tab3.setOnSelectionChanged(new EventHandler<Event>()
{
public void handle(Event t)
{
if (tab3.isSelected())
{
preCollisionDistance.setVisible(true);
upPCS.setVisible(true);
downPCS.setVisible(true);
radarDistance.setVisible(false);
group.setVisible(false);
radar1.setVisible(false);
pcs.setVisible(true);
}
}
}
);
preCollisionDistance.setTranslateX(65);
preCollisionDistance.setTranslateY(100);
tp.getStylesheets().add(this.getClass().getResource("radarcruise.css").toExternalForm());
tp.applyCss();
tp.getTabs().addAll(tab1, tab2, tab3);
borderPane.prefHeightProperty().bind(scene.heightProperty());
borderPane.prefWidthProperty().bind(scene.widthProperty());
borderPane.setCenter(tp);
root.getChildren().addAll(borderPane, radarDistance, upRadar, downRadar, preCollisionDistance, upPCS, downPCS, group, radar1, pcs);
s.setScene(scene);
s.show();
}
}