0
|
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC.
|
|
2 // All rights reserved.
|
|
3 //
|
|
4 //-------------------------------------------------------------------------
|
|
5 // This file is part of the TightVNC software. Please visit our Web site:
|
|
6 //
|
|
7 // http://www.tightvnc.com/
|
|
8 //
|
|
9 // This program is free software; you can redistribute it and/or modify
|
|
10 // it under the terms of the GNU General Public License as published by
|
|
11 // the Free Software Foundation; either version 2 of the License, or
|
|
12 // (at your option) any later version.
|
|
13 //
|
|
14 // This program is distributed in the hope that it will be useful,
|
|
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 // GNU General Public License for more details.
|
|
18 //
|
|
19 // You should have received a copy of the GNU General Public License along
|
|
20 // with this program; if not, write to the Free Software Foundation, Inc.,
|
|
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
22 //-------------------------------------------------------------------------
|
|
23 //
|
|
24
|
|
25 package com.glavsoft.drawing;
|
|
26
|
|
27 /**
|
|
28 * Abstract class for operations with soft cursor positions, dimensions and
|
|
29 * hot point position.
|
|
30 */
|
|
31 public abstract class SoftCursor {
|
|
32
|
|
33 protected int hotX, hotY;
|
|
34 private int x, y;
|
|
35 public int width, height;
|
|
36 public int rX, rY;
|
|
37 public int oldRX, oldRY;
|
|
38 public int oldWidth, oldHeight;
|
|
39 private final Object lock = new Object();
|
|
40
|
|
41 public SoftCursor(int hotX, int hotY, int width, int height) {
|
|
42 this.hotX = hotX;
|
|
43 this.hotY = hotY;
|
|
44 oldWidth = this.width = width;
|
|
45 oldHeight = this.height = height;
|
|
46 oldRX = rX = 0;
|
|
47 oldRY = rY = 0;
|
|
48 }
|
|
49
|
|
50 /**
|
|
51 * Update cursor position
|
|
52 *
|
|
53 * @param newX
|
|
54 * @param newY
|
|
55 */
|
|
56 public void updatePosition(int newX, int newY) {
|
|
57 oldRX = rX; oldRY = rY;
|
|
58 oldWidth = width; oldHeight = height;
|
|
59 x = newX; y = newY;
|
|
60 rX = x - hotX; rY = y - hotY;
|
|
61 }
|
|
62
|
|
63 /**
|
|
64 * Set new cursor dimensions and hot point position
|
|
65 *
|
|
66 * @param hotX
|
|
67 * @param hotY
|
|
68 * @param width
|
|
69 * @param height
|
|
70 */
|
|
71 public void setNewDimensions(int hotX, int hotY, int width, int height) {
|
|
72 this.hotX = hotX;
|
|
73 this.hotY = hotY;
|
|
74 oldWidth = this.width;
|
|
75 oldHeight = this.height;
|
|
76 oldRX = rX; oldRY = rY;
|
|
77 rX = x - hotX; rY = y - hotY;
|
|
78 this.width = width;
|
|
79 this.height = height;
|
|
80 }
|
|
81
|
|
82 public void createCursor(int[] cursorPixels, int hotX, int hotY, int width, int height) {
|
|
83 createNewCursorImage(cursorPixels, hotX, hotY, width, height);
|
|
84 setNewDimensions(hotX, hotY, width, height);
|
|
85 }
|
|
86
|
|
87 protected abstract void createNewCursorImage(int[] cursorPixels, int hotX, int hotY, int width, int height);
|
|
88
|
|
89 public Object getLock() {
|
|
90 return lock;
|
|
91 }
|
|
92 } |