OSDN Git Service

2003-10-15 Michael Koch <konqueror@gmx.de>
[pf3gnuchains/gcc-fork.git] / libjava / javax / swing / UIDefaults.java
1 /* UIDefaults.java -- database for all settings and interface bindings.
2    Copyright (C) 2002 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
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)
9 any later version.
10
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.
15
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., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
20
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
24 combination.
25
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. */
37
38 package javax.swing;
39
40 import java.awt.Color;
41 import java.awt.Dimension;
42 import java.awt.Font;
43 import java.awt.Insets;
44 import java.beans.PropertyChangeListener;
45 import java.util.Hashtable;
46 import java.util.Locale;
47 import javax.swing.border.Border;
48 import javax.swing.plaf.ComponentUI;
49
50 /**
51  * UIDefaults is a database where all settings and interface bindings are
52  * stored into. An PLAF implementation fills one of these (see for example
53  * plaf/basic/BasicDefaults.java) with "JButton" -> new BasicButtonUI().
54  *
55  * @author Ronald Veldema (rveldema@cs.vu.nl)
56  */
57 public class UIDefaults extends Hashtable
58 {
59   interface ActiveValue
60   {
61     Object createValue(UIDefaults table);
62   } // interface ActiveValue
63
64   public static class LazyInputMap implements LazyValue
65   {
66     public LazyInputMap(Object[] bindings)
67     {
68     }
69     public Object createValue(UIDefaults table)
70     {
71       throw new Error("not implemented");
72     }
73   } // class LazyInputMap
74
75   interface LazyValue
76   {
77     Object createValue(UIDefaults table);
78   } // interface LazyValue
79
80   public static class ProxyLazyValue implements LazyValue
81   {
82     public ProxyLazyValue(String s)
83     {
84       throw new Error("not implemented");
85     }
86     public ProxyLazyValue(String c, String m)
87     {
88       throw new Error("not implemented");
89     }
90     public ProxyLazyValue(String c, Object[] o)
91     {
92       throw new Error("not implemented");
93     }
94     public ProxyLazyValue(String c, String m, Object[] o)
95     {
96       throw new Error("not implemented");
97     }
98     public Object createValue(UIDefaults table)
99     {
100       throw new Error("not implemented");
101     }
102   } // class ProxyLazyValue
103
104   private static final long serialVersionUID = 7341222528856548117L;
105
106   public UIDefaults()
107   {
108   }
109
110   public UIDefaults(Object[] entries)
111   {
112     // XXX
113   }
114
115   public Object get(Object key)
116   {
117     // XXX Obey 1.4 specs
118     return super.get(key);
119   }
120
121   public Object get(Object key, Locale l)
122   {
123     throw new Error("not implemented");
124   }
125
126   public Object put(Object key, Object value)
127   {
128     throw new Error("not implemented");
129   }
130
131   public void putDefaults(Object[] list)
132   {
133     throw new Error("not implemented");
134   }
135
136   public Font getFont(Object key)
137   {
138     Object o = get(key);
139     return o instanceof Font ? (Font) o : null;
140   }
141
142   public Font getFont(Object key, Locale l)
143   {
144     Object o = get(key, l);
145     return o instanceof Font ? (Font) o : null;
146   }
147
148   public Color getColor(Object key)
149   {
150     Object o = get(key);
151     return o instanceof Color ? (Color) o : null;
152   }
153
154   public Color getColor(Object key, Locale l)
155   {
156     Object o = get(key, l);
157     return o instanceof Color ? (Color) o : null;
158   }
159
160   public Icon getIcon(Object key)
161   {
162     Object o = get(key);
163     return o instanceof Icon ? (Icon) o : null;
164   }
165
166   public Icon getIcon(Object key, Locale l)
167   {
168     Object o = get(key, l);
169     return o instanceof Icon ? (Icon) o : null;
170   }
171
172   public Border getBorder(Object key)
173   {
174     Object o = get(key);
175     return o instanceof Border ? (Border) o : null;
176   }
177
178   public Border getBorder(Object key, Locale l)
179   {
180     Object o = get(key, l);
181     return o instanceof Border ? (Border) o : null;
182   }
183
184   public String getString(Object key)
185   {
186     Object o = get(key);
187     return o instanceof String ? (String) o : null;
188   }
189
190   public String getString(Object key, Locale l)
191   {
192     Object o = get(key, l);
193     return o instanceof String ? (String) o : null;
194   }
195
196   int getInt(Object key)
197   {
198     Object o = get(key);
199     return o instanceof Integer ? ((Integer) o).intValue() : 0;
200   }
201
202   int getInt(Object key, Locale l)
203   {
204     Object o = get(key, l);
205     return o instanceof Integer ? ((Integer) o).intValue() : 0;
206   }
207
208   public boolean getBoolean(Object key)
209   {
210     return Boolean.TRUE.equals(get(key));
211   }
212
213   public boolean getBoolean(Object key, Locale l)
214   {
215     return Boolean.TRUE.equals(get(key, l));
216   }
217
218   public Insets getInsets(Object key) 
219   {
220     Object o = get(key);
221     return o instanceof Insets ? (Insets) o : null;
222   }
223
224   public Insets getInsets(Object key, Locale l) 
225   {
226     Object o = get(key, l);
227     return o instanceof Insets ? (Insets) o : null;
228   }
229
230   public Dimension getDimension(Object key) 
231   {
232     Object o = get(key);
233     return o instanceof Dimension ? (Dimension) o : null;
234   }
235
236   public Dimension getDimension(Object key, Locale l) 
237   {
238     Object o = get(key, l);
239     return o instanceof Dimension ? (Dimension) o : null;
240   }
241
242   public Class getUIClass(String id, ClassLoader loader)
243   {
244     throw new Error("not implemented");
245   }
246
247   public Class getUIClass(String id)
248   {
249     throw new Error("not implemented");
250   }
251
252   protected void getUIError(String msg)
253   {
254     // Does nothing unless overridden.
255   }
256
257   public ComponentUI getUI(JComponent a)
258   {
259     String pp = a.getUIClassID();
260     ComponentUI p = (ComponentUI) get(pp);
261     if (p == null)
262       getUIError("failed to locate UI:" + pp);
263     return p;
264   }
265
266   void addPropertyChangeListener(PropertyChangeListener l)
267   {
268     throw new Error("not implemented");
269   }
270
271   void removePropertyChangeListener(PropertyChangeListener l)
272   {
273     throw new Error("not implemented");
274   }
275
276   public PropertyChangeListener[] getPropertyChangeListeners()
277   {
278     throw new Error("not implemented");
279   }
280
281   protected void firePropertyChange(String property, Object o, Object n)
282   {
283     throw new Error("not implemented");
284   }
285
286   void addResourceBundle(String name)
287   {
288     throw new Error("not implemented");
289   }
290
291   void removeResourceBundle(String name)
292   {
293     throw new Error("not implemented");
294   }
295
296   void setDefaultLocale(Locale l)
297   {
298     throw new Error("not implemented");
299   }
300
301   public Locale getDefaultLocale()
302   {
303     throw new Error("not implemented");
304   }
305 } // class UIDefaults