1 /*
2 * Copyright (c) 2001, 2009, 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
48 /**
49 * Corresponds to a MetalTheme font type.
50 */
51 private int type;
52
53
54 /**
55 * Creates a MetalFontDesktopProperty. The key used to lookup the
56 * desktop property is determined from the type of font.
57 *
58 * @param type MetalTheme font type.
59 */
60 MetalFontDesktopProperty(int type) {
61 this(propertyMapping[type], type);
62 }
63
64 /**
65 * Creates a MetalFontDesktopProperty.
66 *
67 * @param key Key used in looking up desktop value.
68 * @param toolkit Toolkit used to fetch property from, can be null
69 * in which default will be used.
70 * @param type Type of font being used, corresponds to MetalTheme font
71 * type.
72 */
73 MetalFontDesktopProperty(String key, int type) {
74 super(key, null);
75 this.type = type;
76 }
77
78 /**
79 * Overriden to create a Font with the size coming from the desktop
80 * and the style and name coming from DefaultMetalTheme.
81 */
82 protected Object configureValue(Object value) {
83 if (value instanceof Integer) {
84 value = new Font(DefaultMetalTheme.getDefaultFontName(type),
85 DefaultMetalTheme.getDefaultFontStyle(type),
86 ((Integer)value).intValue());
87 }
88 return super.configureValue(value);
89 }
|
1 /*
2 * Copyright (c) 2001, 2017, 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
48 /**
49 * Corresponds to a MetalTheme font type.
50 */
51 private int type;
52
53
54 /**
55 * Creates a MetalFontDesktopProperty. The key used to lookup the
56 * desktop property is determined from the type of font.
57 *
58 * @param type MetalTheme font type.
59 */
60 MetalFontDesktopProperty(int type) {
61 this(propertyMapping[type], type);
62 }
63
64 /**
65 * Creates a MetalFontDesktopProperty.
66 *
67 * @param key Key used in looking up desktop value.
68 * @param type Type of font being used, corresponds to MetalTheme font
69 * type.
70 */
71 MetalFontDesktopProperty(String key, int type) {
72 super(key, null);
73 this.type = type;
74 }
75
76 /**
77 * Overriden to create a Font with the size coming from the desktop
78 * and the style and name coming from DefaultMetalTheme.
79 */
80 protected Object configureValue(Object value) {
81 if (value instanceof Integer) {
82 value = new Font(DefaultMetalTheme.getDefaultFontName(type),
83 DefaultMetalTheme.getDefaultFontStyle(type),
84 ((Integer)value).intValue());
85 }
86 return super.configureValue(value);
87 }
|