Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / saveraster / ui / main / InputSizeDataPanel.java @ 11267

History | View | Annotate | Download (4.85 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19
package org.gvsig.rastertools.saveraster.ui.main;
20

    
21
import javax.swing.JPanel;
22
import javax.swing.JLabel;
23
import javax.swing.JTextField;
24
import javax.swing.JComboBox;
25

    
26
import java.awt.Color;
27
import java.awt.FlowLayout;
28

    
29
/**
30
 * 
31
 * @version 18/04/2007
32
 * @author Nacho Brodin (nachobrodin@gmail.com)
33
 *
34
 */
35
public class InputSizeDataPanel extends JPanel {
36

    
37
        private JPanel pBorder = null;
38
        private JLabel lWidth = null;
39
        private JTextField tWidth = null;
40
        private JLabel lHeight = null;
41
        private JTextField tHeight = null;
42
        private JComboBox cbMeasureType = null;
43
        private JPanel jPanel = null;
44

    
45
        /**
46
         * This is the default constructor
47
         */
48
        public InputSizeDataPanel() {
49
                super();
50
                initialize();
51
                this.setActive(false);
52
        }
53

    
54
        /**
55
         * This method initializes this
56
         * 
57
         * @return void
58
         */
59
        private void initialize() {
60
                FlowLayout flowLayout = new FlowLayout();
61
                flowLayout.setHgap(0);
62
                flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
63
                flowLayout.setVgap(0);
64
                this.setLayout(flowLayout);
65
                this.setSize(337, 28);
66
                this.setPreferredSize(new java.awt.Dimension(337,28));
67
                this.add(getPBorder(), null);
68
        }
69

    
70
        /**
71
         * This method initializes jPanel        
72
         *         
73
         * @return javax.swing.JPanel        
74
         */
75
        private JPanel getPBorder() {
76
                if (pBorder == null) {
77
                        FlowLayout flowLayout1 = new FlowLayout();
78
                        flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
79
                        flowLayout1.setHgap(0);
80
                        flowLayout1.setVgap(4);
81
                        lHeight = new JLabel();
82
                        lHeight.setText("Alto:");
83
                        lWidth = new JLabel();
84
                        lWidth.setText("Ancho:");
85
                        pBorder = new JPanel();
86
                        pBorder.setLayout(flowLayout1);
87
                        pBorder.setPreferredSize(new java.awt.Dimension(337,28));
88
                        pBorder.add(lWidth, null);
89
                        pBorder.add(getTWidth(), null);
90
                        pBorder.add(lHeight, null);
91
                        pBorder.add(getTHeight(), null);
92
                        pBorder.add(getJPanel(), null);
93
                }
94
                return pBorder;
95
        }
96

    
97
        /**
98
         * This method initializes jTextField        
99
         *         
100
         * @return javax.swing.JTextField        
101
         */
102
        public JTextField getTWidth() {
103
                if (tWidth == null) {
104
                        tWidth = new JTextField();
105
                        tWidth.setPreferredSize(new java.awt.Dimension(85,19));
106
                }
107
                return tWidth;
108
        }
109

    
110
        /**
111
         * This method initializes jTextField1        
112
         *         
113
         * @return javax.swing.JTextField        
114
         */
115
        public JTextField getTHeight() {
116
                if (tHeight == null) {
117
                        tHeight = new JTextField();
118
                        tHeight.setPreferredSize(new java.awt.Dimension(85,19));
119
                }
120
                return tHeight;
121
        }
122

    
123
        /**
124
         * This method initializes jComboBox        
125
         *         
126
         * @return javax.swing.JComboBox        
127
         */
128
        public JComboBox getCbMeasureType() {
129
                if (cbMeasureType == null) {
130
                        cbMeasureType = new JComboBox();
131
                        cbMeasureType.setPreferredSize(new java.awt.Dimension(65,24));
132
                        cbMeasureType.addItem("Pixels");
133
                        cbMeasureType.addItem("Cms");
134
                        cbMeasureType.addItem("Mms");
135
                        cbMeasureType.addItem("Mts");
136
                        cbMeasureType.addItem("Inches");
137
                }
138
                return cbMeasureType;
139
        }
140

    
141
        /**
142
         * Activa o desactiva las cajas de texto con los datos
143
         * ancho y alto.
144
         * @param active true activa los JTextBox y false los desactiva
145
         */
146
        public void setActive(boolean active){
147
                Color backgroudColor = getBackground();
148
                
149
                this.getTWidth().setEnabled(active);
150
                this.getTHeight().setEnabled(active);
151
                this.getCbMeasureType().setEnabled(active);
152
                
153
                if(active){
154
                        getTWidth().setBackground(Color.white);
155
                        getTHeight().setBackground(Color.white);
156
                }else{
157
                        getTWidth().setBackground(backgroudColor);
158
                        getTHeight().setBackground(backgroudColor);
159
                }
160
        }
161

    
162
        /**
163
         * This method initializes jPanel        
164
         *         
165
         * @return javax.swing.JPanel        
166
         */
167
        private JPanel getJPanel() {
168
                if (jPanel == null) {
169
                        FlowLayout flowLayout2 = new FlowLayout();
170
                        flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
171
                        flowLayout2.setVgap(0);
172
                        flowLayout2.setHgap(14);
173
                        jPanel = new JPanel();
174
                        jPanel.setLayout(flowLayout2);
175
                        jPanel.setPreferredSize(new java.awt.Dimension(82,28));
176
                        jPanel.add(getCbMeasureType(), null);
177
                }
178
                return jPanel;
179
        }
180
        
181
        /**
182
         * Obtiene la etiqueta con el valor ancho
183
         * @return
184
         */
185
        public JLabel getLWidth(){
186
                return this.lWidth;
187
        }
188
        
189
        /**
190
         * Obtiene la etiqueta con el valor alto
191
         * @return
192
         */
193
        public JLabel getLHeight(){
194
                return this.lHeight;
195
        }
196
}