Statistics
| Revision:

root / branches / v10 / extensions / extRasterTools / src / org / gvsig / rasterTools / scaleManager / ScaleManagerPanel.java @ 12339

History | View | Annotate | Download (7.51 KB)

1
package org.gvsig.rasterTools.scaleManager;
2

    
3
import java.awt.Dimension;
4
import java.awt.FlowLayout;
5
import java.awt.GridLayout;
6

    
7
import javax.swing.ButtonGroup;
8
import javax.swing.JLabel;
9
import javax.swing.JPanel;
10
import javax.swing.JRadioButton;
11
import javax.swing.JTextField;
12

    
13
import org.cresques.filter.IStackManager;
14
import org.cresques.filter.RasterFilterStackManager;
15
import org.cresques.ui.raster.IResize;
16

    
17
import com.iver.andami.PluginServices;
18
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
19
import com.iver.cit.gvsig.gui.panels.IRasterPropertiesRegistrable;
20
import com.iver.cit.gvsig.gui.panels.PropertiesRasterDialog;
21
import com.iver.cit.gvsig.project.documents.view.toc.gui.FLyrRasterAdjustPropertiesTocMenuEntry;
22

    
23
public class ScaleManagerPanel extends JPanel implements IResize,
24
                IRasterPropertiesRegistrable {
25

    
26
        /**
27
         *
28
         */
29
        private static final long serialVersionUID = 177311346136230777L;
30

    
31
        private String panelName = null;
32

    
33
        private int sizeX = 445;
34

    
35
        private int sizeY = 174;
36

    
37
        private int wComp = 445, hComp = 239;
38

    
39
        private JPanel jPanel1 = null;
40

    
41
        private JPanel jPanel4 = null;
42

    
43
        private JPanel jPanel5 = null;
44

    
45
        private ButtonGroup buttonGroup = null;
46

    
47
        private JLabel jLabel4 = null;
48

    
49
        private JLabel jLabel3 = null;
50

    
51
        private JLabel jLabel2 = null;
52

    
53
        private JLabel jLabel1 = null;
54

    
55
        private JRadioButton jRadioButton = null;
56

    
57
        private JRadioButton jRadioButton1 = null;
58

    
59
        private JTextField jTextField1 = null;
60

    
61
        private JTextField jTextField2 = null;
62

    
63
        public ScaleManagerPanel(FLyrRasterAdjustPropertiesTocMenuEntry menu) {
64
                super();
65
                initialize();
66
                this.setTranslation();
67
                menu.register(this);
68
        }
69

    
70
        /* (non-Javadoc)
71
         * @see org.cresques.ui.raster.IResize#setComponentSize(int, int)
72
         */
73
        public void setComponentSize(int w, int h) {
74
                wComp = w;
75
                hComp = h;
76
                this.setSize(wComp, hComp);
77
        }
78

    
79
        /* (non-Javadoc)
80
         * @see com.iver.cit.gvsig.gui.panels.IRasterPropertiesRegistrable#actionPerformed(org.cresques.filter.RasterFilterStackManager, com.iver.cit.gvsig.gui.panels.PropertiesRasterDialog, com.iver.cit.gvsig.fmap.layers.FLyrRaster)
81
         */
82
        public void actionPerformed(RasterFilterStackManager stackManager,
83
                        PropertiesRasterDialog propsDialog, FLyrRaster fLayer) {
84
                if (fLayer == null){
85
                        return;
86
                }
87
                double minScale = -1;
88
                double maxScale = -1;
89
                String minText = this.getJTextField1().getText();
90
                String maxText = this.getJTextField2().getText();
91

    
92
                if (!minText.equals("")) {
93
                        try{
94
                                minScale = Double.parseDouble(minText);
95
                        } catch (NumberFormatException e) {
96
                                // TODO: handle exception
97
                                minScale = fLayer.getMinScale();
98
                        }
99
                }
100
                if (!maxText.equals("")) {
101
                        try{
102
                                maxScale = Double.parseDouble(maxText);
103
                        } catch (NumberFormatException e) {
104
                                // TODO: handle exception
105
                                maxScale = fLayer.getMaxScale();
106
                        }
107
                }
108

    
109
                fLayer.setMaxScale(maxScale);
110
                fLayer.setMinScale(minScale);
111

    
112
        }
113

    
114
        public void addTabPanel(FLyrRasterAdjustPropertiesTocMenuEntry menu) {
115
                menu.getPropertiesDialog().addTab(this.getName(), this);
116
        }
117

    
118
        public IStackManager getStackManager() {
119
                return null;
120
        }
121

    
122
        public void setStackManager(RasterFilterStackManager stackManager) {
123
        }
124

    
125
        public String getName() {
126
                if (this.panelName == null) {
127
                        this.panelName = PluginServices.getText(this, "escala");
128
                }
129
                return panelName;
130
        }
131

    
132
        void initialize() {
133
                this.setPreferredSize(new Dimension(sizeX, sizeY));
134
                this.setLayout(new GridLayout(1, 1));
135
                this.setLocation(0, 0);
136
                this.setSize(wComp, hComp);
137
                this.add(getJPanel1(), null);
138

    
139
        }
140

    
141
        /**
142
         * Traducciones del panel
143
         */
144
        public void setTranslation() {
145
                // this.getCbActiveSharpening().setText(PluginServices.getText(this,"onSharpening"));
146
                // this.getPSharpNorth().setBorder(javax.swing.BorderFactory.createTitledBorder(null,
147
                // PluginServices.getText(this,"selectBandaRefinado"),
148
                // javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
149
                // javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
150
        }
151

    
152
        private JPanel getJPanel1() {
153
                if (jPanel1 == null) {
154
                        jPanel1 = new JPanel();
155
                        jPanel1.setLayout(null);
156
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
157
                                        null, PluginServices.getText(this, "rango_de_escalas"),
158
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
159
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
160
                                        null));
161
                        jPanel1.setBounds(5, 61, 432, 137);
162
                        jPanel1.add(getJPanel4(), null);
163
                        jPanel1.add(getJPanel5(), null);
164
                }
165
                return jPanel1;
166
        }
167

    
168
        private JPanel getJPanel4() {
169
                if (jPanel4 == null) {
170
                        jPanel4 = new JPanel();
171
                        jPanel4.setLayout(null);
172
                        jPanel4.setBounds(6, 21, 398, 46);
173
                        jPanel4.add(getJRadioButton(), null);
174
                        jPanel4.add(getJRadioButton1(), null);
175
                        buttonGroup = new ButtonGroup();
176
                        buttonGroup.add(getJRadioButton());
177
                        buttonGroup.add(getJRadioButton1());
178
                }
179
                return jPanel4;
180
        }
181

    
182
        private JPanel getJPanel5() {
183
                if (jPanel5 == null) {
184
                        jLabel4 = new JLabel();
185
                        jLabel3 = new JLabel();
186
                        jLabel2 = new JLabel();
187
                        jLabel1 = new JLabel();
188
                        jPanel5 = new JPanel();
189
                        jPanel5.setLayout(null);
190
                        jLabel1
191
                                        .setText(PluginServices
192
                                                        .getText(this, "este_por_debajo_de_"));
193
                        jLabel1.setBounds(6, 6, 138, 20);
194
                        jLabel1.setEnabled(false);
195
                        jLabel2.setText("(" + PluginServices.getText(this, "escala_minima")
196
                                        + ")");
197
                        jLabel2.setBounds(302, 6, 111, 20);
198
                        jLabel2.setEnabled(false);
199
                        jPanel5.setBounds(15, 69, 414, 53);
200
                        jLabel3.setBounds(6, 31, 138, 20);
201
                        jLabel3.setText(PluginServices.getText(this, "este_por_encima_de"));
202
                        jLabel3.setEnabled(false);
203
                        jLabel4.setBounds(302, 31, 111, 20);
204
                        jLabel4.setText("(" + PluginServices.getText(this, "escala_maxima")
205
                                        + ")");
206
                        jLabel4.setEnabled(false);
207
                        jPanel5.add(jLabel1, null);
208
                        jPanel5.add(getJTextField1(), null);
209
                        jPanel5.add(jLabel2, null);
210
                        jPanel5.add(jLabel3, null);
211
                        jPanel5.add(getJTextField2(), null);
212
                        jPanel5.add(jLabel4, null);
213
                }
214
                return jPanel5;
215
        }
216

    
217
        public JRadioButton getJRadioButton() {
218
                if (jRadioButton == null) {
219
                        jRadioButton = new JRadioButton();
220
                        jRadioButton.setText(PluginServices
221
                                        .getText(this, "Mostrar_siempre"));
222
                        jRadioButton.setBounds(0, 0, 301, 23);
223
                        jRadioButton.setSelected(true);
224
                        jRadioButton.addActionListener(new java.awt.event.ActionListener() {
225
                                public void actionPerformed(java.awt.event.ActionEvent e) {
226
                                        // jPanel5.setEnabled(false);
227
                                        jLabel1.setEnabled(false);
228
                                        jTextField1.setEnabled(false);
229
                                        jLabel2.setEnabled(false);
230
                                        jLabel3.setEnabled(false);
231
                                        jTextField2.setEnabled(false);
232
                                        jLabel4.setEnabled(false);
233
                                }
234
                        });
235
                }
236
                return jRadioButton;
237
        }
238

    
239
        public JRadioButton getJRadioButton1() {
240
                if (jRadioButton1 == null) {
241
                        jRadioButton1 = new JRadioButton();
242
                        jRadioButton1.setText(PluginServices.getText(this,
243
                                        "No_mostrar_la_capa_cuando_la_escala"));
244
                        jRadioButton1.setBounds(0, 23, 301, 23);
245
                        jRadioButton1
246
                                        .addActionListener(new java.awt.event.ActionListener() {
247
                                                public void actionPerformed(java.awt.event.ActionEvent e) {
248
                                                        // jPanel5.setEnabled(true);
249
                                                        jLabel1.setEnabled(true);
250
                                                        jTextField1.setEnabled(true);
251
                                                        jLabel2.setEnabled(true);
252
                                                        jLabel3.setEnabled(true);
253
                                                        jTextField2.setEnabled(true);
254
                                                        jLabel4.setEnabled(true);
255
                                                }
256
                                        });
257
                }
258
                return jRadioButton1;
259
        }
260

    
261
        public JTextField getJTextField1() {
262
                if (jTextField1 == null) {
263
                        jTextField1 = new JTextField();
264
                        jTextField1.setBounds(147, 6, 152, 20);
265
                        jTextField1.setEnabled(false);
266
                }
267
                return jTextField1;
268
        }
269

    
270
        public JTextField getJTextField2() {
271
                if (jTextField2 == null) {
272
                        jTextField2 = new JTextField();
273
                        jTextField2.setBounds(147, 31, 152, 20);
274
                        jTextField2.setEnabled(false);
275
                }
276
                return jTextField2;
277
        }
278

    
279
}