Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/make/src/classes/build/tools/generatenimbus/UIStyle.java
32287 views
/*1* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package build.tools.generatenimbus;2627import java.util.ArrayList;28import java.util.List;29import javax.xml.bind.annotation.XmlElement;30import javax.xml.bind.annotation.XmlElementWrapper;313233class UIStyle {34public static enum CacheMode {35NO_CACHING, FIXED_SIZES, NINE_SQUARE_SCALE36}3738@XmlElement private UIColor textForeground = null;39@XmlElement(name="inherit-textForeground")40private boolean textForegroundInherited = true;4142@XmlElement private UIColor textBackground = null;43@XmlElement(name="inherit-textBackground")44private boolean textBackgroundInherited = true;4546@XmlElement private UIColor background = null;47@XmlElement(name="inherit-background")48private boolean backgroundInherited = true;4950@XmlElement private boolean cacheSettingsInherited = true;51@XmlElement CacheMode cacheMode = CacheMode.FIXED_SIZES;52@XmlElement String maxHozCachedImgScaling = "1.0";53@XmlElement String maxVertCachedImgScaling = "1.0";5455@XmlElement(name="uiProperty")56@XmlElementWrapper(name="uiproperties")57private List<UIProperty> uiProperties = new ArrayList<UIProperty>();5859private UIStyle parentStyle = null;60public void setParentStyle(UIStyle parentStyle) {61this.parentStyle = parentStyle;62}6364public CacheMode getCacheMode() {65if (cacheSettingsInherited) {66return (parentStyle == null ?67CacheMode.FIXED_SIZES : parentStyle.getCacheMode());68} else {69return cacheMode;70}71}7273public String getMaxHozCachedImgScaling() {74if (cacheSettingsInherited) {75return (parentStyle == null ?76"1.0" : parentStyle.getMaxHozCachedImgScaling());77} else {78return maxHozCachedImgScaling;79}80}8182public String getMaxVertCachedImgScaling() {83if (cacheSettingsInherited) {84return (parentStyle == null ?85"1.0" : parentStyle.getMaxVertCachedImgScaling());86} else {87return maxVertCachedImgScaling;88}89}9091public String write(String prefix) {92StringBuilder sb = new StringBuilder();93if (! textForegroundInherited) {94sb.append(String.format(" addColor(d, \"%s%s\", %s);\n",95prefix, "textForeground", textForeground.getValue().write()));96}97if (! textBackgroundInherited) {98sb.append(String.format(" addColor(d, \"%s%s\", %s);\n",99prefix, "textBackground", textBackground.getValue().write()));100}101if (! backgroundInherited) {102sb.append(String.format(" addColor(d, \"%s%s\", %s);\n",103prefix, "background", background.getValue().write()));104}105for (UIProperty property : uiProperties) {106sb.append(property.write(prefix));107}108return sb.toString();109}110}111112113