source: trunk/src/org/expeditee/core/Cursor.java@ 1097

Last change on this file since 1097 was 1097, checked in by davidb, 6 years ago

Newly structured files from Corey's work on logic/graphics separation

File size: 1.4 KB
Line 
1package org.expeditee.core;
2
3import org.expeditee.gui.DisplayController;
4
5/**
6 * TODO: Comment. cts16
7 *
8 * @author cts16
9 */
10public class Cursor {
11
12 public enum CursorType {
13 DEFAULT,
14 TEXT,
15 CROSSHAIR,
16 CUSTOM
17 }
18
19 /** Caches the invisible cursor. */
20 private static Cursor _invisibleCursor = null;
21
22 private Image _image;
23 private Point _hotspot;
24 private String _name;
25 private CursorType _type;
26
27 public Cursor(Image image, Point hotspot, String name)
28 {
29 assert(image != null && hotspot != null && name != null);
30
31 _image = image;
32 _hotspot = hotspot.clone();
33 _name = name;
34 _type = CursorType.CUSTOM;
35 }
36
37 public Cursor(CursorType type)
38 {
39 _image = null;
40 _hotspot = null;
41 _name = null;
42 _type = type;
43 }
44
45 public Image getImage()
46 {
47 return _image;
48 }
49
50 public Point getHotspot()
51 {
52 return _hotspot.clone();
53 }
54
55 public String getName()
56 {
57 return _name;
58 }
59
60 public CursorType getType()
61 {
62 return _type;
63 }
64
65 /** Creates an invisible cursor. */
66 public static Cursor createInvisibleCursor()
67 {
68 if (_invisibleCursor == null) {
69 int[] pixels = new int[DisplayController.SMALL_CURSOR_SIZE * DisplayController.SMALL_CURSOR_SIZE];
70 Image image = Image.createImage(DisplayController.SMALL_CURSOR_SIZE, DisplayController.SMALL_CURSOR_SIZE, pixels);
71 _invisibleCursor = new Cursor(image, new Point(0, 0), "invisiblecursor");
72 }
73
74 return _invisibleCursor;
75 }
76
77}
Note: See TracBrowser for help on using the repository browser.