-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dimensions.java
247 lines (209 loc) · 9.45 KB
/
Dimensions.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
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.input.MouseEvent;
import javafx.scene.text.Font;
public class Dimensions extends Pane {
//Constants
private final String SOUND_ICON = "/img/soundIcon.png";
private final String SETTINGS_ICON = "/img/Settings-icon.png";
private final String BACK_ICON = "/img/backIcon.png";
private final String COPYRIGHT_LABEL = "Developed by Royal Flush";
private final double WIDTH = 1080;
private final double HEIGHT = 720;
private final double COPYRIGHT_PANEL_SIZE = 60;
private final int ICON_SIZE = 64;
//Variables
private Label name;
//Labels
private Label copyRightLabel;
private Pane copyRightPanel;
private Label version;
private Label[] leftAt;
private Label[] numberOfStarsLabel;
//Buttons
private Button soundButton;
private Button settingsButton;
private Button backButton;
private Button[] sixToSix;
//Images
private ImageView soundImage;
private ImageView settingsImage;
private ImageView backImage;
private Image[] stars;
private ImageView fullStar;
//ProgressBar
private ProgressBar[] dimensionProgression;
public Dimensions() {
super();
initialize();
}
public void initialize(){
//Creating middle panel
this.setMinHeight(HEIGHT - COPYRIGHT_PANEL_SIZE);
this.setMinWidth(WIDTH);
//Creating copyright panel
copyRightPanel = new Pane();
//Copyright label
copyRightLabel = new Label(COPYRIGHT_LABEL);
//Version label
version = new Label("Version b0.1");
//How_To Panel
name = new Label("");
name.setStyle("-fx-font-weight: bold;");
name.setGraphic(new ImageView("/img/dimensions.png"));
name.setMaxSize(450,75);
name.setFont(new Font("American Typewriter", 75));
name.setLayoutX(300 );
name.setLayoutY(25);
//Sound button
soundImage = new ImageView(new Image(SOUND_ICON));
soundImage.setFitWidth(ICON_SIZE);
soundImage.setFitHeight(ICON_SIZE);
soundButton = new Button();
soundButton.setGraphic(soundImage);
soundButton.setStyle("-fx-background-color: transparent");
soundButton.setMinSize(ICON_SIZE, ICON_SIZE);
soundButton.setLayoutX(WIDTH - 100);
soundButton.setLayoutY(25);
//Settings button
settingsImage = new ImageView(new Image(SETTINGS_ICON));
settingsImage.setFitWidth(ICON_SIZE);
settingsImage.setFitHeight(ICON_SIZE);
settingsButton = new Button();
settingsButton.setGraphic(settingsImage);
settingsButton.setStyle("-fx-background-color: transparent");
settingsButton.setMinSize(ICON_SIZE, ICON_SIZE);
settingsButton.setLayoutX(WIDTH - 200);
settingsButton.setLayoutY(25);
//Back button
backImage = new ImageView(BACK_ICON);
backImage.setFitWidth(ICON_SIZE);
backImage.setFitHeight(ICON_SIZE);
backButton = new Button();
backButton.setGraphic(backImage);
backButton.setStyle("-fx-background-color: transparent");
backButton.setMinSize(ICON_SIZE, ICON_SIZE);
backButton.setLayoutX(25);
backButton.setLayoutY(25);
//Images for stars
stars = new Image[3];
stars[0] = new Image(getClass().getResourceAsStream("/img/fullStar.png"));
fullStar = new ImageView(stars[0]);
//There is a problem here.
ImageView fullStar2 = new ImageView(stars[0]);
ImageView fullStar3 = new ImageView(stars[0]);
//Left at label array
int variable = 5;
int variable2 = 10;
int variable3 = 15;
//charts.getLeftAt();
leftAt = new Label[3];
for ( int i = 0; i < 3; i++){
leftAt[i] = new Label();
leftAt[i].setStyle("-fx-border-color: black ; -fx-border-width: 3px ;");
leftAt[i].setMinWidth(200);
}
leftAt[0].setText("Left at #" + variable);
leftAt[1].setText("Left at #" + variable2);
leftAt[2].setText("Left at #" + variable3);
//Number of stars label array
int numberOfStars = 5;
int numberOfStars2 = 10;
int numberOfStars3 = 15;
//charts.getLeftAt();
numberOfStarsLabel = new Label[3];
for ( int i = 0; i < 3; i++){
numberOfStarsLabel[i] = new Label();
numberOfStarsLabel[i].setStyle("-fx-border-color: black ; -fx-border-width: 3px ;");
numberOfStarsLabel[i].setMinWidth(176);
}
numberOfStarsLabel[0].setText("" + numberOfStars);
numberOfStarsLabel[1].setText("" + numberOfStars2);
numberOfStarsLabel[2].setText("" + numberOfStars3);
//Dimensions array
dimensionProgression = new ProgressBar[3];
for ( int i = 0; i < 3; i++){
dimensionProgression[i] = new ProgressBar();
dimensionProgression[i].setStyle("-fx-accent: #914b28 ; -fx-border-color: black ; -fx-border-width: 3px ;");
dimensionProgression[i].setMinWidth(200);
}
//charts.getProgression();
dimensionProgression[0].setProgress(0.5);
dimensionProgression[1].setProgress(0.7);
dimensionProgression[2].setProgress(1);
//Buttons array
sixToSix = new Button[3];
for ( int i = 0; i < 3; i++){
sixToSix[i] = new Button();
sixToSix[i].setStyle("-fx-border-color: black ; -fx-border-width: 3px ; -fx-font-family: 'Verdana'; -fx-font-weight: bold; -fx-font-size: 25pt ;");
sixToSix[i].setStyle("-fx-background-color: transparent");
sixToSix[i].setMinSize(200, (HEIGHT - 175) / 2);
}
sixToSix[0].setStyle("-fx-background-image: url('/img/dim1.png')");
sixToSix[1].setStyle("-fx-background-image: url('/img/dim2.png')");
sixToSix[2].setStyle("-fx-background-image: url('/img/dim3.png')");
VBox vBox = new VBox(0); // spacing = 8
VBox vBox2 = new VBox(0); // spacing = 8
VBox vBox3 = new VBox(0); // spacing = 8
HBox hBox = new HBox(0); // spacing = 8
HBox hBox2 = new HBox(0); // spacing = 8
HBox hBox3 = new HBox(0); // spacing = 8
HBox panel = new HBox((WIDTH - 600) / 4); // spacing = 8
panel.setLayoutX((WIDTH - 650) / 4);
panel.setLayoutY(HEIGHT / 2 - 200);
hBox.getChildren().addAll(fullStar, numberOfStarsLabel[0]);
vBox.getChildren().addAll(dimensionProgression[0], sixToSix[0], leftAt[0], hBox);
hBox2.getChildren().addAll(fullStar2, numberOfStarsLabel[1]);
vBox2.getChildren().addAll(dimensionProgression[1], sixToSix[1], leftAt[1], hBox2);
hBox3.getChildren().addAll(fullStar3, numberOfStarsLabel[2]);
vBox3.getChildren().addAll(dimensionProgression[2], sixToSix[2], leftAt[2], hBox3);
panel.getChildren().addAll(vBox, vBox2, vBox3);
addAnimation(10);
//Adding buttons to middle panel
this.getChildren().addAll(name, soundButton, settingsButton, backButton, panel);
//How_To Panel ends
//Adding labels to panel
copyRightPanel.getChildren().add(copyRightLabel);
copyRightPanel.getChildren().add(version);
//Default theme
setCurrentColor(null);
}
public void setCurrentColor(String colorCSS){
if (colorCSS == null){
this.setStyle("-fx-background-color: #81aae6;");
}else{
this.setStyle(colorCSS);
}
}
public void addHandler( GameManager.ButtonListener e) {
// add the button listener to the back button
backButton.addEventHandler(MouseEvent.MOUSE_CLICKED, e);
// add button listeners to all the dimensions
GameManager.ButtonListener dim1 = e.clone();
GameManager.ButtonListener dim2 = e.clone();
GameManager.ButtonListener dim3 = e.clone();
dim1.setIndex(6);
dim2.setIndex(8);
dim3.setIndex(10);
sixToSix[0].addEventHandler(MouseEvent.MOUSE_CLICKED, dim1);
sixToSix[1].addEventHandler(MouseEvent.MOUSE_CLICKED, dim2);
sixToSix[2].addEventHandler(MouseEvent.MOUSE_CLICKED, dim3);
GameManager.ButtonListener settings = e.clone();
settings.setIndex(4);
settingsButton.addEventHandler(MouseEvent.MOUSE_CLICKED, settings);
}
public void addAnimation(int factor) {
soundButton.setOnMouseEntered(new GameManager.Animation(soundButton, factor, true));
soundButton.setOnMouseExited(new GameManager.Animation(soundButton, factor, false));
settingsButton.setOnMouseEntered(new GameManager.Animation(settingsButton, factor, true));
settingsButton.setOnMouseExited(new GameManager.Animation(settingsButton, factor, false));
backButton.setOnMouseEntered(new GameManager.Animation(backButton, factor, true));
backButton.setOnMouseExited(new GameManager.Animation(backButton, factor, false));
}
}