Revision 1822 branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/dialogs/FBorderDialog.java
FBorderDialog.java | ||
---|---|---|
48 | 48 |
import com.iver.andami.ui.mdiManager.View; |
49 | 49 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
50 | 50 |
|
51 |
import com.iver.cit.gvsig.fmap.core.FGeometryCollection; |
|
52 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
53 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
54 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
55 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
|
56 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
|
57 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
51 | 58 |
import com.iver.cit.gvsig.gui.layout.FLayoutGraphics; |
52 | 59 |
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
53 | 60 |
import com.iver.cit.gvsig.gui.layout.Layout; |
54 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrame;
|
|
55 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics;
|
|
61 |
import com.iver.cit.gvsig.gui.layout.LayoutEditableFeature;
|
|
62 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphic; |
|
56 | 63 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGroup; |
57 | 64 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
58 | 65 |
import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameGraphicsDialog; |
... | ... | |
60 | 67 |
import java.awt.Color; |
61 | 68 |
import java.awt.geom.Rectangle2D; |
62 | 69 |
|
70 |
import java.io.IOException; |
|
71 |
|
|
63 | 72 |
import java.util.ArrayList; |
64 | 73 |
|
65 | 74 |
import javax.swing.ButtonGroup; |
... | ... | |
93 | 102 |
private javax.swing.JButton bCancelar = null; |
94 | 103 |
private Layout layout = null; |
95 | 104 |
private ArrayList selecList = new ArrayList(); |
96 |
private FFrameGraphics fframegraphics = null;
|
|
105 |
private FSymbol symbol = null;
|
|
97 | 106 |
private FLayoutGraphics flg = null; |
98 | 107 |
private String m_NameUnit = null; |
99 | 108 |
private javax.swing.JButton bConfigurar = null; |
... | ... | |
107 | 116 |
super(); |
108 | 117 |
layout = l; |
109 | 118 |
flg = new FLayoutGraphics(layout); |
110 |
fframegraphics = new FFrameGraphics(layout.getCadToolAdapter()); |
|
111 |
//fframegraphics.setColor(Color.red); |
|
112 |
//fframegraphics.update(Layout.RECTANGLESIMPLE, layout.getAT()); |
|
113 |
|
|
119 |
symbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE, Color.RED); |
|
114 | 120 |
initialize(); |
115 | 121 |
} |
116 | 122 |
|
... | ... | |
118 | 124 |
* This method initializes this |
119 | 125 |
*/ |
120 | 126 |
private void initialize() { |
121 |
for (int i = 0; i < layout.getFFrames().size(); i++) { |
|
122 |
if (((IFFrame) layout.getFFrames().get(i)).getSelected() != FFrame.NOSELECT) { |
|
123 |
selecList.add(layout.getFFrames().get(i)); |
|
127 |
for (int i = 0; i < layout.getAllFFrames().size(); i++) { |
|
128 |
if ((((IFFrame) layout.getAllFFrames().get(i)).getSelected() != IFFrame.NOSELECT) && |
|
129 |
!layout.isInvalidate(i)) { |
|
130 |
selecList.add(layout.getAllFFrames().get(i)); |
|
124 | 131 |
} |
125 | 132 |
} |
126 | 133 |
|
... | ... | |
493 | 500 |
if (!getChbAgrupar().isSelected()) { |
494 | 501 |
Rectangle2D.Double re = new Rectangle2D.Double(); |
495 | 502 |
|
503 |
// crear un Rect?ngulo alrededor de los FFrame seleccionados. |
|
496 | 504 |
if (getRbSeleccionados().isSelected()) { |
497 | 505 |
if (selecList.size() > 0) { |
498 | 506 |
re.setRect(((IFFrame) selecList.get(0)).getBoundBox()); |
... | ... | |
503 | 511 |
re.add(rectaux); |
504 | 512 |
} |
505 | 513 |
|
506 |
// crear un Rect?ngulo alrededor de los fframes seleccionados.
|
|
514 |
//crear un Rect?ngulo alrededor de todos los fframes.
|
|
507 | 515 |
} else if (getRbTodos().isSelected()) { |
508 |
if (layout.getFFrames().size() > 0) { |
|
509 |
re.setRect(((IFFrame) layout.getFFrames() |
|
510 |
.get(0)).getBoundBox()); |
|
516 |
IFFrame[] frames = layout.getFFrames1(); |
|
517 |
|
|
518 |
if (frames.length > 0) { |
|
519 |
re.setRect(frames[0].getBoundBox()); |
|
511 | 520 |
} |
512 | 521 |
|
513 |
for (int i = 1; i < layout.getFFrames().size(); |
|
514 |
i++) { |
|
515 |
Rectangle2D.Double rectaux = ((IFFrame) layout.getFFrames() |
|
516 |
.get(i)).getBoundBox(); |
|
522 |
for (int i = 1; i < frames.length; i++) { |
|
523 |
Rectangle2D.Double rectaux = frames[i].getBoundBox(); |
|
517 | 524 |
re.add(rectaux); |
518 | 525 |
} |
519 | 526 |
|
520 |
// creaer un Rect?ngulo que incluya a todos los fframes.
|
|
527 |
//crear un Rect?ngulo que incluya a todos los fframes.
|
|
521 | 528 |
} else if (getRbMargen().isSelected()) { |
522 |
// creaer un Rect?ngulo en los m?rgenes del Layout.
|
|
529 |
//crear un Rect?ngulo en los m?rgenes del Layout.
|
|
523 | 530 |
re.setRect(layout.getAtributes().getArea()); |
524 | 531 |
} |
525 | 532 |
|
... | ... | |
536 | 543 |
*/ |
537 | 544 |
re = FLayoutUtilities.toSheetRect(rectangle, |
538 | 545 |
layout.getAT()); |
539 |
fframegraphics.setBoundBox(re); |
|
540 |
layout.addFFrame(fframegraphics, true); |
|
546 |
addRectGeom(re); |
|
541 | 547 |
} else { //Agrupar |
542 | 548 |
|
543 | 549 |
Rectangle2D.Double re = new Rectangle2D.Double(); |
... | ... | |
555 | 561 |
|
556 | 562 |
// crear un Rect?ngulo alrededor de los fframes seleccionados. |
557 | 563 |
} else if (getRbTodos().isSelected()) { |
558 |
if (layout.getFFrames().size() > 0) { |
|
559 |
re.setRect(((IFFrame) layout.getFFrames() |
|
560 |
.get(0)).getBoundBox()); |
|
564 |
IFFrame[] frames = layout.getFFrames1(); |
|
565 |
|
|
566 |
if (frames.length > 0) { |
|
567 |
re.setRect(frames[0].getBoundBox()); |
|
561 | 568 |
} |
562 | 569 |
|
563 |
for (int i = 1; i < layout.getFFrames().size(); |
|
564 |
i++) { |
|
565 |
Rectangle2D.Double rectaux = ((IFFrame) layout.getFFrames() |
|
566 |
.get(i)).getBoundBox(); |
|
567 |
((IFFrame) layout.getFFrames().get(i)).setSelected(true); |
|
570 |
for (int i = 1; i < frames.length; i++) { |
|
571 |
Rectangle2D.Double rectaux = frames[i].getBoundBox(); |
|
572 |
frames[i].setSelected(true); |
|
568 | 573 |
re.add(rectaux); |
569 | 574 |
} |
570 | 575 |
|
... | ... | |
577 | 582 |
re.setRect(re.x - x, re.y - y, re.width + x + w, |
578 | 583 |
re.height + y + h); |
579 | 584 |
|
580 |
Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re, |
|
581 |
layout.getAT()); |
|
582 |
|
|
585 |
//Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re, |
|
586 |
// layout.getAT()); |
|
583 | 587 |
/*if (layout.isCuadricula()){ |
584 | 588 |
FLayoutUtilities.setRectGrid(rectangle, |
585 | 589 |
layout.getAtributes().getUnitInPixelsX(),layout.getAtributes().getUnitInPixelsY(), layout.getAT()); |
586 | 590 |
}*/ |
587 |
re.setRect(FLayoutUtilities.toSheetRect(rectangle, |
|
588 |
layout.getAT())); |
|
589 |
fframegraphics.setBoundBox(re); |
|
590 |
layout.addFFrame(fframegraphics, false); |
|
591 |
flg.grouping(); |
|
591 |
//re.setRect(FLayoutUtilities.toSheetRect(rectangle, |
|
592 |
// layout.getAT())); |
|
593 |
addRectGeom(re); |
|
594 |
|
|
595 |
try { |
|
596 |
flg.grouping(); |
|
597 |
} catch (DriverIOException e1) { |
|
598 |
e1.printStackTrace(); |
|
599 |
} catch (IOException e1) { |
|
600 |
e1.printStackTrace(); |
|
601 |
} |
|
592 | 602 |
} |
593 | 603 |
|
594 | 604 |
PluginServices.getMDIManager().closeView(FBorderDialog.this); |
... | ... | |
640 | 650 |
bConfigurar.addActionListener(new java.awt.event.ActionListener() { |
641 | 651 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
642 | 652 |
FFrameGraphicsDialog graphicsdialog = new FFrameGraphicsDialog(layout, |
643 |
fframegraphics.getGeometries()); |
|
644 |
|
|
653 |
new FFrameGraphic(layout, symbol, |
|
654 |
ShapeFactory.createPolyline2D( |
|
655 |
new GeneralPathX()))); |
|
656 |
symbol = graphicsdialog.getFSymbol(); |
|
645 | 657 |
PluginServices.getMDIManager().addView(graphicsdialog); |
646 | 658 |
} |
647 | 659 |
}); |
... | ... | |
649 | 661 |
|
650 | 662 |
return bConfigurar; |
651 | 663 |
} |
652 |
} |
|
664 |
|
|
665 |
/** |
|
666 |
* A?ade una geometr?a con la forma del rect?ngulo que se pasa como |
|
667 |
* par?metro. |
|
668 |
* |
|
669 |
* @param rect Rect?ngulo. |
|
670 |
*/ |
|
671 |
private void addRectGeom(Rectangle2D rect) { |
|
672 |
ArrayList list = new ArrayList(); |
|
673 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2); |
|
674 |
elShape.moveTo(rect.getX(), rect.getY()); |
|
675 |
elShape.lineTo(rect.getMaxX(), rect.getY()); |
|
676 |
list.add(ShapeFactory.createPolyline2D(elShape)); |
|
677 |
|
|
678 |
elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2); |
|
679 |
elShape.moveTo(rect.getMaxX(), rect.getY()); |
|
680 |
elShape.lineTo(rect.getMaxX(), rect.getMaxY()); |
|
681 |
list.add(ShapeFactory.createPolyline2D(elShape)); |
|
682 |
|
|
683 |
elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2); |
|
684 |
elShape.moveTo(rect.getMaxX(), rect.getMaxY()); |
|
685 |
elShape.lineTo(rect.getX(), rect.getMaxY()); |
|
686 |
list.add(ShapeFactory.createPolyline2D(elShape)); |
|
687 |
|
|
688 |
elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2); |
|
689 |
elShape.moveTo(rect.getX(), rect.getMaxY()); |
|
690 |
elShape.lineTo(rect.getX(), rect.getY()); |
|
691 |
list.add(ShapeFactory.createPolyline2D(elShape)); |
|
692 |
|
|
693 |
IGeometry[] geoms = (IGeometry[]) list.toArray(new IGeometry[0]); |
|
694 |
|
|
695 |
FGeometryCollection fgc = new FGeometryCollection(geoms); |
|
696 |
|
|
697 |
try { |
|
698 |
FFrameGraphic framegraphic = new FFrameGraphic(layout, symbol, fgc); |
|
699 |
((LayoutEditableFeature) layout.getCadToolAdapter() |
|
700 |
.getEditableFeatureSource()).addFFrame(framegraphic); |
|
701 |
} catch (DriverIOException e1) { |
|
702 |
e1.printStackTrace(); |
|
703 |
} catch (IOException e1) { |
|
704 |
e1.printStackTrace(); |
|
705 |
} |
|
706 |
} |
|
707 |
} |
Also available in: Unified diff