SystemUtils.java
1.79 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
package cn.csbr.app.gui.util;
import javafx.stage.Screen;
/**
* 系统工具.
*
* @author fenglinz
* @since 2018-10-26
*/
public final class SystemUtils {
/** 标准宽度 */
//private final static double STANDARD_WIDTH = 1280;
private final static double STANDARD_WIDTH = 960;
/** 标准高度 */
//private final static double STANDARD_HEIGHT = 1024;
private final static double STANDARD_HEIGHT = 768;
/** 主屏幕信息 */
private static Screen primaryScreen;
static {
primaryScreen = Screen.getPrimary();
}
/**
* 获取屏幕宽度.
*
* @return 屏幕宽度.
*/
public static double getScreenWidth() {
double width = primaryScreen.getBounds().getWidth();
return width > STANDARD_WIDTH ? STANDARD_WIDTH : width;
}
/**
* 获取屏幕高度.
*
* @return 屏幕高度
*/
public static double getScreenHeight() {
double height = primaryScreen.getBounds().getHeight();
return height > STANDARD_HEIGHT ? height - ((height - STANDARD_HEIGHT) / 2) : height;
}
/**
* 获取导航按钮区的最小高度.
*
* @return 导航按钮区的最小高度
*/
public static double getNavigationAreaMinHeight() {
return getScreenHeight() - 70;
}
/**
* 获取数据表格的最小高度.
*
* @return 数据表格的最小高度
*/
public static double getDataTableMinHeight() {
return getScreenHeight() - 260;
}
/**
* 获取数据表格的最小高度.
*
* @param extraHeight 额外减少的高度
*
* @return 数据表格的最小高度
*/
public static double getDataTableMinHeight(double extraHeight) {
return getDataTableMinHeight() - extraHeight;
}
}