src/windows/classes/sun/awt/windows/WCustomCursor.java

Print this page




  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 public class WCustomCursor extends CustomCursor {
  42 
  43     public WCustomCursor(Image cursor, Point hotSpot, String name)
  44             throws IndexOutOfBoundsException {
  45         super(cursor, hotSpot, name);
  46     }
  47 
  48     protected void createNativeCursor(Image im, int[] pixels, int w, int h,
  49                                       int xHotSpot, int yHotSpot) {
  50         BufferedImage bimage = new BufferedImage(w, h,
  51                                BufferedImage.TYPE_INT_RGB);
  52         Graphics g = bimage.getGraphics();
  53         try {
  54             if (im instanceof ToolkitImage) {
  55                 ImageRepresentation ir = ((ToolkitImage)im).getImageRep();
  56                 ir.reconstruct(ImageObserver.ALLBITS);
  57             }
  58             g.drawImage(im, 0, 0, w, h, null);
  59         } finally {
  60             g.dispose();




  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 public class WCustomCursor extends CustomCursor {
  43 
  44     public WCustomCursor(Image cursor, Point hotSpot, String name)
  45             throws IndexOutOfBoundsException {
  46         super(cursor, hotSpot, name);
  47     }
  48 
  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 {
  61             g.dispose();