Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/macosx/classes/apple/laf/JRSUIUtils.java
38829 views
1
/*
2
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package apple.laf;
27
28
import com.apple.laf.AquaImageFactory.NineSliceMetrics;
29
30
import apple.laf.JRSUIConstants.*;
31
import sun.security.action.GetPropertyAction;
32
33
import java.security.AccessController;
34
35
public class JRSUIUtils {
36
static boolean isLeopard = isMacOSXLeopard();
37
static boolean isSnowLeopardOrBelow = isMacOSXSnowLeopardOrBelow();
38
39
static boolean isMacOSXLeopard() {
40
return isCurrentMacOSXVersion(5);
41
}
42
43
static boolean isMacOSXSnowLeopardOrBelow() {
44
return currentMacOSXVersionMatchesGivenVersionRange(6, true, true, false);
45
}
46
47
static boolean isCurrentMacOSXVersion(final int version) {
48
return currentMacOSXVersionMatchesGivenVersionRange(version, true, false, false);
49
}
50
51
static boolean currentMacOSXVersionMatchesGivenVersionRange(final int version, final boolean inclusive, final boolean matchBelow, final boolean matchAbove) {
52
// split the "10.x.y" version number
53
String osVersion = AccessController.doPrivileged(new GetPropertyAction("os.version"));
54
String[] fragments = osVersion.split("\\.");
55
56
// sanity check the "10." part of the version
57
if (!fragments[0].equals("10")) return false;
58
if (fragments.length < 2) return false;
59
60
// check if os.version matches the given version using the given match method
61
try {
62
int minorVers = Integer.parseInt(fragments[1]);
63
64
if (inclusive && minorVers == version) return true;
65
if (matchBelow && minorVers < version) return true;
66
if (matchAbove && minorVers > version) return true;
67
68
} catch (NumberFormatException e) {
69
// was not an integer
70
}
71
return false;
72
}
73
74
public static class TabbedPane {
75
public static boolean useLegacyTabs() {
76
return isLeopard;
77
}
78
public static boolean shouldUseTabbedPaneContrastUI() {
79
return !isSnowLeopardOrBelow;
80
}
81
}
82
83
public static class InternalFrame {
84
public static boolean shouldUseLegacyBorderMetrics() {
85
return isSnowLeopardOrBelow;
86
}
87
}
88
89
public static class Tree {
90
public static boolean useLegacyTreeKnobs() {
91
return isLeopard;
92
}
93
}
94
95
public static class ScrollBar {
96
private static native boolean shouldUseScrollToClick();
97
98
public static boolean useScrollToClick() {
99
return shouldUseScrollToClick();
100
}
101
102
public static void getPartBounds(final double[] rect, final JRSUIControl control, final double x, final double y, final double w, final double h, final ScrollBarPart part) {
103
control.getPartBounds(rect, x, y, w, h, part.ordinal);
104
}
105
106
public static double getNativeOffsetChange(final JRSUIControl control, final double x, final double y, final double w, final double h, final int offset, final int visibleAmount, final int extent) {
107
return control.getScrollBarOffsetChange(x, y, w, h, offset, visibleAmount, extent);
108
}
109
}
110
111
public static class Images {
112
public static boolean shouldUseLegacySecurityUIPath() {
113
return isSnowLeopardOrBelow;
114
}
115
}
116
117
public static class HitDetection {
118
public static Hit getHitForPoint(final JRSUIControl control, final double x, final double y, final double w, final double h, final double hitX, final double hitY) {
119
return control.getHitForPoint(x, y, w, h, hitX, hitY);
120
}
121
}
122
123
public interface NineSliceMetricsProvider {
124
public NineSliceMetrics getNineSliceMetricsForState(JRSUIState state);
125
}
126
}
127
128