Revision 27098 branches/v2_0_0_prep/extensions/extGeoreferencing/src/org/gvsig/georeferencing/ui/zoom/layers/ZoomCursorGraphicLayer.java

View differences:

ZoomCursorGraphicLayer.java
25 25
import java.awt.Point;
26 26
import java.awt.Toolkit;
27 27
import java.awt.event.MouseEvent;
28
import java.awt.geom.Rectangle2D;
29 28

  
30 29
import javax.swing.ImageIcon;
31 30

  
32
import org.gvsig.fmap.geom.primitive.DefaultEnvelope;
33 31
import org.gvsig.fmap.geom.primitive.Envelope;
32
import org.gvsig.fmap.geom.util.UtilFunctions;
34 33
import org.gvsig.georeferencing.ui.zoom.CanvasZone;
35 34
import org.gvsig.georeferencing.ui.zoom.IGraphicLayer;
36 35
import org.gvsig.georeferencing.ui.zoom.tools.ToolEvent;
......
136 135
	public Envelope getCursorViewCoordinates() {
137 136
		double x=posX - (wCursor >> 1);
138 137
		double y=posY - (hCursor >> 1);
139
		return new DefaultEnvelope(x, y, x+wCursor, y+hCursor);
138
		return UtilFunctions.createEnvelope(x, y, x + wCursor, y + hCursor);
140 139
	}
141 140

  
142 141
	/*
......
189 188
	 * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
190 189
	 */
191 190
	public void mouseReleased(MouseEvent e) {
192
		if(!isActive())
191
		if(!isActive()) {
193 192
			return;
193
		}
194 194
		if(getOperation() != NONE) {
195 195
			setOperation(NONE);
196
			if(listener != null)
196
			if(listener != null) {
197 197
				listener.endAction(new ToolEvent(this));
198
			}
198 199
		}
199 200
	}
200 201

  
......
203 204
	 * Cuando se pincha y se arrastra en los contornos se redimensiona el marco.
204 205
	 */
205 206
	public void mouseDragged(MouseEvent e) {
206
		if(!isActive())
207
		if(!isActive()) {
207 208
			return;
209
		}
208 210
		if(getOperation() == MOVE_UR) {
209 211
			posX += (e.getX() - (wCursor >> 1)) - posX;
210 212
			posY += (e.getY() + (hCursor >> 1)) - posY;
......
258 260
	 * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
259 261
	 */
260 262
	public void mouseMoved(MouseEvent e) {
261
		if(!isActive())
263
		if(!isActive()) {
262 264
			return;
265
		}
263 266
		int pxLeft = posX - (wCursor >> 1);
264 267
		int pxRight = posX + (wCursor >> 1);
265 268
		int pyUp = posY - (hCursor >> 1);
......
276 279
		}
277 280

  
278 281
		if(e.getX() >= (pxRight - 2) && e.getY() <= (pyUp + 2)) {
279
			if(iconMove != null)
282
			if(iconMove != null) {
280 283
				canvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconMove, new Point(16, 16), ""));
284
			}
281 285
			setOperation(MOVE_UR);
282 286
			return;
283 287
		}
284 288
		if(e.getX() <= (pxLeft + 2) && e.getY() <= (pyUp + 2)) {
285
			if(iconMove != null)
289
			if(iconMove != null) {
286 290
				canvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconMove, new Point(16, 16), ""));
291
			}
287 292
			setOperation(MOVE_UL);
288 293
			return;
289 294
		}
290 295
		if(e.getX() <= (pxLeft + 2) && e.getY() >= (pyDown - 2)) {
291
			if(iconMove != null)
296
			if(iconMove != null) {
292 297
				canvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconMove, new Point(16, 16), ""));
298
			}
293 299
			setOperation(MOVE_LL);
294 300
			return;
295 301
		}
296 302
		if(e.getX() >= (pxRight - 2) && e.getY() >= (pyDown - 2)) {
297
			if(iconMove != null)
303
			if(iconMove != null) {
298 304
				canvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconMove, new Point(16, 16), ""));
305
			}
299 306
			setOperation(MOVE_LR);
300 307
			return;
301 308
		}
302 309
		if(e.getX() <= (pxLeft + 1)) {
303
			if(iconHoriz != null)
310
			if(iconHoriz != null) {
304 311
				canvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconHoriz, new Point(16, 16), ""));
312
			}
305 313
			setOperation(REDIM_LEFT);
306 314
			return;
307 315
		}
308 316
		if(e.getX() >= (pxRight - 1)) {
309
			if(iconHoriz != null)
317
			if(iconHoriz != null) {
310 318
				canvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconHoriz, new Point(16, 16), ""));
319
			}
311 320
			setOperation(REDIM_RIGHT);
312 321
			return;
313 322
		}
314 323
		if(e.getY() <= (pyUp + 1)) {
315
			if(iconVert != null)
324
			if(iconVert != null) {
316 325
				canvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconVert, new Point(16, 16), ""));
326
			}
317 327
			setOperation(REDIM_UP);
318 328
			return;
319 329
		}
320 330
		if(e.getY() >= (pyDown - 1)) {
321
			if(iconVert != null)
331
			if(iconVert != null) {
322 332
				canvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(iconVert, new Point(16, 16), ""));
333
			}
323 334
			setOperation(REDIM_DOWN);
324 335
			return;
325 336
		}
......
344 355
	 */
345 356
	private void setOperation(int op) {
346 357
		operation = op;
347
		if(op != NONE)
358
		if(op != NONE) {
348 359
			listener.onTool(new ToolEvent(this));
360
		}
349 361
	}
350 362

  
351 363
	/**

Also available in: Unified diff