Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / gui / cad / panels / matrix / MatrixProperty.java @ 40557

History | View | Annotate | Download (15.2 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.editing.gui.cad.panels.matrix;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.Dimension;
28
import java.awt.event.ActionListener;
29

    
30
import javax.swing.ImageIcon;
31
import javax.swing.JButton;
32
import javax.swing.JCheckBox;
33
import javax.swing.JDialog;
34
import javax.swing.JLabel;
35
import javax.swing.JPanel;
36
import javax.swing.JTabbedPane;
37
import javax.swing.JTextField;
38

    
39
import org.gvsig.andami.IconThemeHelper;
40
import org.gvsig.andami.PluginServices;
41
import org.gvsig.andami.ui.mdiManager.IWindow;
42
import org.gvsig.andami.ui.mdiManager.WindowInfo;
43
import org.gvsig.editing.gui.cad.tools.MatrixCADTool;
44
import org.gvsig.gui.beans.AcceptCancelPanel;
45
import org.gvsig.utils.DoubleUtilities;
46

    
47

    
48

    
49
public class MatrixProperty extends JPanel implements IWindow{
50

    
51
        private JPanel jPanel = null;
52
        private JTabbedPane jTabbedPane = null;  //  @jve:decl-index=0:visual-constraint="10,10"
53
        private JPanel pRectangular = null;
54
        private JPanel pPolar = null;
55
        private JPanel pNorth = null;
56
        private JLabel lblRows = null;
57
        private JTextField txtRows = null;
58
        private JLabel lblColumns = null;
59
        private JTextField txtColumns = null;
60
        private JPanel pCenter = null;
61
        private JLabel lblDistRows = null;
62
        private JTextField txtDistRows = null;
63
        private JLabel lblDistColumns = null;
64
        private JTextField txtDistColumns = null;
65
        private JLabel lblRotation = null;
66
        private JTextField txtRotation = null;
67
        private AcceptCancelPanel jPanel1;
68
        private MatrixOperations operations;
69
        private JPanel pNorthPolar = null;
70
        private JPanel pCenterPolar = null;
71
        private JLabel lblCenter = null;
72
        private JLabel lblx = null;
73
        private JTextField txtX = null;
74
        private JLabel lblY = null;
75
        private JTextField txtY = null;
76
        private JLabel lblNum = null;
77
        private JTextField txtNum = null;
78
        private JCheckBox chbRotateElements = null;
79
        private JButton bLagXY = null;
80
        private JButton bLagY = null;
81
        private JButton bLagX = null;
82
        private JButton bRotation = null;
83
        private MatrixCADTool matrixCADTool;
84
        private static ImageIcon ilagXY = null;
85
        private static ImageIcon iaddpoint = null;
86

    
87
        /**
88
         * This is the default constructor
89
         */
90
        public MatrixProperty() {
91
                super();
92
                initialize();
93

    
94
        }
95

    
96
        /**
97
         * This method initializes this
98
         *
99
         * @return void
100
         */
101
        private void initialize() {
102
            
103
            iaddpoint = IconThemeHelper.getImageIcon("layer-modify-matrix-addpoint");
104
        ilagXY = IconThemeHelper.getImageIcon("layer-modify-matrix-lagxy");
105

    
106
                this.setLayout(new BorderLayout());
107
                this.setSize(369, 275);
108
                this.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
109
                this.add(getJPanel(), java.awt.BorderLayout.EAST);
110
                this.add(getJPanel1(), java.awt.BorderLayout.SOUTH);
111

    
112
        }
113

    
114
        /**
115
         * This method initializes jPanel
116
         *
117
         * @return javax.swing.JPanel
118
         */
119
        private JPanel getJPanel() {
120
                if (jPanel == null) {
121
                        jPanel = new JPanel();
122
                }
123
                return jPanel;
124
        }
125

    
126
        /**
127
         * This method initializes jTabbedPane
128
         *
129
         * @return javax.swing.JTabbedPane
130
         */
131
        private JTabbedPane getJTabbedPane() {
132
                if (jTabbedPane == null) {
133
                        jTabbedPane = new JTabbedPane();
134
                        jTabbedPane.setSize(new java.awt.Dimension(323,235));
135
                        jTabbedPane.addTab(PluginServices.getText(this,"matriz_rectangular"), null, getPRectangular(), null);
136
                        jTabbedPane.addTab(PluginServices.getText(this,"matriz_polar"), null, getPPolar(), null);
137
                }
138
                return jTabbedPane;
139
        }
140

    
141
        /**
142
         * This method initializes pRectangular
143
         *
144
         * @return javax.swing.JPanel
145
         */
146
        private JPanel getPRectangular() {
147
                if (pRectangular == null) {
148
                        pRectangular = new JPanel();
149
                        pRectangular.setLayout(new BorderLayout());
150
                        pRectangular.setPreferredSize(new Dimension(300,200));
151
                        pRectangular.add(getPNorth(), java.awt.BorderLayout.NORTH);
152
                        pRectangular.add(getPCenter(), java.awt.BorderLayout.CENTER);
153
                }
154
                return pRectangular;
155
        }
156

    
157
        /**
158
         * This method initializes pPolar
159
         *
160
         * @return javax.swing.JPanel
161
         */
162
        private JPanel getPPolar() {
163
                if (pPolar == null) {
164
                        pPolar = new JPanel();
165
                        pPolar.setLayout(new BorderLayout());
166
                        pPolar.add(getPNorthPolar(), java.awt.BorderLayout.NORTH);
167
                        pPolar.add(getPCenterPolar(), java.awt.BorderLayout.CENTER);
168
                }
169
                return pPolar;
170
        }
171

    
172
        /**
173
         * This method initializes pNorth
174
         *
175
         * @return javax.swing.JPanel
176
         */
177
        private JPanel getPNorth() {
178
                if (pNorth == null) {
179
                        lblColumns = new JLabel();
180
                        lblColumns.setText(PluginServices.getText(this,"columns"));
181
                        lblRows = new JLabel();
182
                        lblRows.setText(PluginServices.getText(this,"rows"));
183
                        pNorth = new JPanel();
184
                        pNorth.add(lblRows, null);
185
                        pNorth.add(getTxtRows(), null);
186
                        pNorth.add(lblColumns, null);
187
                        pNorth.add(getTxtColumns(), null);
188
                }
189
                return pNorth;
190
        }
191

    
192
        /**
193
         * This method initializes txtRows
194
         *
195
         * @return javax.swing.JTextField
196
         */
197
        private JTextField getTxtRows() {
198
                if (txtRows == null) {
199
                        txtRows = new JTextField();
200
                        txtRows.setPreferredSize(new Dimension(40,20));
201
                }
202
                return txtRows;
203
        }
204

    
205
        /**
206
         * This method initializes txtColumns
207
         *
208
         * @return javax.swing.JTextField
209
         */
210
        private JTextField getTxtColumns() {
211
                if (txtColumns == null) {
212
                        txtColumns = new JTextField();
213
                        txtColumns.setPreferredSize(new Dimension(40,20));
214
                }
215
                return txtColumns;
216
        }
217

    
218
        /**
219
         * This method initializes pCenter
220
         *
221
         * @return javax.swing.JPanel
222
         */
223
        private JPanel getPCenter() {
224
                if (pCenter == null) {
225
                        lblRotation = new JLabel();
226
                        lblRotation.setBounds(new java.awt.Rectangle(6,73,141,22));
227
                        lblRotation.setText(PluginServices.getText(this,"rotation"));
228
                        lblDistColumns = new JLabel();
229
                        lblDistColumns.setBounds(new java.awt.Rectangle(6,42,141,22));
230
                        lblDistColumns.setText(PluginServices.getText(this,"disp_columns"));
231
                        lblDistRows = new JLabel();
232
                        lblDistRows.setBounds(new java.awt.Rectangle(6,10,141,22));
233
                        lblDistRows.setText(PluginServices.getText(this,"disp_rows"));
234
                        pCenter = new JPanel();
235
                        pCenter.setPreferredSize(new Dimension(200,150));
236
                        pCenter.setLayout(null);
237
                        pCenter.add(lblDistRows, null);
238
                        pCenter.add(getTxtDistRows(), null);
239
                        pCenter.add(lblDistColumns, null);
240
                        pCenter.add(getTxtDistColumns(), null);
241
                        pCenter.add(lblRotation, null);
242
                        pCenter.add(getTxtRotation(), null);
243
                        pCenter.add(getBLagXY(), null);
244
                        pCenter.add(getBLagY(), null);
245
                        pCenter.add(getBLagX(), null);
246
                        pCenter.add(getBRotation(), null);
247
                }
248
                return pCenter;
249
        }
250

    
251
        /**
252
         * This method initializes txtDistRows
253
         *
254
         * @return javax.swing.JTextField
255
         */
256
        private JTextField getTxtDistRows() {
257
                if (txtDistRows == null) {
258
                        txtDistRows = new JTextField();
259
                        txtDistRows.setBounds(new java.awt.Rectangle(153,11,75,22));
260
                }
261
                return txtDistRows;
262
        }
263

    
264
        /**
265
         * This method initializes txtDistColumns
266
         *
267
         * @return javax.swing.JTextField
268
         */
269
        private JTextField getTxtDistColumns() {
270
                if (txtDistColumns == null) {
271
                        txtDistColumns = new JTextField();
272
                        txtDistColumns.setBounds(new java.awt.Rectangle(153,43,75,22));
273
                }
274
                return txtDistColumns;
275
        }
276

    
277
        /**
278
         * This method initializes txtRotation
279
         *
280
         * @return javax.swing.JTextField
281
         */
282
        private JTextField getTxtRotation() {
283
                if (txtRotation == null) {
284
                        txtRotation = new JTextField();
285
                        txtRotation.setBounds(new java.awt.Rectangle(153,72,75,22));
286
                }
287
                return txtRotation;
288
        }
289

    
290
        /**
291
         * This method initializes jPanel
292
         *
293
         * @return javax.swing.JPanel
294
         */
295
        private AcceptCancelPanel getJPanel1() {
296
                if (jPanel1 == null) {
297
                        ActionListener okAction = new java.awt.event.ActionListener() {
298
                                public void actionPerformed(java.awt.event.ActionEvent e) {
299
                                        if (getJTabbedPane().getSelectedIndex()==0) {
300
                                                operations.setRectangular(true);
301
                                                operations.setNumRows(Integer.parseInt(getTxtRows().getText()));
302
                                                operations.setNumColumns(Integer.parseInt(getTxtColumns().getText()));
303
                                                operations.setDistRows(Double.parseDouble(getTxtDistRows().getText()));
304
                                                operations.setDistColumns(Double.parseDouble(getTxtDistColumns().getText()));
305
                                                operations.setRotation(Double.parseDouble(getTxtRotation().getText()));
306
                                        }else {
307
                                                operations.setRectangular(false);
308
                                                operations.setPositionX(Double.parseDouble(getTxtX().getText()));
309
                                                operations.setPositionY(Double.parseDouble(getTxtY().getText()));
310
                                                operations.setNum(Integer.parseInt(getTxtNum().getText()));
311
                                                operations.setRotateElements(getChbRotateElements().isSelected());
312
                                        }
313
                                        operations.setAccepted(true);
314

    
315
                                        if (PluginServices.getMainFrame() == null) {
316
                        ((JDialog) (getParent().getParent().getParent()
317
                                .getParent())).dispose();
318
                    } else {
319
                        PluginServices.getMDIManager().closeWindow(MatrixProperty.this);
320
                    }
321
                                }
322
                        };
323
                        ActionListener cancelAction = new java.awt.event.ActionListener() {
324
                                public void actionPerformed(java.awt.event.ActionEvent e) {
325
                    operations.setAccepted(false);
326
                                        if (PluginServices.getMainFrame() != null) {
327
                        PluginServices.getMDIManager().closeWindow(MatrixProperty.this);
328
                    } else {
329
                        ((JDialog) (getParent().getParent().getParent()
330
                                        .getParent())).dispose();
331
                    }
332
                                }
333
                        };
334
                        jPanel1 = new AcceptCancelPanel(okAction, cancelAction);
335
                }
336
                return jPanel1;
337
        }
338

    
339
        public WindowInfo getWindowInfo() {
340
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
341
                   m_viewinfo.setTitle(PluginServices.getText(this,"matrix"));
342
                    m_viewinfo.setHeight(this.getHeight());
343
                    m_viewinfo.setWidth(this.getWidth());
344
        return m_viewinfo;
345
        }
346

    
347
        public void setMatrixCADTool(MatrixCADTool tool) {
348
                operations=tool.getOperations();
349
                matrixCADTool=tool;
350
                refresh();
351
        }
352

    
353
        /**
354
         * This method initializes pNorthPolar
355
         *
356
         * @return javax.swing.JPanel
357
         */
358
        private JPanel getPNorthPolar() {
359
                if (pNorthPolar == null) {
360
                        lblY = new JLabel();
361
                        lblY.setText("Y: ");
362
                        lblx = new JLabel();
363
                        lblx.setText("X: ");
364
                        lblCenter = new JLabel();
365
                        lblCenter.setText("centro");
366
                        pNorthPolar = new JPanel();
367
                        pNorthPolar.add(lblCenter, null);
368
                        pNorthPolar.add(lblx, null);
369
                        pNorthPolar.add(getTxtX(), null);
370
                        pNorthPolar.add(lblY, null);
371
                        pNorthPolar.add(getTxtY(), null);
372
                }
373
                return pNorthPolar;
374
        }
375

    
376
        /**
377
         * This method initializes pCenterPolar
378
         *
379
         * @return javax.swing.JPanel
380
         */
381
        private JPanel getPCenterPolar() {
382
                if (pCenterPolar == null) {
383
                        lblNum = new JLabel();
384
                        lblNum.setText("num_elementos");
385
                        pCenterPolar = new JPanel();
386
                        pCenterPolar.add(lblNum, null);
387
                        pCenterPolar.add(getTxtNum(), null);
388
                        pCenterPolar.add(getChbRotateElements(), null);
389
                }
390
                return pCenterPolar;
391
        }
392

    
393
        /**
394
         * This method initializes txtX
395
         *
396
         * @return javax.swing.JTextField
397
         */
398
        private JTextField getTxtX() {
399
                if (txtX == null) {
400
                        txtX = new JTextField();
401
                        txtX.setPreferredSize(new java.awt.Dimension(50,20));
402
                }
403
                return txtX;
404
        }
405

    
406
        /**
407
         * This method initializes txtY
408
         *
409
         * @return javax.swing.JTextField
410
         */
411
        private JTextField getTxtY() {
412
                if (txtY == null) {
413
                        txtY = new JTextField();
414
                        txtY.setPreferredSize(new java.awt.Dimension(50,20));
415
                }
416
                return txtY;
417
        }
418

    
419
        /**
420
         * This method initializes txtNum
421
         *
422
         * @return javax.swing.JTextField
423
         */
424
        private JTextField getTxtNum() {
425
                if (txtNum == null) {
426
                        txtNum = new JTextField();
427
                        txtNum.setPreferredSize(new java.awt.Dimension(50,20));
428
                }
429
                return txtNum;
430
        }
431

    
432
        /**
433
         * This method initializes chbRotateElements
434
         *
435
         * @return javax.swing.JCheckBox
436
         */
437
        private JCheckBox getChbRotateElements() {
438
                if (chbRotateElements == null) {
439
                        chbRotateElements = new JCheckBox();
440
                        chbRotateElements.setText("girar_elementos_a_medida_que_se_copian");
441
                }
442
                return chbRotateElements;
443
        }
444

    
445
        /**
446
         * This method initializes bLagXY
447
         *
448
         * @return javax.swing.JButton
449
         */
450
        public JButton getBLagXY() {
451
                if (bLagXY == null) {
452
                        bLagXY = new JButton();
453
                        bLagXY.setBounds(new java.awt.Rectangle(232,8,30,56));
454
                        bLagXY.setIcon(ilagXY);
455
                        bLagXY.addActionListener(new java.awt.event.ActionListener() {
456
                                public void actionPerformed(java.awt.event.ActionEvent e) {
457
                                        operations.setAccepted(false);
458
                                        matrixCADTool.addOption("lagXY");
459
                                }
460
                        });
461
                }
462
                return bLagXY;
463
        }
464

    
465
        /**
466
         * This method initializes bLagY
467
         *
468
         * @return javax.swing.JButton
469
         */
470
        public JButton getBLagY() {
471
                if (bLagY == null) {
472
                        bLagY = new JButton();
473
                        bLagY.setBounds(new java.awt.Rectangle(270,7,28,26));
474
                        bLagY.setIcon(iaddpoint);
475
                        bLagY.addActionListener(new java.awt.event.ActionListener() {
476
                                public void actionPerformed(java.awt.event.ActionEvent e) {
477
                                        operations.setAccepted(false);
478
                                        matrixCADTool.addOption("lagY");
479
                                }
480
                        });
481
                }
482
                return bLagY;
483
        }
484

    
485
        /**
486
         * This method initializes bLagX
487
         *
488
         * @return javax.swing.JButton
489
         */
490
        public JButton getBLagX() {
491
                if (bLagX == null) {
492
                        bLagX = new JButton();
493
                        bLagX.setBounds(new java.awt.Rectangle(270,38,28,26));
494
                        bLagX.setIcon(iaddpoint);
495
                        bLagX.addActionListener(new java.awt.event.ActionListener() {
496
                                public void actionPerformed(java.awt.event.ActionEvent e) {
497
                                        operations.setAccepted(false);
498
                                        matrixCADTool.addOption("lagX");
499
                                }
500
                        });
501
                }
502
                return bLagX;
503
        }
504

    
505
        /**
506
         * This method initializes bRotation
507
         *
508
         * @return javax.swing.JButton
509
         */
510
        public JButton getBRotation() {
511
                if (bRotation == null) {
512
                        bRotation = new JButton();
513
                        bRotation.setBounds(new java.awt.Rectangle(232,70,28,26));
514
                        bRotation.setIcon(iaddpoint);
515
                        bRotation.addActionListener(new java.awt.event.ActionListener() {
516
                                public void actionPerformed(java.awt.event.ActionEvent e) {
517
                                        operations.setAccepted(false);
518
                                        matrixCADTool.addOption("rotation");
519
                                }
520
                        });
521
                }
522
                return bRotation;
523
        }
524

    
525
        public void refresh() {
526
                refreshLagX();
527
                refreshLagY();
528
                refreshRotation();
529
                getTxtColumns().setText(String.valueOf(operations.getNumColumns()));
530
                getTxtRows().setText(String.valueOf(operations.getNumRows()));
531
                getTxtNum().setText(String.valueOf(operations.getNum()));
532
                getTxtX().setText(String.valueOf(operations.getPositionX()));
533
                getTxtY().setText(String.valueOf(operations.getPositionY()));
534
        }
535

    
536
        public void refreshLagX() {
537
                getTxtDistColumns().setText(String.valueOf(DoubleUtilities.format(operations.getDistColumns(),'.',2)));
538

    
539
        }
540

    
541
        public void refreshLagY() {
542
                getTxtDistRows().setText(String.valueOf(DoubleUtilities.format(operations.getDistRows(),'.',2)));
543

    
544
        }
545
        public void refreshRotation() {
546
                getTxtRotation().setText(String.valueOf(DoubleUtilities.format(operations.getRotation(),'.',2)));
547

    
548
        }
549

    
550
        public Object getWindowProfile() {
551
                return WindowInfo.DIALOG_PROFILE;
552
        }
553

    
554

    
555
}  //  @jve:decl-index=0:visual-constraint="10,10"