-
Notifications
You must be signed in to change notification settings - Fork 6
/
StageMaxMin.java
134 lines (107 loc) · 3.76 KB
/
StageMaxMin.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
package potplayer;
import java.util.Map;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import potplayer.DisplayAreaSize;
public class StageMaxMin {
public static double lastX = 0.0;
public static double lastY = 0.0;
public static double lastW = 0.0;
public static double lastH = 0.0;
public static boolean stageMax = false;
public static boolean stageOnTop = false;
public static boolean stageFull = false;
public static boolean stageOntop(Stage topStage) {
if (stageOnTop == false) {
stageOnTop = true;
} else {
stageOnTop = false;
}
topStage.setAlwaysOnTop(stageOnTop);
return stageOnTop;
}
public static void disableStageOntop(Stage topStage) {
topStage.setAlwaysOnTop(false);
stageOnTop = false;
}
public static void stageMax(Stage stage) {
int missionBoardH = DisplayAreaSize.missionBoarHeight();
Map<String, Double> screen = DisplayAreaSize.screenSize();
double screenWidth = screen.get("width");
double screenHeight = screen.get("height");
double xy = stage.getX() + stage.getY();
double size = stage.getWidth() + stage.getHeight();
if ((xy != 0) || (size != screenWidth + screenHeight - missionBoardH)) {
// Size or coordinates is changed, so disable max flag
stageMax = false;
}
if (stageMax == false) {
lastX = stage.getX();
lastY = stage.getY();
lastW = stage.getWidth();
lastH = stage.getHeight();
missionBoardH = DisplayAreaSize.missionBoarHeight();
screen = DisplayAreaSize.screenSize();
screenWidth = screen.get("width");
screenHeight = screen.get("height");
stage.setX(0);
stage.setY(0);
stage.setWidth(screenWidth);
stage.setHeight(screenHeight - missionBoardH);
stageMax = true;
} else {
stage.setX(lastX);
stage.setY(lastY);
stage.setWidth(lastW);
stage.setHeight(lastH);
stageMax = false;
}
}
public static void minimize(Stage stage) {
stage.setIconified(true);
}
public static void saveDraggedMaxBeforeSize(double saveX, double saveY, double saveW, double saveH) {
// The size can only be saved when it is not maximized
if (stageMax != true) {
lastX = saveX;
lastY = saveY;
lastW = saveW;
lastH = saveH;
} else {
return;
}
}
public static void draggedMax(Stage stage, MouseEvent event) {
if (event.getScreenY() <= 0) {
int missionBoardH = DisplayAreaSize.missionBoarHeight();
Map<String, Double> screen = DisplayAreaSize.screenSize();
double screenWidth = screen.get("width");
double screenHeight = screen.get("height");
stage.setX(0);
stage.setY(0);
stage.setWidth(screenWidth);
stage.setHeight(screenHeight - missionBoardH);
stageMax = true;
}
}
public static boolean isDownDragged(double nowY) {
if ((nowY - 0) >= 3) {
return true;
} else {
return false;
}
}
public static void draggedMin(Stage stage, MouseEvent event) {
if (isDownDragged(event.getScreenY()) == true) {
if (stageMax == true) {
stage.setX(event.getScreenX());
stage.setY(event.getScreenY());
stage.setWidth(lastW);
stage.setHeight(lastH);
stageMax = false;
} else {
return;
}
}
}
}