Revision 26225 branches/v2_0_0_prep/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomOutRightButtonListener.java
ZoomOutRightButtonListener.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package org.gvsig.fmap.mapcontrol.tools; |
42 | 42 |
|
43 |
import java.awt.Cursor; |
|
44 | 43 |
import java.awt.Image; |
45 |
import java.awt.Point; |
|
46 |
import java.awt.Toolkit; |
|
47 | 44 |
import java.awt.event.MouseEvent; |
48 | 45 |
import java.awt.geom.Point2D; |
49 |
import java.awt.geom.Rectangle2D; |
|
50 | 46 |
|
51 | 47 |
import javax.swing.ImageIcon; |
52 | 48 |
|
... | ... | |
95 | 91 |
* The image to display when the cursor is active. |
96 | 92 |
*/ |
97 | 93 |
private final Image izoomout = new ImageIcon(MapControl.class.getResource( |
98 |
"images/ZoomOutCursor.gif")).getImage();
|
|
94 |
"images/ZoomOutCursor.gif")).getImage();
|
|
99 | 95 |
|
100 | 96 |
/** |
101 | 97 |
* The cursor used to work with this tool listener. |
102 | 98 |
* |
103 | 99 |
* @see #getCursor() |
104 | 100 |
*/ |
105 |
// private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(izoomout, |
|
106 |
// new Point(16, 16), ""); |
|
101 |
// private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(izoomout,
|
|
102 |
// new Point(16, 16), "");
|
|
107 | 103 |
|
108 | 104 |
/** |
109 | 105 |
* Reference to the <code>MapControl</code> object that uses. |
... | ... | |
115 | 111 |
* |
116 | 112 |
* @param mapControl the <code>MapControl</code> where will be applied the changes |
117 | 113 |
*/ |
118 |
public ZoomOutRightButtonListener(MapControl mapControl) {
|
|
119 |
this.mapControl = mapControl;
|
|
120 |
}
|
|
114 |
public ZoomOutRightButtonListener(MapControl mapControl) {
|
|
115 |
this.mapControl = mapControl;
|
|
116 |
}
|
|
121 | 117 |
|
122 |
/*
|
|
123 |
* (non-Javadoc)
|
|
124 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
|
|
125 |
*/
|
|
126 |
public void point(PointEvent event) {
|
|
127 |
if (event.getEvent().getButton() == MouseEvent.BUTTON3){
|
|
128 |
System.out.println("Zoom out bot?n derecho");
|
|
129 |
ViewPort vp = mapControl.getMapContext().getViewPort();
|
|
130 |
Point2D p2 = vp.toMapPoint(event.getPoint());
|
|
118 |
/*
|
|
119 |
* (non-Javadoc)
|
|
120 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
|
|
121 |
*/
|
|
122 |
public void point(PointEvent event) {
|
|
123 |
if (event.getEvent().getButton() == MouseEvent.BUTTON3){
|
|
124 |
System.out.println("Zoom out bot?n derecho");
|
|
125 |
ViewPort vp = mapControl.getMapContext().getViewPort();
|
|
126 |
Point2D p2 = vp.toMapPoint(event.getPoint());
|
|
131 | 127 |
|
132 |
double nuevoX; |
|
133 |
double nuevoY; |
|
134 |
double factor = 1/MapContext.ZOOMOUTFACTOR; |
|
135 |
if (vp.getExtent()!=null){ |
|
136 |
nuevoX = p2.getX() - ((vp.getExtent().getWidth() * factor) / 2.0); |
|
137 |
nuevoY = p2.getY() - ((vp.getExtent().getHeight() * factor) / 2.0); |
|
138 |
double x = nuevoX; |
|
139 |
double y = nuevoY; |
|
140 |
double width = vp.getExtent().getWidth() * factor; |
|
141 |
double height = vp.getExtent().getHeight() * factor; |
|
128 |
double nuevoX; |
|
129 |
double nuevoY; |
|
130 |
double factor = 1 / MapContext.ZOOMOUTFACTOR; |
|
131 |
if (vp.getExtent() != null) { |
|
132 |
nuevoX = p2.getX() |
|
133 |
- ((vp.getExtent().getWidth() * factor) / 2.0); |
|
134 |
nuevoY = p2.getY() |
|
135 |
- ((vp.getExtent().getHeight() * factor) / 2.0); |
|
136 |
double x = nuevoX; |
|
137 |
double y = nuevoY; |
|
138 |
double width = vp.getExtent().getWidth() * factor; |
|
139 |
double height = vp.getExtent().getHeight() * factor; |
|
142 | 140 |
|
143 |
vp.setEnvelope(new DefaultEnvelope(2,new double[]{x,y},new double[]{x+width,y+height}));
|
|
144 |
}
|
|
145 |
}
|
|
146 |
mapControl.getMapContext().clearAllCachingImageDrawnLayers();
|
|
147 |
}
|
|
141 |
vp.setEnvelope(new DefaultEnvelope(2, new double[] { x, y },
|
|
142 |
new double[] { x + width, y + height }));
|
|
143 |
}
|
|
144 |
}
|
|
145 |
}
|
|
148 | 146 |
|
149 | 147 |
/* |
150 | 148 |
* (non-Javadoc) |
... | ... | |
159 | 157 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing() |
160 | 158 |
*/ |
161 | 159 |
public boolean cancelDrawing() { |
162 |
System.out.println("cancelDrawing del ZoomOutRightButtonListener");
|
|
160 |
System.out.println("cancelDrawing del ZoomOutRightButtonListener");
|
|
163 | 161 |
return true; |
164 | 162 |
} |
165 | 163 |
|
Also available in: Unified diff