OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [javax/] [swing/] [plaf/] [multi/] [MultiToolTipUI.java] - Blame information for rev 772

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 772 jeremybenn
/* MultiToolTipUI.java --
2
   Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 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.plaf.multi;
39
 
40
import java.awt.Dimension;
41
import java.awt.Graphics;
42
import java.util.Iterator;
43
import java.util.Vector;
44
 
45
import javax.accessibility.Accessible;
46
import javax.swing.JComponent;
47
import javax.swing.LookAndFeel;
48
import javax.swing.UIManager;
49
import javax.swing.plaf.ComponentUI;
50
import javax.swing.plaf.ToolTipUI;
51
 
52
/**
53
 * A UI delegate that that coordinates multiple {@link ToolTipUI}
54
 * instances, one from the primary look and feel, and one or more from the
55
 * auxiliary look and feel(s).
56
 *
57
 * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
58
 */
59
public class MultiToolTipUI extends ToolTipUI
60
{
61
 
62
  /** A list of references to the actual component UIs. */
63
  protected Vector uis;
64
 
65
  /**
66
   * Creates a new <code>MultiToolTipUI</code> instance.
67
   *
68
   * @see #createUI(JComponent)
69
   */
70
  public MultiToolTipUI()
71
  {
72
    uis = new Vector();
73
  }
74
 
75
  /**
76
   * Creates a delegate object for the specified component.  If any auxiliary
77
   * look and feels support this component, a <code>MultiToolTipUI</code> is
78
   * returned, otherwise the UI from the default look and feel is returned.
79
   *
80
   * @param target  the component.
81
   *
82
   * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
83
   */
84
  public static ComponentUI createUI(JComponent target)
85
  {
86
    MultiToolTipUI mui = new MultiToolTipUI();
87
    return MultiLookAndFeel.createUIs(mui, mui.uis, target);
88
  }
89
 
90
  /**
91
   * Calls the {@link ComponentUI#installUI(JComponent)} method for all
92
   * the UI delegates managed by this <code>MultiToolTipUI</code>.
93
   *
94
   * @param c  the component.
95
   */
96
  public void installUI(JComponent c)
97
  {
98
    Iterator iterator = uis.iterator();
99
    while (iterator.hasNext())
100
    {
101
      ComponentUI ui = (ComponentUI) iterator.next();
102
      ui.installUI(c);
103
    }
104
  }
105
 
106
  /**
107
   * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
108
   * the UI delegates managed by this <code>MultiToolTipUI</code>.
109
   *
110
   * @param c  the component.
111
   */
112
  public void uninstallUI(JComponent c)
113
  {
114
    Iterator iterator = uis.iterator();
115
    while (iterator.hasNext())
116
    {
117
      ComponentUI ui = (ComponentUI) iterator.next();
118
      ui.uninstallUI(c);
119
    }
120
  }
121
 
122
  /**
123
   * Returns an array containing the UI delegates managed by this
124
   * <code>MultiToolTipUI</code>.  The first item in the array is always
125
   * the UI delegate from the installed default look and feel.
126
   *
127
   * @return An array of UI delegates.
128
   */
129
  public ComponentUI[] getUIs()
130
  {
131
    return MultiLookAndFeel.uisToArray(uis);
132
  }
133
 
134
  /**
135
   * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
136
   * the UI delegates managed by this <code>MultiToolTipUI</code>,
137
   * returning the result for the UI delegate from the primary look and
138
   * feel.
139
   *
140
   * @param c  the component.
141
   * @param x  the x-coordinate.
142
   * @param y  the y-coordinate.
143
   *
144
   * @return <code>true</code> if the specified (x, y) coordinate falls within
145
   *         the bounds of the component as rendered by the UI delegate in the
146
   *         primary look and feel, and <code>false</code> otherwise.
147
   */
148
  public boolean contains(JComponent c, int x, int y)
149
  {
150
    boolean result = false;
151
    Iterator iterator = uis.iterator();
152
    // first UI delegate provides the return value
153
    if (iterator.hasNext())
154
      {
155
        ComponentUI ui = (ComponentUI) iterator.next();
156
        result = ui.contains(c, x, y);
157
      }
158
    // return values from auxiliary UI delegates are ignored
159
    while (iterator.hasNext())
160
      {
161
        ComponentUI ui = (ComponentUI) iterator.next();
162
        /* boolean ignored = */ ui.contains(c, x, y);
163
      }
164
    return result;
165
  }
166
 
167
  /**
168
   * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
169
   * the UI delegates managed by this <code>MultiToolTipUI</code>.
170
   *
171
   * @param g  the graphics device.
172
   * @param c  the component.
173
   */
174
  public void update(Graphics g, JComponent c)
175
  {
176
    Iterator iterator = uis.iterator();
177
    while (iterator.hasNext())
178
    {
179
      ComponentUI ui = (ComponentUI) iterator.next();
180
      ui.update(g, c);
181
    }
182
  }
183
 
184
  /**
185
   * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
186
   * delegates managed by this <code>MultiToolTipUI</code>.
187
   *
188
   * @param g  the graphics device.
189
   * @param c  the component.
190
   */
191
  public void paint(Graphics g, JComponent c)
192
  {
193
    Iterator iterator = uis.iterator();
194
    while (iterator.hasNext())
195
    {
196
      ComponentUI ui = (ComponentUI) iterator.next();
197
      ui.paint(g, c);
198
    }
199
  }
200
 
201
  /**
202
   * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
203
   * the UI delegates managed by this <code>MultiToolTipUI</code>,
204
   * returning the preferred size for the UI delegate from the primary look and
205
   * feel.
206
   *
207
   * @param c  the component.
208
   *
209
   * @return The preferred size returned by the UI delegate from the primary
210
   *         look and feel.
211
   */
212
  public Dimension getPreferredSize(JComponent c)
213
  {
214
    Dimension result = null;
215
    Iterator iterator = uis.iterator();
216
    // first UI delegate provides the return value
217
    if (iterator.hasNext())
218
      {
219
        ComponentUI ui = (ComponentUI) iterator.next();
220
        result = ui.getPreferredSize(c);
221
      }
222
    // return values from auxiliary UI delegates are ignored
223
    while (iterator.hasNext())
224
      {
225
        ComponentUI ui = (ComponentUI) iterator.next();
226
        /* Dimension ignored = */ ui.getPreferredSize(c);
227
      }
228
    return result;
229
  }
230
 
231
  /**
232
   * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
233
   * the UI delegates managed by this <code>MultiToolTipUI</code>,
234
   * returning the minimum size for the UI delegate from the primary look and
235
   * feel.
236
   *
237
   * @param c  the component.
238
   *
239
   * @return The minimum size returned by the UI delegate from the primary
240
   *         look and feel.
241
   */
242
  public Dimension getMinimumSize(JComponent c)
243
  {
244
    Dimension result = null;
245
    Iterator iterator = uis.iterator();
246
    // first UI delegate provides the return value
247
    if (iterator.hasNext())
248
      {
249
        ComponentUI ui = (ComponentUI) iterator.next();
250
        result = ui.getMinimumSize(c);
251
      }
252
    // return values from auxiliary UI delegates are ignored
253
    while (iterator.hasNext())
254
      {
255
        ComponentUI ui = (ComponentUI) iterator.next();
256
        /* Dimension ignored = */ ui.getMinimumSize(c);
257
      }
258
    return result;
259
  }
260
 
261
  /**
262
   * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
263
   * the UI delegates managed by this <code>MultiToolTipUI</code>,
264
   * returning the maximum size for the UI delegate from the primary look and
265
   * feel.
266
   *
267
   * @param c  the component.
268
   *
269
   * @return The maximum size returned by the UI delegate from the primary
270
   *         look and feel.
271
   */
272
  public Dimension getMaximumSize(JComponent c)
273
  {
274
    Dimension result = null;
275
    Iterator iterator = uis.iterator();
276
    // first UI delegate provides the return value
277
    if (iterator.hasNext())
278
      {
279
        ComponentUI ui = (ComponentUI) iterator.next();
280
        result = ui.getMaximumSize(c);
281
      }
282
    // return values from auxiliary UI delegates are ignored
283
    while (iterator.hasNext())
284
      {
285
        ComponentUI ui = (ComponentUI) iterator.next();
286
        /* Dimension ignored = */ ui.getMaximumSize(c);
287
      }
288
    return result;
289
  }
290
 
291
  /**
292
   * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
293
   * for all the UI delegates managed by this <code>MultiToolTipUI</code>,
294
   * returning the count for the UI delegate from the primary look and
295
   * feel.
296
   *
297
   * @param c  the component.
298
   *
299
   * @return The count returned by the UI delegate from the primary
300
   *         look and feel.
301
   */
302
  public int getAccessibleChildrenCount(JComponent c)
303
  {
304
    int result = 0;
305
    Iterator iterator = uis.iterator();
306
    // first UI delegate provides the return value
307
    if (iterator.hasNext())
308
      {
309
        ComponentUI ui = (ComponentUI) iterator.next();
310
        result = ui.getAccessibleChildrenCount(c);
311
      }
312
    // return values from auxiliary UI delegates are ignored
313
    while (iterator.hasNext())
314
      {
315
        ComponentUI ui = (ComponentUI) iterator.next();
316
        /* int ignored = */ ui.getAccessibleChildrenCount(c);
317
      }
318
    return result;
319
  }
320
 
321
  /**
322
   * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
323
   * for all the UI delegates managed by this <code>MultiToolTipUI</code>,
324
   * returning the child for the UI delegate from the primary look and
325
   * feel.
326
   *
327
   * @param c  the component
328
   * @param i  the child index.
329
   *
330
   * @return The child returned by the UI delegate from the primary
331
   *         look and feel.
332
   */
333
  public Accessible getAccessibleChild(JComponent c, int i)
334
  {
335
    Accessible result = null;
336
    Iterator iterator = uis.iterator();
337
    // first UI delegate provides the return value
338
    if (iterator.hasNext())
339
      {
340
        ComponentUI ui = (ComponentUI) iterator.next();
341
        result = ui.getAccessibleChild(c, i);
342
      }
343
    // return values from auxiliary UI delegates are ignored
344
    while (iterator.hasNext())
345
      {
346
        ComponentUI ui = (ComponentUI) iterator.next();
347
        /* Accessible ignored = */ ui.getAccessibleChild(c, i);
348
      }
349
    return result;
350
  }
351
 
352
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.