1 /* SynthStyle.java -- A set of style properties
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing.plaf.synth;
41 import gnu.classpath.NotImplementedException;
43 import java.awt.Color;
45 import java.awt.Insets;
47 import javax.swing.Icon;
50 * A set of style properties that can be installed on a component.
52 * @author Roman Kennke (kennke@aicas.com)
56 public abstract class SynthStyle
60 * Creates a new <code>SynthStyle</code> object.
63 throws NotImplementedException
65 // FIXME: Implement this correctly.
68 public SynthGraphicsUtils getGraphicsUtils(SynthContext ctx)
69 throws NotImplementedException
71 // FIXME: Implement this correctly.
75 public Color getColor(SynthContext ctx, ColorType type)
76 throws NotImplementedException
78 // FIXME: Implement this correctly.
82 protected abstract Color getColorForState(SynthContext ctx, ColorType type);
84 public Font getFont(SynthContext ctx)
85 throws NotImplementedException
87 // FIXME: Implement this correctly.
91 protected abstract Font getFontForState(SynthContext ctx);
93 public Insets getInsets(SynthContext ctx, Insets result)
94 throws NotImplementedException
96 // FIXME: Implement this correctly.
100 public SynthPainter getPainter(SynthContext ctx)
101 throws NotImplementedException
103 // FIXME: Implement this correctly.
107 public boolean isOpaque(SynthContext ctx)
108 throws NotImplementedException
110 // FIXME: Implement this correctly.
114 public Object get(SynthContext ctx, Object key)
115 throws NotImplementedException
117 // FIXME: Implement this correctly.
121 public void installDefaults(SynthContext ctx)
122 throws NotImplementedException
124 // FIXME: Implement this correctly.
127 public void uninstallDefaults(SynthContext ctx)
128 throws NotImplementedException
130 // FIXME: Implement this correctly.
134 * A convenience method to fetch an integer property.
135 * If the property's value is a {@link Number}, then the
136 * integer value is returned. Otherwise, the default value
138 * @param ctx the context
139 * @param key the key to fetch
140 * @param defaultValue the default value
141 * @return the integer value of the property, or the default value
143 public int getInt(SynthContext ctx, Object key, int defaultValue)
145 Object obj = get(ctx, key);
146 if (obj instanceof Number)
147 return ((Number) obj).intValue();
152 * A convenience method to fetch an integer property.
153 * If the property's value is a {@link Boolean}, then the
154 * value is returned. Otherwise, the default value
156 * @param ctx the context
157 * @param key the key to fetch
158 * @param defaultValue the default value
159 * @return the boolean value of the property, or the default value
161 public boolean getBoolean(SynthContext ctx, Object key,
162 boolean defaultValue)
164 Object obj = get(ctx, key);
165 if (obj instanceof Boolean)
166 return ((Boolean) obj).booleanValue();
171 * A convenience method to fetch an Icon-valued property.
172 * If the property's value is an {@link Icon}, then the
173 * value is returned. Otherwise, null is returned.
174 * @param ctx the context
175 * @param key the key to fetch
176 * @return the icon, or null
178 public Icon getIcon(SynthContext ctx, Object key)
180 Object obj = get(ctx, key);
181 if (key instanceof Icon)
187 * A convenience method to fetch a String property.
188 * If the property's value is a {@link String}, then the
189 * value is returned. Otherwise, the default value
191 * @param ctx the context
192 * @param key the key to fetch
193 * @param defaultValue the default value
194 * @return the String value of the property, or the default value
196 public String getString(SynthContext ctx, Object key, String defaultValue)
198 Object obj = get(ctx, key);
199 if (obj instanceof String)