Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / gui / dialogs / FBorderDialog.java @ 9392

History | View | Annotate | Download (22.1 KB)

1
/*
2
 * Created on 28-jul-2004
3
 *
4
 */
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
package com.iver.cit.gvsig.project.documents.layout.gui.dialogs;
46

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

    
52
import javax.swing.ButtonGroup;
53
import javax.swing.JPanel;
54

    
55
import com.iver.andami.PluginServices;
56
import com.iver.andami.ui.mdiManager.IWindow;
57
import com.iver.andami.ui.mdiManager.WindowInfo;
58
import com.iver.cit.gvsig.fmap.core.adapter.GeometryAdapter;
59
import com.iver.cit.gvsig.fmap.core.adapter.RectangleAdapter;
60
import com.iver.cit.gvsig.project.documents.layout.FLayoutGraphics;
61
import com.iver.cit.gvsig.project.documents.layout.LayoutControl;
62
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameGraphics;
63
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
64
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameGraphicsDialog;
65
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
66

    
67

    
68
/**
69
 * Di?logo con todas las opciones para crear un borde a los fframes.
70
 *
71
 * @author Vicente Caballero Navarro
72
 */
73
public class FBorderDialog extends JPanel implements IWindow {
74
        private javax.swing.JRadioButton rbSeleccionados = null;
75
        private javax.swing.JRadioButton rbTodos = null;
76
        private javax.swing.JRadioButton rbMargen = null;
77
        private javax.swing.JCheckBox chbAgrupar = null;
78
        private javax.swing.JPanel pPosicion = null;
79
        private javax.swing.JCheckBox chbIgualLados = null;
80
        private javax.swing.JLabel lunidades = null;
81
        private javax.swing.JTextField tTodosLados = null;
82
        private javax.swing.JLabel lSuperior = null;
83
        private javax.swing.JLabel lInferior = null;
84
        private javax.swing.JTextField tSuperior = null;
85
        private javax.swing.JTextField tInferior = null;
86
        private javax.swing.JLabel lIzquierda = null;
87
        private javax.swing.JLabel lDerecha = null;
88
        private javax.swing.JTextField tIzquierda = null;
89
        private javax.swing.JTextField tDerecha = null;
90
        private javax.swing.JLabel lUnidades = null;
91
        private javax.swing.JButton bAceptar = null;
92
        private javax.swing.JButton bCancelar = null;
93
        private Layout layout = null;
94
        private IFFrame[] selecList;// = new ArrayList();
95
        private FFrameGraphics fframegraphics = null;
96
        private FLayoutGraphics flg = null;
97
        private String m_NameUnit = null;
98
        private javax.swing.JButton bConfigurar = null;
99
        GeometryAdapter geometry=new RectangleAdapter();
100

    
101
        /**
102
         * This is the default constructor
103
         *
104
         * @param l Referencia al Layout.
105
         */
106
        public FBorderDialog(Layout l) {
107
                super();
108
                layout = l;
109
                flg = new FLayoutGraphics(layout);
110

    
111
                fframegraphics = new FFrameGraphics();
112
                fframegraphics.setLayout(layout);
113

    
114
                fframegraphics.setColor(Color.black);
115
                fframegraphics.update(FFrameGraphics.RECTANGLE, layout.getLayoutControl().getAT());
116

    
117

    
118
                initialize();
119
                startFFrameGraphic();
120
        }
121
        private void startFFrameGraphic() {
122
                IFFrame[] fframes=layout.getLayoutContext().getFFrames();
123
                double x = Double.parseDouble(getTIzquierda().getText()
124
                                  .toString());
125
                double y = Double.parseDouble(getTSuperior().getText()
126
                                  .toString());
127
                double w = Double.parseDouble(getTDerecha().getText()
128
                                  .toString());
129
                double h = Double.parseDouble(getTInferior().getText()
130
                                  .toString());
131

    
132
                Rectangle2D re = new Rectangle2D.Double();
133

    
134
                if (getRbSeleccionados().isSelected()) {
135
                        if (selecList.length > 0) {
136
                                re=getRectangle(selecList[0]);
137

    
138
                        }
139

    
140
                        for (int i = 1; i < selecList.length; i++) {
141
                                Rectangle2D rectaux = getRectangle(selecList[i]);
142
                                re.add(rectaux);
143
                        }
144

    
145
                        //                                                crear un Rect?ngulo alrededor de los fframes seleccionados.
146
                } else if (getRbTodos().isSelected()) {
147
                        if (fframes.length > 0) {
148
                                re=getRectangle(fframes[0]);
149
                        }
150

    
151
                        for (int i = 1; i < fframes.length;
152
                                        i++) {
153
                                Rectangle2D rectaux = getRectangle(fframes[i]);
154
                                re.add(rectaux);
155
                        }
156

    
157
                        //                                                creaer un Rect?ngulo que incluya a todos los fframes.
158
                } else if (getRbMargen().isSelected()) {
159
                        //                                                creaer un Rect?ngulo en los m?rgenes del Layout.
160
                        re.setRect(layout.getLayoutContext().getAtributes().getArea());
161
                }
162

    
163
                re.setRect(re.getX() - x, re.getY() - y, re.getWidth() + x + w,
164
                        re.getHeight() + y + h);
165

    
166
                //Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re,
167
                //                layout.getAT());
168

    
169
                /*if (layout.isCuadricula()){
170
                   FLayoutUtilities.setRectGrid(rectangle,
171
                                      layout.getAtributes().getUnitInPixelsX(),layout.getAtributes().getUnitInPixelsY(), layout.getAT());
172
                   }
173
                 */
174
                //re = FLayoutUtilities.toSheetRect(rectangle,
175
                //                layout.getAT());
176
                geometry.addPoint(new Point2D.Double(re.getX(),re.getY()));
177
                geometry.addPoint(new Point2D.Double(re.getMaxX(),re.getMaxY()));
178
                geometry.end();
179
                fframegraphics.setGeometryAdapter(geometry);
180
        }
181
        /**
182
         * This method initializes this
183
         */
184
        private void initialize() {
185
                selecList=layout.getLayoutContext().getFFrameSelected();
186
                /*for (int i = 0; i < layout.getFFrames().size(); i++) {
187
                        if (((IFFrame) layout.getFFrames().get(i)).getSelected() != IFFrame.NOSELECT) {
188
                                selecList.add(layout.getFFrames().get(i));
189
                        }
190
                }
191
                */
192
                this.setLayout(null);
193
                m_NameUnit = layout.getLayoutContext().getAtributes().getNameUnit();
194
                this.add(getRbSeleccionados(), null);
195
                this.add(getRbTodos(), null);
196
                this.add(getRbMargen(), null);
197
                this.add(getChbAgrupar(), null);
198
                this.add(getPPosicion(), null);
199
                this.add(getBAceptar(), null);
200
                this.add(getBCancelar(), null);
201
                this.add(getBConfigurar(), null);
202
                this.setSize(371, 223);
203

    
204
                ButtonGroup group = new ButtonGroup();
205
                group.add(getRbSeleccionados());
206
                group.add(getRbTodos());
207
                group.add(getRbMargen());
208
        }
209

    
210
        /**
211
         * This method initializes rbSeleccionados
212
         *
213
         * @return javax.swing.JRadioButton
214
         */
215
        private javax.swing.JRadioButton getRbSeleccionados() {
216
                if (rbSeleccionados == null) {
217
                        rbSeleccionados = new javax.swing.JRadioButton();
218
                        rbSeleccionados.setBounds(10, 8, 416, 20);
219
                        rbSeleccionados.setText(PluginServices.getText(this,
220
                                        "colocar_alrededor_seleccionados"));
221

    
222
                        if (selecList.length == 0) {
223
                                rbSeleccionados.setEnabled(false);
224
                                getRbTodos().setSelected(true);
225
                        } else {
226
                                rbSeleccionados.setSelected(true);
227
                        }
228
                }
229

    
230
                return rbSeleccionados;
231
        }
232

    
233
        /**
234
         * This method initializes rbTodos
235
         *
236
         * @return javax.swing.JRadioButton
237
         */
238
        private javax.swing.JRadioButton getRbTodos() {
239
                if (rbTodos == null) {
240
                        rbTodos = new javax.swing.JRadioButton();
241
                        rbTodos.setBounds(10, 29, 332, 20);
242
                        rbTodos.setText(PluginServices.getText(this,
243
                                        "colocar_alrededor_todos"));
244
                }
245

    
246
                return rbTodos;
247
        }
248

    
249
        /**
250
         * This method initializes rbMargen
251
         *
252
         * @return javax.swing.JRadioButton
253
         */
254
        private javax.swing.JRadioButton getRbMargen() {
255
                if (rbMargen == null) {
256
                        rbMargen = new javax.swing.JRadioButton();
257
                        rbMargen.setBounds(10, 51, 286, 20);
258
                        rbMargen.setText(PluginServices.getText(this, "colocar_a_margenes"));
259
                }
260

    
261
                return rbMargen;
262
        }
263

    
264
        /**
265
         * This method initializes chbAgrupar
266
         *
267
         * @return javax.swing.JCheckBox
268
         */
269
        private javax.swing.JCheckBox getChbAgrupar() {
270
                if (chbAgrupar == null) {
271
                        chbAgrupar = new javax.swing.JCheckBox();
272
                        chbAgrupar.setBounds(10, 70, 280, 20);
273
                        chbAgrupar.setText(PluginServices.getText(this, "agrupar_linea"));
274
                }
275

    
276
                return chbAgrupar;
277
        }
278

    
279
        /**
280
         * This method initializes pPosicion
281
         *
282
         * @return javax.swing.JPanel
283
         */
284
        private javax.swing.JPanel getPPosicion() {
285
                if (pPosicion == null) {
286
                        pPosicion = new javax.swing.JPanel();
287
                        pPosicion.setLayout(null);
288
                        pPosicion.add(getChbIgualLados(), null);
289
                        pPosicion.add(getLunidades(), null);
290
                        pPosicion.add(getTTodosLados(), null);
291
                        pPosicion.add(getLSuperior(), null);
292
                        pPosicion.add(getLInferior(), null);
293
                        pPosicion.add(getTSuperior(), null);
294
                        pPosicion.add(getTInferior(), null);
295
                        pPosicion.add(getLIzquierda(), null);
296
                        pPosicion.add(getLDerecha(), null);
297
                        pPosicion.add(getTIzquierda(), null);
298
                        pPosicion.add(getTDerecha(), null);
299
                        pPosicion.add(getLUnidades(), null);
300
                        pPosicion.setBounds(12, 92, 350, 97);
301
                        pPosicion.setBorder(javax.swing.BorderFactory.createTitledBorder(
302
                                        null, PluginServices.getText(this, "posicion_linea"),
303
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
304
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
305
                }
306

    
307
                return pPosicion;
308
        }
309

    
310
        /**
311
         * This method initializes chbIgualLados
312
         *
313
         * @return javax.swing.JCheckBox
314
         */
315
        private javax.swing.JCheckBox getChbIgualLados() {
316
                if (chbIgualLados == null) {
317
                        chbIgualLados = new javax.swing.JCheckBox();
318
                        chbIgualLados.setBounds(10, 16, 243, 21);
319
                        chbIgualLados.setText(PluginServices.getText(this,
320
                                        "igual_todos_lados"));
321
                        chbIgualLados.setSelected(true);
322
                        chbIgualLados.addActionListener(new java.awt.event.ActionListener() {
323
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
324
                                                if (!chbIgualLados.isSelected()) {
325
                                                        getTTodosLados().setEnabled(false);
326
                                                        getTSuperior().setEnabled(true);
327
                                                        getTInferior().setEnabled(true);
328
                                                        getTIzquierda().setEnabled(true);
329
                                                        getTDerecha().setEnabled(true);
330
                                                } else {
331
                                                        getTTodosLados().setEnabled(true);
332
                                                        getTSuperior().setEnabled(false);
333
                                                        getTInferior().setEnabled(false);
334
                                                        getTIzquierda().setEnabled(false);
335
                                                        getTDerecha().setEnabled(false);
336
                                                        getTSuperior().setText(tTodosLados.getText());
337
                                                        getTInferior().setText(tTodosLados.getText());
338
                                                        getTIzquierda().setText(tTodosLados.getText());
339
                                                        getTDerecha().setText(tTodosLados.getText());
340
                                                }
341
                                        }
342
                                });
343
                }
344

    
345
                return chbIgualLados;
346
        }
347

    
348
        /**
349
         * This method initializes lunidades
350
         *
351
         * @return javax.swing.JLabel
352
         */
353
        private javax.swing.JLabel getLunidades() {
354
                if (lunidades == null) {
355
                        lunidades = new javax.swing.JLabel();
356
                        lunidades.setBounds(264, 64, 78, 18);
357
                        lunidades.setText(PluginServices.getText(this,m_NameUnit));
358
                }
359

    
360
                return lunidades;
361
        }
362

    
363
        /**
364
         * This method initializes tTodosLados
365
         *
366
         * @return javax.swing.JTextField
367
         */
368
        private javax.swing.JTextField getTTodosLados() {
369
                if (tTodosLados == null) {
370
                        tTodosLados = new javax.swing.JTextField();
371
                        tTodosLados.setBounds(267, 19, 48, 16);
372
                        tTodosLados.setText("0.5");
373
                        tTodosLados.addCaretListener(new javax.swing.event.CaretListener() {
374
                                        public void caretUpdate(javax.swing.event.CaretEvent e) {
375
                                                if (getChbIgualLados().isSelected()) {
376
                                                        getTSuperior().setText(tTodosLados.getText());
377
                                                        getTInferior().setText(tTodosLados.getText());
378
                                                        getTIzquierda().setText(tTodosLados.getText());
379
                                                        getTDerecha().setText(tTodosLados.getText());
380
                                                }
381
                                        }
382
                                });
383
                }
384

    
385
                return tTodosLados;
386
        }
387

    
388
        /**
389
         * This method initializes lSuperior
390
         *
391
         * @return javax.swing.JLabel
392
         */
393
        private javax.swing.JLabel getLSuperior() {
394
                if (lSuperior == null) {
395
                        lSuperior = new javax.swing.JLabel();
396
                        lSuperior.setBounds(10, 55, 62, 16);
397
                        lSuperior.setText(PluginServices.getText(this, "Superior"));
398
                }
399

    
400
                return lSuperior;
401
        }
402

    
403
        /**
404
         * This method initializes lInferior
405
         *
406
         * @return javax.swing.JLabel
407
         */
408
        private javax.swing.JLabel getLInferior() {
409
                if (lInferior == null) {
410
                        lInferior = new javax.swing.JLabel();
411
                        lInferior.setBounds(10, 72, 62, 16);
412
                        lInferior.setText(PluginServices.getText(this, "Inferior"));
413
                }
414

    
415
                return lInferior;
416
        }
417

    
418
        /**
419
         * This method initializes tSuperior
420
         *
421
         * @return javax.swing.JTextField
422
         */
423
        private javax.swing.JTextField getTSuperior() {
424
                if (tSuperior == null) {
425
                        tSuperior = new javax.swing.JTextField();
426
                        tSuperior.setBounds(78, 55, 48, 16);
427
                        tSuperior.setText("0.5");
428
                        tSuperior.setEnabled(false);
429
                }
430

    
431
                return tSuperior;
432
        }
433

    
434
        /**
435
         * This method initializes tInferior
436
         *
437
         * @return javax.swing.JTextField
438
         */
439
        private javax.swing.JTextField getTInferior() {
440
                if (tInferior == null) {
441
                        tInferior = new javax.swing.JTextField();
442
                        tInferior.setBounds(78, 72, 48, 16);
443
                        tInferior.setText("0.5");
444
                        tInferior.setEnabled(false);
445
                }
446

    
447
                return tInferior;
448
        }
449

    
450
        /**
451
         * This method initializes lIzquierda
452
         *
453
         * @return javax.swing.JLabel
454
         */
455
        private javax.swing.JLabel getLIzquierda() {
456
                if (lIzquierda == null) {
457
                        lIzquierda = new javax.swing.JLabel();
458
                        lIzquierda.setBounds(140, 55, 62, 16);
459
                        lIzquierda.setText(PluginServices.getText(this, "Izquierda"));
460
                }
461

    
462
                return lIzquierda;
463
        }
464

    
465
        /**
466
         * This method initializes lDerecha
467
         *
468
         * @return javax.swing.JLabel
469
         */
470
        private javax.swing.JLabel getLDerecha() {
471
                if (lDerecha == null) {
472
                        lDerecha = new javax.swing.JLabel();
473
                        lDerecha.setBounds(140, 72, 62, 16);
474
                        lDerecha.setText(PluginServices.getText(this, "Derecha"));
475
                }
476

    
477
                return lDerecha;
478
        }
479

    
480
        /**
481
         * This method initializes tIzquierda
482
         *
483
         * @return javax.swing.JTextField
484
         */
485
        private javax.swing.JTextField getTIzquierda() {
486
                if (tIzquierda == null) {
487
                        tIzquierda = new javax.swing.JTextField();
488
                        tIzquierda.setBounds(207, 55, 48, 16);
489
                        tIzquierda.setText("0.5");
490
                        tIzquierda.setEnabled(false);
491
                }
492

    
493
                return tIzquierda;
494
        }
495

    
496
        /**
497
         * This method initializes tDerecha
498
         *
499
         * @return javax.swing.JTextField
500
         */
501
        private javax.swing.JTextField getTDerecha() {
502
                if (tDerecha == null) {
503
                        tDerecha = new javax.swing.JTextField();
504
                        tDerecha.setBounds(207, 72, 48, 16);
505
                        tDerecha.setText("0.5");
506
                        tDerecha.setEnabled(false);
507
                }
508

    
509
                return tDerecha;
510
        }
511

    
512
        /**
513
         * This method initializes lUnidades
514
         *
515
         * @return javax.swing.JLabel
516
         */
517
        private javax.swing.JLabel getLUnidades() {
518
                if (lUnidades == null) {
519
                        lUnidades = new javax.swing.JLabel();
520
                        lUnidades.setBounds(207, 36, 134, 18);
521
                        lUnidades.setText(PluginServices.getText(this, "map_units"));
522
                }
523

    
524
                return lUnidades;
525
        }
526

    
527
        /**
528
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
529
         */
530
        public WindowInfo getWindowInfo() {
531
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
532
                m_viewinfo.setTitle(PluginServices.getText(this, "ajustes_linea_grafica"));
533

    
534
                return m_viewinfo;
535
        }
536

    
537
        /**
538
         * This method initializes bAceptar
539
         *
540
         * @return javax.swing.JButton
541
         */
542
        private javax.swing.JButton getBAceptar() {
543
                if (bAceptar == null) {
544
                        bAceptar = new javax.swing.JButton();
545
                        bAceptar.setBounds(134, 193, 100, 20);
546
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
547
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
548
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
549
                                                IFFrame[] fframes=layout.getLayoutContext().getFFrames();
550
                                                double x = Double.parseDouble(getTIzquierda().getText()
551
                                                                                                                  .toString());
552
                                                double y = Double.parseDouble(getTSuperior().getText()
553
                                                                                                                  .toString());
554
                                                double w = Double.parseDouble(getTDerecha().getText()
555
                                                                                                                  .toString());
556
                                                double h = Double.parseDouble(getTInferior().getText()
557
                                                                                                                  .toString());
558

    
559
                                                if (!getChbAgrupar().isSelected()) {
560
                                                        Rectangle2D re = new Rectangle2D.Double();
561

    
562
                                                        if (getRbSeleccionados().isSelected()) {
563
                                                                if (selecList.length > 0) {
564
                                                                        re=getRectangle(selecList[0]);
565

    
566
                                                                }
567

    
568
                                                                for (int i = 1; i < selecList.length; i++) {
569
                                                                        Rectangle2D rectaux = getRectangle(selecList[i]);
570
                                                                        re.add(rectaux);
571
                                                                }
572

    
573
                                                                //                                                crear un Rect?ngulo alrededor de los fframes seleccionados.
574
                                                        } else if (getRbTodos().isSelected()) {
575
                                                                if (fframes.length > 0) {
576
                                                                        re=getRectangle(fframes[0]);
577
                                                                }
578

    
579
                                                                for (int i = 1; i < fframes.length;
580
                                                                                i++) {
581
                                                                        Rectangle2D rectaux = getRectangle(fframes[i]);
582
                                                                        re.add(rectaux);
583
                                                                }
584

    
585
                                                                //                                                creaer un Rect?ngulo que incluya a todos los fframes.
586
                                                        } else if (getRbMargen().isSelected()) {
587
                                                                //                                                creaer un Rect?ngulo en los m?rgenes del Layout.
588
                                                                re.setRect(layout.getLayoutContext().getAtributes().getArea());
589
                                                        }
590

    
591
                                                        re.setRect(re.getX() - x, re.getY() - y, re.getWidth() + x + w,
592
                                                                re.getHeight() + y + h);
593

    
594
                                                        /*Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re,
595
                                                                        layout.getAT());
596

597
                                                        if (layout.isCuadricula()){
598
                                                           FLayoutUtilities.setRectGrid(rectangle,
599
                                                                              layout.getAtributes().getUnitInPixelsX(),layout.getAtributes().getUnitInPixelsY(), layout.getAT());
600
                                                           }
601

602
                                                        re = FLayoutUtilities.toSheetRect(rectangle,
603
                                                                        layout.getAT());
604
                                                                         */
605
                                                        geometry.addPoint(new Point2D.Double(re.getX(),re.getY()));
606
                                                        geometry.addPoint(new Point2D.Double(re.getMaxX(),re.getMaxY()));
607
                                                        geometry.end();
608
                                                        fframegraphics.setGeometryAdapter(geometry);
609
                                                        fframegraphics.setBoundBox(re);
610
                                                        layout.getLayoutContext().addFFrame(fframegraphics, true,true);
611
                                                } else { //Agrupar
612

    
613
                                                        Rectangle2D re = new Rectangle2D.Double();
614
                                                        //FFrameGroup fframegroup = new FFrameGroup();
615

    
616
                                                        if (getRbSeleccionados().isSelected()) {
617
                                                                if (selecList.length > 0) {
618
                                                                        re=getRectangle(selecList[0]);
619
                                                                }
620

    
621
                                                                for (int i = 1; i < selecList.length; i++) {
622
                                                                        Rectangle2D rectaux = getRectangle(selecList[i]);
623
                                                                        re.add(rectaux);
624
                                                                }
625

    
626
                                                                //                                                crear un Rect?ngulo alrededor de los fframes seleccionados.
627
                                                        } else if (getRbTodos().isSelected()) {
628
                                                                if (fframes.length > 0) {
629
                                                                        re=getRectangle(fframes[0]);
630
                                                                }
631

    
632
                                                                for (int i = 1; i < fframes.length;
633
                                                                                i++) {
634
                                                                        Rectangle2D rectaux = getRectangle(fframes[i]);
635
                                                                        fframes[i].setSelected(true);
636
                                                                        re.add(rectaux);
637
                                                                }
638

    
639
                                                                //                                                creaer un Rect?ngulo que incluya a todos los fframes.
640
                                                        } else if (getRbMargen().isSelected()) {
641
                                                                //                                                creaer un Rect?ngulo en los m?rgenes del Layout.
642
                                                                re.setRect(layout.getLayoutContext().getAtributes().getArea());
643
                                                        }
644

    
645
                                                        re.setRect(re.getX() - x, re.getY() - y, re.getWidth() + x + w,
646
                                                                re.getHeight() + y + h);
647

    
648
                                                        /*Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re,
649
                                                                        layout.getAT());
650

651
                                                        if (layout.isCuadricula()){
652
                                                           FLayoutUtilities.setRectGrid(rectangle,
653
                                                                           layout.getAtributes().getUnitInPixelsX(),layout.getAtributes().getUnitInPixelsY(), layout.getAT());
654
                                                           }
655
                                                        re.setRect(FLayoutUtilities.toSheetRect(rectangle,
656
                                                                        layout.getAT()));
657
                                                                        */
658
                                                        geometry.addPoint(new Point2D.Double(re.getX(),re.getY()));
659
                                                        geometry.addPoint(new Point2D.Double(re.getMaxX(),re.getMaxY()));
660
                                                        geometry.end();
661
                                                        fframegraphics.setGeometryAdapter(geometry);
662
                                                        fframegraphics.setBoundBox(re);
663

    
664
                                                        layout.getLayoutContext().getEFS().startComplexCommand();
665
                                                        layout.getLayoutContext().addFFrame(fframegraphics, false,true);
666
                                                        flg.grouping();
667
                                                        layout.getLayoutContext().getEFS().endComplexCommand(PluginServices.getText(this,"group_graphic_line"));
668

    
669
                                                }
670

    
671
                                                PluginServices.getMDIManager().closeWindow(FBorderDialog.this);
672
                                                layout.getLayoutControl().setStatus(LayoutControl.DESACTUALIZADO);
673
                                                layout.getLayoutControl().repaint();
674
                                        }
675
                                });
676
                }
677

    
678
                return bAceptar;
679
        }
680

    
681
        /**
682
         * This method initializes bCancelar
683
         *
684
         * @return javax.swing.JButton
685
         */
686
        private javax.swing.JButton getBCancelar() {
687
                if (bCancelar == null) {
688
                        bCancelar = new javax.swing.JButton();
689
                        bCancelar.setBounds(251, 193, 100, 20);
690
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
691
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
692
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
693
                                                PluginServices.getMDIManager().closeWindow(FBorderDialog.this);
694
                                        }
695
                                });
696
                }
697

    
698
                return bCancelar;
699
        }
700

    
701
        /**
702
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
703
         */
704
        public void viewActivated() {
705
        }
706

    
707
        /**
708
         * This method initializes bConfigurar
709
         *
710
         * @return javax.swing.JButton
711
         */
712
        private javax.swing.JButton getBConfigurar() {
713
                if (bConfigurar == null) {
714
                        bConfigurar = new javax.swing.JButton();
715
                        bConfigurar.setBounds(17, 193, 100, 20);
716
                        bConfigurar.setText(PluginServices.getText(this, "configurar"));
717
                        bConfigurar.addActionListener(new java.awt.event.ActionListener() {
718
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
719
                                                FFrameGraphicsDialog graphicsdialog = new FFrameGraphicsDialog(layout,
720
                                                                fframegraphics);
721

    
722
                                                PluginServices.getMDIManager().addWindow(graphicsdialog);
723
                                        }
724
                                });
725
                }
726

    
727
                return bConfigurar;
728
        }
729
        private Rectangle2D getRectangle(IFFrame f){
730
                Rectangle2D.Double re= new Rectangle2D.Double();
731
                re.setRect(f.getBoundBox());
732
                Point2D p1=new Point2D.Double();
733
                Point2D p2=new Point2D.Double();
734
                Point2D p3=new Point2D.Double();
735
                Point2D p4=new Point2D.Double();
736
                double rotation=(f).getRotation();
737
                AffineTransform at=new AffineTransform();
738
                at.rotate(Math.toRadians(rotation), re.x + (re.width / 2),
739
                                re.y + (re.height / 2));
740
                at.transform(new Point2D.Double(re.getX(),re.getY()),p1);
741
                at.transform(new Point2D.Double(re.getMaxX(),re.getY()),p2);
742
                at.transform(new Point2D.Double(re.getMaxX(),re.getMaxY()),p3);
743
                at.transform(new Point2D.Double(re.getX(),re.getMaxY()),p4);
744
                if (p1.getX()<p4.getX()){
745
                        re.x=p1.getX();
746
                }else{
747
                        re.x=p4.getX();
748
                }
749
                if (p1.getY()<p2.getY()){
750
                        re.y=p1.getY();
751
                }else{
752
                        re.y=p2.getY();
753
                }
754
                if (p2.getX()>p3.getX()){
755
                        re.width=p2.getX()-re.x;
756
                }else{
757
                        re.width=p3.getX()-re.x;
758
                }
759
                if (p4.getY()>p3.getY()){
760
                        re.height=p4.getY()-re.y;
761
                }else{
762
                        re.height=p3.getY()-re.y;
763
                }
764
                return re;
765
        }
766
}