svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / ui / cmd / CmdPan.java @ 109
History | View | Annotate | Download (1017 Bytes)
1 | 91 | luisw | package org.cresques.ui.cmd; |
---|---|---|---|
2 | |||
3 | import java.awt.geom.Point2D; |
||
4 | |||
5 | 109 | luisw | import org.cresques.ui.CQCursor; |
6 | 91 | luisw | import org.cresques.ui.CQMapCanvas; |
7 | |||
8 | 92 | luisw | /**
|
9 | * Comando pan.
|
||
10 | * A?ade al canvas la capacidad de desplazar la vista.
|
||
11 | * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
||
12 | */
|
||
13 | 91 | luisw | public class CmdPan extends Cmd { |
14 | 92 | luisw | private Point2D ptIni = null; |
15 | 91 | luisw | |
16 | 92 | luisw | /**
|
17 | * Construye un nuevo CmdPan para el Canvas.
|
||
18 | * @param canvas
|
||
19 | */
|
||
20 | public CmdPan(CQMapCanvas canvas) {
|
||
21 | 91 | luisw | super(canvas);
|
22 | eventsWanted = LEFT | PRESS | RELEASE; |
||
23 | 109 | luisw | cursor = CQCursor.getCursor(CQCursor.PAN_CURSOR); |
24 | 91 | luisw | } |
25 | |||
26 | 92 | luisw | /**
|
27 | * Recibe los eventos del rat?n.
|
||
28 | */
|
||
29 | 91 | luisw | public void cmd(Point2D pt, int btn, int mouseEvent) { |
30 | if (mouseEvent == Cmd.RELEASE) {
|
||
31 | 92 | luisw | pan(ptIni, pt); |
32 | 91 | luisw | } else if (mouseEvent == Cmd.PRESS) { |
33 | 92 | luisw | ptIni = pt; |
34 | 91 | luisw | } |
35 | } |
||
36 | 92 | luisw | |
37 | /**
|
||
38 | * Realiza un desplazamiento de la vista.
|
||
39 | * @param ptIni Punto inicial.
|
||
40 | * @param ptFin Punto final.
|
||
41 | */void pan(Point2D ptIni, Point2D ptFin) { |
||
42 | canvas.getVPData().pan(ptIni, ptFin); |
||
43 | canvas.viewPortChanged(); |
||
44 | canvas.repaint(); |
||
45 | } |
||
46 | 91 | luisw | } |