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 sun.awt.windows;
27
28 import sun.awt.CustomCursor;
29 import java.awt.*;
30 import java.awt.image.*;
31 import sun.awt.image.ImageRepresentation;
32 import sun.awt.image.IntegerComponentRaster;
33 import sun.awt.image.ToolkitImage;
34
35 /**
36 * A class to encapsulate a custom image-based cursor.
37 *
38 * @see Component#setCursor
39 * @author ThomasBall
40 */
41 final class WCustomCursor extends CustomCursor {
42
43 WCustomCursor(Image cursor, Point hotSpot, String name)
44 throws IndexOutOfBoundsException {
45 super(cursor, hotSpot, name);
46 }
47
48 @Override
49 protected void createNativeCursor(Image im, int[] pixels, int w, int h,
50 int xHotSpot, int yHotSpot) {
51 BufferedImage bimage = new BufferedImage(w, h,
52 BufferedImage.TYPE_INT_RGB);
53 Graphics g = bimage.getGraphics();
54 try {
55 if (im instanceof ToolkitImage) {
56 ImageRepresentation ir = ((ToolkitImage)im).getImageRep();
57 ir.reconstruct(ImageObserver.ALLBITS);
58 }
59 g.drawImage(im, 0, 0, w, h, null);
60 } finally {
|
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 sun.awt.windows;
27
28 import sun.awt.CustomCursor;
29 import java.awt.*;
30 import java.awt.image.*;
31 import sun.awt.image.ImageRepresentation;
32 import sun.awt.image.IntegerComponentRaster;
33 import sun.awt.image.ToolkitImage;
34
35 /**
36 * A class to encapsulate a custom image-based cursor.
37 *
38 * @see Component#setCursor
39 * @author ThomasBall
40 */
41 @SuppressWarnings("serial") // JDK-implementation class
42 final class WCustomCursor extends CustomCursor {
43
44 WCustomCursor(Image cursor, Point hotSpot, String name)
45 throws IndexOutOfBoundsException {
46 super(cursor, hotSpot, name);
47 }
48
49 @Override
50 protected void createNativeCursor(Image im, int[] pixels, int w, int h,
51 int xHotSpot, int yHotSpot) {
52 BufferedImage bimage = new BufferedImage(w, h,
53 BufferedImage.TYPE_INT_RGB);
54 Graphics g = bimage.getGraphics();
55 try {
56 if (im instanceof ToolkitImage) {
57 ImageRepresentation ir = ((ToolkitImage)im).getImageRep();
58 ir.reconstruct(ImageObserver.ALLBITS);
59 }
60 g.drawImage(im, 0, 0, w, h, null);
61 } finally {
|