Statistics
| Revision:

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

History | View | Annotate | Download (21.7 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.gui.layout.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.View;
57
import com.iver.andami.ui.mdiManager.ViewInfo;
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.gui.layout.FLayoutGraphics;
61
import com.iver.cit.gvsig.gui.layout.Layout;
62
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics;
63
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
64
import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameGraphicsDialog;
65

    
66

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

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

    
110
                fframegraphics = new FFrameGraphics();
111

    
112
                fframegraphics.setColor(Color.black);
113
                fframegraphics.update(Layout.RECTANGLESIMPLE, layout.getAT());
114

    
115

    
116
                initialize();
117
                startFFrameGraphic();
118
        }
119
        private void startFFrameGraphic() {
120
                double x = Double.parseDouble(getTIzquierda().getText()
121
                                  .toString());
122
                double y = Double.parseDouble(getTSuperior().getText()
123
                                  .toString());
124
                double w = Double.parseDouble(getTDerecha().getText()
125
                                  .toString());
126
                double h = Double.parseDouble(getTInferior().getText()
127
                                  .toString());
128

    
129
                Rectangle2D re = new Rectangle2D.Double();
130

    
131
                if (getRbSeleccionados().isSelected()) {
132
                        if (selecList.length > 0) {
133
                                re=getRectangle((IFFrame) selecList[0]);
134

    
135
                        }
136

    
137
                        for (int i = 1; i < selecList.length; i++) {
138
                                Rectangle2D rectaux = getRectangle((IFFrame) selecList[i]);
139
                                re.add(rectaux);
140
                        }
141

    
142
                        //                                                crear un Rect?ngulo alrededor de los fframes seleccionados.
143
                } else if (getRbTodos().isSelected()) {
144
                        if (layout.getFFrames().length > 0) {
145
                                re=getRectangle((IFFrame) layout.getFFrame(0));
146
                        }
147

    
148
                        for (int i = 1; i < layout.getFFrames().length;
149
                                        i++) {
150
                                Rectangle2D rectaux = getRectangle((IFFrame) layout.getFFrame(i));
151
                                re.add(rectaux);
152
                        }
153

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

    
160
                re.setRect(re.getX() - x, re.getY() - y, re.getWidth() + x + w,
161
                        re.getHeight() + y + h);
162

    
163
                //Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re,
164
                //                layout.getAT());
165

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

    
201
                ButtonGroup group = new ButtonGroup();
202
                group.add(getRbSeleccionados());
203
                group.add(getRbTodos());
204
                group.add(getRbMargen());
205
        }
206

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

    
219
                        if (selecList.length == 0) {
220
                                rbSeleccionados.setEnabled(false);
221
                                getRbTodos().setSelected(true);
222
                        } else {
223
                                rbSeleccionados.setSelected(true);
224
                        }
225
                }
226

    
227
                return rbSeleccionados;
228
        }
229

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

    
243
                return rbTodos;
244
        }
245

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

    
258
                return rbMargen;
259
        }
260

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

    
273
                return chbAgrupar;
274
        }
275

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

    
304
                return pPosicion;
305
        }
306

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

    
342
                return chbIgualLados;
343
        }
344

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

    
357
                return lunidades;
358
        }
359

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

    
382
                return tTodosLados;
383
        }
384

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

    
397
                return lSuperior;
398
        }
399

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

    
412
                return lInferior;
413
        }
414

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

    
428
                return tSuperior;
429
        }
430

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

    
444
                return tInferior;
445
        }
446

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

    
459
                return lIzquierda;
460
        }
461

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

    
474
                return lDerecha;
475
        }
476

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

    
490
                return tIzquierda;
491
        }
492

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

    
506
                return tDerecha;
507
        }
508

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

    
521
                return lUnidades;
522
        }
523

    
524
        /**
525
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
526
         */
527
        public ViewInfo getViewInfo() {
528
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
529
                m_viewinfo.setTitle(PluginServices.getText(this, "ajustes_linea_grafica"));
530

    
531
                return m_viewinfo;
532
        }
533

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

    
555
                                                if (!getChbAgrupar().isSelected()) {
556
                                                        Rectangle2D re = new Rectangle2D.Double();
557

    
558
                                                        if (getRbSeleccionados().isSelected()) {
559
                                                                if (selecList.length > 0) {
560
                                                                        re=getRectangle((IFFrame) selecList[0]);
561

    
562
                                                                }
563

    
564
                                                                for (int i = 1; i < selecList.length; i++) {
565
                                                                        Rectangle2D rectaux = getRectangle((IFFrame) selecList[i]);
566
                                                                        re.add(rectaux);
567
                                                                }
568

    
569
                                                                //                                                crear un Rect?ngulo alrededor de los fframes seleccionados.
570
                                                        } else if (getRbTodos().isSelected()) {
571
                                                                if (layout.getFFrames().length > 0) {
572
                                                                        re=getRectangle((IFFrame) layout.getFFrame(0));
573
                                                                }
574

    
575
                                                                for (int i = 1; i < layout.getFFrames().length;
576
                                                                                i++) {
577
                                                                        Rectangle2D rectaux = getRectangle((IFFrame) layout.getFFrame(i));
578
                                                                        re.add(rectaux);
579
                                                                }
580

    
581
                                                                //                                                creaer un Rect?ngulo que incluya a todos los fframes.
582
                                                        } else if (getRbMargen().isSelected()) {
583
                                                                //                                                creaer un Rect?ngulo en los m?rgenes del Layout.
584
                                                                re.setRect(layout.getAtributes().getArea());
585
                                                        }
586

    
587
                                                        re.setRect(re.getX() - x, re.getY() - y, re.getWidth() + x + w,
588
                                                                re.getHeight() + y + h);
589

    
590
                                                        /*Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re,
591
                                                                        layout.getAT());
592

593
                                                        if (layout.isCuadricula()){
594
                                                           FLayoutUtilities.setRectGrid(rectangle,
595
                                                                              layout.getAtributes().getUnitInPixelsX(),layout.getAtributes().getUnitInPixelsY(), layout.getAT());
596
                                                           }
597

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

    
609
                                                        Rectangle2D re = new Rectangle2D.Double();
610
                                                        //FFrameGroup fframegroup = new FFrameGroup();
611

    
612
                                                        if (getRbSeleccionados().isSelected()) {
613
                                                                if (selecList.length > 0) {
614
                                                                        re=getRectangle((IFFrame) selecList[0]);
615
                                                                }
616

    
617
                                                                for (int i = 1; i < selecList.length; i++) {
618
                                                                        Rectangle2D rectaux = getRectangle((IFFrame) selecList[i]);
619
                                                                        re.add(rectaux);
620
                                                                }
621

    
622
                                                                //                                                crear un Rect?ngulo alrededor de los fframes seleccionados.
623
                                                        } else if (getRbTodos().isSelected()) {
624
                                                                if (layout.getFFrames().length > 0) {
625
                                                                        re=getRectangle((IFFrame) layout.getFFrame(0));
626
                                                                }
627

    
628
                                                                for (int i = 1; i < layout.getFFrames().length;
629
                                                                                i++) {
630
                                                                        Rectangle2D rectaux = getRectangle((IFFrame) layout.getFFrame(i));
631
                                                                        ((IFFrame) layout.getFFrame(i)).setSelected(true);
632
                                                                        re.add(rectaux);
633
                                                                }
634

    
635
                                                                //                                                creaer un Rect?ngulo que incluya a todos los fframes.
636
                                                        } else if (getRbMargen().isSelected()) {
637
                                                                //                                                creaer un Rect?ngulo en los m?rgenes del Layout.
638
                                                                re.setRect(layout.getAtributes().getArea());
639
                                                        }
640

    
641
                                                        re.setRect(re.getX() - x, re.getY() - y, re.getWidth() + x + w,
642
                                                                re.getHeight() + y + h);
643

    
644
                                                        /*Rectangle2D.Double rectangle = FLayoutUtilities.fromSheetRect(re,
645
                                                                        layout.getAT());
646

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

    
660
                                                        layout.getEFS().startComplexCommand();
661
                                                        layout.addFFrame(fframegraphics, false,true);
662
                                                        flg.grouping();
663
                                                        layout.getEFS().endComplexCommand();
664

    
665
                                                }
666

    
667
                                                PluginServices.getMDIManager().closeView(FBorderDialog.this);
668
                                                layout.setStatus(Layout.DESACTUALIZADO);
669
                                                layout.repaint();
670
                                        }
671
                                });
672
                }
673

    
674
                return bAceptar;
675
        }
676

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

    
694
                return bCancelar;
695
        }
696

    
697
        /**
698
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
699
         */
700
        public void viewActivated() {
701
        }
702

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

    
718
                                                PluginServices.getMDIManager().addView(graphicsdialog);
719
                                        }
720
                                });
721
                }
722

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