Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/make/src/classes/build/tools/generatenimbus/UIProperty.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 javax.xml.bind.annotation.XmlAttribute;28import javax.xml.bind.annotation.XmlElement;2930class UIProperty extends UIDefault<String> {31public static enum PropertyType {32BOOLEAN, INT, FLOAT, DOUBLE, STRING, FONT, COLOR, INSETS, DIMENSION, BORDER33}34@XmlAttribute private PropertyType type;3536@XmlElement private Border border;37@XmlElement private Dimension dimension;38@XmlElement private Insets insets;39@XmlElement private Matte matte;40@XmlElement private Typeface typeface;4142@XmlAttribute43@Override public void setValue(String value) {44super.setValue(value);45}4647public String write(String prefix) {48switch (type) {49case BOOLEAN:50return String.format(" d.put(\"%s%s\", Boolean.%s);\n",51prefix, getName(), getValue().toUpperCase()); ///autobox52case STRING:53return String.format(" d.put(\"%s%s\", \"%s\");\n",54prefix, getName(), getValue());55case INT:56return String.format(" d.put(\"%s%s\", new Integer(%s));\n",57prefix, getName(), getValue());58case FLOAT:59return String.format(" d.put(\"%s%s\", new Float(%sf));\n",60prefix, getName(), getValue());61case DOUBLE:62return String.format(" d.put(\"%s%s\", new Double(%s));\n",63prefix, getName(), getValue());64case COLOR:65return String.format(" addColor(d, \"%s%s\", %s);\n",66prefix, getName(), matte.write());67case FONT:68return String.format(" d.put(\"%s%s\", %s);\n",69prefix, getName(), typeface.write());70case INSETS:71return String.format(" d.put(\"%s%s\", %s);\n",72prefix, getName(), insets.write(true));73case DIMENSION:74return String.format(" d.put(\"%s%s\", new DimensionUIResource(%d, %d));\n",75prefix, getName(), dimension.width, dimension.height);76case BORDER:77return String.format(" d.put(\"%s%s\", new BorderUIResource(%s));\n",78prefix, getName(), border.write());79default:80return "### Look, something's wrong with UIProperty.write() $$$";81}82}83}848586