~ubuntu-branches/ubuntu/precise/classpath/precise

« back to all changes in this revision

Viewing changes to java/awt/peer/ComponentPeer.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2006-05-27 16:11:15 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060527161115-h6e39eposdt5snb6
Tags: 2:0.91-3
* Install header files to /usr/include/classpath.
* debian/control: classpath: Conflict with jamvm < 1.4.3 and
  cacao < 0.96 (Closes: #368172).

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
import java.awt.image.ImageProducer;
60
60
import java.awt.image.VolatileImage;
61
61
 
 
62
/**
 
63
 * Defines the methods that a component peer is required to implement.
 
64
 */
62
65
public interface ComponentPeer
63
66
{
 
67
  /**
 
68
   * Returns the construction status of the specified image. This is called
 
69
   * by {@link Component#checkImage(Image, int, int, ImageObserver)}.
 
70
   *
 
71
   * @param img the image
 
72
   * @param width the width of the image
 
73
   * @param height the height of the image
 
74
   * @param ob the image observer to be notified of updates of the status
 
75
   *
 
76
   * @return a bitwise ORed set of ImageObserver flags
 
77
   */
64
78
  int checkImage(Image img, int width, int height, 
65
 
                 ImageObserver ob);
 
79
                 ImageObserver ob);
 
80
 
 
81
  /**
 
82
   * Creates an image by starting the specified image producer. This is called
 
83
   * by {@link Component#createImage(ImageProducer)}.
 
84
   *
 
85
   * @param prod the image producer to be used to create the image
 
86
   *
 
87
   * @return the created image
 
88
   */
66
89
  Image createImage(ImageProducer prod);
 
90
 
 
91
  /**
 
92
   * Creates an empty image with the specified <code>width</code> and
 
93
   * <code>height</code>.
 
94
   *
 
95
   * @param width the width of the image to be created
 
96
   * @param height the height of the image to be created
 
97
   *
 
98
   * @return the created image
 
99
   */
67
100
  Image createImage(int width, int height);
 
101
 
 
102
  /**
 
103
   * Disables the component. This is called by {@link Component#disable()}.
 
104
   */
68
105
  void disable();
 
106
 
 
107
  /**
 
108
   * Disposes the component peer. This should release all resources held by the
 
109
   * peer. This is called when the component is no longer in use.
 
110
   */
69
111
  void dispose();
 
112
 
 
113
  /**
 
114
   * Enables the component. This is called by {@link Component#enable()}.
 
115
   */
70
116
  void enable();
 
117
 
 
118
  /**
 
119
   * Returns the color model of the component. This is currently not used.
 
120
   *
 
121
   * @return the color model of the component
 
122
   */
71
123
  ColorModel getColorModel();
 
124
 
 
125
  /**
 
126
   * Returns the font metrics for the specified font. This is called by
 
127
   * {@link Component#getFontMetrics(Font)}.
 
128
   *
 
129
   * @param f the font for which to query the font metrics
 
130
   *
 
131
   * @return the font metrics for the specified font
 
132
   */
72
133
  FontMetrics getFontMetrics(Font f);
 
134
 
 
135
  /**
 
136
   * Returns a {@link Graphics} object suitable for drawing on this component.
 
137
   * This is called by {@link Component#getGraphics()}.
 
138
   *
 
139
   * @return a graphics object suitable for drawing on this component
 
140
   */
73
141
  Graphics getGraphics();
 
142
 
 
143
  /**
 
144
   * Returns the location of this component in screen coordinates. This is
 
145
   * called by {@link Component#getLocationOnScreen()}.
 
146
   *
 
147
   * @return the location of this component in screen coordinates
 
148
   */
74
149
  Point getLocationOnScreen();
 
150
 
 
151
  /**
 
152
   * Returns the minimum size for the component. This is called by
 
153
   * {@link Component#getMinimumSize()}.
 
154
   *
 
155
   * @return the minimum size for the component
 
156
   */
75
157
  Dimension getMinimumSize();
 
158
 
 
159
  /**
 
160
   * Returns the preferred size for the component. This is called by
 
161
   * {@link Component#getPreferredSize()}.
 
162
   *
 
163
   * @return the preferred size for the component
 
164
   */
76
165
  Dimension getPreferredSize();
 
166
 
 
167
  /**
 
168
   * Returns the toolkit that created this peer.
 
169
   *
 
170
   * @return the toolkit that created this peer
 
171
   */
77
172
  Toolkit getToolkit();
 
173
 
 
174
  /**
 
175
   * Handles the given event. This is called from
 
176
   * {@link Component#dispatchEvent(AWTEvent)} to give the peer a chance to 
 
177
   * react to events for the component.
 
178
   *
 
179
   * @param e the event
 
180
   */
78
181
  void handleEvent(AWTEvent e);
 
182
 
 
183
  /**
 
184
   * Makes the component invisible. This is called from
 
185
   * {@link Component#hide()}.
 
186
   */
79
187
  void hide();
80
188
 
81
189
  /**
82
 
   * Part of the earlier 1.1 API, replaced by isFocusable().
 
190
   * Returns <code>true</code> if the component can receive keyboard input
 
191
   * focus. This is called from {@link Component#isFocusTraversable()}.
 
192
   * 
 
193
   * @specnote Part of the earlier 1.1 API, replaced by isFocusable().
83
194
   */
84
195
  boolean isFocusTraversable();
 
196
 
 
197
  /**
 
198
   * Returns <code>true</code> if the component can receive keyboard input
 
199
   * focus. This is called from {@link Component#isFocusable()}.
 
200
   */
85
201
  boolean isFocusable();
 
202
 
 
203
  /**
 
204
   * Returns the minimum size for the component. This is called by
 
205
   * {@link Component#minimumSize()}.
 
206
   *
 
207
   * @return the minimum size for the component
 
208
   */
86
209
  Dimension minimumSize();
 
210
 
 
211
  /**
 
212
   * Returns the preferred size for the component. This is called by
 
213
   * {@link Component#getPreferredSize()}.
 
214
   *
 
215
   * @return the preferred size for the component
 
216
   */
87
217
  Dimension preferredSize();
 
218
 
88
219
  void paint(Graphics graphics);
 
220
 
 
221
  /**
 
222
   * Prepares an image for rendering on this component. This is called by
 
223
   * {@link Component#prepareImage(Image, int, int, ImageObserver)}.
 
224
   *
 
225
   * @param img the image to prepare
 
226
   * @param width the desired width of the rendered image
 
227
   * @param height the desired height of the rendered image
 
228
   * @param ob the image observer to be notified of updates in the preparation
 
229
   *        process
 
230
   *
 
231
   * @return <code>true</code> if the image has been fully prepared,
 
232
   *         <code>false</code> otherwise (in which case the image observer
 
233
   *         receives updates)
 
234
   */
89
235
  boolean prepareImage(Image img, int width, int height,
90
236
                              ImageObserver ob);
 
237
 
91
238
  void print(Graphics graphics);
 
239
 
 
240
  /**
 
241
   * Repaints the specified rectangle of this component. This is called from
 
242
   * {@link Component#repaint(long, int, int, int, int)}.
 
243
   *
 
244
   * @param tm number of milliseconds to wait with repainting
 
245
   * @param x the X coordinate of the upper left corner of the damaged rectangle
 
246
   * @param y the Y coordinate of the upper left corner of the damaged rectangle
 
247
   * @param width the width of the damaged rectangle
 
248
   * @param height the height of the damaged rectangle
 
249
   */
92
250
  void repaint(long tm, int x, int y, int width, int height);
93
251
 
94
252
  /**
95
 
   * Part of the earlier 1.1 API, apparently replaced by argument 
96
 
   * form of the same method.
 
253
   * Requests that this component receives the focus. This is called from
 
254
   * {@link Component#requestFocus()}.
 
255
   * 
 
256
   * @specnote Part of the earlier 1.1 API, apparently replaced by argument 
 
257
   *           form of the same method.
97
258
   */
98
259
  void requestFocus();
99
 
  boolean requestFocus (Component source, boolean bool1, boolean bool2, long x);
100
 
 
 
260
 
 
261
  /**
 
262
   * Requests that this component receives the focus. This is called from
 
263
   * {@link Component#requestFocus()}.
 
264
   *
 
265
   * @param source TODO
 
266
   * @param bool1 TODO
 
267
   * @param bool2 TODO
 
268
   * @param x TODO
 
269
   */
 
270
  boolean requestFocus(Component source, boolean bool1, boolean bool2, long x);
 
271
 
 
272
  /**
 
273
   * Notifies the peer that the bounds of this component have changed. This
 
274
   * is called by {@link Component#reshape(int, int, int, int)}.
 
275
   *
 
276
   * @param x the X coordinate of the upper left corner of the component
 
277
   * @param y the Y coordinate of the upper left corner of the component
 
278
   * @param width the width of the component
 
279
   * @param height the height of the component
 
280
   */
101
281
  void reshape(int x, int y, int width, int height);
 
282
 
 
283
  /**
 
284
   * Sets the background color of the component. This is called by
 
285
   * {@link Component#setBackground(Color)}.
 
286
   *
 
287
   * @param color the background color to set
 
288
   */
102
289
  void setBackground(Color color);
 
290
 
 
291
  /**
 
292
   * Notifies the peer that the bounds of this component have changed. This
 
293
   * is called by {@link Component#setBounds(int, int, int, int)}.
 
294
   *
 
295
   * @param x the X coordinate of the upper left corner of the component
 
296
   * @param y the Y coordinate of the upper left corner of the component
 
297
   * @param width the width of the component
 
298
   * @param height the height of the component
 
299
   */
103
300
  void setBounds(int x, int y, int width, int height);
104
301
 
105
302
  /**
106
 
   * Part of the earlier 1.1 API, apparently no longer needed.
 
303
   * Sets the cursor of the component. This is called by
 
304
   * {@link Component#setCursor(Cursor)}.
 
305
   *
 
306
   * @specnote Part of the earlier 1.1 API, apparently no longer needed.
107
307
   */
108
308
  void setCursor(Cursor cursor);
109
309
 
 
310
  /**
 
311
   * Sets the enabled/disabled state of this component. This is called by
 
312
   * {@link Component#setEnabled(boolean)}.
 
313
   *
 
314
   * @param enabled <code>true</code> to enable the component,
 
315
   *        <code>false</code> to disable it
 
316
   */
110
317
  void setEnabled(boolean enabled);
 
318
 
 
319
  /**
 
320
   * Sets the font of the component. This is called by
 
321
   * {@link Component#setFont(Font)}.
 
322
   *
 
323
   * @param font the font to set
 
324
   */
111
325
  void setFont(Font font);
 
326
 
 
327
  /**
 
328
   * Sets the foreground color of the component. This is called by
 
329
   * {@link Component#setForeground(Color)}.
 
330
   *
 
331
   * @param color the foreground color to set
 
332
   */
112
333
  void setForeground(Color color);
 
334
 
 
335
  /**
 
336
   * Sets the visibility state of the component. This is called by
 
337
   * {@link Component#setVisible(boolean)}.
 
338
   *
 
339
   * @param visible <code>true</code> to make the component visible,
 
340
   *        <code>false</code> to make it invisible
 
341
   */
113
342
  void setVisible(boolean visible);
 
343
 
 
344
  /**
 
345
   * Makes the component visible. This is called by {@link Component#show()}.
 
346
   */
114
347
  void show();
115
348
 
116
349
  /** 
117
350
   * Get the graphics configuration of the component. The color model
118
351
   * of the component can be derived from the configuration.
 
352
   *
 
353
   * @return the graphics configuration of the component
119
354
   */
120
355
  GraphicsConfiguration getGraphicsConfiguration();
121
356
 
122
357
  /**
123
358
   * Part of an older API, no longer needed.
124
359
   */
125
 
  void setEventMask (long mask);
 
360
  void setEventMask(long mask);
126
361
 
127
 
  // Methods below are introduced since 1.1
 
362
  /**
 
363
   * Returns <code>true</code> if this component has been obscured,
 
364
   * <code>false</code> otherwise. This will only work if
 
365
   * {@link #canDetermineObscurity()} also returns <code>true</code>.
 
366
   *
 
367
   * @return <code>true</code> if this component has been obscured,
 
368
   *         <code>false</code> otherwise.
 
369
   */
128
370
  boolean isObscured();
 
371
 
 
372
  /**
 
373
   * Returns <code>true</code> if this component peer can determine if the
 
374
   * component has been obscured, <code>false</code> otherwise.
 
375
   *
 
376
   * @return <code>true</code> if this component peer can determine if the
 
377
   *         component has been obscured, <code>false</code> otherwise
 
378
   */
129
379
  boolean canDetermineObscurity();
 
380
 
 
381
  /**
 
382
   * Coalesces the specified paint event.
 
383
   *
 
384
   * @param e the paint event
 
385
   */
130
386
  void coalescePaintEvent(PaintEvent e);
 
387
 
 
388
  /**
 
389
   * Updates the cursor.
 
390
   */
131
391
  void updateCursorImmediately();
 
392
 
 
393
  /**
 
394
   * Returns true, if this component can handle wheel scrolling,
 
395
   * <code>false</code> otherwise.
 
396
   *
 
397
   * @return true, if this component can handle wheel scrolling,
 
398
   *         <code>false</code> otherwise
 
399
   */
132
400
  boolean handlesWheelScrolling();
133
401
 
134
402
  /**