1 /*
2 * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.awt.peer;
27
28 import java.awt.*;
29 import java.awt.event.PaintEvent;
30 import java.awt.event.FocusEvent.Cause;
31 import java.awt.image.ColorModel;
32 import java.awt.image.ImageObserver;
33 import java.awt.image.ImageProducer;
34 import java.awt.image.VolatileImage;
35
36 import sun.java2d.pipe.Region;
37
38
39 /**
40 * The peer interface for {@link Component}. This is the top level peer
41 * interface for widgets and defines the bulk of methods for AWT component
42 * peers. Most component peers have to implement this interface (via one
43 * of the subinterfaces), except menu components, which implement
44 * {@link MenuComponentPeer}.
45 *
46 * The peer interfaces are intended only for use in porting
47 * the AWT. They are not intended for use by application
48 * developers, and developers should not implement peers
49 * nor invoke any of the peer methods directly on the peer
50 * instances.
51 */
52 public interface ComponentPeer {
53
54 /**
55 * Operation for {@link #setBounds(int, int, int, int, int)}, indicating
56 * a change in the component location only.
57 *
58 * @see #setBounds(int, int, int, int, int)
338 * @param time the time of the focus change request
339 * @param cause the cause of the focus change request
340 *
341 * @return {@code true} if the focus change is guaranteed to be
342 * granted, {@code false} otherwise
343 */
344 boolean requestFocus(Component lightweightChild, boolean temporary,
345 boolean focusedWindowChangeAllowed, long time,
346 Cause cause);
347
348 /**
349 * Returns {@code true} when the component takes part in the focus
350 * traversal, {@code false} otherwise.
351 *
352 * @return {@code true} when the component takes part in the focus
353 * traversal, {@code false} otherwise
354 */
355 boolean isFocusable();
356
357 /**
358 * Creates an image using the specified image producer.
359 *
360 * @param producer the image producer from which the image pixels will be
361 * produced
362 *
363 * @return the created image
364 *
365 * @see Component#createImage(ImageProducer)
366 */
367 Image createImage(ImageProducer producer);
368
369 /**
370 * Creates an empty image with the specified width and height. This is
371 * generally used as a non-accelerated backbuffer for drawing onto the
372 * component (e.g. by Swing).
373 *
374 * @param width the width of the image
375 * @param height the height of the image
376 *
377 * @return the created image
378 *
379 * @see Component#createImage(int, int)
380 */
381 // TODO: Maybe make that return a BufferedImage, because some stuff will
382 // break if a different kind of image is returned.
383 Image createImage(int width, int height);
384
385 /**
386 * Creates an empty volatile image with the specified width and height.
387 * This is generally used as an accelerated backbuffer for drawing onto
388 * the component (e.g. by Swing).
389 *
390 * @param width the width of the image
391 * @param height the height of the image
392 *
393 * @return the created volatile image
394 *
395 * @see Component#createVolatileImage(int, int)
396 */
397 // TODO: Include capabilities here and fix Component#createVolatileImage
398 VolatileImage createVolatileImage(int width, int height);
399
400 /**
401 * Prepare the specified image for rendering on this component. This should
402 * start loading the image (if not already loaded) and create an
403 * appropriate screen representation.
404 *
405 * @param img the image to prepare
406 * @param w the width of the screen representation
407 * @param h the height of the screen representation
408 * @param o an image observer to observe the progress
409 *
410 * @return {@code true} if the image is already fully prepared,
411 * {@code false} otherwise
412 *
413 * @see Component#prepareImage(Image, int, int, ImageObserver)
414 */
415 boolean prepareImage(Image img, int w, int h, ImageObserver o);
416
417 /**
418 * Determines the status of the construction of the screen representation
419 * of the specified image.
420 *
421 * @param img the image to check
422 * @param w the target width
423 * @param h the target height
424 * @param o the image observer to notify
425 *
426 * @return the status as bitwise ORed ImageObserver flags
427 *
428 * @see Component#checkImage(Image, int, int, ImageObserver)
429 */
430 int checkImage(Image img, int w, int h, ImageObserver o);
431
432 /**
433 * Returns the graphics configuration that corresponds to this component.
434 *
435 * @return the graphics configuration that corresponds to this component
436 *
437 * @see Component#getGraphicsConfiguration()
438 */
439 GraphicsConfiguration getGraphicsConfiguration();
440
441 /**
442 * Determines if the component handles wheel scrolling itself. Otherwise
443 * it is delegated to the component's parent.
444 *
445 * @return {@code true} if the component handles wheel scrolling,
446 * {@code false} otherwise
447 *
448 * @see Component#dispatchEventImpl(AWTEvent)
449 */
450 boolean handlesWheelScrolling();
451
452 /**
|
1 /*
2 * Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.awt.peer;
27
28 import java.awt.AWTEvent;
29 import java.awt.AWTException;
30 import java.awt.BufferCapabilities;
31 import java.awt.Color;
32 import java.awt.Component;
33 import java.awt.Dimension;
34 import java.awt.EventQueue;
35 import java.awt.Font;
36 import java.awt.FontMetrics;
37 import java.awt.Graphics;
38 import java.awt.GraphicsConfiguration;
39 import java.awt.Image;
40 import java.awt.Point;
41 import java.awt.event.FocusEvent.Cause;
42 import java.awt.event.PaintEvent;
43 import java.awt.image.ColorModel;
44 import java.awt.image.VolatileImage;
45
46 import sun.java2d.pipe.Region;
47
48 /**
49 * The peer interface for {@link Component}. This is the top level peer
50 * interface for widgets and defines the bulk of methods for AWT component
51 * peers. Most component peers have to implement this interface (via one
52 * of the subinterfaces), except menu components, which implement
53 * {@link MenuComponentPeer}.
54 *
55 * The peer interfaces are intended only for use in porting
56 * the AWT. They are not intended for use by application
57 * developers, and developers should not implement peers
58 * nor invoke any of the peer methods directly on the peer
59 * instances.
60 */
61 public interface ComponentPeer {
62
63 /**
64 * Operation for {@link #setBounds(int, int, int, int, int)}, indicating
65 * a change in the component location only.
66 *
67 * @see #setBounds(int, int, int, int, int)
347 * @param time the time of the focus change request
348 * @param cause the cause of the focus change request
349 *
350 * @return {@code true} if the focus change is guaranteed to be
351 * granted, {@code false} otherwise
352 */
353 boolean requestFocus(Component lightweightChild, boolean temporary,
354 boolean focusedWindowChangeAllowed, long time,
355 Cause cause);
356
357 /**
358 * Returns {@code true} when the component takes part in the focus
359 * traversal, {@code false} otherwise.
360 *
361 * @return {@code true} when the component takes part in the focus
362 * traversal, {@code false} otherwise
363 */
364 boolean isFocusable();
365
366 /**
367 * Creates an empty image with the specified width and height. This is
368 * generally used as a non-accelerated backbuffer for drawing onto the
369 * component (e.g. by Swing).
370 *
371 * @param width the width of the image
372 * @param height the height of the image
373 *
374 * @return the created image
375 *
376 * @see Component#createImage(int, int)
377 */
378 // TODO: Maybe make that return a BufferedImage, because some stuff will
379 // break if a different kind of image is returned.
380 Image createImage(int width, int height);
381
382 /**
383 * Creates an empty volatile image with the specified width and height.
384 * This is generally used as an accelerated backbuffer for drawing onto
385 * the component (e.g. by Swing).
386 *
387 * @param width the width of the image
388 * @param height the height of the image
389 *
390 * @return the created volatile image
391 *
392 * @see Component#createVolatileImage(int, int)
393 */
394 // TODO: Include capabilities here and fix Component#createVolatileImage
395 VolatileImage createVolatileImage(int width, int height);
396
397 /**
398 * Returns the graphics configuration that corresponds to this component.
399 *
400 * @return the graphics configuration that corresponds to this component
401 *
402 * @see Component#getGraphicsConfiguration()
403 */
404 GraphicsConfiguration getGraphicsConfiguration();
405
406 /**
407 * Determines if the component handles wheel scrolling itself. Otherwise
408 * it is delegated to the component's parent.
409 *
410 * @return {@code true} if the component handles wheel scrolling,
411 * {@code false} otherwise
412 *
413 * @see Component#dispatchEventImpl(AWTEvent)
414 */
415 boolean handlesWheelScrolling();
416
417 /**
|