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 26package build.tools.generatenimbus; 27 28import java.util.ArrayList; 29import javax.xml.bind.annotation.*; 30 31 32@XmlRootElement(name="synthModel") 33public class SynthModel { 34 @XmlElement private UIStyle style; 35 36 @XmlElement(name="uiColor") 37 @XmlElementWrapper(name="colors") 38 private ArrayList<UIColor> colors; 39 40 @XmlElement(name="uiFont") 41 @XmlElementWrapper(name="fonts") 42 private ArrayList<UIFont> fonts; 43 44 @XmlElement(name="uiComponent") 45 @XmlElementWrapper(name="components") 46 private ArrayList<UIComponent> components; 47 48 public void initStyles() { 49 for (UIComponent c: components) { 50 c.initStyles(this.style); 51 } 52 } 53 54 public void write(StringBuilder defBuffer, StringBuilder styleBuffer, String packageName) { 55 defBuffer.append(" //Color palette\n"); 56 for (UIColor c: colors) defBuffer.append(c.write()); 57 defBuffer.append('\n'); 58 59 defBuffer.append(" //Font palette\n"); 60 defBuffer.append(" d.put(\"defaultFont\", new FontUIResource(defaultFont));\n"); 61 for (UIFont f: fonts) defBuffer.append(f.write()); 62 defBuffer.append('\n'); 63 64 defBuffer.append(" //Border palette\n"); 65 defBuffer.append('\n'); 66 67 defBuffer.append(" //The global style definition\n"); 68 defBuffer.append(style.write("")); 69 defBuffer.append('\n'); 70 71 for (UIComponent c: components) { 72 String prefix = Utils.escape(c.getKey()); 73 defBuffer.append(" //Initialize ").append(prefix).append("\n"); 74 c.write(defBuffer, styleBuffer, c, prefix, packageName); 75 defBuffer.append('\n'); 76 } 77 } 78} 79