1 /* -------------------------------------------------------------------
2 GeoVISTA Center (Penn State, Dept. of Geography)
3 Java source file for the class GeoCursors
4 Copyright (c), 2002, GeoVISTA Center
5 All Rights Reserved.
6 Original Author: Frank Hardisty
7 $Author: hardisty $
8 $Id: GeoCursors.java,v 1.2 2003/04/25 17:47:59 hardisty Exp $
9 $Date: 2003/04/25 17:47:59 $
10 Reference: Document no:
11 ___ ___
12 ------------------------------------------------------------------- *
13 */
14
15
16 package edu.psu.geovista.ui.cursor;
17 import java.awt.*;
18 import javax.swing.*;
19 import javax.swing.border.*;
20 import java.awt.event.*;
21 import java.net.*;
22 /***
23 * GeoCursors is used to manufacture custom cursors.
24 *
25 * GeoCursors lazily creates and then keeps instances of
26 * cursors to be called when needed.
27 *
28 */
29 public class GeoCursors extends Component {
30
31 private transient Cursor[] cursors;
32 private transient URL[] urls;
33
34 public static int CURSOR_PAN = 0;
35 public static int CURSOR_ZOOM_OUT = 1;
36 public static int CURSOR_ZOOM_IN = 2;
37 public static int CURSOR_INFO = 3;
38 public static int CURSOR_ARROW_PAN = 4;
39 public static int CURSOR_GRAB = 5;
40 public static int CURSOR_ARROW_ZOOM_IN = 6;
41 public static int CURSOR_ARROW_ZOOM_OUT = 7;
42 public static int CURSOR_ARROW_SELECT = 8;
43 private static int numCursors = 9;
44
45 private static URL urlPan = GeoCursors.class.getResource("resources/pan.gif");
46 //private static URL urlZoomIn = GeoCursors.class.getResource("resources/zoomIn.gif");
47 //private static URL urlZoomOut = GeoCursors.class.getResource("resources/zoomOut.gif");
48 private static URL urlGrab = GeoCursors.class.getResource("resources/grab.gif");
49 private static URL urlArrowZoomIn = GeoCursors.class.getResource("resources/arrowZoomIn.gif");
50 private static URL urlArrowZoomOut = GeoCursors.class.getResource("resources/arrowZoomOut.gif");
51 private static URL urlArrowSelect = GeoCursors.class.getResource("resources/arrowSelect.gif");
52 private static URL urlArrowPan = GeoCursors.class.getResource("resources/arrowPan.gif");
53
54 private static Point ptHand = new Point(16,16);
55 private static Point ptArrow = new Point(10,8);
56 /***
57 * null ctr
58 */
59 public GeoCursors(){
60 cursors = new Cursor[numCursors];
61 urls = new URL[numCursors];
62 urls[this.CURSOR_PAN] = this.urlPan;
63 urls[this.CURSOR_ZOOM_IN] = this.urlArrowZoomIn;
64 urls[this.CURSOR_ZOOM_OUT] = this.urlArrowZoomOut;
65 urls[this.CURSOR_GRAB] = this.urlGrab;
66 urls[this.CURSOR_ARROW_ZOOM_IN] = this.urlArrowZoomIn;
67 urls[this.CURSOR_ARROW_ZOOM_OUT] = this.urlArrowZoomOut;
68 urls[this.CURSOR_ARROW_SELECT] = this.urlArrowSelect;
69 urls[this.CURSOR_ARROW_PAN] = this.urlArrowPan;
70
71 }
72
73
74 /***
75 * Returns the cursor specified.
76 */
77 public Cursor getCursor(int cursor) {
78 //lazily create cursor, if need be
79 if (cursors[cursor] == null) {
80 Point pt = null;
81 if (cursor == this.CURSOR_PAN || cursor == this.CURSOR_GRAB) {
82 pt = this.ptHand;
83 } else {
84 pt = this.ptArrow;
85 }
86 URL urlGif = urls[cursor];
87 ImageIcon imIcon = new ImageIcon(urlGif);
88 Image im = imIcon.getImage();
89 cursors[cursor] = this.getToolkit().createCustomCursor(im,pt,"custom");
90 }
91 return cursors[cursor];
92 }
93
94
95 }
This page was automatically generated by Maven