-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrain.java
192 lines (164 loc) · 6.26 KB
/
Train.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
package BlackRock;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.ScrollPane;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javax.swing.plaf.MenuBarUI;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class Train {
private Scene sceneTrain;
private VBox vBox = new VBox(10);
private ScrollPane scrollPaneTrain;
private VBox playInfo = new VBox();
private VBox profileInfo = new VBox();
private VBox connectInfo = new VBox();
private HBox menuBar = new HBox();
private Button playButton;
private Button profileButton;
private Button connectButton;
public Train() {
setUpButtons();
setInfo();
setUpScroll();
setUpTrainPage();
playButton.setOnAction(e -> fillInfo("play"));
profileButton.setOnAction(e -> fillInfo("profile"));
connectButton.setOnAction(e -> fillInfo("connect"));
sceneTrain = new Scene(vBox, 500,1000);
vBox.requestFocus();
}
private Button getBackButton(){
Button back = new Button("Go Back");
back.setFocusTraversable(false);
back.setOnAction(handleBack());
back.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY, Insets.EMPTY)));
back.setTranslateX(140);
back.setTextFill(Color.GRAY);
return back;
}
private void setUpButtons(){
playButton = new Button(" Play ");
playButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY, Insets.EMPTY)));
playButton.setTextFill(Color.WHITE);
playButton.setScaleX(1.9);
playButton.setScaleY(1.9);
profileButton = new Button("Profile");
profileButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY, Insets.EMPTY)));
profileButton.setTextFill(Color.WHITE);
profileButton.setScaleX(1.9);
profileButton.setScaleY(1.9);
connectButton = new Button("Connect");
connectButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY, Insets.EMPTY)));
connectButton.setTextFill(Color.WHITE);
connectButton.setScaleX(1.9);
connectButton.setScaleY(1.9);
menuBar.getChildren().addAll(playButton, profileButton, connectButton);
menuBar.setAlignment(Pos.BOTTOM_CENTER);
menuBar.setTranslateX(17);
menuBar.setTranslateY(23);
menuBar.setSpacing(70);
}
private void setInfo(){
setPlayInfo();
setProfileInfo();
setConnectInfo();
}
private void setPlayInfo(){
Button back = getBackButton();
try {
FileInputStream input = new FileInputStream("/Users/rachelbick/Documents/Hackathon-BlackRockApp/src/BlackRock/play.jpg");
ImageView fact1 = new ImageView(new Image(input));
fact1.setFitWidth(360);
fact1.setFitHeight(800);
playInfo.getChildren().addAll(back, fact1);
playInfo.setAlignment(Pos.CENTER);
} catch (FileNotFoundException e){
e.printStackTrace();
}
}
private void setProfileInfo(){
Button back = getBackButton();
try {
FileInputStream input = new FileInputStream("/Users/rachelbick/Documents/Hackathon-BlackRockApp/src/BlackRock/profile page update.009.jpg");
ImageView fact1 = new ImageView(new Image(input));
fact1.setFitWidth(360);
fact1.setScaleX(2.5);
fact1.setTranslateX(-10);
profileInfo.getChildren().addAll(back, fact1);
profileInfo.setAlignment(Pos.CENTER);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
private void setConnectInfo(){
Button back = getBackButton();
try {
FileInputStream input = new FileInputStream("/Users/rachelbick/Documents/Hackathon-BlackRockApp/src/BlackRock/2.jpg");
ImageView fact1 = new ImageView(new Image(input));
fact1.setFitWidth(360);
fact1.setFitHeight(800);
connectInfo.getChildren().addAll(back, fact1);
connectInfo.setAlignment(Pos.CENTER);
} catch (FileNotFoundException e){
e.printStackTrace();
}
}
private void setUpScroll(){
scrollPaneTrain = new ScrollPane();
scrollPaneTrain.setPrefSize(380, 560);
scrollPaneTrain.setMaxWidth(380);
scrollPaneTrain.setTranslateX(13);
scrollPaneTrain.setContent(profileInfo);
}
private void setUpTrainPage(){
try {
FileInputStream input = new FileInputStream("/Users/rachelbick/Documents/Hackathon-BlackRockApp/src/BlackRock/latest 1.005.jpg");
Image trainBackgroundImage = new Image(input);
BackgroundImage backgroundImage = new BackgroundImage(trainBackgroundImage,
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT,BackgroundPosition.CENTER,
BackgroundSize.DEFAULT);
vBox.setBackground(new Background(backgroundImage));
} catch(java.io.FileNotFoundException e) {
System.out.println(e);
}
vBox.getChildren().addAll(scrollPaneTrain,menuBar);
vBox.setAlignment(Pos.CENTER);
}
private void fillInfo(String page){
if(page.equals("play")){
scrollPaneTrain.setContent(playInfo);
}
if(page.equals("profile")){
scrollPaneTrain.setContent(profileInfo);
}
if(page.equals("connect")){
scrollPaneTrain.setContent(connectInfo);
}
}
public Scene getTrainScene(){
return sceneTrain;
}
EventHandler<ActionEvent> handleBack() {
return event -> {
goBack();
};
}
public void goBack(){
PageEvent event = new PageEvent(PageEvent.LEAVE_PAGE);
Event.fireEvent(sceneTrain, event);
}
}