1 /*
   2  * Copyright (c) 2009, 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 import java.awt.BasicStroke;
  27 import java.awt.Color;
  28 import java.awt.Graphics;
  29 import java.awt.Graphics2D;
  30 import java.awt.Toolkit;
  31 import java.awt.Point;
  32 
  33 /**
  34  * An interface provides a set of custom cursors
  35  */
  36 
  37 public interface MyCursor {
  38     public static final java.awt.Cursor NO_DROP = Toolkit.getDefaultToolkit().createCustomCursor(
  39         new ImageGenerator(32, 32, new Color(0xff, 0xff, 0xff, 0x00) ) {
  40                 @Override public void paint(Graphics gr) {
  41                     gr.setColor(Color.GREEN);
  42                     ((Graphics2D)gr).setStroke(new BasicStroke(3));
  43 
  44                     gr.translate(width/2, height/2);
  45                     int R = width/4;
  46                     gr.drawOval(-R, -R, 2*R, 2*R);
  47                     gr.drawLine(-R, R, R, -R);
  48                 }
  49             }.getImage(),
  50             new Point(0, 0),
  51             "My NoDrop Cursor"
  52     );
  53     public static final java.awt.Cursor MOVE = Toolkit.getDefaultToolkit().createCustomCursor(
  54         new ImageGenerator(32, 32, new Color(0xff, 0xff, 0xff, 0x00) ) {
  55                 @Override public void paint(Graphics gr) {
  56                     gr.setColor(Color.GREEN);
  57                     ((Graphics2D)gr).setStroke(new BasicStroke(3));
  58 
  59                     gr.drawLine(0, 0, width, height);
  60                     gr.drawLine(0, 0, width/2, 0);
  61                     gr.drawLine(0, 0, 0, height/2);
  62                 }
  63             }.getImage(),
  64             new Point(0, 0),
  65             "My Move Cursor"
  66     );
  67     public static final java.awt.Cursor COPY = Toolkit.getDefaultToolkit().createCustomCursor(
  68         new ImageGenerator(32, 32, new Color(0xff, 0xff, 0xff, 0x00) ) {
  69                 @Override public void paint(Graphics gr) {
  70                     gr.setColor(Color.GREEN);
  71                     ((Graphics2D)gr).setStroke(new BasicStroke(3));
  72                     //arrow
  73                     gr.drawLine(0, 0, width/2, height/2);
  74                     gr.drawLine(0, 0, width/2, 0);
  75                     gr.drawLine(0, 0, 0, height/2);
  76                     //plus
  77                     gr.drawRect(width/2 - 1, height/2 -1, width/2 - 1, height/2 - 1);
  78                     gr.drawLine(width*3/4 - 1, height/2 - 1, width*3/4 - 1, height);
  79                     gr.drawLine(width/2 - 1, height*3/4 - 1, width, height*3/4 - 1);
  80                  }
  81             }.getImage(),
  82             new Point(0, 0),
  83             "My Copy Cursor"
  84     );
  85 }
  86