Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/make/src/classes/build/tools/generatenimbus/UIStyle.java
32287 views
1
/*
2
* Copyright (c) 2002, 2013, 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 build.tools.generatenimbus;
27
28
import java.util.ArrayList;
29
import java.util.List;
30
import javax.xml.bind.annotation.XmlElement;
31
import javax.xml.bind.annotation.XmlElementWrapper;
32
33
34
class UIStyle {
35
public static enum CacheMode {
36
NO_CACHING, FIXED_SIZES, NINE_SQUARE_SCALE
37
}
38
39
@XmlElement private UIColor textForeground = null;
40
@XmlElement(name="inherit-textForeground")
41
private boolean textForegroundInherited = true;
42
43
@XmlElement private UIColor textBackground = null;
44
@XmlElement(name="inherit-textBackground")
45
private boolean textBackgroundInherited = true;
46
47
@XmlElement private UIColor background = null;
48
@XmlElement(name="inherit-background")
49
private boolean backgroundInherited = true;
50
51
@XmlElement private boolean cacheSettingsInherited = true;
52
@XmlElement CacheMode cacheMode = CacheMode.FIXED_SIZES;
53
@XmlElement String maxHozCachedImgScaling = "1.0";
54
@XmlElement String maxVertCachedImgScaling = "1.0";
55
56
@XmlElement(name="uiProperty")
57
@XmlElementWrapper(name="uiproperties")
58
private List<UIProperty> uiProperties = new ArrayList<UIProperty>();
59
60
private UIStyle parentStyle = null;
61
public void setParentStyle(UIStyle parentStyle) {
62
this.parentStyle = parentStyle;
63
}
64
65
public CacheMode getCacheMode() {
66
if (cacheSettingsInherited) {
67
return (parentStyle == null ?
68
CacheMode.FIXED_SIZES : parentStyle.getCacheMode());
69
} else {
70
return cacheMode;
71
}
72
}
73
74
public String getMaxHozCachedImgScaling() {
75
if (cacheSettingsInherited) {
76
return (parentStyle == null ?
77
"1.0" : parentStyle.getMaxHozCachedImgScaling());
78
} else {
79
return maxHozCachedImgScaling;
80
}
81
}
82
83
public String getMaxVertCachedImgScaling() {
84
if (cacheSettingsInherited) {
85
return (parentStyle == null ?
86
"1.0" : parentStyle.getMaxVertCachedImgScaling());
87
} else {
88
return maxVertCachedImgScaling;
89
}
90
}
91
92
public String write(String prefix) {
93
StringBuilder sb = new StringBuilder();
94
if (! textForegroundInherited) {
95
sb.append(String.format(" addColor(d, \"%s%s\", %s);\n",
96
prefix, "textForeground", textForeground.getValue().write()));
97
}
98
if (! textBackgroundInherited) {
99
sb.append(String.format(" addColor(d, \"%s%s\", %s);\n",
100
prefix, "textBackground", textBackground.getValue().write()));
101
}
102
if (! backgroundInherited) {
103
sb.append(String.format(" addColor(d, \"%s%s\", %s);\n",
104
prefix, "background", background.getValue().write()));
105
}
106
for (UIProperty property : uiProperties) {
107
sb.append(property.write(prefix));
108
}
109
return sb.toString();
110
}
111
}
112
113