Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / gui / panels / GeorefOptionsPanel.java @ 5550

History | View | Annotate | Download (8.16 KB)

1 5217 nacho
package org.gvsig.georeferencing.gui.panels;
2
3
import java.awt.BorderLayout;
4
import java.awt.FlowLayout;
5
import java.awt.GridBagConstraints;
6
import java.awt.GridBagLayout;
7
import java.awt.event.ActionListener;
8
9
import javax.swing.JCheckBox;
10
import javax.swing.JComboBox;
11
import javax.swing.JLabel;
12
import javax.swing.JPanel;
13
14
import org.gvsig.georeferencing.gui.dialogs.GeoreferencingDialog;
15
16
import com.iver.andami.PluginServices;
17 5241 nacho
import com.iver.cit.gvsig.fmap.layers.FLyrPoints;
18 5217 nacho
import com.iver.cit.gvsig.gui.View;
19
/**
20
 * Panel que contiene opciones de georreferenciaci?n a elegir por
21
 * el usuario. Esta clase no maneja eventos.
22
 *
23
 * @author Nacho Brodin (brodin_ign@gva.es)
24
 *
25
 */
26
public class GeorefOptionsPanel extends JPanel implements ActionListener{
27
28
        private JPanel pGeneral = null;
29
        private JPanel pGrado = null;
30
        private GeoreferencingDialog grd = null;
31
32
        private JLabel lGrado = null;
33
        private JComboBox cbGrado = null;
34
        private JPanel pAlgoritmo = null;
35
        private JLabel lAlgoritmo = null;
36
        private JComboBox cbAlgoritmo = null;
37
        private JPanel jPanel = null;
38
        private JPanel jPanel1 = null;
39
        private JPanel jPanel11 = null;
40
        private JPanel jPanel12 = null;
41 5447 nacho
        private JPanel jPanel13 = null;
42 5217 nacho
43
        /**
44
         * This is the default constructor
45
         */
46
        public GeorefOptionsPanel(GeoreferencingDialog grd) {
47
                super();
48
                this.grd = grd;
49
                initialize();
50
        }
51
52
        /**
53
         * This method initializes this
54
         *
55
         * @return void
56
         */
57
        private void initialize() {
58
        this.setLayout(new BorderLayout());
59
        this.setPreferredSize(new java.awt.Dimension(380,160));
60
        this.setBounds(0, 0, 380, 160);
61
        this.add(getPGeneral(), java.awt.BorderLayout.CENTER);
62
        }
63
64
        /**
65
         * This method initializes jPanel
66
         *
67
         * @return javax.swing.JPanel
68
         */
69
        private JPanel getPGeneral() {
70
                if (pGeneral == null) {
71
                        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
72
                        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
73
                        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
74
                        pGeneral = new JPanel();
75
                        pGeneral.setLayout(new GridBagLayout());
76
                        pGeneral.setPreferredSize(new java.awt.Dimension(380,20));
77
                        gridBagConstraints5.gridx = 0;
78
                        gridBagConstraints5.gridy = 0;
79
                        gridBagConstraints5.anchor = java.awt.GridBagConstraints.CENTER;
80
                        gridBagConstraints5.gridheight = 1;
81
                        gridBagConstraints5.gridwidth = 1;
82
                        gridBagConstraints1.gridx = 0;
83
                        gridBagConstraints1.gridy = 1;
84
                        gridBagConstraints7.gridx = 0;
85
                        gridBagConstraints7.gridy = 2;
86
                        pGeneral.add(getPGrado(), gridBagConstraints5);
87
                        pGeneral.add(getPAlgoritmo(), gridBagConstraints1);
88
                        pGeneral.add(getJPanel(), gridBagConstraints7);
89
                }
90
                return pGeneral;
91
        }
92
        /**
93
         * This method initializes jPanel1
94
         *
95
         * @return javax.swing.JPanel
96
         */
97
        private JPanel getPGrado() {
98
                if (pGrado == null) {
99
                        lGrado = new JLabel();
100
                        FlowLayout flowLayout6 = new FlowLayout();
101
                        pGrado = new JPanel();
102
                        pGrado.setLayout(flowLayout6);
103
                        pGrado.setPreferredSize(new java.awt.Dimension(370,30));
104
                        pGrado.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0));
105
                        flowLayout6.setAlignment(java.awt.FlowLayout.LEFT);
106
                        flowLayout6.setHgap(10);
107
                        flowLayout6.setVgap(3);
108
                        lGrado.setText(PluginServices.getText(this,"grado_polinomio"));
109
                        pGrado.add(lGrado, null);
110
                        pGrado.add(getCbGrado(), null);
111
                        lGrado.setVisible(false);
112
                        getCbGrado().setVisible(false);
113
                }
114
                return pGrado;
115
        }
116
117
        /**
118
         * This method initializes jComboBox
119
         *
120
         * @return javax.swing.JComboBox
121
         */
122
        private JComboBox getCbGrado() {
123
                if (cbGrado == null) {
124
                        cbGrado = new JComboBox();
125
                }
126
                return cbGrado;
127
        }
128
        /**
129
         * This method initializes jPanel
130
         *
131
         * @return javax.swing.JPanel
132
         */
133
        private JPanel getPAlgoritmo() {
134
                if (pAlgoritmo == null) {
135
                        lAlgoritmo = new JLabel();
136
                        FlowLayout flowLayout2 = new FlowLayout();
137
                        pAlgoritmo = new JPanel();
138
                        pAlgoritmo.setLayout(flowLayout2);
139
                        lAlgoritmo.setText(PluginServices.getText(this,"algoritmo"));
140
                        pAlgoritmo.setPreferredSize(new java.awt.Dimension(370,30));
141
                        flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
142
                        flowLayout2.setHgap(10);
143
                        flowLayout2.setVgap(3);
144
                        pAlgoritmo.add(lAlgoritmo, null);
145
                        pAlgoritmo.add(getCbAlgoritmo(), null);
146
                        pAlgoritmo.setVisible(false);
147
                        getCbAlgoritmo().setVisible(false);
148
                }
149
                return pAlgoritmo;
150
        }
151
        /**
152
         * This method initializes jComboBox
153
         *
154
         * @return javax.swing.JComboBox
155
         */
156
        private JComboBox getCbAlgoritmo() {
157
                if (cbAlgoritmo == null) {
158
                        cbAlgoritmo = new JComboBox();
159
                }
160
                return cbAlgoritmo;
161
        }
162
        /**
163
         * This method initializes jPanel
164
         *
165
         * @return javax.swing.JPanel
166
         */
167
        private JPanel getJPanel() {
168
                if (jPanel == null) {
169
                        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
170
                        gridBagConstraints2.gridx = 0;
171
                        gridBagConstraints2.gridy = 1;
172
                        GridBagConstraints gridBagConstraints = new GridBagConstraints();
173
                        gridBagConstraints.gridx = 0;
174
                        gridBagConstraints.gridy = 0;
175 5447 nacho
                        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
176
                        gridBagConstraints.gridx = 0;
177
                        gridBagConstraints.gridy = 2;
178 5217 nacho
                        jPanel = new JPanel();
179
                        jPanel.setLayout(new GridBagLayout());
180
                        jPanel.setPreferredSize(new java.awt.Dimension(370,75));
181
                        jPanel.add(getJPanel11(), gridBagConstraints);
182
                        jPanel.add(getJPanel12(), gridBagConstraints2);
183 5447 nacho
                        jPanel.add(getJPanel13(), gridBagConstraints3);
184 5217 nacho
                }
185
                return jPanel;
186
        }
187
188
        /**
189
         * Acci?n cuando se pulsa el bot?n de aceptar en el dialogo.
190
         * <UL>
191
         * <LI>Cambiamos el nombre a la capa georraster</LI>
192
         * <LI>A la capa Georraster le asignamos la capa de puntos para poder recuperarla</LI>
193
         * <LI>Cerramos la ventana</LI>
194
         * </UL>
195
         */
196
        public void actionPerformed(java.awt.event.ActionEvent e) {
197
                if(e.getSource() instanceof JCheckBox){
198
                        if(((JCheckBox)e.getSource()).getName().equals("mostrar_puntos")){
199
                                FLyrPoints lyrPoints = grd.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getLyrPoints();
200
                                View theView = null;
201
                                try{
202
                                        theView = (View) PluginServices.getMDIManager().getActiveView();
203
                                }catch(ClassCastException exc){
204
                                        return;
205
                                }
206
207
                                if(((JCheckBox)e.getSource()).isSelected()){ //Mostramos el n?mero de punto
208
                                        grd.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getLyrPoints().setShowNumber(true);
209
                                        grd.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().draw();
210
                                        grd.getConectorPanel().getAdjustGeorefPanel().getZoomRight().draw();
211
                                        theView.getMapControl().getMapContext().invalidate();
212
                                }else{ //Ocultamos el n?mero de punto
213
                                        grd.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getLyrPoints().setShowNumber(false);
214
                                        grd.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().draw();
215
                                        grd.getConectorPanel().getAdjustGeorefPanel().getZoomRight().draw();
216
                                        theView.getMapControl().getMapContext().invalidate();
217
                                }
218
                        }
219
220
                        if(((JCheckBox)e.getSource()).getName().equals("crear_worldfile")){
221
                                if(((JCheckBox)e.getSource()).isSelected())
222
                                        grd.setCreateWorldFile(true);
223
                                else
224
                                        grd.setCreateWorldFile(false);
225
                        }
226 5447 nacho
227
                        if(((JCheckBox)e.getSource()).getName().equals("errores_csv")){
228
                                if(((JCheckBox)e.getSource()).isSelected())
229
                                        grd.setErrorCSV(true);
230
                                else
231
                                        grd.setErrorCSV(false);
232
                        }
233 5217 nacho
                }
234
        }
235
236
        /**
237
         * This method initializes jPanel11
238
         *
239
         * @return javax.swing.JPanel
240
         */
241
        private JPanel getJPanel11() {
242
                if (jPanel11 == null) {
243
                        jPanel11 =  new OptionsPanel(this.grd, "mostrar_puntos");
244
                        ((OptionsPanel)jPanel11).getCbCheckBox().addActionListener(this);
245
                }
246
                return jPanel11;
247
        }
248
249
        /**
250
         * This method initializes jPanel12
251
         *
252
         * @return javax.swing.JPanel
253
         */
254
        private JPanel getJPanel12() {
255
                if (jPanel12 == null) {
256
                        jPanel12 =  new OptionsPanel(this.grd, "crear_worldfile");
257
                        ((OptionsPanel)jPanel12).getCbCheckBox().setSelected(false);
258
                        ((OptionsPanel)jPanel12).getCbCheckBox().addActionListener(this);
259
                }
260
                return jPanel12;
261
        }
262
263 5447 nacho
        /**
264
         * This method initializes jPanel13
265
         *
266
         * @return javax.swing.JPanel
267
         */
268
        private JPanel getJPanel13() {
269
                if (jPanel13 == null) {
270
                        jPanel13 =  new OptionsPanel(this.grd, "errores_csv");
271
                        ((OptionsPanel)jPanel13).getCbCheckBox().setSelected(true);
272
                        ((OptionsPanel)jPanel13).getCbCheckBox().addActionListener(this);
273
                }
274
                return jPanel13;
275
        }
276
277 5217 nacho
 }