svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / cmd / Cmd.java @ 2312
History | View | Annotate | Download (2.41 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.ui.cmd; |
25 |
|
26 |
import java.awt.Cursor; |
27 |
import java.awt.geom.Point2D; |
28 |
import java.util.TreeMap; |
29 |
|
30 |
import org.cresques.ui.CQMapCanvas; |
31 |
|
32 |
/**
|
33 |
* Clase Cmd, ancestro de todos los comandos del canvas.
|
34 |
* Permite a?adir al canvas funcionalidades que responden a eventos de
|
35 |
* rat?n y producen canvios en el estado del canvas.
|
36 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
37 |
*/
|
38 |
public abstract class Cmd { |
39 |
public static final int LEFT = 0x0001; |
40 |
public static final int RIGHT = 0x0002; |
41 |
public static final int MIDDLE = 0x0004; |
42 |
public static final int PRESS = 0x0008; |
43 |
public static final int RELEASE = 0x0010; |
44 |
public static final int DRAG = 0x0020; |
45 |
|
46 |
public static final int type=0; |
47 |
CQMapCanvas canvas = null;
|
48 |
int eventsWanted = 0; |
49 |
protected Cursor cursor = null; |
50 |
private static TreeMap cmdPool = null;; |
51 |
|
52 |
/**
|
53 |
* Inicializaci?n de la pool de comandos.
|
54 |
*/
|
55 |
static {
|
56 |
cmdPool = new TreeMap(); |
57 |
} |
58 |
|
59 |
public static void register(String cmdStr, Cmd command) { |
60 |
Cmd.cmdPool.put(cmdStr, command); |
61 |
} |
62 |
|
63 |
public static Cmd get(String cmdStr) { |
64 |
return (Cmd) Cmd.cmdPool.get(cmdStr);
|
65 |
} |
66 |
|
67 |
/**
|
68 |
* Construye un nuevo Cmd para el Canvas
|
69 |
* @param canvas
|
70 |
*/
|
71 |
public Cmd(CQMapCanvas canvas) {
|
72 |
this.canvas = canvas;
|
73 |
} |
74 |
|
75 |
/**
|
76 |
* Recibe los eventos del rat?n.
|
77 |
*/
|
78 |
abstract public void cmd(Point2D pt, int bt, int mouseEvent); |
79 |
|
80 |
/**
|
81 |
* Devuelve un Bitset con los eventos de raton que requiere.
|
82 |
* @return eventsWanted (BitSet)
|
83 |
*/
|
84 |
public int getEventsWanted() { |
85 |
return eventsWanted;
|
86 |
} |
87 |
|
88 |
public Cursor getCursor() { |
89 |
return cursor;
|
90 |
} |
91 |
} |