Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools / src / com / iver / cit / gvsig / rasterTools / saveRaster / pruebas2 / InputScaleDataPanel.java @ 4269

History | View | Annotate | Download (5.06 KB)

1
package com.iver.cit.gvsig.rasterTools.saveRaster.pruebas2;
2

    
3
import java.awt.Color;
4
import java.awt.FlowLayout;
5
import java.awt.GridBagConstraints;
6
import java.awt.GridBagLayout;
7

    
8
import javax.swing.JComboBox;
9
import javax.swing.JLabel;
10
import javax.swing.JPanel;
11
import javax.swing.JTextField;
12

    
13
public class InputScaleDataPanel extends JPanel {
14

    
15
        private JPanel pScale = null;
16
        private JPanel pResolution = null;
17
        private JPanel pMtsPixel = null;
18
        private JLabel lScale = null;
19
        private JLabel lResolution = null;
20
        private JLabel lMtsPixel = null;
21
        private JTextField tScale = null;
22
        private JTextField tMtsPixel = null;
23
        private JComboBox cResolution = null;
24
        /**
25
         * This is the default constructor
26
         */
27
        public InputScaleDataPanel() {
28
                super();
29
                initialize();
30
                setActiveScale(0);
31
        }
32

    
33
        /**
34
         * This method initializes this
35
         * 
36
         * @return void
37
         */
38
        private void initialize() {
39
                GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
40
                gridBagConstraints2.gridx = 0;
41
                gridBagConstraints2.gridy = 2;
42
                GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
43
                gridBagConstraints1.gridx = 0;
44
                gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
45
                gridBagConstraints1.gridy = 1;
46
                GridBagConstraints gridBagConstraints = new GridBagConstraints();
47
                gridBagConstraints.gridx = 0;
48
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
49
                gridBagConstraints.gridy = 0;
50
                this.setLayout(new GridBagLayout());
51
                this.setSize(180, 92);
52
                this.setPreferredSize(new java.awt.Dimension(180,92));
53
                this.add(getPScale(), gridBagConstraints);
54
                this.add(getPResolution(), gridBagConstraints1);
55
                this.add(getPMtsPixel(), gridBagConstraints2);
56
        }
57

    
58
        /**
59
         * This method initializes jPanel        
60
         *         
61
         * @return javax.swing.JPanel        
62
         */
63
        private JPanel getPScale() {
64
                if (pScale == null) {
65
                        FlowLayout flowLayout2 = new FlowLayout();
66
                        flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
67
                        lScale = new JLabel();
68
                        lScale.setText("Escala:");
69
                        pScale = new JPanel();
70
                        pScale.setLayout(flowLayout2);
71
                        pScale.setPreferredSize(new java.awt.Dimension(180,29));
72
                        pScale.add(lScale, null);
73
                        pScale.add(getTScale(), null);
74
                }
75
                return pScale;
76
        }
77

    
78
        /**
79
         * This method initializes jPanel1        
80
         *         
81
         * @return javax.swing.JPanel        
82
         */
83
        private JPanel getPResolution() {
84
                if (pResolution == null) {
85
                        FlowLayout flowLayout1 = new FlowLayout();
86
                        flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
87
                        lResolution = new JLabel();
88
                        lResolution.setText("Resoluci?n:");
89
                        pResolution = new JPanel();
90
                        pResolution.setLayout(flowLayout1);
91
                        pResolution.setPreferredSize(new java.awt.Dimension(180,34));
92
                        pResolution.add(lResolution, null);
93
                        pResolution.add(getCbResolution(), null);
94
                }
95
                return pResolution;
96
        }
97

    
98
        /**
99
         * This method initializes jPanel2        
100
         *         
101
         * @return javax.swing.JPanel        
102
         */
103
        private JPanel getPMtsPixel() {
104
                if (pMtsPixel == null) {
105
                        FlowLayout flowLayout = new FlowLayout();
106
                        flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
107
                        lMtsPixel = new JLabel();
108
                        lMtsPixel.setText("Mts/Pixel:");
109
                        pMtsPixel = new JPanel();
110
                        pMtsPixel.setLayout(flowLayout);
111
                        pMtsPixel.setPreferredSize(new java.awt.Dimension(180,29));
112
                        pMtsPixel.add(lMtsPixel, null);
113
                        pMtsPixel.add(getTMtsPixel(), null);
114
                }
115
                return pMtsPixel;
116
        }
117

    
118
        /**
119
         * This method initializes jTextField        
120
         *         
121
         * @return javax.swing.JTextField        
122
         */
123
        private JTextField getTScale() {
124
                if (tScale == null) {
125
                        tScale = new JTextField();
126
                        tScale.setPreferredSize(new java.awt.Dimension(80,19));
127
                }
128
                return tScale;
129
        }
130

    
131
        /**
132
         * This method initializes jTextField2        
133
         *         
134
         * @return javax.swing.JTextField        
135
         */
136
        private JTextField getTMtsPixel() {
137
                if (tMtsPixel == null) {
138
                        tMtsPixel = new JTextField();
139
                        tMtsPixel.setPreferredSize(new java.awt.Dimension(80,19));
140
                }
141
                return tMtsPixel;
142
        }
143

    
144
        /**
145
         * This method initializes jComboBox        
146
         *         
147
         * @return javax.swing.JComboBox        
148
         */
149
        private JComboBox getCbResolution() {
150
                if (cResolution == null) {
151
                        cResolution = new JComboBox();
152
                        cResolution.setPreferredSize(new java.awt.Dimension(80,24));
153
                        cResolution.addItem(75+"");
154
                        cResolution.addItem(150+"");
155
                        cResolution.addItem(300+"");
156
                }
157
                return cResolution;
158
        }
159

    
160
        /**
161
         * Pone como activo el input scale o mts por pixel dependiendo del
162
         * valor del par?metro. 
163
         * @param active Si vale 0 activa la Escala y desactiva mts/pixel.
164
         *         Si vale 1 activa mts/pixel y desactiva la Escala.
165
         *         Si vale 2 desactiva ambos.
166
         */
167
        public void setActiveScale(int active){
168
                Color backgroudColor = getBackground();
169
                this.getCbResolution().setEnabled(true);
170
                
171
                if(active == 0){
172
                        getTScale().setEnabled(true);
173
                        getTMtsPixel().setEnabled(false);
174
                        getTScale().setBackground(Color.white);
175
                        getTMtsPixel().setBackground(backgroudColor);
176
                }else if(active == 1){
177
                        getTScale().setEnabled(false);
178
                        getTMtsPixel().setEnabled(true);
179
                        getTScale().setBackground(backgroudColor);
180
                        getTMtsPixel().setBackground(Color.white);
181
                }else if(active == 2){
182
                        getTScale().setEnabled(false);
183
                        getTMtsPixel().setEnabled(false);
184
                        getTScale().setBackground(backgroudColor);
185
                        getTMtsPixel().setBackground(backgroudColor);
186
                }
187
        }
188
}