Revision 111 trunk/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutZooms.java

View differences:

FLayoutZooms.java
21 21
 */
22 22
package org.gvsig.app.project.documents.layout;
23 23

  
24
import java.awt.Dimension;
24 25
import java.awt.Point;
25 26
import java.awt.Toolkit;
26 27
import java.awt.geom.AffineTransform;
......
258 259
            if (fframes[i] instanceof IFFrameUseFMap) {
259 260
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
260 261
                if (fframe.getATMap() != null) {
262
                    
263
                    Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
264
                        p1, fframes[i]);
265
                    Point2D vppo2 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
266
                        p2, fframes[i]);
267
                    
261 268
                    Point2D px1 =
262
                        FLayoutFunctions.toMapPoint(p1, fframe.getATMap());
269
                        FLayoutFunctions.toMapPoint(vppo1, fframe.getATMap());
263 270
                    Point2D px2 =
264
                        FLayoutFunctions.toMapPoint(p2, fframe.getATMap());
271
                        FLayoutFunctions.toMapPoint(vppo2, fframe.getATMap());
265 272
                    fframe.setPointsToZoom(px1, px2);
266 273
                }
267 274
            }
......
365 372
     * @param p2
366 373
     *            Punto final del rect?ngulo
367 374
     */
368
    public void setViewZoomIn(Point2D p1, Point2D p2) {
375
    public void setViewZoomIn(Point2D poi1, Point2D poi2) {
369 376
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
370 377
        for (int i = 0; i < fframes.length; i++) {
371 378
            if (fframes[i] instanceof IFFrameUseFMap) {
372 379
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
373 380

  
374 381
                if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
375
                    // IFFrameUseFMap
376
                    // fframeAux=(IFFrameUseFMap)((IFFrame)fframe).cloneFFrame(layout);
377
                    p1 = FLayoutFunctions.toMapPoint(p1, fframe.getATMap());
378
                    p2 = FLayoutFunctions.toMapPoint(p2, fframe.getATMap());
382
                    
383
                    Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
384
                        poi1, fframes[i]);
385
                    Point2D vppo2 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
386
                        poi2, fframes[i]);
387
                    
388
                    Point2D.Double mapp1 = FLayoutFunctions.toMapPoint(vppo1, fframe.getATMap());
389
                    Point2D.Double mapp2 = FLayoutFunctions.toMapPoint(vppo2, fframe.getATMap());
379 390

  
380 391
                    // Borramos el anterior
381 392
                    observers.notifyObservers(this, 
382 393
                        new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED));
383 394
                    Rectangle2D.Double r = new Rectangle2D.Double();
384 395

  
385
                    if (java.lang.Math.abs(p1.getX() - p2.getX()) <= 3) {
396
                    if (java.lang.Math.abs(poi1.getX() - poi2.getX()) <= 3) {
386 397
                        double nuevoX;
387 398
                        double nuevoY;
388 399
                        double cX;
389 400
                        double cY;
390 401

  
391
                        cX = p2.getX();
392
                        cY = p2.getY();
402
                        cX = mapp2.getX();
403
                        cY = mapp2.getY();
393 404

  
394 405
                        double factor = 1 / MapContext.ZOOMINFACTOR;
395 406

  
......
408 419
                    } else {
409 420
                        // Fijamos el nuevo extent
410 421

  
411
                        r.setFrameFromDiagonal(p1, p2);
422
                        r.setFrameFromDiagonal(mapp1, mapp2);
412 423

  
413 424
                        // fframeAux.setNewExtent(r);
414 425
                    }
......
458 469
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
459 470

  
460 471
                if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
461
                    // IFFrameUseFMap
462
                    // fframeAux=(IFFrameUseFMap)((IFFrame)fframe).cloneFFrame(layout);
472

  
463 473
                    double nuevoX;
464 474
                    double nuevoY;
465 475
                    double cX;
466 476
                    double cY;
467 477
                    Point pScreen = new Point((int) p2.getX(), (int) p2.getY());
468
                    pWorld =
469
                        FLayoutFunctions.toMapPoint(pScreen, fframe.getATMap());
478
                    
479
                    Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
480
                        pScreen, fframes[i]);
481
                    
482
                    pWorld = FLayoutFunctions.toMapPoint(vppo1, fframe.getATMap());
470 483

  
471 484
                    cX = pWorld.getX();
472 485
                    cY = pWorld.getY();
......
513 526
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
514 527
                AffineTransform at = fframe.getATMap();
515 528
                if (at != null) {
516
                    Point2D px1 = FLayoutFunctions.toMapPoint(p1, at);
517
                    Point2D px2 = FLayoutFunctions.toMapPoint(p2, at);
529
                    
530
                    Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
531
                        p1, fframes[i]);
532
                    Point2D vppo2 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
533
                        p2, fframes[i]);
534

  
535
                    Point2D px1 = FLayoutFunctions.toMapPoint(vppo1, at);
536
                    Point2D px2 = FLayoutFunctions.toMapPoint(vppo2, at);
518 537
                    fframe.movePoints(px1, px2);
519 538
                }
520 539
            }

Also available in: Unified diff