svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / gui / dialogs / GeoreferencingDialog.java @ 5550
History | View | Annotate | Download (38.7 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 |
theView.getMapControl().getMapContext().invalidate(); |
412 |
} |
413 |
|
414 |
} |
415 |
} |
416 |
} |
417 |
|
418 |
/**
|
419 |
* Funci?n que se ejecuta al pulsar el bot?n aceptar. Este procesamiento calcula a partir de
|
420 |
* los puntos de control la georreferenciaci?n de la imagen, crear el fichero .rmf de georreferenciaci?n
|
421 |
* y descarga la capa del TOC. A continuaci?n vuelve a cargar la capa como FLyrRaster dando
|
422 |
* por finalizada la georreferenciaci?n.
|
423 |
* @param theView
|
424 |
*/
|
425 |
private void accept(View theView)throws Exception{ |
426 |
if(getLyrPoints() == null) |
427 |
throw new Exception("LyrPoints not loaded."); |
428 |
|
429 |
if(this.getLyrPoints().getCountPoints() > 0){ |
430 |
|
431 |
//Creamos el fichero de georreferenciaci?n
|
432 |
GeoOperations go = new GeoOperations(getLyrPoints());
|
433 |
go.setCreateWorldFile(this.createWorldFile);
|
434 |
go.createGeorefFile( (int)getLyrGeoRaster().getImageWidth(),
|
435 |
(int)getLyrGeoRaster().getImageHeight(),
|
436 |
getLyrGeoRaster().getSource().getFiles()[0].getName());
|
437 |
|
438 |
FLayers lyrs = this.getLyrGeoRaster().getParentLayer();
|
439 |
for(int i = 0; i < lyrs.getLayersCount();i++){ |
440 |
if(this.getLyrGeoRaster().getName().equals(lyrs.getLayer(i).getName())){ |
441 |
|
442 |
//Eliminamos la capa
|
443 |
lyrs.removeLayer(i); |
444 |
File fich = new File(getLyrGeoRaster().getSource().getFiles()[0].getName()); |
445 |
try{
|
446 |
//Creamos la nueva capa GeoRaster y la a?adimos al TOC.
|
447 |
/*FLyrGeoRaster lyrGeoRaster =
|
448 |
GeoLayerFactory.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()),
|
449 |
(RasterDriver)getLyrGeoRaster().getSource().getDriver(),
|
450 |
fich,
|
451 |
getLyrGeoRaster().getProjection(),
|
452 |
getLyrGeoRaster().getImageWidth(),
|
453 |
getLyrGeoRaster().getImageHeight());
|
454 |
getLyrPoints().setVisible(false);
|
455 |
this.getLyrPoints().setLyrGeoRaster(lyrGeoRaster);
|
456 |
lyrGeoRaster.setFLyrPoints(this.getLyrPoints());
|
457 |
lyrGeoRaster.setGeoDialog(this);
|
458 |
this.lyrGeoRaster = lyrGeoRaster;
|
459 |
calcNewMiniExtent(theView);
|
460 |
lyrs.addLayer(lyrGeoRaster);
|
461 |
|
462 |
lyrGeoRaster.setActive(false);*/
|
463 |
|
464 |
FLyrRaster lyrRaster = GeoLayerFactory.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()),
|
465 |
(RasterDriver)getLyrGeoRaster().getSource().getDriver(), |
466 |
fich, |
467 |
getLyrGeoRaster().getProjection()); |
468 |
lyrs.addLayer(lyrRaster); |
469 |
|
470 |
theView.getMapControl().getMapContext().invalidate(); |
471 |
|
472 |
try{
|
473 |
frame.setClosed(true);
|
474 |
}catch(PropertyVetoException exc){} |
475 |
|
476 |
}catch(DriverException exc){
|
477 |
|
478 |
} |
479 |
break;
|
480 |
} |
481 |
} |
482 |
|
483 |
} |
484 |
} |
485 |
|
486 |
/**
|
487 |
* Funci?n que se ejecuta al pulsar el bot?n aceptar
|
488 |
* @param theView
|
489 |
*/
|
490 |
/*private void accept(View theView)throws Exception{
|
491 |
if(getLyrPoints() == null)
|
492 |
throw new Exception("LyrPoints not loaded.");
|
493 |
|
494 |
if(lyrGeoRaster != null){
|
495 |
getLyrPoints().setVisible(false);
|
496 |
lyrGeoRaster.setName(lyrGeoRaster.getName().substring(1, lyrGeoRaster.getName().length()));
|
497 |
lyrGeoRaster.setActive(false);
|
498 |
theView.getMapControl().getMapContext().invalidate();
|
499 |
}
|
500 |
close();
|
501 |
}*/
|
502 |
|
503 |
/**
|
504 |
* Funci?n que se ejecuta al pulsar el bot?n cancelar
|
505 |
* @param theView
|
506 |
*/
|
507 |
private void cancel(View theView)throws Exception{ |
508 |
if(getLyrPoints() == null) |
509 |
throw new Exception("LyrPoints not loaded."); |
510 |
|
511 |
//Cerramos la ventana
|
512 |
//(se ejecuta el evento internalFrameClosing de GeoRasterFrameListener)
|
513 |
try{
|
514 |
frame.setClosed(true);
|
515 |
theView.getMapControl().getMapContext().invalidate(); |
516 |
}catch(PropertyVetoException exc){} |
517 |
} |
518 |
|
519 |
/**
|
520 |
* Funci?n que se ejecuta al pulsar el bot?n de cargar puntos
|
521 |
* @param theView
|
522 |
*/
|
523 |
private void loadPoints(View theView)throws Exception{ |
524 |
if(getLyrPoints() == null) |
525 |
throw new Exception("LyrPoints not loaded."); |
526 |
|
527 |
if(messageBoxYesOrNot("cargar_puntos")){ |
528 |
String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf(".")); |
529 |
String path = ((RasterFileAdapter)lyrGeoRaster.getSource()).getFile().getAbsolutePath();
|
530 |
String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf"; |
531 |
|
532 |
//Antes de cargar puntos plegamos el cuadro
|
533 |
getSelectPointsPanel().setEnlarge(true);
|
534 |
|
535 |
getLyrPoints().saveState(); |
536 |
getLyrPoints().XML2PointList(nameRmf); |
537 |
|
538 |
//Esto es por si el panel ha sido estirado cuando cargamos los puntos
|
539 |
frame.pack(); |
540 |
frame.show(); |
541 |
} |
542 |
} |
543 |
|
544 |
/**
|
545 |
* Funci?n que se ejecuta al pulsar el bot?n salvar puntos
|
546 |
* @param theView
|
547 |
*/
|
548 |
public void savePoints()throws Exception{ |
549 |
if(getLyrPoints() == null) |
550 |
throw new Exception("LyrPoints not loaded."); |
551 |
String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf(".")); |
552 |
String path = ((RasterFileAdapter)lyrGeoRaster.getSource()).getFile().getAbsolutePath();
|
553 |
String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf"; |
554 |
|
555 |
File f = new File(nameRmf); |
556 |
if(f.exists()){
|
557 |
if (messageBoxYesOrNot("gcps_exist")){ |
558 |
if(getLyrPoints() != null) |
559 |
getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf"); |
560 |
} |
561 |
}else
|
562 |
getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf"); |
563 |
} |
564 |
|
565 |
/**
|
566 |
* Funci?n que se ejecuta al pulsar el bot?n de export a ascii
|
567 |
* @param theView
|
568 |
*/
|
569 |
private void exportToASCII(View theView)throws Exception{ |
570 |
if(getLyrPoints() == null) |
571 |
throw new Exception("LyrPoints not loaded."); |
572 |
|
573 |
JFileChooser chooser = new JFileChooser(lastPathSave); |
574 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
575 |
|
576 |
FileFilter f = null; |
577 |
for(int i=0; i<this.fileFilters.length;i++){ |
578 |
f = new SelectFileFilter(chooser, this.fileFilters[i]); |
579 |
chooser.addChoosableFileFilter(f); |
580 |
} |
581 |
int returnVal = chooser.showOpenDialog(this); |
582 |
if(returnVal == JFileChooser.APPROVE_OPTION){ |
583 |
String fName = chooser.getSelectedFile().toString();
|
584 |
lastPathSave = chooser.getCurrentDirectory().getAbsolutePath(); |
585 |
if(checkFileExists(fName, true)){ |
586 |
if(getLyrPoints() != null) |
587 |
getLyrPoints().PointList2Ascii(fName); |
588 |
} |
589 |
} |
590 |
} |
591 |
|
592 |
/**
|
593 |
* Funci?n que se ejecuta al pulsar el bot?n desactivar panel
|
594 |
* @param theView
|
595 |
*/
|
596 |
private void deactivatePanel(View theView, JCheckBox cb)throws Exception{ |
597 |
if(getLyrPoints() == null) |
598 |
throw new Exception("LyrPoints not loaded."); |
599 |
|
600 |
if(cb.isSelected()){
|
601 |
this.setEnabled(true); |
602 |
getLyrPoints().setPointActive(getSelectedPoint(), true);
|
603 |
}else{
|
604 |
this.setEnabled(false); |
605 |
getLyrPoints().setPointActive(getSelectedPoint(), false);
|
606 |
} |
607 |
|
608 |
//Al activar y desactivar tenemos que recalcular errores
|
609 |
this.getPointManager().setErrors(getSelectedPoint());
|
610 |
|
611 |
theView.getMapControl().getMapContext().invalidate(); |
612 |
getZoomControlLeft().draw(); |
613 |
getZoomControlRight().draw(); |
614 |
} |
615 |
|
616 |
/**
|
617 |
* Recalcula el extent de la mini-imagen que corresponde a los puntos en coordenadas
|
618 |
* pixel.Para esto calcula el nuevo centro a partir de la capa y con la distancia entre
|
619 |
* el nuevo centro y el viejo desplaza el extent completo de la mini-imagen.
|
620 |
* @param theView
|
621 |
*/
|
622 |
private void calcNewMiniExtent(View theView){ |
623 |
|
624 |
ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort(); |
625 |
for(int j = 0; j < getLyrPoints().getCountPoints(); j++){ |
626 |
//Calculamos el nuevo centro
|
627 |
Point2D oldCenter = getLyrPoints().getPoint(j).leftCenterPoint;
|
628 |
Point2D newCenter = new Point2D.Double(); |
629 |
newCenter.setLocation( lyrGeoRaster.img2World(getLyrPoints().getPoint(j).pixelPoint)); |
630 |
|
631 |
double diffX = oldCenter.getX() - newCenter.getX();
|
632 |
double diffY = oldCenter.getY() - newCenter.getY();
|
633 |
|
634 |
getLyrPoints().getPoint(j).leftCenterPoint = newCenter; |
635 |
|
636 |
ViewPort vpOld = getLyrPoints().getPoint(j).leftViewPort; |
637 |
Rectangle2D newExtent = new Rectangle2D.Double( vpOld.getExtent().getMinX() - diffX, |
638 |
vpOld.getExtent().getMinY() - diffY, |
639 |
vpOld.getExtent().getWidth(), |
640 |
vpOld.getExtent().getHeight() ); |
641 |
ViewPort vpNew = new ViewPort(vpOld.getProjection());
|
642 |
vpNew.setExtent(newExtent); |
643 |
vpNew.setImageSize(vpOld.getImageSize()); |
644 |
vpNew.setScale(); |
645 |
getLyrPoints().getPoint(j).leftViewPort = vpNew; |
646 |
} |
647 |
} |
648 |
|
649 |
/**
|
650 |
* This method initializes jButton
|
651 |
*
|
652 |
* @return javax.swing.JButton
|
653 |
*/
|
654 |
public JButton getBAccept() { |
655 |
if (bAceptar == null) { |
656 |
bAceptar = new JButton(); |
657 |
bAceptar.setText(PluginServices.getText(this,"aceptar")); |
658 |
bAceptar.setToolTipText(PluginServices.getText(this,"accept_tip")); |
659 |
bAceptar.addActionListener(this);
|
660 |
} |
661 |
return bAceptar;
|
662 |
} |
663 |
|
664 |
/**
|
665 |
* This method initializes bProcesar
|
666 |
*
|
667 |
* @return javax.swing.JButton
|
668 |
*/
|
669 |
public JButton getBProcess() { |
670 |
if (bProcesar == null) { |
671 |
bProcesar = new JButton(); |
672 |
bProcesar.setText(PluginServices.getText(this,"procesar")); |
673 |
bProcesar.setToolTipText(PluginServices.getText(this,"process_tip")); |
674 |
bProcesar.setEnabled(true);
|
675 |
bProcesar.addActionListener(this);
|
676 |
} |
677 |
return bProcesar;
|
678 |
} |
679 |
|
680 |
/**
|
681 |
* El bot?n cancelar restaura el extent con el que se carg? la imagen a georreferenciar
|
682 |
* y cierra la ventana.
|
683 |
*
|
684 |
* @return javax.swing.JButton
|
685 |
*/
|
686 |
public JButton getBCancel() { |
687 |
if (bCancelar == null) { |
688 |
bCancelar = new JButton(); |
689 |
bCancelar.setText(PluginServices.getText(this,"cancelar")); |
690 |
bCancelar.setToolTipText(PluginServices.getText(this,"cancel_tip")); |
691 |
bCancelar.addActionListener(this);
|
692 |
} |
693 |
return bCancelar;
|
694 |
} |
695 |
|
696 |
/**
|
697 |
* This method initializes jButton
|
698 |
*
|
699 |
* @return javax.swing.JButton
|
700 |
*/
|
701 |
private JButton getBLoadPoints() { |
702 |
if (bLoadPoints == null) { |
703 |
bLoadPoints = new JButton(); |
704 |
bLoadPoints.setText(PluginServices.getText(this,"cargar")); |
705 |
bLoadPoints.setEnabled(true);
|
706 |
bLoadPoints.addActionListener(this);
|
707 |
} |
708 |
return bLoadPoints;
|
709 |
} |
710 |
|
711 |
/**
|
712 |
* Asigna a las textbox el valor de pixel pasado
|
713 |
* @param x valor x
|
714 |
* @param y valor y
|
715 |
*/
|
716 |
public void setPixelText(double x, double y){ |
717 |
getSelectPointsPanel().getDataPointPanel().getTX().setText(String.valueOf(x));
|
718 |
getSelectPointsPanel().getDataPointPanel().getTY().setText(String.valueOf(y));
|
719 |
} |
720 |
|
721 |
/**
|
722 |
* Asigna a las textbox el valor de coordenadas pasado
|
723 |
* @param x valor x
|
724 |
* @param y valor y
|
725 |
*/
|
726 |
public void setMapCoordText(double x, double y){ |
727 |
getSelectPointsPanel().getDataPointPanel().getLongitud().setText(MathUtils.tailDecimals(String.valueOf(x), 5)); |
728 |
getSelectPointsPanel().getDataPointPanel().getLatitud().setText(MathUtils.tailDecimals(String.valueOf(y), 5)); |
729 |
} |
730 |
|
731 |
/**
|
732 |
* Esta funci?n resetea los controles del panel de info de un punto.
|
733 |
*/
|
734 |
public void resetControls(boolean active){ |
735 |
getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().setSaveToDisk(active); |
736 |
getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().resetControls(active); |
737 |
getConectorPanel().getAdjustGeorefPanel().getZoomLeft().clear(); |
738 |
setEnabled(active); |
739 |
} |
740 |
|
741 |
/* (non-Javadoc)
|
742 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
743 |
*/
|
744 |
public void componentHidden(ComponentEvent arg0) { |
745 |
// TODO Auto-generated method stub
|
746 |
|
747 |
} |
748 |
/* (non-Javadoc)
|
749 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
750 |
*/
|
751 |
public void componentMoved(ComponentEvent arg0) { |
752 |
// TODO Auto-generated method stub
|
753 |
|
754 |
} |
755 |
/* (non-Javadoc)
|
756 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
757 |
*/
|
758 |
public void componentResized(ComponentEvent ev) { |
759 |
|
760 |
if(frame.getWidth() <= this.normalWidth + 10) |
761 |
frame.setSize(this.normalWidth, frame.getHeight());
|
762 |
|
763 |
if(this.getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 1){ |
764 |
tmpWidth = frame.getWidth(); |
765 |
this.newFrameSize(frame.getWidth(), frame.getHeight() - 10); |
766 |
} |
767 |
} |
768 |
/* (non-Javadoc)
|
769 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
770 |
*/
|
771 |
public void componentShown(ComponentEvent arg0) { |
772 |
// TODO Auto-generated method stub
|
773 |
|
774 |
} |
775 |
|
776 |
/**
|
777 |
*Inicializa el tama?o del dialogo
|
778 |
*/
|
779 |
public void resetSize(){ |
780 |
if(!enlarge){
|
781 |
frame.setSize(this.normalWidth + 12, this.normalHeight + 10); |
782 |
}else{
|
783 |
frame.setSize(this.normalWidth + 12, this.enlargeHeight + 10); |
784 |
} |
785 |
newFrameSize((int)Math.round(this.normalWidth / 0.98), this.normalHeight); |
786 |
} |
787 |
|
788 |
/**
|
789 |
* Calculo del nuevo tama?o a partir de un frame redimensionado
|
790 |
* @param w Ancho del frame
|
791 |
* @param h Alto del frame
|
792 |
*/
|
793 |
public void newFrameSize(int w, int h){ |
794 |
int newWidth = (int)Math.round(w * 0.98); |
795 |
|
796 |
this.setSize(new java.awt.Dimension(newWidth, normalHeight )); |
797 |
this.setPreferredSize(new java.awt.Dimension(newWidth, normalHeight )); |
798 |
this.getConectorPanel().newFrameSize(newWidth, h);
|
799 |
} |
800 |
|
801 |
/**
|
802 |
* Elimina un punto de la tabla de puntos
|
803 |
* @param pos Posici?n del punto a eliminar
|
804 |
*/
|
805 |
public void removeTableValueAt(int pos) throws ArrayIndexOutOfBoundsException{ |
806 |
((DefaultTableModel)this.getTable().getTable().getModel()).removeRow(pos); |
807 |
} |
808 |
|
809 |
/**
|
810 |
* A partir de nuevas coordenadas actualiza la vista, minimagen, capa de puntos el
|
811 |
* dialogo y la tabla.
|
812 |
*
|
813 |
*/
|
814 |
public void updateData(int nPunto, Point2D pixel, Point2D map, View view){ |
815 |
getPointManager().updateData(nPunto, pixel, map, this, view);
|
816 |
} |
817 |
|
818 |
/**
|
819 |
* Esta funci?n deshabilita todos los controles y guarda sus valores
|
820 |
* de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue
|
821 |
* se vuelvan a quedar como estaba
|
822 |
*/
|
823 |
public void disableAllControls(){ |
824 |
if(!disableAllControls){
|
825 |
disableAllControls = true;
|
826 |
|
827 |
//Salvamos los estados
|
828 |
buttonsState[0] = getBProcess().isEnabled();
|
829 |
buttonsState[1] = getBAccept().isEnabled();
|
830 |
buttonsState[2] = getBCancel().isEnabled();
|
831 |
|
832 |
//Desactivamos controles
|
833 |
getBProcess().setEnabled(false);
|
834 |
getBAccept().setEnabled(false);
|
835 |
getBCancel().setEnabled(false);
|
836 |
} |
837 |
} |
838 |
|
839 |
/**
|
840 |
* Esta funci?n deja los controles como estaban al ejecutar la funci?n
|
841 |
* disableAllControls
|
842 |
*/
|
843 |
public void restoreControlsValue(){ |
844 |
if(disableAllControls){
|
845 |
disableAllControls = false;
|
846 |
getBProcess().setEnabled(buttonsState[0]);
|
847 |
getBAccept().setEnabled(buttonsState[1]);
|
848 |
getBCancel().setEnabled(buttonsState[2]);
|
849 |
} |
850 |
} |
851 |
//**********************End Methods***************************
|
852 |
|
853 |
//**********************Setters & Getters*********************
|
854 |
/**
|
855 |
* Obtiene la tabla de puntos
|
856 |
*/
|
857 |
public PointTable getTable(){
|
858 |
return this.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getJTable(); |
859 |
} |
860 |
|
861 |
/**
|
862 |
* Asigna un valor a una posici?n de la tabla
|
863 |
* @param value Valor a asignar
|
864 |
* @param row Fila en la que se asigna
|
865 |
* @param col Columna en la que se asigna
|
866 |
*/
|
867 |
public void setTableValueAt(String value, int row, int col)throws ArrayIndexOutOfBoundsException{ |
868 |
((DefaultTableModel)this.getTable().getTable().getModel()).setValueAt(value, row, col); |
869 |
} |
870 |
|
871 |
/**
|
872 |
* Obtiene el n?mero de filas de la tabla
|
873 |
* @return N?mero de filas de la tabla
|
874 |
*/
|
875 |
public int getTableRowCount(){ |
876 |
return this.getTable().getTable().getRowCount(); |
877 |
} |
878 |
|
879 |
/**
|
880 |
* A?ade una nueva fila a la tabla de puntos
|
881 |
*/
|
882 |
public void addTableNew(){ |
883 |
this.getTable().getTableModel().addNew();
|
884 |
} |
885 |
/**
|
886 |
* @return Returns the tmpWidth.
|
887 |
*/
|
888 |
public int getTmpWidth() { |
889 |
return tmpWidth;
|
890 |
} |
891 |
/**
|
892 |
* @param tmpWidth The tmpWidth to set.
|
893 |
*/
|
894 |
public void setTmpWidth(int tmpWidth) { |
895 |
this.tmpWidth = tmpWidth;
|
896 |
} |
897 |
/**
|
898 |
* @return Returns the enlargeHeight.
|
899 |
*/
|
900 |
public int getEnlargeHeight() { |
901 |
return enlargeHeight;
|
902 |
} |
903 |
/**
|
904 |
* @return Returns the normalHeight.
|
905 |
*/
|
906 |
public int getNormalHeight() { |
907 |
return normalHeight;
|
908 |
} |
909 |
|
910 |
/**
|
911 |
* @return Returns the normalWidth.
|
912 |
*/
|
913 |
public int getNormalWidth() { |
914 |
return normalWidth;
|
915 |
} |
916 |
|
917 |
/**
|
918 |
* This method initializes jButton
|
919 |
*
|
920 |
* @return javax.swing.JButton
|
921 |
*/
|
922 |
private JButton getBSavePoints() { |
923 |
if (bSavePoints == null) { |
924 |
bSavePoints = new JButton(); |
925 |
bSavePoints.setText(PluginServices.getText(this,"salvar")); |
926 |
//bSavePoints.setPreferredSize(new java.awt.Dimension(41,25));
|
927 |
bSavePoints.addActionListener(this);
|
928 |
} |
929 |
return bSavePoints;
|
930 |
} |
931 |
|
932 |
/**
|
933 |
* Asigna el valor del campo RMS
|
934 |
* @param rms Cadena que representa el RMS
|
935 |
*/
|
936 |
public void setRMS(String rms){ |
937 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTRMS().setText(rms);
|
938 |
} |
939 |
|
940 |
/**
|
941 |
* Asigna el valor del campo de residuo en X
|
942 |
* @param rms Cadena que representa el RMS
|
943 |
*/
|
944 |
public void setResX(String resX){ |
945 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResX().setText(resX);
|
946 |
} |
947 |
|
948 |
/**
|
949 |
* Asigna el valor del campo de residuo en Y
|
950 |
* @param rms Cadena que representa el RMS
|
951 |
*/
|
952 |
public void setResY(String resY){ |
953 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResY().setText(resY);
|
954 |
} |
955 |
|
956 |
/**
|
957 |
* Asigna el valor del campo RMS
|
958 |
* @param rms Cadena que representa el RMS
|
959 |
*/
|
960 |
public void setTotal(String total){ |
961 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTTotal().setText(total);
|
962 |
} |
963 |
|
964 |
/**
|
965 |
* @return Returns the lyrGeoRaster.
|
966 |
*/
|
967 |
public FLyrGeoRaster getLyrGeoRaster() {
|
968 |
return lyrGeoRaster;
|
969 |
} |
970 |
|
971 |
/**
|
972 |
* @return Returns the lyrPoints.
|
973 |
*/
|
974 |
public FLyrPoints getLyrPoints() {
|
975 |
try{
|
976 |
return lyrGeoRaster.getFLyrPoints();
|
977 |
}catch(ClassCastException exc){ |
978 |
return null; |
979 |
} |
980 |
} |
981 |
|
982 |
/**
|
983 |
* Selecciona un tab del cuadro
|
984 |
* @param index
|
985 |
*/
|
986 |
public void setSelectedTab(int index){ |
987 |
try{
|
988 |
this.getConectorPanel().getDataPointsTabPanel().getTbPoints().setSelectedIndex(index);
|
989 |
}catch(IllegalArgumentException ex){ |
990 |
//Si peta al seleccionar un tab, pues nada.
|
991 |
} |
992 |
} |
993 |
|
994 |
/**
|
995 |
* @param extended The extended to set.
|
996 |
*/
|
997 |
public void setEnlarge(boolean enlarge) { |
998 |
this.enlarge = enlarge;
|
999 |
if(!enlarge){
|
1000 |
frame.setSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
1001 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
1002 |
this.setPreferredSize(new Dimension(this.normalWidth, this.normalHeight)); |
1003 |
this.setSize(new Dimension(this.normalWidth, this.normalHeight)); |
1004 |
this.getConectorPanel().setCanvasVisible(false); |
1005 |
}else{
|
1006 |
frame.setSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
1007 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
1008 |
this.setPreferredSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
1009 |
this.setSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
1010 |
this.getConectorPanel().setCanvasVisible(true); |
1011 |
} |
1012 |
frame.pack(); |
1013 |
} |
1014 |
|
1015 |
/**
|
1016 |
* @return Returns the extended.
|
1017 |
*/
|
1018 |
public boolean isEnlarge() { |
1019 |
return enlarge;
|
1020 |
} |
1021 |
|
1022 |
/**
|
1023 |
* Obtiene el panel conector
|
1024 |
* @return
|
1025 |
*/
|
1026 |
public ConectorPanel getConectorPanel() {
|
1027 |
if (conectorPanel == null) { |
1028 |
conectorPanel = new ConectorPanel(this); |
1029 |
} |
1030 |
|
1031 |
return conectorPanel;
|
1032 |
} |
1033 |
|
1034 |
/**
|
1035 |
* This method initializes jPanel
|
1036 |
*
|
1037 |
* @return javax.swing.JPanel
|
1038 |
*/
|
1039 |
private JPanel getPBotones() { |
1040 |
if (pBotones == null) { |
1041 |
FlowLayout flowLayout1 = new FlowLayout(); |
1042 |
pBotones = new JPanel(); |
1043 |
pBotones.setLayout(flowLayout1); |
1044 |
flowLayout1.setHgap(10);
|
1045 |
flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT); |
1046 |
pBotones.add(getBProcess(), null);
|
1047 |
pBotones.add(getBAccept(), null);
|
1048 |
pBotones.add(getBCancel(), null);
|
1049 |
} |
1050 |
return pBotones;
|
1051 |
} |
1052 |
|
1053 |
public static IProjection getLastProjection() { |
1054 |
return proj;
|
1055 |
} |
1056 |
public static void setLastProjection(IProjection proj) { |
1057 |
GeoreferencingDialog.proj = proj; |
1058 |
} |
1059 |
|
1060 |
/**
|
1061 |
* @return Returns the GeoRedimBehavior.
|
1062 |
*/
|
1063 |
public GeoRedimBehavior getGeoRedimBehavior() {
|
1064 |
return rb;
|
1065 |
} |
1066 |
|
1067 |
/**
|
1068 |
* @param rb The GeoRedimBehavior to set.
|
1069 |
*/
|
1070 |
public void setGeoRedimBehavior(GeoRedimBehavior rb) { |
1071 |
this.rb = rb;
|
1072 |
} |
1073 |
|
1074 |
/**
|
1075 |
* @return Returns the GeoMoveBehavior
|
1076 |
*/
|
1077 |
public GeoMoveBehavior getGeoMoveBehavior() {
|
1078 |
return mb;
|
1079 |
} |
1080 |
|
1081 |
/**
|
1082 |
* @param mb The GeoMoveBehavior to set.
|
1083 |
*/
|
1084 |
public void setGeoMoveBehavior(GeoMoveBehavior mb) { |
1085 |
this.mb = mb;
|
1086 |
} |
1087 |
|
1088 |
|
1089 |
/**
|
1090 |
* Obtiene el punto de la lista que ha sido seleccionado
|
1091 |
* @return
|
1092 |
*/
|
1093 |
public int getSelectedPoint(){ |
1094 |
return getConectorPanel().getDataPointsTabPanel().
|
1095 |
getSelectPointsPanel().getTableControlerPanel().getSelectedIndex(); |
1096 |
} |
1097 |
|
1098 |
/**
|
1099 |
* Obtiene el control de la mini imagen que tiene los botones a la izquierda
|
1100 |
* @return ZoomControlPanel
|
1101 |
*/
|
1102 |
public ZoomControlPanel getZoomControlLeft(){
|
1103 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft(); |
1104 |
} |
1105 |
|
1106 |
/**
|
1107 |
* Obtiene el control de la mini imagen que tiene los botones a la derecha
|
1108 |
* @return ZoomControlPanel
|
1109 |
*/
|
1110 |
public ZoomControlPanel getZoomControlRight(){
|
1111 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomRight(); |
1112 |
} |
1113 |
|
1114 |
/**
|
1115 |
* Obtiene el panel de selecci?n de puntos
|
1116 |
* @return Panel de selecci?n de puntos
|
1117 |
*/
|
1118 |
public SelectPointsPanel getSelectPointsPanel(){
|
1119 |
return this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel(); |
1120 |
} |
1121 |
|
1122 |
/**
|
1123 |
* Obtiene el panel de opciones
|
1124 |
* @return OptionPanel
|
1125 |
*/
|
1126 |
public OptionsPanel getOptionsPanel(){
|
1127 |
return getConectorPanel().getAdjustGeorefPanel().getOptionsPanel();
|
1128 |
} |
1129 |
|
1130 |
/**
|
1131 |
* Asigna el frame
|
1132 |
* @param f
|
1133 |
*/
|
1134 |
public void setFrame(JInternalFrame f){ |
1135 |
frame = f; |
1136 |
frame.addComponentListener(this);
|
1137 |
} |
1138 |
|
1139 |
/**
|
1140 |
* Obtiene el frame
|
1141 |
* @return frame
|
1142 |
*/
|
1143 |
public JInternalFrame getFrame(){ |
1144 |
return frame;
|
1145 |
} |
1146 |
|
1147 |
/**
|
1148 |
* Obtiene el gestor de puntos
|
1149 |
* @return PointManager
|
1150 |
*/
|
1151 |
public PointManager getPointManager() {
|
1152 |
return pointManager;
|
1153 |
} |
1154 |
|
1155 |
/**
|
1156 |
* Activa o desactiva este panel y todos los que lo componen
|
1157 |
* @param enabled variable booleana para la activaci?n y/o desactivaci?n
|
1158 |
*/
|
1159 |
public void setEnabled(boolean enabled){ |
1160 |
conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().setEnabled(enabled); |
1161 |
conectorPanel.getAdjustGeorefPanel().setEnabled(enabled); |
1162 |
} |
1163 |
|
1164 |
/**
|
1165 |
* M?todo para notificar si se desea crear o no el fichero de coordenadas .tfw, .wld .jpgw ,...
|
1166 |
* @param createWorldFile
|
1167 |
*/
|
1168 |
public void setCreateWorldFile(boolean createWorldFile) { |
1169 |
this.createWorldFile = createWorldFile;
|
1170 |
} |
1171 |
|
1172 |
/**
|
1173 |
*
|
1174 |
*/
|
1175 |
public ViewPort getLeftInitViewport(ViewPort vp, Point2D center, ViewPort initVp, double zoom){ |
1176 |
return getZoomControlLeft().getCanvas().initViewPort(vp, center, initVp, zoom);
|
1177 |
} |
1178 |
|
1179 |
/**
|
1180 |
* Consulta si se desea incluir los errores cuando se exporta a fichero .csv
|
1181 |
* @param errorCVS true si se incluyen los errores dentro del fichero y false si no se incluyen
|
1182 |
*/
|
1183 |
public boolean isErrorCSV() { |
1184 |
return errorCSV;
|
1185 |
} |
1186 |
|
1187 |
/**
|
1188 |
* M?todo para notificar si se desea incluir los errores cuando se exporta a fichero .csv
|
1189 |
* @param errorCVS true si se incluyen los errores dentro del fichero y false si no se incluyen
|
1190 |
*/
|
1191 |
public void setErrorCSV(boolean errorCSV) { |
1192 |
this.errorCSV = errorCSV;
|
1193 |
} |
1194 |
|
1195 |
/**
|
1196 |
* Obtiene los errores en una matriz de Nx3 en la que cada fila es un punto y la
|
1197 |
* columna 0 es el error en X, la columna 1 es el error en Y y la columna 2 es el error RMS.
|
1198 |
* @return matriz de errores
|
1199 |
*/
|
1200 |
public double[][] getErrors(){ |
1201 |
return pointManager.getErrors();
|
1202 |
} |
1203 |
//**********************End Setters & Getters*****************
|
1204 |
|
1205 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
1206 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|
1207 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|