root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / tools / ZoomOutListenerImpl.java @ 770
History | View | Annotate | Download (2.05 KB)
1 |
package com.iver.cit.gvsig.fmap.tools; |
---|---|
2 |
|
3 |
import java.awt.Cursor; |
4 |
import java.awt.Image; |
5 |
import java.awt.Point; |
6 |
import java.awt.Toolkit; |
7 |
import java.awt.geom.Point2D; |
8 |
import java.awt.geom.Rectangle2D; |
9 |
|
10 |
import javax.swing.ImageIcon; |
11 |
|
12 |
import com.iver.cit.gvsig.fmap.NewMapControl; |
13 |
import com.iver.cit.gvsig.fmap.ViewPort; |
14 |
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent; |
15 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener; |
16 |
|
17 |
|
18 |
/**
|
19 |
* DOCUMENT ME!
|
20 |
*
|
21 |
* @author Vicente Caballero Navarro
|
22 |
*/
|
23 |
public class ZoomOutListenerImpl implements PointListener { |
24 |
private final Image izoomout = new ImageIcon(NewMapControl.class.getResource( |
25 |
"images/ZoomOutCursor.gif")).getImage();
|
26 |
private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(izoomout, |
27 |
new Point(16, 16), ""); |
28 |
|
29 |
private NewMapControl mapControl;
|
30 |
|
31 |
/**
|
32 |
* Crea un nuevo ZoomOutListenerImpl.
|
33 |
*
|
34 |
* @param vp DOCUMENT ME!
|
35 |
*/
|
36 |
public ZoomOutListenerImpl(NewMapControl mapControl) {
|
37 |
this.mapControl = mapControl;
|
38 |
} |
39 |
|
40 |
/**
|
41 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.PointEvent)
|
42 |
*/
|
43 |
public void point(PointEvent event) { |
44 |
ViewPort vp = mapControl.getMapContext().getViewPort(); |
45 |
Point2D p2 = vp.toMapPoint(event.getPoint());
|
46 |
|
47 |
double nuevoX;
|
48 |
double nuevoY;
|
49 |
double factor = 1.8; |
50 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
51 |
|
52 |
nuevoX = p2.getX() - ((vp.getExtent().getWidth() * factor) / 2.0);
|
53 |
nuevoY = p2.getY() - ((vp.getExtent().getHeight() * factor) / 2.0);
|
54 |
r.x = nuevoX; |
55 |
r.y = nuevoY; |
56 |
r.width = vp.getExtent().getWidth() * factor; |
57 |
r.height = vp.getExtent().getHeight() * factor; |
58 |
|
59 |
vp.setExtent(r); |
60 |
|
61 |
mapControl.drawMap(); |
62 |
} |
63 |
|
64 |
/**
|
65 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
|
66 |
*/
|
67 |
public Cursor getCursor() { |
68 |
return cur;
|
69 |
} |
70 |
|
71 |
/**
|
72 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
|
73 |
*/
|
74 |
public boolean cancelDrawing() { |
75 |
return true; |
76 |
} |
77 |
} |