1 /* SynthLookAndFeel.java -- A skinnable Swing look and feel
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.Component;
44 import java.io.InputStream;
45 import java.text.ParseException;
47 import javax.swing.JComponent;
48 import javax.swing.UIDefaults;
49 import javax.swing.plaf.ComponentUI;
50 import javax.swing.plaf.basic.BasicLookAndFeel;
54 * A look and feel that can be customized either by providing a file to
55 * {@link #load} or by setting a {@link SynthStyleFactory} using
56 * {@link #setStyleFactory}.
58 * @author Roman Kennke (kennke@aicas.com)
62 public class SynthLookAndFeel
63 extends BasicLookAndFeel
67 * The style factory that will be used by the UI classes to load their
70 private static SynthStyleFactory styleFactory;
73 * Creates a new instance of <code>SynthLookAndFeel</code>. In order to use
74 * the Synth look and feel you either need to call {@link #load} to load a
75 * set of styles from an XML file, or you need to call
76 * {@link #setStyleFactory} to provide your own style factory.
78 public SynthLookAndFeel()
80 // FIXME: What to do here, if anything?
84 * Sets the style factory that the UI classes of Synth will use to load their
87 * @param sf the style factory to set
89 public static void setStyleFactory(SynthStyleFactory sf)
95 * Returns the current style factory that the UI classes of Synth will use to
96 * load their sets of styles.
98 * @return the current style factory
100 public static SynthStyleFactory getStyleFactory()
106 * Returns the style for the specified component and region.
108 * @param c the component for which to return the style
109 * @param r the region of the component for which to return the style
111 * @return the style for the specified component and region
113 public static SynthStyle getStyle(JComponent c, Region r)
115 return getStyleFactory().getStyle(c, r);
119 * Updates all style information of the component and it's children.
121 * @param c the componenent for which to update the style
123 public static void updateStyles(Component c)
124 throws NotImplementedException
126 // FIXME: Implement this properly.
130 * Returns the region for a given Swing component.
132 * @param c the Swing component for which to fetch the region
134 * @return the region for a given Swing component
136 public static Region getRegion(JComponent c)
137 throws NotImplementedException
139 // FIXME: This can be implemented as soon as we have the component UI
140 // classes in place, since this region will be matched via the UI classes.
145 * Creates the Synth look and feel component UI instance for the given
148 * @param c the component for which to create a UI instance
150 * @return the Synth look and feel component UI instance for the given
153 public static ComponentUI createUI(JComponent c)
154 throws NotImplementedException
156 // FIXME: This can be implemented as soon as we have the component UI
162 * Initializes this look and feel.
164 public void initialize()
165 throws NotImplementedException
168 // TODO: Implement at least the following here:
169 // if (styleFactory != null)
170 // styleFactory = new DefaultStyleFactory();
174 * Uninitializes the look and feel.
176 public void uninitialize()
177 throws NotImplementedException
179 super.uninitialize();
180 // TODO: What to do here?
184 * Returns the UI defaults of this look and feel.
186 * @return the UI defaults of this look and feel
188 public UIDefaults getDefaults()
189 throws NotImplementedException
191 // FIXME: This is certainly wrong. The defaults should be fetched/merged
192 // from the file from which the l&f is loaded.
193 return super.getDefaults();
197 * FIXME: DOCUMENT ME!
201 public boolean shouldUpdateStyleOnAncestorChanged()
202 throws NotImplementedException
208 * Loads a set of {@link SynthStyle}s that are used for the look and feel of
209 * the components. The <code>resourceBase</code> parameter is used to resolve
210 * references against, like icons and other files.
212 * @param in the input stream from where to load the styles
213 * @param resourceBase the base against which references are resolved.
215 * @throws ParseException if the input stream cannot be parsed
216 * @throws IllegalArgumentException if one of the parameters is
219 public void load(InputStream in, Class<?> resourceBase)
220 throws ParseException, IllegalArgumentException, NotImplementedException
222 // FIXME: Implement this correctly.
226 * Returns a textual description of the Synth look and feel. This returns
227 * "Synth look and feel".
229 * @return a textual description of the Synth look and feel
231 public String getDescription()
233 return "Synth look and feel";
237 * Returns the ID of the Synth look and feel. This returns "Synth".
239 * @return the ID of the Synth look and feel
241 public String getID()
247 * Returns the name of the Synth look and feel. This returns
248 * "Synth look and feel".
250 * @return the name of the Synth look and feel
252 public String getName()
254 return "Synth look and feel";
258 * Returns <code>false</code> since the Synth look and feel is not a native
261 * @return <code>false</code>
263 public boolean isNativeLookAndFeel()
269 * Returns <code>true</code> since the Synth look and feel is always a
270 * supported look and feel.
272 * @return <code>true</code>
274 public boolean isSupportedLookAndFeel()