root / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / gui / dialogs / GeoreferencingDialog.java @ 5587
History | View | Annotate | Download (38.6 KB)
1 |
package org.gvsig.georeferencing.gui.dialogs; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Component; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.FlowLayout; |
7 |
import java.awt.event.ActionListener; |
8 |
import java.awt.event.ComponentEvent; |
9 |
import java.awt.event.ComponentListener; |
10 |
import java.awt.geom.Point2D; |
11 |
import java.awt.geom.Rectangle2D; |
12 |
import java.beans.PropertyVetoException; |
13 |
import java.io.File; |
14 |
|
15 |
import javax.swing.JButton; |
16 |
import javax.swing.JCheckBox; |
17 |
import javax.swing.JFileChooser; |
18 |
import javax.swing.JInternalFrame; |
19 |
import javax.swing.JOptionPane; |
20 |
import javax.swing.JPanel; |
21 |
import javax.swing.filechooser.FileFilter; |
22 |
import javax.swing.table.DefaultTableModel; |
23 |
|
24 |
import org.cresques.cts.IProjection; |
25 |
import org.cresques.px.Extent; |
26 |
import org.gvsig.georeferencing.GeoOperations; |
27 |
import org.gvsig.georeferencing.gui.listeners.GeoRasterFrameListener; |
28 |
import org.gvsig.georeferencing.gui.listeners.GeorefMovePointListener; |
29 |
import org.gvsig.georeferencing.gui.listeners.GeorefPanListener; |
30 |
import org.gvsig.georeferencing.gui.listeners.GeorefPointSelectorListener; |
31 |
import org.gvsig.georeferencing.gui.listeners.ZoomGeorefListener; |
32 |
import org.gvsig.georeferencing.gui.panels.ConectorPanel; |
33 |
import org.gvsig.georeferencing.gui.panels.OptionsPanel; |
34 |
import org.gvsig.georeferencing.gui.panels.ZoomControlPanel; |
35 |
import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel; |
36 |
import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel.PointTable; |
37 |
import org.gvsig.georeferencing.gui.selectPoints.SelectPointsPanel; |
38 |
import org.gvsig.georeferencing.toc.GeoRasterTocMenuEntry; |
39 |
import org.gvsig.georeferencing.utils.GeoLayerFactory; |
40 |
import org.gvsig.georeferencing.utils.GeoPointPersistence; |
41 |
import org.gvsig.georeferencing.utils.MathUtils; |
42 |
import org.gvsig.georeferencing.utils.PointManager; |
43 |
import org.gvsig.georeferencing.utils.StackZoom; |
44 |
|
45 |
import com.iver.andami.PluginServices; |
46 |
import com.iver.cit.gvsig.fmap.DriverException; |
47 |
import com.iver.cit.gvsig.fmap.MapControl; |
48 |
import com.iver.cit.gvsig.fmap.ViewPort; |
49 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
50 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
51 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
52 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
53 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
54 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
55 |
import com.iver.cit.gvsig.fmap.layers.GeoPoint; |
56 |
import com.iver.cit.gvsig.fmap.layers.IGeoUi; |
57 |
import com.iver.cit.gvsig.fmap.layers.RasterAdapter; |
58 |
import com.iver.cit.gvsig.fmap.layers.RasterFileAdapter; |
59 |
import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener; |
60 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
61 |
import com.iver.cit.gvsig.fmap.tools.Behavior.DraggedBehavior; |
62 |
import com.iver.cit.gvsig.fmap.tools.Behavior.GeoMoveBehavior; |
63 |
import com.iver.cit.gvsig.fmap.tools.Behavior.GeoRedimBehavior; |
64 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
65 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
66 |
import com.iver.cit.gvsig.gui.View; |
67 |
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener; |
68 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
69 |
import com.iver.cit.gvsig.project.Project; |
70 |
|
71 |
/**
|
72 |
* Panel que contiene el Wizard de georeferenciaci?n con los tabs
|
73 |
* interiores
|
74 |
*
|
75 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
76 |
*/
|
77 |
public class GeoreferencingDialog extends JPanel implements IGeoUi, ActionListener, ComponentListener { |
78 |
|
79 |
//**********************Vars**********************************
|
80 |
static private IProjection proj = Project.getProjection(); |
81 |
private JPanel pBotones = null; // @jve:decl-index=0: |
82 |
private JButton bProcesar = null; // @jve:decl-index=0: |
83 |
private JButton bCancelar = null; // @jve:decl-index=0: |
84 |
private WizardListener wizardListener = new DialogWizardListener(); |
85 |
private JButton bLoadPoints = null; // @jve:decl-index=0: |
86 |
private GeoRedimBehavior rb = null; |
87 |
private GeoMoveBehavior mb = null; |
88 |
private boolean loadTools = false; |
89 |
private JInternalFrame frame = null; |
90 |
/**
|
91 |
* Lista de formatos soportados
|
92 |
*/
|
93 |
private String[] fileFilters = {"csv"}; |
94 |
/**
|
95 |
* Recuerda la ?ltima ruta seleccionada por el usuario
|
96 |
*/
|
97 |
private String lastPathLoad = "./"; |
98 |
private String lastPathSave = "./"; |
99 |
private ConectorPanel conectorPanel = null; |
100 |
|
101 |
private boolean enlarge = false; |
102 |
private int normalWidth = 400; |
103 |
private int normalHeight = 273; |
104 |
private int enlargeHeight = 438; |
105 |
private int tmpWidth = normalWidth; |
106 |
|
107 |
private JButton bAceptar = null; |
108 |
|
109 |
private JButton bSavePoints = null; |
110 |
private FLyrGeoRaster lyrGeoRaster = null; |
111 |
private TablePointsPanel tablePointsPanel = null; |
112 |
private PointManager pointManager = null; |
113 |
/**
|
114 |
* True si ha de crearse un fichero de georreferenciaci?n
|
115 |
*/
|
116 |
private boolean createWorldFile = false; |
117 |
/**
|
118 |
* True si los errores han de incluirse en el fichero csv
|
119 |
*/
|
120 |
private boolean errorCSV = true; |
121 |
/**
|
122 |
* Estado de los botones cuando se ejecuta disableAllControls
|
123 |
*/
|
124 |
private boolean[] buttonsState = new boolean[3]; |
125 |
/**
|
126 |
* DisableAllControls ha sido ejecutada si est? a true esta variabled
|
127 |
*/
|
128 |
private boolean disableAllControls = false; |
129 |
//**********************End Vars******************************
|
130 |
|
131 |
//**********************Classes*******************************
|
132 |
/**
|
133 |
* Filtro para selecci?n de ficheros.
|
134 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
135 |
*/
|
136 |
class SelectFileFilter extends javax.swing.filechooser.FileFilter { |
137 |
|
138 |
private JFileChooser chooser = null; |
139 |
private String file = null; |
140 |
|
141 |
public SelectFileFilter(JFileChooser ch, String file){ |
142 |
this.chooser = ch;
|
143 |
this.file = file;
|
144 |
} |
145 |
|
146 |
public boolean accept(File f) { |
147 |
|
148 |
return f.isDirectory() || f.getName().toLowerCase().endsWith("."+file); |
149 |
} |
150 |
|
151 |
public String getDescription() { |
152 |
return file;
|
153 |
} |
154 |
|
155 |
} |
156 |
|
157 |
/**
|
158 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
159 |
*/
|
160 |
public class DialogWizardListener implements WizardListener { |
161 |
|
162 |
/**
|
163 |
* @see org.gvsig.georeferencing.gui.wms.WizardListener#error(java.lang.Exception)
|
164 |
*/
|
165 |
public void error(Exception e) { |
166 |
} |
167 |
|
168 |
/**
|
169 |
* @see org.gvsig.georeferencing.gui.wms.WizardListener#wizardStateChanged(boolean)
|
170 |
*/
|
171 |
public void wizardStateChanged(boolean finishable) { |
172 |
getBProcess().setEnabled(finishable); |
173 |
} |
174 |
|
175 |
} |
176 |
//**********************End Classes***************************
|
177 |
|
178 |
//**********************Methods*******************************
|
179 |
/**
|
180 |
* Constructor.
|
181 |
*/
|
182 |
public GeoreferencingDialog(JInternalFrame f, FLyrGeoRaster lyr) { |
183 |
frame = f; |
184 |
lyrGeoRaster = lyr; |
185 |
|
186 |
frame.addComponentListener(this);
|
187 |
initialize(); |
188 |
|
189 |
//Creamos el pointManager y lo asignamos a la capa de puntos
|
190 |
pointManager = new PointManager(this, lyrGeoRaster.getFLyrPoints()); |
191 |
this.lyrGeoRaster.getFLyrPoints().setPointManager(pointManager);
|
192 |
|
193 |
//En estos casos entra cuando la capa se crea al abrir un proyecto
|
194 |
if(lyrGeoRaster.getPersistence() == null){ |
195 |
lyrGeoRaster.setPersistence(new GeoPointPersistence(lyrGeoRaster.getFLyrPoints()));
|
196 |
f.addInternalFrameListener(new GeoRasterFrameListener());
|
197 |
GeoRasterTocMenuEntry.isOpen = true;
|
198 |
} |
199 |
if(lyrGeoRaster.getStackZoom() == null) |
200 |
lyrGeoRaster.setZoom(new StackZoom());
|
201 |
|
202 |
} |
203 |
|
204 |
/**
|
205 |
* En la inicializaci?n de la ventana a?adimos los tags de est? y cargamos
|
206 |
* ls herramientas para manejar las imagenes a georeferenciar.
|
207 |
*/
|
208 |
private void initialize() { |
209 |
//Cargamos las herramientas la primera vez que abrimos la ventana
|
210 |
if(!loadTools){
|
211 |
com.iver.cit.gvsig.gui.View vista = null;
|
212 |
try{
|
213 |
vista = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView(); |
214 |
}catch(ClassCastException exc){ |
215 |
return;
|
216 |
} |
217 |
|
218 |
MapControl mapCtrl = null;
|
219 |
if(vista != null) |
220 |
mapCtrl = vista.getMapControl(); |
221 |
|
222 |
if(mapCtrl != null){ |
223 |
loadTools = true;
|
224 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
225 |
|
226 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(mapCtrl);
|
227 |
ZoomGeorefListener zigl = new ZoomGeorefListener(mapCtrl);
|
228 |
rb = new GeoRedimBehavior(zigl);
|
229 |
mapCtrl.addMapTool("geoZoom", new Behavior[]{rb, |
230 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
231 |
|
232 |
GeorefPanListener pl = new GeorefPanListener(mapCtrl);
|
233 |
mb = new GeoMoveBehavior(pl);
|
234 |
mapCtrl.addMapTool("geoPan", new Behavior[]{mb, new MouseMovementBehavior(sbl)}); |
235 |
|
236 |
//Seleccion de un punto sobre la vista
|
237 |
GeorefPointSelectorListener psl = new GeorefPointSelectorListener(this); |
238 |
mapCtrl.addMapTool("pointLyrSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)}); |
239 |
|
240 |
GeorefMovePointListener mpl = new GeorefMovePointListener(this); |
241 |
mapCtrl.addMapTool("geoMovePoint", new Behavior[]{new DraggedBehavior(mpl), new MouseMovementBehavior(sbl)}); |
242 |
} |
243 |
} |
244 |
|
245 |
this.setLayout(new BorderLayout()); |
246 |
if(!enlarge){
|
247 |
this.setPreferredSize(new java.awt.Dimension(normalWidth, normalHeight)); |
248 |
this.setSize(new java.awt.Dimension(400,273)); |
249 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setVisible(false); |
250 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomRight().setVisible(false); |
251 |
}else{
|
252 |
this.setPreferredSize(new java.awt.Dimension(normalWidth, enlargeHeight)); |
253 |
this.setSize(new java.awt.Dimension(normalWidth, enlargeHeight)); |
254 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setVisible(true); |
255 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomRight().setVisible(true); |
256 |
} |
257 |
this.setLocation(new java.awt.Point(0,0)); |
258 |
|
259 |
this.add(this.getPBotones(), BorderLayout.SOUTH); |
260 |
this.add(this.getConectorPanel(), BorderLayout.NORTH); |
261 |
|
262 |
//A?adimos los listener de los botones de la tabla
|
263 |
//Los botones de borrado los gestiona SelectPointsPanel
|
264 |
//Los botones de cargar y exportar los gestiona GeoreferencigDialog
|
265 |
tablePointsPanel = getConectorPanel().getDataPointsTabPanel().getTablePointsPanel(); |
266 |
tablePointsPanel.getTableControlerPanel().getBClear().addActionListener(this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel());
|
267 |
tablePointsPanel.getTableControlerPanel().getBDelPoint().addActionListener(this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel());
|
268 |
tablePointsPanel.getPButtonsExportImportPanel().getBLoad().addActionListener(this);
|
269 |
tablePointsPanel.getPButtonsExportImportPanel().getBSave().addActionListener(this);
|
270 |
tablePointsPanel.getPButtonsExportImportPanel().getBExportToAscii().addActionListener(this);
|
271 |
conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive().addActionListener(this);
|
272 |
} |
273 |
|
274 |
/**
|
275 |
* Comprueba si existe el fichero pasado por par?metro existe solicitando confirmaci?n
|
276 |
* de sobreescritura. Si el usuario acepta devolver? true y si no acepta devuelve false.
|
277 |
* Si se acepta la sobreescritura el fichero es borrado.
|
278 |
* @param file Cadena con el nombre del fichero a comprobar su existencia.
|
279 |
* @return Devuelve true si el fichero existe y va a ser sobreescrito
|
280 |
*/
|
281 |
public boolean checkFileExists(String file, boolean delete){ |
282 |
File f = new File(file); |
283 |
if(f.exists()){
|
284 |
if (messageBoxYesOrNot("file_exists")){ |
285 |
if(delete)
|
286 |
f.delete(); |
287 |
return true; |
288 |
}else
|
289 |
return false; |
290 |
} |
291 |
return true; |
292 |
} |
293 |
|
294 |
/**
|
295 |
* MessageBox con dos botones (OK y Cancel) que mostrar? el mensaje pasado por
|
296 |
* par?metro
|
297 |
* @param msg Mensaje a mostrar
|
298 |
* @return true si el usuario pulsa Ok y false si pulsa Cancel
|
299 |
*/
|
300 |
public boolean messageBoxYesOrNot(String msg){ |
301 |
String string1 = PluginServices.getText(this, "yes"); |
302 |
String string2 = PluginServices.getText(this, "no"); |
303 |
Object[] options = {string1, string2}; |
304 |
int n = JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(), |
305 |
PluginServices.getText(this, msg),
|
306 |
PluginServices.getText(this, "confirmacion"), |
307 |
JOptionPane.YES_NO_OPTION,
|
308 |
JOptionPane.QUESTION_MESSAGE,
|
309 |
null,
|
310 |
options, |
311 |
string1); |
312 |
if (n == JOptionPane.YES_OPTION) |
313 |
return true; |
314 |
else
|
315 |
return false; |
316 |
} |
317 |
|
318 |
/**
|
319 |
* Acci?n cuando se pulsa el bot?n de aceptar en el dialogo.
|
320 |
* <UL>
|
321 |
* <LI>Cambiamos el nombre a la capa georraster</LI>
|
322 |
* <LI>A la capa Georraster le asignamos la capa de puntos para poder recuperarla</LI>
|
323 |
* <LI>Cerramos la ventana</LI>
|
324 |
* </UL>
|
325 |
*/
|
326 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
327 |
com.iver.cit.gvsig.gui.View theView = null;
|
328 |
try{
|
329 |
theView = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView(); |
330 |
}catch(ClassCastException exc){ |
331 |
return;
|
332 |
} |
333 |
|
334 |
try{
|
335 |
//ACEPTAR
|
336 |
if(e.getSource() == bAceptar)
|
337 |
accept(theView); |
338 |
|
339 |
//CANCELAR
|
340 |
if(e.getSource() == bCancelar)
|
341 |
cancel(theView); |
342 |
|
343 |
//CARGAR PUNTOS
|
344 |
if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBLoad())
|
345 |
loadPoints(theView); |
346 |
|
347 |
//SALVAR PUNTOS
|
348 |
if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBSave())
|
349 |
savePoints(); |
350 |
|
351 |
|
352 |
//EXPORTAR A ASCII
|
353 |
if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBExportToAscii())
|
354 |
exportToASCII(theView); |
355 |
|
356 |
//DESACTIVAR PANELES
|
357 |
JCheckBox cb = this.conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive(); |
358 |
if(e.getSource() == cb)
|
359 |
deactivatePanel(theView, cb); |
360 |
|
361 |
//PROCESAR
|
362 |
if(e.getSource() == this.getBProcess()) |
363 |
process(theView); |
364 |
}catch(Exception exc){ |
365 |
exc.printStackTrace(); |
366 |
return;
|
367 |
} |
368 |
} |
369 |
|
370 |
/**
|
371 |
* Cierra el dialogo
|
372 |
*/
|
373 |
public void close(){ |
374 |
try{
|
375 |
frame.setClosed(true);
|
376 |
}catch(PropertyVetoException exc){} |
377 |
} |
378 |
|
379 |
/**
|
380 |
* Funci?n que se ejecuta al pulsar el bot?n procesar. Este procesamiento calcula a partir de
|
381 |
* los puntos de control la georreferenciaci?n de la imagen y la asigna como extent temporal de
|
382 |
* la capa FLyrGeoRaster. Cuando termina actualiza la visualizaci?n.
|
383 |
* @param theView
|
384 |
*/
|
385 |
private void process(View theView)throws Exception{ |
386 |
if(getLyrPoints() == null) |
387 |
throw new Exception("LyrPoints not loaded."); |
388 |
|
389 |
if(this.getLyrPoints().getCountPoints() > 0){ |
390 |
|
391 |
//Calculamos las coordenadas de georreferenciaci?n
|
392 |
GeoOperations go = new GeoOperations(getLyrPoints());
|
393 |
double[] begin = go.transformPoint(0, 0, go.getAffine()); |
394 |
double[] end = go.transformPoint((int)lyrGeoRaster.getImageWidth(), (int)lyrGeoRaster.getImageHeight(), go.getAffine()); |
395 |
Extent ext = new Extent(begin[0], begin[1], end[0], end[1]); |
396 |
|
397 |
//Asignamos el extent temporal a la capa de georreferenciaci?n
|
398 |
ViewPort vp = theView.getMapControl().getMapContext().getViewPort(); |
399 |
((FLyrGeoRaster)theView.getMapControl().getMapContext().getLayers().getLayer(lyrGeoRaster.getName())).setAssignExtent(ext); |
400 |
|
401 |
//Si la capa tiene puntos de control hacemos un update de estos
|
402 |
//a su posici?n para que se actualicen los controles
|
403 |
for(int i=0; i<lyrGeoRaster.getFLyrPoints().getCountPoints(); i++){ |
404 |
Point2D center = lyrGeoRaster.img2World(lyrGeoRaster.getFLyrPoints().getPoint(i).pixelPoint);
|
405 |
lyrGeoRaster.getFLyrPoints().setMiniExtent( i, |
406 |
center, |
407 |
getLeftInitViewport(vp, center, lyrGeoRaster.getFLyrPoints().getPoint(i).leftViewPort, 1),
|
408 |
false);
|
409 |
if(i == getSelectedPoint())
|
410 |
updateData(i + 1, lyrGeoRaster.getFLyrPoints().getPoint(i).pixelPoint, null, theView); |
411 |
} |
412 |
theView.getMapControl().getMapContext().invalidate(); |
413 |
} |
414 |
} |
415 |
|
416 |
/**
|
417 |
* Funci?n que se ejecuta al pulsar el bot?n aceptar. Este procesamiento calcula a partir de
|
418 |
* los puntos de control la georreferenciaci?n de la imagen, crear el fichero .rmf de georreferenciaci?n
|
419 |
* y descarga la capa del TOC. A continuaci?n vuelve a cargar la capa como FLyrRaster dando
|
420 |
* por finalizada la georreferenciaci?n.
|
421 |
* @param theView
|
422 |
*/
|
423 |
private void accept(View theView)throws Exception{ |
424 |
if(getLyrPoints() == null) |
425 |
throw new Exception("LyrPoints not loaded."); |
426 |
|
427 |
if(this.getLyrPoints().getCountPoints() > 0){ |
428 |
|
429 |
//Creamos el fichero de georreferenciaci?n
|
430 |
GeoOperations go = new GeoOperations(getLyrPoints());
|
431 |
go.setCreateWorldFile(this.createWorldFile);
|
432 |
go.createGeorefFile( (int)getLyrGeoRaster().getImageWidth(),
|
433 |
(int)getLyrGeoRaster().getImageHeight(),
|
434 |
getLyrGeoRaster().getSource().getFiles()[0].getName());
|
435 |
|
436 |
FLayers lyrs = this.getLyrGeoRaster().getParentLayer();
|
437 |
for(int i = 0; i < lyrs.getLayersCount();i++){ |
438 |
if(this.getLyrGeoRaster().getName().equals(lyrs.getLayer(i).getName())){ |
439 |
|
440 |
//Eliminamos la capa
|
441 |
lyrs.removeLayer(i); |
442 |
File fich = new File(getLyrGeoRaster().getSource().getFiles()[0].getName()); |
443 |
try{
|
444 |
//Creamos la nueva capa GeoRaster y la a?adimos al TOC.
|
445 |
/*FLyrGeoRaster lyrGeoRaster =
|
446 |
GeoLayerFactory.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()),
|
447 |
(RasterDriver)getLyrGeoRaster().getSource().getDriver(),
|
448 |
fich,
|
449 |
getLyrGeoRaster().getProjection(),
|
450 |
getLyrGeoRaster().getImageWidth(),
|
451 |
getLyrGeoRaster().getImageHeight());
|
452 |
getLyrPoints().setVisible(false);
|
453 |
this.getLyrPoints().setLyrGeoRaster(lyrGeoRaster);
|
454 |
lyrGeoRaster.setFLyrPoints(this.getLyrPoints());
|
455 |
lyrGeoRaster.setGeoDialog(this);
|
456 |
this.lyrGeoRaster = lyrGeoRaster;
|
457 |
calcNewMiniExtent(theView);
|
458 |
lyrs.addLayer(lyrGeoRaster);
|
459 |
|
460 |
lyrGeoRaster.setActive(false);*/
|
461 |
|
462 |
FLyrRaster lyrRaster = GeoLayerFactory.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()),
|
463 |
(RasterDriver)getLyrGeoRaster().getSource().getDriver(), |
464 |
fich, |
465 |
getLyrGeoRaster().getProjection()); |
466 |
lyrs.addLayer(lyrRaster); |
467 |
|
468 |
theView.getMapControl().getMapContext().invalidate(); |
469 |
|
470 |
try{
|
471 |
frame.setClosed(true);
|
472 |
}catch(PropertyVetoException exc){} |
473 |
|
474 |
}catch(DriverException exc){
|
475 |
|
476 |
} |
477 |
break;
|
478 |
} |
479 |
} |
480 |
|
481 |
} |
482 |
} |
483 |
|
484 |
/**
|
485 |
* Funci?n que se ejecuta al pulsar el bot?n cancelar
|
486 |
* @param theView
|
487 |
*/
|
488 |
private void cancel(View theView)throws Exception{ |
489 |
if(getLyrPoints() == null) |
490 |
throw new Exception("LyrPoints not loaded."); |
491 |
|
492 |
//Cerramos la ventana
|
493 |
//(se ejecuta el evento internalFrameClosing de GeoRasterFrameListener)
|
494 |
try{
|
495 |
frame.setClosed(true);
|
496 |
theView.getMapControl().getMapContext().invalidate(); |
497 |
}catch(PropertyVetoException exc){} |
498 |
} |
499 |
|
500 |
/**
|
501 |
* Funci?n que se ejecuta al pulsar el bot?n de cargar puntos
|
502 |
* @param theView
|
503 |
*/
|
504 |
private void loadPoints(View theView)throws Exception{ |
505 |
if(getLyrPoints() == null) |
506 |
throw new Exception("LyrPoints not loaded."); |
507 |
|
508 |
if(messageBoxYesOrNot("cargar_puntos")){ |
509 |
String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf(".")); |
510 |
String path = ((RasterFileAdapter)lyrGeoRaster.getSource()).getFile().getAbsolutePath();
|
511 |
String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf"; |
512 |
|
513 |
//Antes de cargar puntos plegamos el cuadro
|
514 |
getSelectPointsPanel().setEnlarge(true);
|
515 |
|
516 |
getLyrPoints().saveState(); |
517 |
getLyrPoints().XML2PointList(nameRmf); |
518 |
|
519 |
//Esto es por si el panel ha sido estirado cuando cargamos los puntos
|
520 |
frame.pack(); |
521 |
frame.show(); |
522 |
|
523 |
//Por problemas con repaint e hilos concurrentes tenemos que poner esto explicitamente
|
524 |
//ya que es posible que se haga un paint de las miniimagenes antes de que cleanCanvas vuelva a valer false
|
525 |
this.getZoomControlLeft().getCanvas().setCleanCanvas(false); |
526 |
this.getZoomControlRight().getCanvas().setCleanCanvas(false); |
527 |
} |
528 |
} |
529 |
|
530 |
/**
|
531 |
* Funci?n que se ejecuta al pulsar el bot?n salvar puntos
|
532 |
* @param theView
|
533 |
*/
|
534 |
public void savePoints()throws Exception{ |
535 |
if(getLyrPoints() == null) |
536 |
throw new Exception("LyrPoints not loaded."); |
537 |
String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf(".")); |
538 |
String path = ((RasterFileAdapter)lyrGeoRaster.getSource()).getFile().getAbsolutePath();
|
539 |
String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf"; |
540 |
|
541 |
File f = new File(nameRmf); |
542 |
if(f.exists()){
|
543 |
if (messageBoxYesOrNot("gcps_exist")){ |
544 |
if(getLyrPoints() != null) |
545 |
getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf"); |
546 |
} |
547 |
}else
|
548 |
getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf"); |
549 |
} |
550 |
|
551 |
/**
|
552 |
* Funci?n que se ejecuta al pulsar el bot?n de export a ascii
|
553 |
* @param theView
|
554 |
*/
|
555 |
private void exportToASCII(View theView)throws Exception{ |
556 |
if(getLyrPoints() == null) |
557 |
throw new Exception("LyrPoints not loaded."); |
558 |
|
559 |
JFileChooser chooser = new JFileChooser(lastPathSave); |
560 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
561 |
|
562 |
FileFilter f = null; |
563 |
for(int i=0; i<this.fileFilters.length;i++){ |
564 |
f = new SelectFileFilter(chooser, this.fileFilters[i]); |
565 |
chooser.addChoosableFileFilter(f); |
566 |
} |
567 |
int returnVal = chooser.showOpenDialog(this); |
568 |
if(returnVal == JFileChooser.APPROVE_OPTION){ |
569 |
String fName = chooser.getSelectedFile().toString();
|
570 |
lastPathSave = chooser.getCurrentDirectory().getAbsolutePath(); |
571 |
if(checkFileExists(fName, true)){ |
572 |
if(getLyrPoints() != null) |
573 |
getLyrPoints().PointList2Ascii(fName); |
574 |
} |
575 |
} |
576 |
} |
577 |
|
578 |
/**
|
579 |
* Funci?n que se ejecuta al pulsar el bot?n desactivar panel
|
580 |
* @param theView
|
581 |
*/
|
582 |
private void deactivatePanel(View theView, JCheckBox cb)throws Exception{ |
583 |
if(getLyrPoints() == null) |
584 |
throw new Exception("LyrPoints not loaded."); |
585 |
|
586 |
if(cb.isSelected()){
|
587 |
this.setEnabled(true); |
588 |
getLyrPoints().setPointActive(getSelectedPoint(), true);
|
589 |
}else{
|
590 |
this.setEnabled(false); |
591 |
getLyrPoints().setPointActive(getSelectedPoint(), false);
|
592 |
} |
593 |
|
594 |
//Al activar y desactivar tenemos que recalcular errores
|
595 |
this.getPointManager().setErrors(getSelectedPoint());
|
596 |
|
597 |
theView.getMapControl().getMapContext().invalidate(); |
598 |
getZoomControlLeft().draw(); |
599 |
getZoomControlRight().draw(); |
600 |
} |
601 |
|
602 |
/**
|
603 |
* Recalcula el extent de la mini-imagen que corresponde a los puntos en coordenadas
|
604 |
* pixel.Para esto calcula el nuevo centro a partir de la capa y con la distancia entre
|
605 |
* el nuevo centro y el viejo desplaza el extent completo de la mini-imagen.
|
606 |
* @param theView
|
607 |
*/
|
608 |
private void calcNewMiniExtent(View theView){ |
609 |
|
610 |
ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort(); |
611 |
for(int j = 0; j < getLyrPoints().getCountPoints(); j++){ |
612 |
//Calculamos el nuevo centro
|
613 |
Point2D oldCenter = getLyrPoints().getPoint(j).leftCenterPoint;
|
614 |
Point2D newCenter = new Point2D.Double(); |
615 |
newCenter.setLocation( lyrGeoRaster.img2World(getLyrPoints().getPoint(j).pixelPoint)); |
616 |
|
617 |
double diffX = oldCenter.getX() - newCenter.getX();
|
618 |
double diffY = oldCenter.getY() - newCenter.getY();
|
619 |
|
620 |
getLyrPoints().getPoint(j).leftCenterPoint = newCenter; |
621 |
|
622 |
ViewPort vpOld = getLyrPoints().getPoint(j).leftViewPort; |
623 |
Rectangle2D newExtent = new Rectangle2D.Double( vpOld.getExtent().getMinX() - diffX, |
624 |
vpOld.getExtent().getMinY() - diffY, |
625 |
vpOld.getExtent().getWidth(), |
626 |
vpOld.getExtent().getHeight() ); |
627 |
ViewPort vpNew = new ViewPort(vpOld.getProjection());
|
628 |
vpNew.setExtent(newExtent); |
629 |
vpNew.setImageSize(vpOld.getImageSize()); |
630 |
vpNew.setScale(); |
631 |
getLyrPoints().getPoint(j).leftViewPort = vpNew; |
632 |
} |
633 |
} |
634 |
|
635 |
/**
|
636 |
* This method initializes jButton
|
637 |
*
|
638 |
* @return javax.swing.JButton
|
639 |
*/
|
640 |
public JButton getBAccept() { |
641 |
if (bAceptar == null) { |
642 |
bAceptar = new JButton(); |
643 |
bAceptar.setText(PluginServices.getText(this,"aceptar")); |
644 |
bAceptar.setToolTipText(PluginServices.getText(this,"accept_tip")); |
645 |
bAceptar.addActionListener(this);
|
646 |
} |
647 |
return bAceptar;
|
648 |
} |
649 |
|
650 |
/**
|
651 |
* This method initializes bProcesar
|
652 |
*
|
653 |
* @return javax.swing.JButton
|
654 |
*/
|
655 |
public JButton getBProcess() { |
656 |
if (bProcesar == null) { |
657 |
bProcesar = new JButton(); |
658 |
bProcesar.setText(PluginServices.getText(this,"procesar")); |
659 |
bProcesar.setToolTipText(PluginServices.getText(this,"process_tip")); |
660 |
bProcesar.setEnabled(true);
|
661 |
bProcesar.addActionListener(this);
|
662 |
} |
663 |
return bProcesar;
|
664 |
} |
665 |
|
666 |
/**
|
667 |
* El bot?n cancelar restaura el extent con el que se carg? la imagen a georreferenciar
|
668 |
* y cierra la ventana.
|
669 |
*
|
670 |
* @return javax.swing.JButton
|
671 |
*/
|
672 |
public JButton getBCancel() { |
673 |
if (bCancelar == null) { |
674 |
bCancelar = new JButton(); |
675 |
bCancelar.setText(PluginServices.getText(this,"cancelar")); |
676 |
bCancelar.setToolTipText(PluginServices.getText(this,"cancel_tip")); |
677 |
bCancelar.addActionListener(this);
|
678 |
} |
679 |
return bCancelar;
|
680 |
} |
681 |
|
682 |
/**
|
683 |
* This method initializes jButton
|
684 |
*
|
685 |
* @return javax.swing.JButton
|
686 |
*/
|
687 |
private JButton getBLoadPoints() { |
688 |
if (bLoadPoints == null) { |
689 |
bLoadPoints = new JButton(); |
690 |
bLoadPoints.setText(PluginServices.getText(this,"cargar")); |
691 |
bLoadPoints.setEnabled(true);
|
692 |
bLoadPoints.addActionListener(this);
|
693 |
} |
694 |
return bLoadPoints;
|
695 |
} |
696 |
|
697 |
/**
|
698 |
* Asigna a las textbox el valor de pixel pasado
|
699 |
* @param x valor x
|
700 |
* @param y valor y
|
701 |
*/
|
702 |
public void setPixelText(double x, double y){ |
703 |
getSelectPointsPanel().getDataPointPanel().getTX().setText(String.valueOf(x));
|
704 |
getSelectPointsPanel().getDataPointPanel().getTY().setText(String.valueOf(y));
|
705 |
} |
706 |
|
707 |
/**
|
708 |
* Asigna a las textbox el valor de coordenadas pasado
|
709 |
* @param x valor x
|
710 |
* @param y valor y
|
711 |
*/
|
712 |
public void setMapCoordText(double x, double y){ |
713 |
getSelectPointsPanel().getDataPointPanel().getLongitud().setText(MathUtils.tailDecimals(String.valueOf(x), 5)); |
714 |
getSelectPointsPanel().getDataPointPanel().getLatitud().setText(MathUtils.tailDecimals(String.valueOf(y), 5)); |
715 |
} |
716 |
|
717 |
/**
|
718 |
* Esta funci?n resetea los controles del panel de info de un punto.
|
719 |
*/
|
720 |
public void resetControls(boolean active){ |
721 |
getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().setSaveToDisk(active); |
722 |
getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().resetControls(active); |
723 |
getConectorPanel().getAdjustGeorefPanel().getZoomLeft().clear(); |
724 |
getConectorPanel().getAdjustGeorefPanel().getZoomRight().clear(); |
725 |
setEnabled(active); |
726 |
} |
727 |
|
728 |
/* (non-Javadoc)
|
729 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
730 |
*/
|
731 |
public void componentHidden(ComponentEvent arg0) { |
732 |
// TODO Auto-generated method stub
|
733 |
|
734 |
} |
735 |
/* (non-Javadoc)
|
736 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
737 |
*/
|
738 |
public void componentMoved(ComponentEvent arg0) { |
739 |
// TODO Auto-generated method stub
|
740 |
|
741 |
} |
742 |
/* (non-Javadoc)
|
743 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
744 |
*/
|
745 |
public void componentResized(ComponentEvent ev) { |
746 |
|
747 |
if(frame.getWidth() <= this.normalWidth + 10) |
748 |
frame.setSize(this.normalWidth, frame.getHeight());
|
749 |
|
750 |
if(this.getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 1){ |
751 |
tmpWidth = frame.getWidth(); |
752 |
this.newFrameSize(frame.getWidth(), frame.getHeight() - 10); |
753 |
} |
754 |
} |
755 |
/* (non-Javadoc)
|
756 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
757 |
*/
|
758 |
public void componentShown(ComponentEvent arg0) { |
759 |
// TODO Auto-generated method stub
|
760 |
|
761 |
} |
762 |
|
763 |
/**
|
764 |
*Inicializa el tama?o del dialogo
|
765 |
*/
|
766 |
public void resetSize(){ |
767 |
if(!enlarge){
|
768 |
frame.setSize(this.normalWidth + 12, this.normalHeight + 10); |
769 |
}else{
|
770 |
frame.setSize(this.normalWidth + 12, this.enlargeHeight + 10); |
771 |
} |
772 |
newFrameSize((int)Math.round(this.normalWidth / 0.98), this.normalHeight); |
773 |
} |
774 |
|
775 |
/**
|
776 |
* Calculo del nuevo tama?o a partir de un frame redimensionado
|
777 |
* @param w Ancho del frame
|
778 |
* @param h Alto del frame
|
779 |
*/
|
780 |
public void newFrameSize(int w, int h){ |
781 |
int newWidth = (int)Math.round(w * 0.98); |
782 |
|
783 |
this.setSize(new java.awt.Dimension(newWidth, normalHeight )); |
784 |
this.setPreferredSize(new java.awt.Dimension(newWidth, normalHeight )); |
785 |
this.getConectorPanel().newFrameSize(newWidth, h);
|
786 |
} |
787 |
|
788 |
/**
|
789 |
* Elimina un punto de la tabla de puntos
|
790 |
* @param pos Posici?n del punto a eliminar
|
791 |
*/
|
792 |
public void removeTableValueAt(int pos) throws ArrayIndexOutOfBoundsException{ |
793 |
((DefaultTableModel)this.getTable().getTable().getModel()).removeRow(pos); |
794 |
} |
795 |
|
796 |
/**
|
797 |
* A partir de nuevas coordenadas actualiza la vista, minimagen, capa de puntos el
|
798 |
* dialogo y la tabla.
|
799 |
*
|
800 |
*/
|
801 |
public void updateData(int nPunto, Point2D pixel, Point2D map, View view){ |
802 |
getPointManager().updateData(nPunto, pixel, map, this, view);
|
803 |
} |
804 |
|
805 |
/**
|
806 |
* Esta funci?n deshabilita todos los controles y guarda sus valores
|
807 |
* de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue
|
808 |
* se vuelvan a quedar como estaba
|
809 |
*/
|
810 |
public void disableAllControls(){ |
811 |
if(!disableAllControls){
|
812 |
disableAllControls = true;
|
813 |
|
814 |
//Salvamos los estados
|
815 |
buttonsState[0] = getBProcess().isEnabled();
|
816 |
buttonsState[1] = getBAccept().isEnabled();
|
817 |
buttonsState[2] = getBCancel().isEnabled();
|
818 |
|
819 |
//Desactivamos controles
|
820 |
getBProcess().setEnabled(false);
|
821 |
getBAccept().setEnabled(false);
|
822 |
getBCancel().setEnabled(false);
|
823 |
} |
824 |
} |
825 |
|
826 |
/**
|
827 |
* Esta funci?n deja los controles como estaban al ejecutar la funci?n
|
828 |
* disableAllControls
|
829 |
*/
|
830 |
public void restoreControlsValue(){ |
831 |
if(disableAllControls){
|
832 |
disableAllControls = false;
|
833 |
getBProcess().setEnabled(buttonsState[0]);
|
834 |
getBAccept().setEnabled(buttonsState[1]);
|
835 |
getBCancel().setEnabled(buttonsState[2]);
|
836 |
} |
837 |
} |
838 |
//**********************End Methods***************************
|
839 |
|
840 |
//**********************Setters & Getters*********************
|
841 |
/**
|
842 |
* Obtiene la tabla de puntos
|
843 |
*/
|
844 |
public PointTable getTable(){
|
845 |
return this.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getJTable(); |
846 |
} |
847 |
|
848 |
/**
|
849 |
* Asigna un valor a una posici?n de la tabla
|
850 |
* @param value Valor a asignar
|
851 |
* @param row Fila en la que se asigna
|
852 |
* @param col Columna en la que se asigna
|
853 |
*/
|
854 |
public void setTableValueAt(String value, int row, int col)throws ArrayIndexOutOfBoundsException{ |
855 |
((DefaultTableModel)this.getTable().getTable().getModel()).setValueAt(value, row, col); |
856 |
} |
857 |
|
858 |
/**
|
859 |
* Obtiene el n?mero de filas de la tabla
|
860 |
* @return N?mero de filas de la tabla
|
861 |
*/
|
862 |
public int getTableRowCount(){ |
863 |
return this.getTable().getTable().getRowCount(); |
864 |
} |
865 |
|
866 |
/**
|
867 |
* A?ade una nueva fila a la tabla de puntos
|
868 |
*/
|
869 |
public void addTableNew(){ |
870 |
this.getTable().getTableModel().addNew();
|
871 |
} |
872 |
/**
|
873 |
* @return Returns the tmpWidth.
|
874 |
*/
|
875 |
public int getTmpWidth() { |
876 |
return tmpWidth;
|
877 |
} |
878 |
/**
|
879 |
* @param tmpWidth The tmpWidth to set.
|
880 |
*/
|
881 |
public void setTmpWidth(int tmpWidth) { |
882 |
this.tmpWidth = tmpWidth;
|
883 |
} |
884 |
/**
|
885 |
* @return Returns the enlargeHeight.
|
886 |
*/
|
887 |
public int getEnlargeHeight() { |
888 |
return enlargeHeight;
|
889 |
} |
890 |
/**
|
891 |
* @return Returns the normalHeight.
|
892 |
*/
|
893 |
public int getNormalHeight() { |
894 |
return normalHeight;
|
895 |
} |
896 |
|
897 |
/**
|
898 |
* @return Returns the normalWidth.
|
899 |
*/
|
900 |
public int getNormalWidth() { |
901 |
return normalWidth;
|
902 |
} |
903 |
|
904 |
/**
|
905 |
* This method initializes jButton
|
906 |
*
|
907 |
* @return javax.swing.JButton
|
908 |
*/
|
909 |
private JButton getBSavePoints() { |
910 |
if (bSavePoints == null) { |
911 |
bSavePoints = new JButton(); |
912 |
bSavePoints.setText(PluginServices.getText(this,"salvar")); |
913 |
//bSavePoints.setPreferredSize(new java.awt.Dimension(41,25));
|
914 |
bSavePoints.addActionListener(this);
|
915 |
} |
916 |
return bSavePoints;
|
917 |
} |
918 |
|
919 |
/**
|
920 |
* Asigna el valor del campo RMS
|
921 |
* @param rms Cadena que representa el RMS
|
922 |
*/
|
923 |
public void setRMS(String rms){ |
924 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTRMS().setText(rms);
|
925 |
} |
926 |
|
927 |
/**
|
928 |
* Asigna el valor del campo de residuo en X
|
929 |
* @param rms Cadena que representa el RMS
|
930 |
*/
|
931 |
public void setResX(String resX){ |
932 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResX().setText(resX);
|
933 |
} |
934 |
|
935 |
/**
|
936 |
* Asigna el valor del campo de residuo en Y
|
937 |
* @param rms Cadena que representa el RMS
|
938 |
*/
|
939 |
public void setResY(String resY){ |
940 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResY().setText(resY);
|
941 |
} |
942 |
|
943 |
/**
|
944 |
* Asigna el valor del campo RMS
|
945 |
* @param rms Cadena que representa el RMS
|
946 |
*/
|
947 |
public void setTotal(String total){ |
948 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTTotal().setText(total);
|
949 |
} |
950 |
|
951 |
/**
|
952 |
* @return Returns the lyrGeoRaster.
|
953 |
*/
|
954 |
public FLyrGeoRaster getLyrGeoRaster() {
|
955 |
return lyrGeoRaster;
|
956 |
} |
957 |
|
958 |
/**
|
959 |
* @return Returns the lyrPoints.
|
960 |
*/
|
961 |
public FLyrPoints getLyrPoints() {
|
962 |
try{
|
963 |
return lyrGeoRaster.getFLyrPoints();
|
964 |
}catch(ClassCastException exc){ |
965 |
return null; |
966 |
} |
967 |
} |
968 |
|
969 |
/**
|
970 |
* Selecciona un tab del cuadro
|
971 |
* @param index
|
972 |
*/
|
973 |
public void setSelectedTab(int index){ |
974 |
try{
|
975 |
this.getConectorPanel().getDataPointsTabPanel().getTbPoints().setSelectedIndex(index);
|
976 |
}catch(IllegalArgumentException ex){ |
977 |
//Si peta al seleccionar un tab, pues nada.
|
978 |
} |
979 |
} |
980 |
|
981 |
/**
|
982 |
* @param extended The extended to set.
|
983 |
*/
|
984 |
public void setEnlarge(boolean enlarge) { |
985 |
this.enlarge = enlarge;
|
986 |
if(!enlarge){
|
987 |
frame.setSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
988 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
989 |
this.setPreferredSize(new Dimension(this.normalWidth, this.normalHeight)); |
990 |
this.setSize(new Dimension(this.normalWidth, this.normalHeight)); |
991 |
this.getConectorPanel().setCanvasVisible(false); |
992 |
}else{
|
993 |
frame.setSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
994 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
995 |
this.setPreferredSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
996 |
this.setSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
997 |
this.getConectorPanel().setCanvasVisible(true); |
998 |
} |
999 |
frame.pack(); |
1000 |
} |
1001 |
|
1002 |
/**
|
1003 |
* @return Returns the extended.
|
1004 |
*/
|
1005 |
public boolean isEnlarge() { |
1006 |
return enlarge;
|
1007 |
} |
1008 |
|
1009 |
/**
|
1010 |
* Obtiene el panel conector
|
1011 |
* @return
|
1012 |
*/
|
1013 |
public ConectorPanel getConectorPanel() {
|
1014 |
if (conectorPanel == null) { |
1015 |
conectorPanel = new ConectorPanel(this); |
1016 |
} |
1017 |
|
1018 |
return conectorPanel;
|
1019 |
} |
1020 |
|
1021 |
/**
|
1022 |
* This method initializes jPanel
|
1023 |
*
|
1024 |
* @return javax.swing.JPanel
|
1025 |
*/
|
1026 |
private JPanel getPBotones() { |
1027 |
if (pBotones == null) { |
1028 |
FlowLayout flowLayout1 = new FlowLayout(); |
1029 |
pBotones = new JPanel(); |
1030 |
pBotones.setLayout(flowLayout1); |
1031 |
flowLayout1.setHgap(10);
|
1032 |
flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT); |
1033 |
pBotones.add(getBProcess(), null);
|
1034 |
pBotones.add(getBAccept(), null);
|
1035 |
pBotones.add(getBCancel(), null);
|
1036 |
} |
1037 |
return pBotones;
|
1038 |
} |
1039 |
|
1040 |
public static IProjection getLastProjection() { |
1041 |
return proj;
|
1042 |
} |
1043 |
public static void setLastProjection(IProjection proj) { |
1044 |
GeoreferencingDialog.proj = proj; |
1045 |
} |
1046 |
|
1047 |
/**
|
1048 |
* @return Returns the GeoRedimBehavior.
|
1049 |
*/
|
1050 |
public GeoRedimBehavior getGeoRedimBehavior() {
|
1051 |
return rb;
|
1052 |
} |
1053 |
|
1054 |
/**
|
1055 |
* @param rb The GeoRedimBehavior to set.
|
1056 |
*/
|
1057 |
public void setGeoRedimBehavior(GeoRedimBehavior rb) { |
1058 |
this.rb = rb;
|
1059 |
} |
1060 |
|
1061 |
/**
|
1062 |
* @return Returns the GeoMoveBehavior
|
1063 |
*/
|
1064 |
public GeoMoveBehavior getGeoMoveBehavior() {
|
1065 |
return mb;
|
1066 |
} |
1067 |
|
1068 |
/**
|
1069 |
* @param mb The GeoMoveBehavior to set.
|
1070 |
*/
|
1071 |
public void setGeoMoveBehavior(GeoMoveBehavior mb) { |
1072 |
this.mb = mb;
|
1073 |
} |
1074 |
|
1075 |
|
1076 |
/**
|
1077 |
* Obtiene el punto de la lista que ha sido seleccionado
|
1078 |
* @return
|
1079 |
*/
|
1080 |
public int getSelectedPoint(){ |
1081 |
return getConectorPanel().getDataPointsTabPanel().
|
1082 |
getSelectPointsPanel().getTableControlerPanel().getSelectedIndex(); |
1083 |
} |
1084 |
|
1085 |
/**
|
1086 |
* Obtiene el control de la mini imagen que tiene los botones a la izquierda
|
1087 |
* @return ZoomControlPanel
|
1088 |
*/
|
1089 |
public ZoomControlPanel getZoomControlLeft(){
|
1090 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft(); |
1091 |
} |
1092 |
|
1093 |
/**
|
1094 |
* Obtiene el control de la mini imagen que tiene los botones a la derecha
|
1095 |
* @return ZoomControlPanel
|
1096 |
*/
|
1097 |
public ZoomControlPanel getZoomControlRight(){
|
1098 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomRight(); |
1099 |
} |
1100 |
|
1101 |
/**
|
1102 |
* Obtiene el panel de selecci?n de puntos
|
1103 |
* @return Panel de selecci?n de puntos
|
1104 |
*/
|
1105 |
public SelectPointsPanel getSelectPointsPanel(){
|
1106 |
return this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel(); |
1107 |
} |
1108 |
|
1109 |
/**
|
1110 |
* Obtiene el panel de opciones
|
1111 |
* @return OptionPanel
|
1112 |
*/
|
1113 |
public OptionsPanel getOptionsPanel(){
|
1114 |
return getConectorPanel().getAdjustGeorefPanel().getOptionsPanel();
|
1115 |
} |
1116 |
|
1117 |
/**
|
1118 |
* Asigna el frame
|
1119 |
* @param f
|
1120 |
*/
|
1121 |
public void setFrame(JInternalFrame f){ |
1122 |
frame = f; |
1123 |
frame.addComponentListener(this);
|
1124 |
} |
1125 |
|
1126 |
/**
|
1127 |
* Obtiene el frame
|
1128 |
* @return frame
|
1129 |
*/
|
1130 |
public JInternalFrame getFrame(){ |
1131 |
return frame;
|
1132 |
} |
1133 |
|
1134 |
/**
|
1135 |
* Obtiene el gestor de puntos
|
1136 |
* @return PointManager
|
1137 |
*/
|
1138 |
public PointManager getPointManager() {
|
1139 |
return pointManager;
|
1140 |
} |
1141 |
|
1142 |
/**
|
1143 |
* Activa o desactiva este panel y todos los que lo componen
|
1144 |
* @param enabled variable booleana para la activaci?n y/o desactivaci?n
|
1145 |
*/
|
1146 |
public void setEnabled(boolean enabled){ |
1147 |
conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().setEnabled(enabled); |
1148 |
conectorPanel.getAdjustGeorefPanel().setEnabled(enabled); |
1149 |
} |
1150 |
|
1151 |
/**
|
1152 |
* M?todo para notificar si se desea crear o no el fichero de coordenadas .tfw, .wld .jpgw ,...
|
1153 |
* @param createWorldFile
|
1154 |
*/
|
1155 |
public void setCreateWorldFile(boolean createWorldFile) { |
1156 |
this.createWorldFile = createWorldFile;
|
1157 |
} |
1158 |
|
1159 |
/**
|
1160 |
*
|
1161 |
*/
|
1162 |
public ViewPort getLeftInitViewport(ViewPort vp, Point2D center, ViewPort initVp, double zoom){ |
1163 |
return getZoomControlLeft().getCanvas().initViewPort(vp, center, initVp, zoom);
|
1164 |
} |
1165 |
|
1166 |
/**
|
1167 |
* Consulta si se desea incluir los errores cuando se exporta a fichero .csv
|
1168 |
* @param errorCVS true si se incluyen los errores dentro del fichero y false si no se incluyen
|
1169 |
*/
|
1170 |
public boolean isErrorCSV() { |
1171 |
return errorCSV;
|
1172 |
} |
1173 |
|
1174 |
/**
|
1175 |
* M?todo para notificar si se desea incluir los errores cuando se exporta a fichero .csv
|
1176 |
* @param errorCVS true si se incluyen los errores dentro del fichero y false si no se incluyen
|
1177 |
*/
|
1178 |
public void setErrorCSV(boolean errorCSV) { |
1179 |
this.errorCSV = errorCSV;
|
1180 |
} |
1181 |
|
1182 |
/**
|
1183 |
* Obtiene los errores en una matriz de Nx3 en la que cada fila es un punto y la
|
1184 |
* columna 0 es el error en X, la columna 1 es el error en Y y la columna 2 es el error RMS.
|
1185 |
* @return matriz de errores
|
1186 |
*/
|
1187 |
public double[][] getErrors(){ |
1188 |
return pointManager.getErrors();
|
1189 |
} |
1190 |
//**********************End Setters & Getters*****************
|
1191 |
|
1192 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
1193 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|
1194 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|