Revision 1714 trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrame.java

View differences:

FFrame.java
34 34
import java.awt.geom.Point2D;
35 35
import java.awt.geom.Rectangle2D;
36 36
import java.awt.image.BufferedImage;
37

  
38 37
import org.gvsig.andami.PluginServices;
39
import org.gvsig.andami.ui.mdiManager.IWindowListener;
40 38
import org.gvsig.app.project.ProjectManager;
41 39
import org.gvsig.app.project.documents.Document;
42 40
import org.gvsig.app.project.documents.layout.Attributes;
......
99 97
    protected FrameFactory frameFactory;
100 98

  
101 99
    private static Image iNEResize = null;
102
    private static Image iEResize = null;
103
    private static Image iNResize = null;
100
    public static Image iEResize = null;
101
    public static Image iNResize = null;
104 102
    private static Image iMove = null;
105 103
    private static Image iSEResize = null;
106 104

  
......
126 124
     * @param g
127 125
     *            Graphics sobre el que dibujar.
128 126
     */
127
    @Override
129 128
    public void drawHandlers(Graphics2D g) {
130 129
        int size = 10;
131 130
        Rectangle2D r = getBoundingBox(null);
......
193 192
     * @param e   Mouse event that triggered this method call
194 193
     * @see {@link #isSelected()}, {@link #getSelected()}
195 194
     */
195
    @Override
196 196
    public void setSelected(Point2D p, MouseEvent e) {
197 197
        doSetSelected(getContains(p));
198 198
    }
......
206 206
     * @param at
207 207
     *            Matriz de transformaci�n.
208 208
     */
209
    @Override
209 210
    public void updateRect(Rectangle2D r, AffineTransform at) {
210 211
        Rectangle2D.Double rec = FLayoutUtilities.toSheetRect(r, at);
211 212
        rec.setRect((int) rec.getMinX(), (int) rec.getMinY(),
......
225 226
     * @return rect�ngulo modificado en funci�n del desplazamiento
226 227
     *         realizado.
227 228
     */
229
    @Override
228 230
    public Rectangle2D getMovieRect(int difx, int dify) {
229
        double x = 0;
230
        double y = 0;
231
        double w = 0;
232
        double h = 0;
231
        return getMovieRect(difx, dify, false);
232
    }
233
    
234
    @Override
235
    public Rectangle2D getMovieRect(int difx, int dify, boolean prop) {
236
        double x;
237
        double y;
238
        double w;
239
        double h;
233 240

  
234 241
        lastMoveRect =
235 242
            new Rectangle2D.Double(this.getBoundingBox(null).x,
236 243
                this.getBoundingBox(null).y, this.getBoundingBox(null).width,
237 244
                this.getBoundingBox(null).height);
238 245
        Rectangle2D.Double rec = this.getBoundingBox(null);
239
        int difn = 0;
240
        difn = difx;
246
        
241 247
        x = lastMoveRect.getX();
242 248
        y = lastMoveRect.getY();
243 249
        w = lastMoveRect.getWidth();
244 250
        h = lastMoveRect.getHeight();
251
        double ratio = w / h;
245 252

  
246 253
        switch (this.getSelected()) {
247 254
        case (RECT):
......
250 257
            break;
251 258

  
252 259
        case (N):
253

  
260
            
254 261
            if ((y + dify) > rec.getMaxY()) {
255 262
                y = rec.getMaxY();
256 263
            } else {
......
295 302

  
296 303
        case (NE):
297 304

  
298
            if ((y - difn) > rec.getMaxY()) {
305
            if ((y + dify) > rec.getMaxY()) {
299 306
                y = rec.getMaxY();
300
                x = rec.getMaxX() + difn;
301 307
            } else {
302
                y = y - difn;
308
                y = y + dify;
303 309
            }
310
            if(prop) {
311
                difx = -(int) (dify * ratio);
312
            }
313
            if (x > (rec.getMaxX() + difx)) {
314
                x = rec.getMaxX() + difx;
315
            }
316
            
304 317

  
305
            lastMoveRect.setRect(x, y, Math.abs(w + difn), Math.abs(h + difn));
318
            lastMoveRect.setRect(x, y, Math.abs(w + difx), Math.abs(h - dify));
306 319

  
307 320
            break;
308 321

  
309 322
        case (NO):
310 323

  
311
            if ((y + difn) > rec.getMaxY()) {
324
            if ((y + dify) > rec.getMaxY()) {
312 325
                y = rec.getMaxY();
326
            } else {
327
                y = y + dify;
328
            }
329
            if(prop) {
330
                difx = (int) (dify * ratio);
331
            }
332
            if ((x + difx) > rec.getMaxX()) {
313 333
                x = rec.getMaxX();
314 334
            } else {
315
                x = x + difn;
316
                y = y + difn;
335
                x = x + difx;
317 336
            }
318 337

  
319
            lastMoveRect.setRect(x, y, Math.abs(w - difn), Math.abs(h - difn));
320 338

  
339
            lastMoveRect.setRect(x, y, Math.abs(w - difx), Math.abs(h - dify));
340
            
321 341
            break;
322 342

  
323 343
        case (SE):
324 344

  
325
            if (y > (rec.getMaxY() + difn)) {
326
                y = rec.getMaxY() + difn;
327
                x = rec.getMaxX() + difn;
345
            if (y > (rec.getMaxY() + dify)) {
346
                y = rec.getMaxY() + dify;
328 347
            }
329

  
330
            lastMoveRect.setRect(x, y, Math.abs(w + difn), Math.abs(h + difn));
331

  
348
            if(prop) {
349
                difx = (int) (dify * ratio);
350
            }
351
            if (x > (rec.getMaxX() + difx)) {
352
                x = rec.getMaxX() + difx;
353
            }
354
            
355
            lastMoveRect.setRect(x, y, Math.abs(w + difx), Math.abs(h + dify));
356
            
332 357
            break;
333 358

  
334 359
        case (SO):
335 360

  
336
            if ((x + difn) > rec.getMaxX()) {
361
            if (y > (rec.getMaxY() + dify)) {
362
                y = rec.getMaxY() + dify;
363
            }
364
            if(prop) {
365
                difx = (int) -(dify * ratio);
366
            }
367
            if ((x + difx) > rec.getMaxX()) {
337 368
                x = rec.getMaxX();
338
                y = rec.getMaxY() - difn;
339 369
            } else {
340
                x = x + difn;
370
                x = x + difx;
341 371
            }
342 372

  
343
            lastMoveRect.setRect(x, y, Math.abs(w - difn), Math.abs(h - difn));
344

  
373
            lastMoveRect.setRect(x, y, Math.abs(w - difx), Math.abs(h + dify));
374
            
345 375
            break;
346 376

  
347 377
        default:
......
358 388
     * @return Rectangle2D
359 389
     * 
360 390
     */
391
    @Override
361 392
    public Rectangle2D getLastMoveRect() {
362 393
        return lastMoveRect;
363 394
    }
......
373 404
     * @see {@link #isSelected()}, {@link #setSelected(boolean)}
374 405
     * @return The type of selection that has been applied
375 406
     */
407
    @Override
376 408
    public int getSelected() {
377 409
        return m_Selected;
378 410
    }
......
384 416
     *    <code>false</code> otherwise
385 417
     * @see {@link #getSelected()}, {@link #setSelected(boolean)}
386 418
     */
419
    @Override
387 420
    public boolean isSelected() {
388 421
    	return getSelected()!=IFFrame.NOSELECT;
389 422
    }
......
393 426
     * dentro del boundingbox del fframe.
394 427
     * 
395 428
     * @param p
396
     *            punto a comprobar.
429
     *            punto a comprobar en pixels.
397 430
     * 
398 431
     * @return true si el punto esta dentro del boundingbox.
399 432
     */
433
    @Override
400 434
    public boolean contains(Point2D p) {
401 435
        return getBoundingBox(null).contains(p.getX(), p.getY());
402 436
    }
......
405 439
     * (non-Javadoc)
406 440
     * @see org.gvsig.app.project.documents.layout.fframes.IFFrame#getContains(Point2D)
407 441
     */
442
    @Override
408 443
    public int getContains(Point2D p) {
409 444
    	Point2D point = new Point2D.Double();
410 445
    	AffineTransform rotationAT = getRotationAT();
......
459 494
     * 
460 495
     * @return Cursor adecuado a la posici�n.
461 496
     */
497
    @Override
462 498
    public Image getMapCursor(Point2D p) {
463 499
        int select = getContains(p);
464 500

  
......
506 542
     * @param visibleLayoutDocRect visible rectangle
507 543
     * @param imgBase Image used to speed up the drawing process
508 544
     */
545
    @Override
509 546
    public abstract void draw(Graphics2D g, AffineTransform at, Rectangle2D r,
510 547
        BufferedImage imgBase);
511 548

  
......
519 556
     * @return Rectangle representing the bounding box (in pixels) of this
520 557
     * FFrame
521 558
     */
559
    @Override
522 560
    public Rectangle2D.Double getBoundingBox(AffineTransform at) {
523 561
        if (at != null) {
524 562
            lastAT = (AffineTransform) at.clone();
......
533 571
     * @param r
534 572
     *            Rectangle in centimeters
535 573
     */
574
    @Override
536 575
    public void setBoundBox(Rectangle2D r) {
537 576
        if (r == null) {
538 577
            LOG.info("Warning: BBOX set to NULL in FFrame!");
......
549 588
     * 
550 589
     * @return The bounding box of this FFrame, measured in centimeters.
551 590
     */
591
    @Override
552 592
    public Rectangle2D.Double getBoundBox() {
553 593
        return m_BoundBox;
554 594
    }
......
561 601
     *            unselect it
562 602
     * @see {@link #isSelected()}, {@link #getSelected()}
563 603
     */
604
    @Override
564 605
    public void setSelected(boolean selected) {
565 606
        if (selected) {
566 607
        	doSetSelected(IFFrame.RECT);
......
579 620
     * @param g
580 621
     *            Graphics so bre el que dibujar.
581 622
     */
623
    @Override
582 624
    public void drawDraft(Graphics2D g) {
583 625
        Rectangle2D r = getBoundingBox(null);
584 626

  
......
602 644
     * @param i
603 645
     *            n�mero
604 646
     */
647
    @Override
605 648
    public void setNum(int i) {
606 649
        num = i;
607 650
    }
......
627 670
        Font f = new Font("SansSerif", Font.PLAIN, scale);
628 671
        g.setFont(f);
629 672

  
630
        String s =
673
        String str =
631 674
            this.getNameFFrame() + " " + PluginServices.getText(this, "vacia");
632 675

  
633
        g.drawString(s, (int) (r.getCenterX() - ((s.length() * scale) / 4)),
676
        g.drawString(str, (int) (r.getCenterX() - ((str.length() * scale) / 4)),
634 677
            (int) (r.getCenterY()));
635 678
    }
636 679

  
......
645 688
     * 
646 689
     * @return True si intersecta o es null.
647 690
     */
691
    @Override
648 692
    public boolean intersects(Rectangle2D rv, Rectangle2D r) {
649 693
        return (((rv != null) && rv.intersects(r)) || (rv == null));
650 694
    }
......
655 699
     * @param s
656 700
     *            String que representa el valor a guardar en el tag.
657 701
     */
702
    @Override
658 703
    public void setTag(String s) {
659 704
        tag = s;
660 705
    }
......
664 709
     * 
665 710
     * @return tag.
666 711
     */
712
    @Override
667 713
    public String getTag() {
668 714
        return tag;
669 715
    }
......
675 721
     * @param g
676 722
     *            Graphics sobre el que dibujar el icono.
677 723
     */
724
    @Override
678 725
    public void drawSymbolTag(Graphics2D g) {
679 726
        Rectangle2D rec = getBoundingBox(null);
680 727
        g.rotate(Math.toRadians(getRotation()), rec.getX()
......
698 745
     * @param rotation
699 746
     *            Rotation to apply to the frame
700 747
     */
748
    @Override
701 749
    public void setRotation(double rotation) {
702 750
        m_rotation = rotation;
703 751
    }
......
725 773
     * 
726 774
     * @return Rotation of the frame
727 775
     */
776
    @Override
728 777
    public double getRotation() {
729 778
        return m_rotation;
730 779
    }
......
734 783
     * 
735 784
     * @return nivel
736 785
     */
786
    @Override
737 787
    public int getLevel() {
738 788
        return level;
739 789
    }
......
744 794
     * @param l
745 795
     *            entero que refleja el nivel del FFrame.
746 796
     */
797
    @Override
747 798
    public void setLevel(int l) {
748 799
        level = l;
749 800
    }
750 801

  
751 802
    @Override
752 803
    public Object clone() throws CloneNotSupportedException {
753
        IFFrame frame = (IFFrame) super.clone();
754
        this.m_BoundBox = new Rectangle2D.Double(m_BoundBox.x, m_BoundBox.y, m_BoundBox.width, m_BoundBox.height);
755
        frame.setBoundBox(this.getBoundBox());
804
        FFrame frame = (FFrame) super.clone();
805
        frame.m_BoundBox = (Rectangle2D.Double)this.m_BoundBox.clone();
756 806
        return frame;
757 807
    }
758 808

  
809
    @Override
759 810
    public void setFrameFactory(FrameFactory flf) {
760 811
        frameFactory = flf;
761 812
    }
762 813

  
814
    @Override
763 815
    public FrameFactory getFrameFactory() {
764 816
        return frameFactory;
765 817
    }
......
814 866
        FFrameGridCoordinateFormat.registerPersistence();
815 867
    }
816 868

  
869
    @Override
817 870
    public void loadFromState(PersistentState state)
818 871
        throws PersistenceException {
819 872
        m_BoundBox = (Rectangle2D.Double) state.get(BOUNDINGBOX_FIELD);
......
830 883
        }
831 884
    }
832 885

  
886
    @Override
833 887
    public void saveToState(PersistentState state) throws PersistenceException {
834 888
        state.set(BOUNDINGBOX_FIELD, getBoundBox());
835 889
        state.set(SELECTED_FIELD, m_Selected);
......
841 895
        state.set(LAYOUT_CONTEXT_FIELD, getLayoutContext());
842 896
    }
843 897

  
898
    @Override
844 899
    public void addObserver(Observer o) {
845 900
        observers.addObserver(o);        
846 901
    }
847 902

  
903
    @Override
848 904
    public void deleteObserver(Observer o) {
849 905
      observers.deleteObserver(o);        
850 906
    }
851 907

  
908
    @Override
852 909
    public void deleteObservers() {
853 910
       observers.deleteObservers();        
854 911
    }
......
857 914
     * (non-Javadoc)
858 915
     * @see org.gvsig.tools.dispose.Disposable#dispose()
859 916
     */
917
    @Override
860 918
	public void dispose() {
861 919
		
862 920
	}
......
865 923
     * (non-Javadoc)
866 924
     * @see org.gvsig.app.project.documents.layout.fframes.IFFrame#frameRemoved()
867 925
     */
926
    @Override
868 927
	public void frameRemoved() {}
869 928
	
870 929
    /*
871 930
     * (non-Javadoc)
872 931
     * @see org.gvsig.app.project.documents.layout.fframes.IFFrame#frameAdded()
873 932
     */
933
    @Override
874 934
	public void frameAdded() {}
875 935
	
936
    @Override
876 937
	public LayoutContext getLayoutContext() {
877 938
		return layoutContext;
878 939
	}
879 940

  
941
    @Override
880 942
	public void setLayoutContext(LayoutContext layoutContext) {
881 943
		this.layoutContext = layoutContext;
882 944
	}
883 945

  
946
    @Override
884 947
	public Document getDocument() {
885 948
		return document;
886 949
	}
887 950

  
951
    @Override
888 952
	public void setDocument(Document document) {
889 953
		this.document = document;
890 954
	}
......
921 985
	    		Area nonRotatedVisibleArea = visibleArea.createTransformedArea(at.createInverse());
922 986
	    		Rectangle2D nonRotatedVisibleBounds = nonRotatedVisibleArea.getBounds2D();
923 987
	    		return nonRotatedVisibleBounds;
924
			} catch (NoninvertibleTransformException e) {
925
				LoggerFactory.getLogger(FFrame.class).error(e.getMessage(), e);
988
			} catch (NoninvertibleTransformException ex) {
989
				LoggerFactory.getLogger(FFrame.class).error(ex.getMessage(), ex);
926 990
				return null;
927 991
			}
928 992
    	}

Also available in: Unified diff