Statistics
| Revision:

root / trunk / extensions / extgvSIGPiloto-Raster / src / org / gvsig / rasterTools / raw / ui / main / GeometryPropertiesLeftPanel.java @ 9045

History | View | Annotate | Download (12.1 KB)

1
package org.gvsig.rasterTools.raw.ui.main;
2

    
3
import java.awt.Dimension;
4
import java.awt.FlowLayout;
5
import java.awt.GridBagConstraints;
6
import java.awt.GridBagLayout;
7
import java.text.NumberFormat;
8

    
9
import javax.swing.JFormattedTextField;
10
import javax.swing.JLabel;
11
import javax.swing.JPanel;
12
import javax.swing.JTextField;
13

    
14
import com.iver.andami.PluginServices;
15
import com.iver.utiles.StringUtilities;
16

    
17
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
18
 *
19
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
20
 *
21
 * This program is free software; you can redistribute it and/or
22
 * modify it under the terms of the GNU General Public License
23
 * as published by the Free Software Foundation; either version 2
24
 * of the License, or (at your option) any later version.
25
 *
26
 * This program is distributed in the hope that it will be useful,
27
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 * GNU General Public License for more details.
30
 *
31
 * You should have received a copy of the GNU General Public License
32
 * along with this program; if not, write to the Free Software
33
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
34
 *
35
 * For more information, contact:
36
 *
37
 *  Generalitat Valenciana
38
 *   Conselleria d'Infraestructures i Transport
39
 *   Av. Blasco Ib??ez, 50
40
 *   46010 VALENCIA
41
 *   SPAIN
42
 *
43
 *      +34 963862235
44
 *   gvsig@gva.es
45
 *      www.gvsig.gva.es
46
 *
47
 *    or
48
 *
49
 *   IVER T.I. S.A
50
 *   Salamanca 50
51
 *   46005 Valencia
52
 *   Spain
53
 *
54
 *   +34 963163400
55
 *   dac@iver.es
56
 */
57
/* CVS MESSAGES:
58
 *
59
 * $Id: GeometryPropertiesLeftPanel.java 9045 2006-11-28 11:49:25Z nacho $
60
 * $Log$
61
 * Revision 1.1  2006-11-28 11:49:25  nacho
62
 * *** empty log message ***
63
 *
64
 * Revision 1.1  2006/10/10 16:11:22  nacho
65
 * *** empty log message ***
66
 *
67
 * Revision 1.3  2006/08/01 11:19:04  jorpiell
68
 * Ajustado el tama?o de las ventanas
69
 *
70
 * Revision 1.2  2006/07/28 13:13:27  jorpiell
71
 * Unos peque?os cambios para que coja el ancho y el alto de la imagen
72
 *
73
 * Revision 1.1  2006/07/28 12:51:40  jorpiell
74
 * Primer commit de las clases empleadas para abrir raw
75
 *
76
 *
77
 */
78
/**
79
 * This panel contains the left panel of the "Set Geometry"
80
 * panel. It is the imput to write the image width, the heigth,
81
 * the number of bands and the image header size.
82
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
83
 */
84
public class GeometryPropertiesLeftPanel extends JPanel{
85
        private JPanel bandsLabelPanel = null;
86
        private JPanel headerSizeLabelPanel = null;
87
        private JPanel heigthLabelPanel = null;
88
        private JLabel heigthLabel = null;
89
        private JPanel labelsPanel = null;
90
        private JPanel fieldsPanel = null;
91
        private JPanel widthTextPanel = null;
92
        private JPanel heigthTextPanel = null;
93
        private JPanel widthLabelPanel = null;
94
        private JLabel widthLabel = null;
95
        private JLabel bandsLabel = null;
96
        private JPanel bandsTextPanel = null;
97
        private JPanel headerSizeTextPanel = null;
98
        private JFormattedTextField widthText = null;
99
        private JLabel headerSizeLabel = null;
100
        private JFormattedTextField heigthText = null;
101
        private JFormattedTextField bandsText = null;
102
        private JFormattedTextField headerSizeText = null;
103
        
104
        private final int WIDTH = 245;
105
        private final int HEIGHT = 110;
106
        private final int LABELS_PANEL_WIDTH = 120;
107
        private final int TEXTS_PANEL_WIDTH = 125;
108
        private final int LABELS_WIDTH = 120;
109
        private final int LABELS_HEIGHT = 19;
110
        private final int TEXTS_WIDTH = 120;
111
        private final int TEXTS_HEIGHT = 19;
112
        
113
        /**
114
         * This is the default constructor
115
         */
116
        public GeometryPropertiesLeftPanel() {
117
                super();
118
                initialize();
119
        }
120

    
121
        /**
122
         * This method initializes this
123
         * 
124
         * @return void
125
         */
126
        private void initialize() {                
127
                
128
                this.setLayout(new GridBagLayout());
129
                this.setPreferredSize(new java.awt.Dimension(WIDTH,HEIGHT));
130
                this.add(getLabelsPanel(), new GridBagConstraints());
131
                this.add(getFieldsPanel(), new GridBagConstraints());
132
        }
133
        
134
        /**
135
         * This method initializes pX        
136
         *         
137
         * @return javax.swing.JPanel        
138
         */
139
        private JPanel getBandsLabelPanel() {
140
                if (bandsLabelPanel == null) {
141
                        bandsLabel = new JLabel();
142
                        bandsLabel.setText(PluginServices.getText(this, "bands_number"));
143
                        FlowLayout flowLayout2 = new FlowLayout();
144
                        flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
145
                        bandsLabelPanel = new JPanel();
146
                        bandsLabelPanel.setLayout(flowLayout2);
147
                        bandsLabelPanel.setPreferredSize(new java.awt.Dimension(LABELS_WIDTH,LABELS_HEIGHT));
148
                        bandsLabelPanel.add(bandsLabel, null);
149
                        flowLayout2.setVgap(1);
150
                        flowLayout2.setHgap(0);
151
                }
152
                return bandsLabelPanel;
153
        }
154

    
155
        /**
156
         * This method initializes pY        
157
         *         
158
         * @return javax.swing.JPanel        
159
         */
160
        private JPanel getHeaderSizeLabelPanel() {
161
                if (headerSizeLabelPanel == null) {
162
                        headerSizeLabel = new JLabel();
163
                        headerSizeLabel.setText(PluginServices.getText(this, "header_Size"));
164
                        FlowLayout flowLayout1 = new FlowLayout();
165
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
166
                        headerSizeLabelPanel = new JPanel();
167
                        headerSizeLabelPanel.setLayout(flowLayout1);
168
                        headerSizeLabelPanel.setPreferredSize(new java.awt.Dimension(LABELS_WIDTH,LABELS_HEIGHT));
169
                        headerSizeLabelPanel.add(headerSizeLabel, null);
170
                        flowLayout1.setHgap(0);
171
                        flowLayout1.setVgap(1);
172
                }
173
                return headerSizeLabelPanel;
174
        }
175

    
176
        /**
177
         * This method initializes pLatitud        
178
         *         
179
         * @return javax.swing.JPanel        
180
         */
181
        private JPanel getHeigthLabelPanel() {
182
                if (heigthLabelPanel == null) {
183
                        heigthLabel = new JLabel();
184
                        heigthLabel.setText(PluginServices.getText(this, "alto"));
185
                        FlowLayout flowLayout3 = new FlowLayout();
186
                        flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
187
                        heigthLabelPanel = new JPanel();
188
                        heigthLabelPanel.setLayout(flowLayout3);
189
                        heigthLabelPanel.setPreferredSize(new java.awt.Dimension(LABELS_WIDTH,LABELS_HEIGHT));
190
                        flowLayout3.setHgap(0);
191
                        flowLayout3.setVgap(1);
192
                        heigthLabelPanel.add(heigthLabel, null);
193
                }
194
                return heigthLabelPanel;
195
        }
196
        
197
        /**
198
         * This method initializes jPanel3        
199
         *         
200
         * @return javax.swing.JPanel        
201
         */
202
        private JPanel getWidthLabelPanel() {
203
                if (widthLabelPanel == null) {
204
                        widthLabel = new JLabel();
205
                        widthLabel.setText(PluginServices.getText(this, "ancho"));
206
                        FlowLayout flowLayout4 = new FlowLayout();
207
                        flowLayout4.setHgap(0);
208
                        flowLayout4.setAlignment(java.awt.FlowLayout.LEFT);
209
                        flowLayout4.setVgap(1);
210
                        widthLabelPanel = new JPanel();
211
                        widthLabelPanel.setPreferredSize(new java.awt.Dimension(LABELS_WIDTH,LABELS_HEIGHT));
212
                        widthLabelPanel.setLayout(flowLayout4);
213
                        widthLabelPanel.add(widthLabel, null);
214
                }
215
                return widthLabelPanel;
216
        }
217
        
218
        
219

    
220
        
221
        /**
222
         * This method initializes jPanel        
223
         *         
224
         * @return javax.swing.JPanel        
225
         */
226
        private JPanel getLabelsPanel() {
227
                if (labelsPanel == null) {
228
                        labelsPanel = new JPanel();
229
                        labelsPanel.setPreferredSize(new java.awt.Dimension(LABELS_PANEL_WIDTH,HEIGHT));
230
                        labelsPanel.add(getWidthLabelPanel(), null);
231
                        labelsPanel.add(getHeigthLabelPanel(), null);
232
                        labelsPanel.add(getBandsLabelPanel(), null);
233
                        labelsPanel.add(getHeaderSizeLabelPanel(), null);
234
                }
235
                return labelsPanel;
236
        }
237

    
238
        /**
239
         * This method initializes jPanel        
240
         *         
241
         * @return javax.swing.JPanel        
242
         */
243
        private JPanel getFieldsPanel() {
244
                if (fieldsPanel == null) {
245
                        fieldsPanel = new JPanel();
246
                        fieldsPanel.setPreferredSize(new java.awt.Dimension(TEXTS_PANEL_WIDTH,HEIGHT));
247
                        fieldsPanel.add(getWidthTextPanel(), null);
248
                        fieldsPanel.add(getHeigthTextPanel(), null);
249
                        fieldsPanel.add(getBandsTextPanel(), null);
250
                        fieldsPanel.add(getHeaderSizeTextPanel(), null);
251
                }
252
                return fieldsPanel;
253
        }
254

    
255
        /**
256
         * This method initializes jPanel        
257
         *         
258
         * @return javax.swing.JPanel        
259
         */
260
        private JPanel getWidthTextPanel() {
261
                if (widthTextPanel == null) {
262
                        FlowLayout flowLayout = new FlowLayout();
263
                        flowLayout.setHgap(0);
264
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
265
                        flowLayout.setVgap(1);
266
                        widthTextPanel = new JPanel();
267
                        widthTextPanel.setPreferredSize(new java.awt.Dimension(TEXTS_WIDTH,TEXTS_HEIGHT));
268
                        widthTextPanel.setLayout(flowLayout);
269
                        widthTextPanel.add(getWidthText(), null);
270
                }
271
                return widthTextPanel;
272
        }
273
        
274
        /**
275
         * This method initializes jPanel1        
276
         *         
277
         * @return javax.swing.JPanel        
278
         */
279
        private JPanel getHeigthTextPanel() {
280
                if (heigthTextPanel == null) {
281
                        FlowLayout flowLayout5 = new FlowLayout();
282
                        flowLayout5.setHgap(0);
283
                        flowLayout5.setAlignment(java.awt.FlowLayout.LEFT);
284
                        flowLayout5.setVgap(1);
285
                        heigthTextPanel = new JPanel();
286
                        heigthTextPanel.setPreferredSize(new java.awt.Dimension(TEXTS_WIDTH,TEXTS_HEIGHT));
287
                        heigthTextPanel.setLayout(flowLayout5);
288
                        heigthTextPanel.add(getHeigthText(), null);
289
                }
290
                return heigthTextPanel;
291
        }        
292

    
293
        /**
294
         * This method initializes jPanel2        
295
         *         
296
         * @return javax.swing.JPanel        
297
         */
298
        private JPanel getHeaderSizeTextPanel() {
299
                if (headerSizeTextPanel == null) {
300
                        FlowLayout flowLayout8 = new FlowLayout();
301
                        flowLayout8.setHgap(0);
302
                        flowLayout8.setAlignment(FlowLayout.LEFT);
303
                        flowLayout8.setVgap(1);
304
                        headerSizeTextPanel = new JPanel();
305
                        headerSizeTextPanel.setPreferredSize(new java.awt.Dimension(TEXTS_WIDTH,TEXTS_HEIGHT));
306
                        headerSizeTextPanel.setLayout(flowLayout8);
307
                        headerSizeTextPanel.add(getHeaderSizeText(), null);
308
                }
309
                return headerSizeTextPanel;
310
        }
311
        
312
        /**
313
         * This method initializes oficialTextPanel        
314
         *         
315
         * @return javax.swing.JPanel        
316
         */
317
        private JPanel getBandsTextPanel() {
318
                if (bandsTextPanel == null) {
319
                        FlowLayout flowLayout9 = new FlowLayout();
320
                        flowLayout9.setHgap(0);
321
                        flowLayout9.setAlignment(FlowLayout.LEFT);
322
                        flowLayout9.setVgap(1);
323
                        bandsTextPanel = new JPanel();
324
                        bandsTextPanel.setPreferredSize(new java.awt.Dimension(TEXTS_WIDTH,TEXTS_HEIGHT));
325
                        bandsTextPanel.setLayout(flowLayout9);                        
326
                        bandsTextPanel.add(getBandsText(), null);
327
                }
328
                return bandsTextPanel;
329
        }
330

    
331

    
332
        
333
        /**
334
         * This method initializes pronunciacionText        
335
         *         
336
         * @return javax.swing.JTextField        
337
         */
338
        private JFormattedTextField getWidthText() {
339
                if (widthText == null) {
340
                        widthText = new JFormattedTextField(NumberFormat.getIntegerInstance());
341
                        widthText.setPreferredSize(new Dimension(TEXTS_WIDTH,TEXTS_HEIGHT));
342
                        widthText.setText("0");
343
                }
344
                return widthText;
345
        }
346

    
347
        /**
348
         * This method initializes etimologyText        
349
         *         
350
         * @return javax.swing.JTextField        
351
         */
352
        private JFormattedTextField getHeigthText() {
353
                if (heigthText == null) {
354
                        heigthText = new JFormattedTextField(NumberFormat.getIntegerInstance());
355
                        heigthText.setPreferredSize(new Dimension(TEXTS_WIDTH,TEXTS_HEIGHT));
356
                        heigthText.setText("0");
357
                }
358
                return heigthText;
359
        }
360

    
361
        /**
362
         * This method initializes bandsText        
363
         *         
364
         * @return javax.swing.JTextField        
365
         */
366
        private JFormattedTextField getBandsText() {
367
                if (bandsText == null) {
368
                        bandsText = new JFormattedTextField(NumberFormat.getIntegerInstance());
369
                        bandsText.setPreferredSize(new Dimension(TEXTS_WIDTH,TEXTS_HEIGHT));
370
                        bandsText.setText("0");
371
                }
372
                return bandsText;
373
        }
374

    
375
        /**
376
         * This method initializes headerSizeText        
377
         *         
378
         * @return javax.swing.JTextField        
379
         */
380
        private JFormattedTextField getHeaderSizeText() {
381
                if (headerSizeText == null) {
382
                        headerSizeText = new JFormattedTextField(NumberFormat.getIntegerInstance());
383
                        headerSizeText.setPreferredSize(new Dimension(TEXTS_WIDTH,TEXTS_HEIGHT));
384
                        headerSizeText.setText("0");
385
                }
386
                return headerSizeText;
387
        }
388
        
389
        /**
390
         * gets the image width
391
         * @return
392
         */
393
        public int getImageWidth(){
394
                try{
395
                        String buffer = StringUtilities.replace(getWidthText().getText(),".","");
396
                        buffer = StringUtilities.replace(buffer,",","");
397
                        return Integer.parseInt(buffer);
398
                }catch(NumberFormatException e){
399
                        return 0;
400
                }
401
        }
402
        
403
        /**
404
         * gets the image height
405
         * @return
406
         */
407
        public int getImageHeight(){
408
                try{
409
                        String buffer = StringUtilities.replace(getHeigthText().getText(),".","");
410
                        buffer = StringUtilities.replace(buffer,",","");
411
                        return Integer.parseInt(buffer);
412
                }catch(NumberFormatException e){
413
                        return 0;
414
                }
415
        }
416
        
417
        /**
418
         * gets the number of bands
419
         * @return
420
         */
421
        public int getNumberOfBands(){
422
                try{
423
                        return Integer.valueOf(getBandsText().getText()).intValue();
424
                }catch(NumberFormatException e){
425
                        return 0;
426
                }
427
        }
428
        
429
        /**
430
         * gets the header size
431
         * @return
432
         */
433
        public int getHeaderSize(){
434
                try{
435
                        return Integer.valueOf(getHeaderSizeText().getText()).intValue();
436
                }catch(NumberFormatException e){
437
                        return 0;
438
                }
439
        }
440
}