1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package net.sourceforge.hivegui.component; |
16 | |
17 | import java.awt.Cursor; |
18 | import java.awt.Dimension; |
19 | import java.awt.Point; |
20 | import java.awt.Toolkit; |
21 | |
22 | import javax.swing.ImageIcon; |
23 | |
24 | /** |
25 | * @author Jean-Francois Poilpret |
26 | */ |
27 | public class CursorInfo |
28 | { |
29 | public CursorInfo(Cursor cursor) |
30 | { |
31 | _icon = null; |
32 | _hotspot = null; |
33 | _size = null; |
34 | _cursor = cursor; |
35 | } |
36 | |
37 | public CursorInfo(ImageIcon icon, Point hotspot, Dimension size) |
38 | { |
39 | _icon = icon; |
40 | _hotspot = hotspot; |
41 | _size = size; |
42 | } |
43 | |
44 | public ImageIcon getIcon() |
45 | { |
46 | return _icon; |
47 | } |
48 | |
49 | public Point getHotspot() |
50 | { |
51 | return _hotspot; |
52 | } |
53 | |
54 | public Dimension getSize() |
55 | { |
56 | return _size; |
57 | } |
58 | |
59 | public Cursor getCursor() |
60 | { |
61 | if (_cursor == null) |
62 | { |
63 | _cursor = Toolkit.getDefaultToolkit().createCustomCursor( |
64 | _icon.getImage(), _hotspot, ""); |
65 | } |
66 | return _cursor; |
67 | } |
68 | |
69 | final private ImageIcon _icon; |
70 | final private Point _hotspot; |
71 | final private Dimension _size; |
72 | private Cursor _cursor; |
73 | } |