root / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / gui / panels / DataPointsTabPanel.java @ 7304
History | View | Annotate | Download (8.48 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 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.georeferencing.gui.panels; |
20 |
|
21 |
import java.awt.Component; |
22 |
import java.awt.geom.Point2D; |
23 |
|
24 |
import javax.swing.JOptionPane; |
25 |
import javax.swing.JPanel; |
26 |
import javax.swing.JTabbedPane; |
27 |
import javax.swing.event.ChangeEvent; |
28 |
import javax.swing.event.ChangeListener; |
29 |
|
30 |
import org.gvsig.georeferencing.gui.dialog.GeoreferencingDialog; |
31 |
import org.gvsig.georeferencing.gui.options.GeorefTableOptionsPanel; |
32 |
import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel; |
33 |
import org.gvsig.georeferencing.gui.selectPoints.DataPointPanel; |
34 |
import org.gvsig.georeferencing.gui.selectPoints.SelectPointsPanel; |
35 |
|
36 |
import com.iver.andami.PluginServices; |
37 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
38 |
|
39 |
public class DataPointsTabPanel extends JPanel implements ChangeListener{ |
40 |
|
41 |
private GeoreferencingDialog parent = null; |
42 |
private SelectPointsPanel selectPointsPanel = null; |
43 |
private TablePointsPanel tablePointsPanel = null; |
44 |
private GeorefOptionsPanel georefOptionsPanel = null; |
45 |
private GeorefTableOptionsPanel georefTableOptionsPanel = null; |
46 |
private JTabbedPane tbPoints = null; |
47 |
private int widthTab = 390, heightTab = 205; |
48 |
|
49 |
/**
|
50 |
* This is the default constructor
|
51 |
*/
|
52 |
public DataPointsTabPanel(GeoreferencingDialog p) {
|
53 |
super();
|
54 |
this.parent = p;
|
55 |
initialize(); |
56 |
} |
57 |
|
58 |
/**
|
59 |
* This method initializes this
|
60 |
*
|
61 |
* @return void
|
62 |
*/
|
63 |
private void initialize() { |
64 |
this.setPreferredSize(new java.awt.Dimension(395,210)); |
65 |
this.setSize(new java.awt.Dimension(395,210)); |
66 |
this.setLocation(new java.awt.Point(0,0)); |
67 |
this.add(getTbPoints(), null); |
68 |
} |
69 |
|
70 |
/**
|
71 |
* @return Returns the selectPointsPanel.
|
72 |
*/
|
73 |
public TablePointsPanel getTablePointsPanel() {
|
74 |
if(tablePointsPanel == null){ |
75 |
tablePointsPanel = new TablePointsPanel(parent);
|
76 |
} |
77 |
return tablePointsPanel;
|
78 |
} |
79 |
|
80 |
/**
|
81 |
* @return Returns the selectPointsPanel.
|
82 |
*/
|
83 |
public SelectPointsPanel getSelectPointsPanel() {
|
84 |
if(selectPointsPanel == null){ |
85 |
selectPointsPanel = new SelectPointsPanel(parent);
|
86 |
} |
87 |
return selectPointsPanel;
|
88 |
} |
89 |
|
90 |
/**
|
91 |
* @return Returns the georefOptionsPanel.
|
92 |
*/
|
93 |
public GeorefOptionsPanel getGeorefOptionsPanel() {
|
94 |
if(georefOptionsPanel == null){ |
95 |
georefOptionsPanel = new GeorefOptionsPanel(parent);
|
96 |
} |
97 |
return georefOptionsPanel;
|
98 |
} |
99 |
|
100 |
/**
|
101 |
* @return Returns the georefTableOptionsPanel.
|
102 |
*/
|
103 |
public GeorefTableOptionsPanel getGeorefTableOptionsPanel() {
|
104 |
if(georefTableOptionsPanel == null){ |
105 |
georefTableOptionsPanel = new GeorefTableOptionsPanel(parent);
|
106 |
} |
107 |
return georefTableOptionsPanel;
|
108 |
} |
109 |
|
110 |
/**
|
111 |
* This method initializes jTabbedPane
|
112 |
*
|
113 |
* @return javax.swing.JTabbedPane
|
114 |
*/
|
115 |
public JTabbedPane getTbPoints() { |
116 |
if (tbPoints == null) { |
117 |
tbPoints = new JTabbedPane(); |
118 |
tbPoints.setSize(widthTab, heightTab); |
119 |
tbPoints.setPreferredSize(new java.awt.Dimension(390,205)); |
120 |
tbPoints.addTab(PluginServices.getText(this, "punto"), this.getSelectPointsPanel()); |
121 |
tbPoints.addTab(PluginServices.getText(this,"table"), this.getTablePointsPanel()); |
122 |
tbPoints.addTab(PluginServices.getText(this,"options"), this.getGeorefOptionsPanel()); |
123 |
//tbPoints.addTab(PluginServices.getText(this,"options"), this.getGeorefTableOptionsPanel());
|
124 |
tbPoints.addChangeListener(this);
|
125 |
} |
126 |
return tbPoints;
|
127 |
} |
128 |
|
129 |
/**
|
130 |
* Cuando cambiamos de tab controlamos lo siguiente:
|
131 |
* <UL>
|
132 |
* <LI>Comprobamos que los TextField del selector de puntos no esten en
|
133 |
* blanco</LI>
|
134 |
* <LI>Controlamos que la ventana sea redimensionable solo cuando
|
135 |
* est? en el tab de tabla</LI>
|
136 |
* <LI>Actualizamos los controles de la ventana a la que vamos con lo
|
137 |
* que se seleccion? en la ventana de la que venimos</LI>
|
138 |
* </UL>
|
139 |
*/
|
140 |
public void stateChanged(ChangeEvent ev) { |
141 |
|
142 |
if (((JTabbedPane)ev.getSource()).getSelectedIndex() == 0 || ((JTabbedPane)ev.getSource()).getSelectedIndex() == 2){ |
143 |
parent.getFrame().setResizable(false);
|
144 |
if(getTablePointsPanel().getTableControlerPanel().getSelectedIndex() != -1) |
145 |
getSelectPointsPanel().updateComboPoint( |
146 |
getTablePointsPanel().getTableControlerPanel().getSelectedIndex() |
147 |
); |
148 |
//Ponemos los paneles en su tama?o original
|
149 |
parent.resetSize(); |
150 |
} |
151 |
|
152 |
if (((JTabbedPane)ev.getSource()).getSelectedIndex() == 1){ |
153 |
//Si la ventana ha sido redimensionada ponemos la dimensi?n temporal
|
154 |
|
155 |
if(parent.getTmpWidth() > parent.getNormalWidth()){
|
156 |
|
157 |
if(parent.isEnlarge()){
|
158 |
parent.getFrame().setSize(parent.getTmpWidth(), parent.getEnlargeHeight() + 10);
|
159 |
parent.newFrameSize(parent.getTmpWidth(), parent.getEnlargeHeight()); |
160 |
}else{
|
161 |
parent.getFrame().setSize(parent.getTmpWidth(), parent.getNormalHeight() + 10);
|
162 |
parent.newFrameSize(parent.getTmpWidth(), parent.getNormalHeight()); |
163 |
} |
164 |
} |
165 |
|
166 |
try{
|
167 |
getSelectPointsPanel().checkInfoPointText(); |
168 |
}catch(NoSuchFieldException exc){ |
169 |
//Si no se han salvado los valores de un punto cuando se activa
|
170 |
//el cambio de tab las coordenadas a las que no se les ha dado
|
171 |
//valor se pondr?n a 0 y se guardar?n.
|
172 |
double tx = 0D, ty = 0D, lon = 0D, lat = 0D; |
173 |
try{
|
174 |
DataPointPanel dp = getSelectPointsPanel().getDataPointPanel(); |
175 |
if(dp.getTX() != null && !dp.getTX().equals("")) |
176 |
tx = Double.valueOf(getSelectPointsPanel().getDataPointPanel().getTX().getText()).doubleValue();
|
177 |
if(dp.getTY() != null && !dp.getTY().equals("")) |
178 |
ty = Double.valueOf(getSelectPointsPanel().getDataPointPanel().getTY().getText()).doubleValue();
|
179 |
if(dp.getLongitud() != null && !dp.getLongitud().equals("")) |
180 |
lon = Double.valueOf(getSelectPointsPanel().getDataPointPanel().getLongitud().getText()).doubleValue();
|
181 |
if(dp.getLatitud() != null && !dp.getLatitud().equals("")) |
182 |
lat = Double.valueOf(getSelectPointsPanel().getDataPointPanel().getLatitud().getText()).doubleValue();
|
183 |
}catch(NumberFormatException ex){ |
184 |
|
185 |
} |
186 |
Point2D pixel = new Point2D.Double(); |
187 |
pixel.setLocation(tx, ty); |
188 |
Point2D map = new Point2D.Double(); |
189 |
map.setLocation(lon, lat); |
190 |
|
191 |
View theView = null; |
192 |
try{
|
193 |
theView = (View)PluginServices.getMDIManager().getActiveWindow();
|
194 |
}catch(ClassCastException exce){ |
195 |
return;
|
196 |
} |
197 |
|
198 |
if(parent.getLyrGeoRaster() != null){ |
199 |
try{
|
200 |
parent.getPointManager().updateData(getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedIndex() + 1,
|
201 |
pixel, |
202 |
map, |
203 |
parent, |
204 |
theView); |
205 |
}catch(ArrayIndexOutOfBoundsException ex){ |
206 |
//Si da una excepci?n de este tipo es que no hay cargado nin?n punto
|
207 |
//por lo que no hacemos nada.
|
208 |
}catch(ClassCastException ex){ |
209 |
//Si da una excepci?n de este tipo lo m?s probable es que no haya una
|
210 |
//vista activa y no se pueda crear una capa de puntos. Tampoco se hace nada.
|
211 |
} |
212 |
}else{
|
213 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
214 |
PluginServices.getText(this, "error_capa_puntos")); |
215 |
} |
216 |
|
217 |
} |
218 |
|
219 |
if(getSelectPointsPanel().getTableControlerPanel().getSelectedIndex() != -1) |
220 |
getTablePointsPanel().updateComboPoint( |
221 |
getSelectPointsPanel().getTableControlerPanel().getSelectedIndex() |
222 |
); |
223 |
|
224 |
parent.getFrame().setResizable(true);
|
225 |
} |
226 |
|
227 |
} |
228 |
|
229 |
/**
|
230 |
* Calculo del nuevo tama?o a partir de un frame redimensionado
|
231 |
* @param w Ancho del frame
|
232 |
* @param h Alto del frame
|
233 |
*/
|
234 |
public void newFrameSize(int w, int h){ |
235 |
int newWidth = w;
|
236 |
|
237 |
this.setSize(new java.awt.Dimension(newWidth, heightTab)); |
238 |
this.setPreferredSize(new java.awt.Dimension(newWidth, heightTab)); |
239 |
this.getTbPoints().setSize(new java.awt.Dimension(newWidth, heightTab)); |
240 |
this.getTbPoints().setPreferredSize(new java.awt.Dimension(newWidth, heightTab)); |
241 |
this.getTablePointsPanel().newFrameSize(newWidth, h);
|
242 |
} |
243 |
|
244 |
} |