Revision 2476

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/dialogs/FBorderDialog.java
45 45
package com.iver.cit.gvsig.gui.layout.dialogs;
46 46

  
47 47
import java.awt.Color;
48
import java.awt.geom.AffineTransform;
49
import java.awt.geom.Point2D;
48 50
import java.awt.geom.Rectangle2D;
49 51
import java.util.ArrayList;
50 52

  
......
487 489
														  .toString());
488 490

  
489 491
						if (!getChbAgrupar().isSelected()) {
490
							Rectangle2D.Double re = new Rectangle2D.Double();
492
							Rectangle2D re = new Rectangle2D.Double();
491 493

  
492 494
							if (getRbSeleccionados().isSelected()) {
493 495
								if (selecList.size() > 0) {
494
									re.setRect(((IFFrame) selecList.get(0)).getBoundBox());
496
									re=getRectangle((IFFrame) selecList.get(0));
497
									
495 498
								}
496 499

  
497 500
								for (int i = 1; i < selecList.size(); i++) {
498
									Rectangle2D.Double rectaux = ((IFFrame) selecList.get(i)).getBoundBox();
501
									Rectangle2D rectaux = getRectangle((IFFrame) selecList.get(i));
499 502
									re.add(rectaux);
500 503
								}
501 504

  
502 505
								//						crear un Rect?ngulo alrededor de los fframes seleccionados. 
503 506
							} else if (getRbTodos().isSelected()) {
504 507
								if (layout.getFFrames().size() > 0) {
505
									re.setRect(((IFFrame) layout.getFFrames()
506
																.get(0)).getBoundBox());
508
									re=getRectangle((IFFrame) layout.getFFrames().get(0));
507 509
								}
508 510

  
509 511
								for (int i = 1; i < layout.getFFrames().size();
510 512
										i++) {
511
									Rectangle2D.Double rectaux = ((IFFrame) layout.getFFrames()
512
																				  .get(i)).getBoundBox();
513
									Rectangle2D rectaux = getRectangle((IFFrame) layout.getFFrames()
514
																				  .get(i));
513 515
									re.add(rectaux);
514 516
								}
515 517

  
......
519 521
								re.setRect(layout.getAtributes().getArea());
520 522
							}
521 523

  
522
							re.setRect(re.x - x, re.y - y, re.width + x + w,
523
								re.height + y + h);
524
							re.setRect(re.getX() - x, re.getY() - y, re.getWidth() + x + w,
525
								re.getHeight() + y + h);
524 526

  
525 527
							Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re,
526 528
									layout.getAT());
......
536 538
							layout.addFFrame(fframegraphics, true);
537 539
						} else { //Agrupar
538 540

  
539
							Rectangle2D.Double re = new Rectangle2D.Double();
541
							Rectangle2D re = new Rectangle2D.Double();
540 542
							//FFrameGroup fframegroup = new FFrameGroup();
541 543

  
542 544
							if (getRbSeleccionados().isSelected()) {
543 545
								if (selecList.size() > 0) {
544
									re.setRect(((IFFrame) selecList.get(0)).getBoundBox());
546
									re=getRectangle((IFFrame) selecList.get(0));
545 547
								}
546 548

  
547 549
								for (int i = 1; i < selecList.size(); i++) {
548
									Rectangle2D.Double rectaux = ((IFFrame) selecList.get(i)).getBoundBox();
550
									Rectangle2D rectaux = getRectangle((IFFrame) selecList.get(i));
549 551
									re.add(rectaux);
550 552
								}
551 553

  
552 554
								//						crear un Rect?ngulo alrededor de los fframes seleccionados. 
553 555
							} else if (getRbTodos().isSelected()) {
554 556
								if (layout.getFFrames().size() > 0) {
555
									re.setRect(((IFFrame) layout.getFFrames()
556
																.get(0)).getBoundBox());
557
									re=getRectangle((IFFrame) layout.getFFrames().get(0));
557 558
								}
558 559

  
559 560
								for (int i = 1; i < layout.getFFrames().size();
560 561
										i++) {
561
									Rectangle2D.Double rectaux = ((IFFrame) layout.getFFrames()
562
																				  .get(i)).getBoundBox();
562
									Rectangle2D rectaux = getRectangle((IFFrame) layout.getFFrames().get(i));
563 563
									((IFFrame) layout.getFFrames().get(i)).setSelected(true);
564 564
									re.add(rectaux);
565 565
								}
......
570 570
								re.setRect(layout.getAtributes().getArea());
571 571
							}
572 572

  
573
							re.setRect(re.x - x, re.y - y, re.width + x + w,
574
								re.height + y + h);
573
							re.setRect(re.getX() - x, re.getY() - y, re.getWidth() + x + w,
574
								re.getHeight() + y + h);
575 575

  
576 576
							Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re,
577 577
									layout.getAT());
......
645 645

  
646 646
		return bConfigurar;
647 647
	}
648
	private Rectangle2D getRectangle(IFFrame f){
649
		Rectangle2D.Double re= new Rectangle2D.Double();
650
		re.setRect(f.getBoundBox());
651
		Point2D p1=new Point2D.Double();
652
		Point2D p2=new Point2D.Double();
653
		Point2D p3=new Point2D.Double();
654
		Point2D p4=new Point2D.Double();
655
		double rotation=(f).getRotation();
656
		AffineTransform at=new AffineTransform();
657
		at.rotate(Math.toRadians(rotation), re.x + (re.width / 2),
658
				re.y + (re.height / 2));
659
		at.transform(new Point2D.Double(re.getX(),re.getY()),p1);
660
		at.transform(new Point2D.Double(re.getMaxX(),re.getY()),p2);
661
		at.transform(new Point2D.Double(re.getMaxX(),re.getMaxY()),p3);
662
		at.transform(new Point2D.Double(re.getX(),re.getMaxY()),p4);
663
		if (p1.getX()<p4.getX()){
664
			re.x=p1.getX();
665
		}else{
666
			re.x=p4.getX();
667
		}
668
		if (p1.getY()<p2.getY()){
669
			re.y=p1.getY();
670
		}else{
671
			re.y=p2.getY();
672
		}
673
		if (p2.getX()>p3.getX()){
674
			re.width=p2.getX()-re.x;
675
		}else{
676
			re.width=p3.getX()-re.x;
677
		}
678
		if (p4.getY()>p3.getY()){
679
			re.height=p4.getY()-re.y;
680
		}else{
681
			re.height=p3.getY()-re.y;
682
		}
683
		return re;
684
	}
648 685
} 

Also available in: Unified diff