Revision 18590

View differences:

trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/view/ViewDialog.java
29 29
import org.gvsig.georeferencing.ui.zoom.ViewListener;
30 30
import org.gvsig.georeferencing.ui.zoom.layers.ZoomCursorGraphicLayer;
31 31
import org.gvsig.georeferencing.ui.zoom.tools.ToolListener;
32
import org.gvsig.raster.util.RasterToolsUtil;
32 33

  
33 34
import com.iver.andami.PluginServices;
34 35
import com.iver.andami.ui.mdiManager.IWindow;
......
224 225
	 */
225 226
	public Rectangle2D getCursorAdjustedWorldCoordinates(int wWindow, int hWindow) {
226 227
		Rectangle2D r = getZoomCursorGraphicLayer().getCursorViewCoordinates();
227

  
228 228
		double x = r.getX(), y = r.getY(), w = r.getWidth(), h = r.getHeight();
229
		if(wWindow < hWindow) { //Si la de destino es m?s alta que ancha
230
			if((r.getWidth() / r.getHeight()) >= (wWindow / hWindow)) {
231
				h = (hWindow * r.getWidth()) / wWindow;
232
				y = r.getCenterY() - (h / 2);
233
			} else {
234
				w = (wWindow * r.getHeight()) / hWindow;
235
				x = r.getCenterX() - (w / 2);
229
		
230
		try {
231
			if(wWindow < hWindow) { //Si la de destino es m?s alta que ancha
232
				if((r.getWidth() / r.getHeight()) >= (wWindow / hWindow)) {
233
					h = (hWindow * r.getWidth()) / wWindow;
234
					y = r.getCenterY() - (h / 2);
235
				} else {
236
					w = (wWindow * r.getHeight()) / hWindow;
237
					x = r.getCenterX() - (w / 2);
238
				}
239
			} else { //Si la de destino es m?s ancha que alta
240
				if((r.getWidth() / r.getHeight()) <= (wWindow / hWindow)) {
241
					w = (wWindow * r.getHeight()) / hWindow;
242
					x = r.getCenterX() - (w / 2);
243
				} else {
244
					h = (hWindow * r.getWidth()) / wWindow;
245
					y = r.getCenterY() - (h / 2);
246
				}
236 247
			}
237
		} else { //Si la de destino es m?s ancha que alta
238
			if((r.getWidth() / r.getHeight()) <= (wWindow / hWindow)) {
239
				w = (wWindow * r.getHeight()) / hWindow;
240
				x = r.getCenterX() - (w / 2);
241
			} else {
242
				h = (hWindow * r.getWidth()) / wWindow;
243
				y = r.getCenterY() - (h / 2);
244
			}
248
		}catch(ArithmeticException ex) {
249
			RasterToolsUtil.debug("Redimensi?n de las ventanas. La altura de estas es menor que cero", this, ex);
250
			return r;
245 251
		}
246 252
		if(zoomPixelControl.getCanvas().getMinxMaxyUL())
247 253
			r = new Rectangle2D.Double(x, y + h, w, h);
trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/ui/table/GCPTablePanel.java
22 22
import java.awt.Dimension;
23 23
import java.awt.GridBagConstraints;
24 24
import java.awt.GridBagLayout;
25
import java.awt.event.ComponentEvent;
26
import java.awt.event.ComponentListener;
25 27
import java.awt.geom.Point2D;
26 28
import java.util.ArrayList;
27 29

  
......
29 31
import javax.swing.JPanel;
30 32
import javax.swing.JToggleButton;
31 33
import javax.swing.table.DefaultTableModel;
34
import javax.swing.table.TableColumn;
32 35

  
33 36
import org.gvsig.georeferencing.main.ApplicationControlsListener;
37
import org.gvsig.georeferencing.main.Georeferencing;
38
import org.gvsig.georeferencing.process.geotransform.GeoTransformDataResult;
39
import org.gvsig.georeferencing.process.geotransform.GeoTransformProcess;
40
import org.gvsig.gui.beans.datainput.DataInputContainer;
34 41
import org.gvsig.gui.beans.table.TableContainer;
35 42
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
36 43
import org.gvsig.gui.beans.table.models.GCPModel;
44
import org.gvsig.raster.datastruct.GeoPoint;
37 45
import org.gvsig.raster.util.RasterToolsUtil;
38 46

  
39 47
import com.iver.andami.PluginServices;
......
46 54
 * 22/12/2007
47 55
 * @author Nacho Brodin (nachobrodin@gmail.com)
48 56
 */
49
public class GCPTablePanel extends JPanel implements IWindow {
57
public class GCPTablePanel extends JPanel implements IWindow, ComponentListener {
50 58
	private static final long             serialVersionUID    = 1L;
51 59
	private String[]                      columnNames         = {"-", "N?", "X", "Y", "X'", "Y'", "Error X", "Error Y", "RMS", "-"};
52 60
	private int[]                         columnWidths        = {25, 25, 90, 90, 90, 90, 50, 50, 50, 0};
......
54 62
	
55 63
	private JPanel                        buttonsPanel        = null;
56 64
	private ApplicationControlsListener   buttonsListener     = null;
57
	private JButton                       saveToXml           = null;
58
	private JButton                       loadFromXml         = null;
59
	private JButton                       saveToAscii         = null;
60
	private JButton                       loadFromAscii       = null;
61
	private JButton                       options             = null;
62
	private JButton                       process             = null;
63
	private JButton                       endGeoref           = null;
64
	private JButton                       centerView          = null;
65
	private JToggleButton                 addPoint            = null;
65
	private JButton                       bSaveToXml           = null;
66
	private JButton                       bLoadFromXml         = null;
67
	private JButton                       bSaveToAscii         = null;
68
	private JButton                       bLoadFromAscii       = null;
69
	private JButton                       bOptions             = null;
70
	private JButton                       bProcess             = null;
71
	private JButton                       bEndGeoref           = null;
72
	private JButton                       bCenterView          = null;
73
	private JToggleButton                 bAddPoint            = null;
74
	private DataInputContainer            error                = null;
66 75
	
67 76
	private int                           w                   = 640;
68 77
	private int                           h                   = 100;
69 78
	private int                           posX                = 0;
70 79
	private int                           posY                = 0;
80
	private GeoTransformProcess           process             = null;
81
	private Georeferencing                appMain             = null;
71 82
	
72 83
	/**
73 84
	 * Constructor.
74 85
	 * Crea la composici?n de controles de zoom.
75 86
	 */
76
	public GCPTablePanel(int posX, int posY, int w, int h) {
87
	public GCPTablePanel(int posX, int posY, int w, int h, Georeferencing appMain) {
77 88
		setPosition(posX, posY);
78 89
		setWindowsSize(w, h);
90
		this.appMain = appMain;
79 91
	}
80 92
		
81 93
	/**
......
84 96
	 */
85 97
	public void initialize(ApplicationControlsListener listener) {
86 98
		this.buttonsListener = listener;
99
		process = new GeoTransformProcess();
100
		this.addComponentListener(this);
87 101
		try {
88 102
			init();
89 103
		} catch (NotInitializeException e) {
......
148 162
			table.setEditable(true);
149 163
			table.getTable().getJTable().getColumnModel().getColumn(columnNames.length - 1).setMinWidth(0);
150 164
			table.getTable().getJTable().getColumnModel().getColumn(columnNames.length - 1).setMaxWidth(0);
165
			table.getTable().getJTable().getColumnModel().getColumn(0).setMinWidth(26);
166
			table.getTable().getJTable().getColumnModel().getColumn(0).setMaxWidth(26);
167
			table.getTable().getJTable().getColumnModel().getColumn(1).setMinWidth(26);
168
			table.getTable().getJTable().getColumnModel().getColumn(1).setMaxWidth(26);
151 169
			table.getModel().addTableModelListener(buttonsListener);
152 170
		}
153 171
		return table;
......
199 217
			gb.gridy = 2;
200 218
			gb.gridx = 0;
201 219
			buttonsPanel.add(getCenterButton(), gb);
220
			
221
			gb.gridy = 3;
222
			gb.gridx = 0;
223
			gb.gridwidth = 4;
224
			buttonsPanel.add(getError(), gb);
202 225
		}
203 226
		return buttonsPanel;
204 227
	}
205 228
	
206 229
	/**
230
	 * Obtiene el objeto con el error total
231
	 * @return
232
	 */
233
	public DataInputContainer getError() {
234
		if(error == null) {
235
			error = new DataInputContainer();
236
			error.setLabelText("RMS");
237
			error.setPreferredSize(new Dimension(90, 35));
238
		}
239
		return error;
240
	}
241
	
242
	/**
207 243
	 * Obtiene el bot?n de finalizar georreferenciaci?n. Si no existe se crea.
208 244
	 * @return JButton
209 245
	 */
210 246
	public JButton getEndGeorefButton() {
211
		if(endGeoref == null) {
212
			endGeoref = new JButton();
213
			endGeoref.setPreferredSize(new Dimension(22, 19));
214
			endGeoref.setIcon(RasterToolsUtil.getIcon("exit-icon"));
215
			endGeoref.setToolTipText(RasterToolsUtil.getText(this, "end_georef"));
216
			endGeoref.addActionListener(buttonsListener);
247
		if(bEndGeoref == null) {
248
			bEndGeoref = new JButton();
249
			bEndGeoref.setPreferredSize(new Dimension(22, 19));
250
			bEndGeoref.setIcon(RasterToolsUtil.getIcon("exit-icon"));
251
			bEndGeoref.setToolTipText(RasterToolsUtil.getText(this, "end_georef"));
252
			bEndGeoref.addActionListener(buttonsListener);
217 253
		}
218
		return endGeoref;
254
		return bEndGeoref;
219 255
	}
220 256
	
221 257
	/**
......
223 259
	 * @return JButton
224 260
	 */
225 261
	public JButton getProcessButton() {
226
		if(endGeoref == null) {
227
			process = new JButton();
228
			process.setPreferredSize(new Dimension(22, 19));
229
			process.setToolTipText(RasterToolsUtil.getText(this, "process"));
230
			process.addActionListener(buttonsListener);
231
			process.setIcon(RasterToolsUtil.getIcon("process-icon"));
262
		if(bProcess == null) {
263
			bProcess = new JButton();
264
			bProcess.setPreferredSize(new Dimension(22, 19));
265
			bProcess.setToolTipText(RasterToolsUtil.getText(this, "process"));
266
			bProcess.addActionListener(buttonsListener);
267
			bProcess.setIcon(RasterToolsUtil.getIcon("process-icon"));
232 268
		}
233
		return process;
269
		return bProcess;
234 270
	}
235 271
		
236 272
	/**
......
238 274
	 * @return JButton
239 275
	 */
240 276
	public JButton getLoadFromCSVButton() {
241
		if(endGeoref == null) {
242
			loadFromAscii = new JButton();
243
			loadFromAscii.setPreferredSize(new Dimension(22, 19));
244
			loadFromAscii.setToolTipText(RasterToolsUtil.getText(this, "load_from_ascii"));
245
			loadFromAscii.addActionListener(buttonsListener);
246
			loadFromAscii.setIcon(RasterToolsUtil.getIcon("importfromcsv-icon"));
277
		if(bLoadFromAscii == null) {
278
			bLoadFromAscii = new JButton();
279
			bLoadFromAscii.setPreferredSize(new Dimension(22, 19));
280
			bLoadFromAscii.setToolTipText(RasterToolsUtil.getText(this, "load_from_ascii"));
281
			bLoadFromAscii.addActionListener(buttonsListener);
282
			bLoadFromAscii.setIcon(RasterToolsUtil.getIcon("importfromcsv-icon"));
247 283
		}
248
		return loadFromAscii;
284
		return bLoadFromAscii;
249 285
	}
250 286
	
251 287
	/**
......
253 289
	 * @return JButton
254 290
	 */
255 291
	public JButton getExporToCSVButton() {
256
		if(endGeoref == null) {
257
			saveToAscii = new JButton();
258
			saveToAscii.setPreferredSize(new Dimension(22, 19));
259
			saveToAscii.setToolTipText(RasterToolsUtil.getText(this, "save_to_ascii"));
260
			saveToAscii.addActionListener(buttonsListener);
261
			saveToAscii.setIcon(RasterToolsUtil.getIcon("exporttocsv-icon"));
292
		if(bSaveToAscii == null) {
293
			bSaveToAscii = new JButton();
294
			bSaveToAscii.setPreferredSize(new Dimension(22, 19));
295
			bSaveToAscii.setToolTipText(RasterToolsUtil.getText(this, "save_to_ascii"));
296
			bSaveToAscii.addActionListener(buttonsListener);
297
			bSaveToAscii.setIcon(RasterToolsUtil.getIcon("exporttocsv-icon"));
262 298
		}
263
		return saveToAscii;
299
		return bSaveToAscii;
264 300
	}
265 301
	
266 302
	/**
......
268 304
	 * @return JButton
269 305
	 */
270 306
	public JButton getLoadFromXMLButton() {
271
		if(endGeoref == null) {
272
			loadFromXml = new JButton();
273
			loadFromXml.setPreferredSize(new Dimension(22, 19));
274
			loadFromXml.setToolTipText(RasterToolsUtil.getText(this, "load_from_xml"));
275
			loadFromXml.addActionListener(buttonsListener);
276
			loadFromXml.setIcon(RasterToolsUtil.getIcon("tfwload-icon"));
307
		if(bLoadFromXml == null) {
308
			bLoadFromXml = new JButton();
309
			bLoadFromXml.setPreferredSize(new Dimension(22, 19));
310
			bLoadFromXml.setToolTipText(RasterToolsUtil.getText(this, "load_from_xml"));
311
			bLoadFromXml.addActionListener(buttonsListener);
312
			bLoadFromXml.setIcon(RasterToolsUtil.getIcon("tfwload-icon"));
277 313
		}
278
		return loadFromXml;
314
		return bLoadFromXml;
279 315
	}
280 316
	
281 317
	/**
......
283 319
	 * @return JButton
284 320
	 */
285 321
	public JButton getSaveToXMLButton() {
286
		if(endGeoref == null) {
287
			saveToXml = new JButton();
288
			saveToXml.setPreferredSize(new Dimension(22, 19));
289
			saveToXml.setToolTipText(RasterToolsUtil.getText(this, "save_to_xml"));
290
			saveToXml.addActionListener(buttonsListener);
291
			saveToXml.setIcon(RasterToolsUtil.getIcon("save-icon"));
322
		if(bSaveToXml == null) {
323
			bSaveToXml = new JButton();
324
			bSaveToXml.setPreferredSize(new Dimension(22, 19));
325
			bSaveToXml.setToolTipText(RasterToolsUtil.getText(this, "save_to_xml"));
326
			bSaveToXml.addActionListener(buttonsListener);
327
			bSaveToXml.setIcon(RasterToolsUtil.getIcon("save-icon"));
292 328
		}
293
		return saveToXml;
329
		return bSaveToXml;
294 330
	}
295 331
	
296 332
	/**
......
298 334
	 * @return JButton
299 335
	 */
300 336
	public JButton getOptionsButton() {
301
		if(endGeoref == null) {
302
			options = new JButton();
303
			options.setPreferredSize(new Dimension(22, 19));
304
			options.setToolTipText(RasterToolsUtil.getText(this, "options"));
305
			options.addActionListener(buttonsListener);
306
			options.setIcon(RasterToolsUtil.getIcon("options-icon"));
337
		if(bOptions == null) {
338
			bOptions = new JButton();
339
			bOptions.setPreferredSize(new Dimension(22, 19));
340
			bOptions.setToolTipText(RasterToolsUtil.getText(this, "options"));
341
			bOptions.addActionListener(buttonsListener);
342
			bOptions.setIcon(RasterToolsUtil.getIcon("options-icon"));
307 343
		}
308
		return options;
344
		return bOptions;
309 345
	}
310 346
	
311 347
	/**
312
	 * Obtiene el bot?n de procesar georreferenciaci?n. Si no existe se crea.
348
	 * Obtiene el bot?n de asignar el punto de control seleccionado en la tabla sobre 
349
	 * una posici?n de la vista. Si no existe se crea.
313 350
	 * @return JButton
314 351
	 */
315 352
	public JToggleButton getToolSelectPointButton() {
316
		if(addPoint == null) {
317
			addPoint = new JToggleButton();
318
			addPoint.setPreferredSize(new Dimension(22, 19));
319
			addPoint.setToolTipText(RasterToolsUtil.getText(this, "add-point"));
320
			addPoint.addActionListener(buttonsListener);
321
			addPoint.setIcon(RasterToolsUtil.getIcon("add-icon"));
353
		if(bAddPoint == null) {
354
			bAddPoint = new JToggleButton();
355
			bAddPoint.setPreferredSize(new Dimension(22, 19));
356
			bAddPoint.setToolTipText(RasterToolsUtil.getText(this, "add-point"));
357
			bAddPoint.addActionListener(buttonsListener);
358
			bAddPoint.setIcon(RasterToolsUtil.getIcon("add-icon"));
322 359
		}
323
		return addPoint;
360
		return bAddPoint;
324 361
	}
325 362
	
326 363
	/**
......
328 365
	 * @return JButton
329 366
	 */
330 367
	public JButton getCenterButton() {
331
		if(centerView == null) {
332
			centerView = new JButton();
333
			centerView.setPreferredSize(new Dimension(22, 19));
334
			centerView.setToolTipText(RasterToolsUtil.getText(this, "center_view"));
335
			centerView.addActionListener(buttonsListener);
336
			centerView.setIcon(RasterToolsUtil.getIcon("centerpoint-icon"));
368
		if(bCenterView == null) {
369
			bCenterView = new JButton();
370
			bCenterView.setPreferredSize(new Dimension(22, 19));
371
			bCenterView.setToolTipText(RasterToolsUtil.getText(this, "center_view"));
372
			bCenterView.addActionListener(buttonsListener);
373
			bCenterView.setIcon(RasterToolsUtil.getIcon("centerpoint-icon"));
337 374
		}
338
		return centerView;
375
		return bCenterView;
339 376
	}
340 377
	
378
	public void componentHidden(ComponentEvent e) {
379
	}
380

  
381
	public void componentMoved(ComponentEvent e) {
382
	}
383

  
384
	public void componentShown(ComponentEvent e) {
385
	}
386
	
387
	/**
388
	 * Cuando la tabla tiene un tama?o mayor de 800 pixeles de ancho se muestran las 
389
	 * columnas de error en X e Y que cuando est? minimizada no aparecen.
390
	 */
391
	public void componentResized(ComponentEvent e) {
392
		try {
393
			Dimension dim = ((GCPTablePanel)e.getSource()).getSize();
394
			if(dim.getWidth() <= 800) {
395
				TableColumn col = getTable().getTable().getJTable().getColumnModel().getColumn(6);
396
				col.setMinWidth(0);
397
				col.setMaxWidth(0);
398
				col = getTable().getTable().getJTable().getColumnModel().getColumn(7);
399
				col.setMinWidth(0);
400
				col.setMaxWidth(0);
401
			} else {
402
				TableColumn col = getTable().getTable().getJTable().getColumnModel().getColumn(6);
403
				col.setMaxWidth(110);
404
				col.setMinWidth(110);
405
				col = getTable().getTable().getJTable().getColumnModel().getColumn(7);
406
				col.setMaxWidth(110);
407
				col.setMinWidth(110);
408
			}
409
			getTable().getTable().invalidate();
410
		} catch (NotInitializeException ex) {
411
			return;
412
		}
413
	}
414

  
341 415
	/*
342 416
	 * (non-Javadoc)
343 417
	 * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
......
459 533
			RasterToolsUtil.messageBoxYesOrNot("table_not_initialize", table);
460 534
		}
461 535
	}
536
	
537
	/**
538
	 * Asigna una valor a una celda de la tabla
539
	 * @param value Valor a asignar
540
	 * @param row Fila
541
	 * @param col Columna
542
	 */
543
	public void setValueAt(Object value, int row, int col) {
544
		try {
545
			getTable().setValueAt(value, row, col);
546
		} catch (NotInitializeException e) {
547
			RasterToolsUtil.messageBoxError("table_not_initialize", this, e);
548
		}
549
	}
550
	
551
	/**
552
	 * Asigna un valor al punto en coordenadas raster de la tabla. Es recomendable gastar este y no 
553
	 * setValueAt para evitar que se recalculen los errores en cada inserci?n de cada celda. De esta
554
	 * forma al actualiza ambas coordenadas a la vez solo se calcular? el error una vez.
555
	 * @param valueX Valor en X
556
	 * @param valueY Valor en Y
557
	 * @param row Fila a actualizar
558
	 * @param col Columna a actualizar
559
	 */
560
	public void updateRasterPoint(Object valueX, Object valueY, int row) {
561
		try {
562
			getTable().setValueAt(valueX, row, 4);
563
			getTable().setValueAt(valueY, row, 5);
564
			updateErrors();
565
		} catch (NotInitializeException e) {
566
			RasterToolsUtil.messageBoxError("table_not_initialize", this, e);
567
		}
568
	}
569
	
570
	/**
571
	 * Asigna un valor al punto en coordenadas del mundo de la tabla. Es recomendable gastar este y no 
572
	 * setValueAt para evitar que se recalculen los errores en cada inserci?n de cada celda. De esta
573
	 * forma al actualiza ambas coordenadas a la vez solo se calcular? el error una vez.
574
	 * @param valueX Valor en X
575
	 * @param valueY Valor en Y
576
	 * @param row Fila a actualizar
577
	 * @param col Columna a actualizar
578
	 */
579
	public void updateMapPoint(Object valueX, Object valueY, int row) {
580
		try {
581
			getTable().setValueAt(valueX, row, 2);
582
			getTable().setValueAt(valueY, row, 3);
583
			updateErrors();
584
		} catch (NotInitializeException e) {
585
			RasterToolsUtil.messageBoxError("table_not_initialize", this, e);
586
		}
587
	}
588
	
589
	/**
590
	 * Asigna un valor al punto de la tabla. Es recomendable gastar este y no 
591
	 * setValueAt para evitar que se recalculen los errores en cada inserci?n de cada celda. De esta
592
	 * forma al actualiza ambas coordenadas a la vez solo se calcular? el error una vez.
593
	 * @param mapX Valor en X en coordenadas del mundo
594
	 * @param mapY Valor en Y en coordenadas del mundo
595
	 * @param pixelX Valor en X en coordenadas del raster
596
	 * @param pixelY Valor en Y en coordenadas del raster
597
	 * @param row Fila a actualizar
598
	 * @param col Columna a actualizar
599
	 */
600
	public void updatePoint(Object mapX, Object mapY, Object pixelX, Object pixelY, int row) {
601
		try {
602
			getTable().setValueAt(mapX, row, 2);
603
			getTable().setValueAt(mapY, row, 3);
604
			getTable().setValueAt(pixelX, row, 4);
605
			getTable().setValueAt(pixelY, row, 5);
606
			updateErrors();
607
		} catch (NotInitializeException e) {
608
			RasterToolsUtil.messageBoxError("table_not_initialize", this, e);
609
		}
610
	}
611
	
612
	/**
613
	 * Actualiza los errores de toda la tabla. Esta funci?n debe ser llamada cuando ha
614
	 * habido alg?n cambio en los valores de los puntos.
615
	 * @throws NotInitializeException
616
	 */
617
	public void updateErrors() {
618
		GeoPoint[] gpList = appMain.getLayerPointManager().getGeoPoints();			
619
		process.addParam("gpcs", gpList);
620
		process.addParam("orden", new Integer(appMain.getOptions().getDegree()));
621
		try {
622
			process.execute();
623
		} catch (InterruptedException e) {
624
			return;
625
		} catch(RuntimeException e) {
626
			//Matriz singular
627
			return;
628
		}
629
		GeoTransformDataResult result = (GeoTransformDataResult)process.getResult();
630
		if(result == null)
631
			return;
632
		
633
		//Actualizamos los errores de toda la tabla
634
		try {
635
			for (int i = 0; i < gpList.length; i++) {
636
				getTable().setValueAt(new Double(result.getXError()[gpList[i].number]), gpList[i].number, 6);
637
				getTable().setValueAt(new Double(result.getYError()[gpList[i].number]), gpList[i].number, 7);
638
				getTable().setValueAt(new Double(result.getRms()[gpList[i].number]), gpList[i].number, 8);	
639
			}
640
		} catch (NotInitializeException e) {
641
			RasterToolsUtil.messageBoxError("table_not_initialize", this, e);
642
		}
643
	}
644
	
645
	/**
646
	 * Obtiene una valor de una celda de la tabla
647
	 * @param row Fila
648
	 * @param col Columna
649
	 * @return Valor obtenido
650
	 */
651
	public Object getValueAt(int row, int col) {
652
		try {
653
			return getTable().getModel().getValueAt(row, col);
654
		} catch (NotInitializeException e) {
655
			RasterToolsUtil.messageBoxError("table_not_initialize", this, e);
656
		}
657
		return null;
658
	}
659
	
660
	/**
661
	 * Obtiene el n?mero de filas de la tabla
662
	 * @return Entero que representa el n?mero de filas de la tabla
663
	 */
664
	public int getRowCount() {
665
		try {
666
			return getTable().getRowCount();
667
		} catch (NotInitializeException e) {
668
			RasterToolsUtil.messageBoxError("table_not_initialize", this, e);
669
		}
670
		return 0;
671
	}
672
	
673
	/**
674
	 * Obtiene el n?mero de columnas de la tabla
675
	 * @return Entero que representa el n?mero de columnas de la tabla
676
	 */
677
	public int getColumnCount() {
678
		try {
679
			return getTable().getModel().getColumnCount();
680
		} catch (NotInitializeException e) {
681
			RasterToolsUtil.messageBoxError("table_not_initialize", this, e);
682
		}
683
		return 0;
684
	}
685
	
686
	/**
687
	 * Inicializa una fila de la tabla con los valores a 0, el n?mero de punto
688
	 * y el identificador. Esto es util para la inserci?n de un nuevo punto antes
689
	 * de introducir sus coordenadas.
690
	 * @param row Fila a inicializar
691
	 * @param id Identificador
692
	 */
693
	public void initializeRow(int row, long id) {
694
		try {
695
			getTable().setValueAt(new Integer(row), row, 1);
696
			for (int i = 2; i <= 9; i++) 
697
				getTable().setValueAt(new Double(0), row, i);
698
			getTable().setValueAt(new Long(id), row, getColumnCount() - 1);
699
		} catch (NotInitializeException e) {
700
			RasterToolsUtil.messageBoxError("table_not_initialize", this, e);
701
		}
702
	}
703

  
704
	
462 705
}
463 706

  
trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/process/geotransform/GeoTransformProcess.java
127 127
		return (gpcs.length>=minGPC);
128 128
	}
129 129

  
130
	/**
131
	 * Obtiene el resultado del proceso.
132
	 * @return
133
	 */
134
	public Object getResult() {
135
		return resultData;
136
	}
130 137
	
131 138
	/**
132 139
	 *  Proceso
......
157 164
			
158 165
			if(externalActions!=null)
159 166
				externalActions.end(resultData);
167
			return;
160 168
		}
169
		resultData = null;
161 170
	}
162 171

  
163 172

  
trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/main/GeoPointsPersistence.java
81 81
			if(!RasterToolsUtil.messageBoxYesOrNot("eliminar_puntos", null))
82 82
				return;
83 83
			
84
			//Eliminamos los puntos existentes
85
			layerPointsManager.removeAllPoints();
86
			tablePanel.removeAllPoints();
87
			
88
			//Cargamos los puntos le?dos del RMF
84 89
			GeoPoint[] pointList = dataset.loadGeoPointsFromRmf();
85 90
			for (int i = 0; i < pointList.length; i++) {
86 91
				long id = layerPointsManager.addPoint(pointList[i].mapPoint, pointList[i].pixelPoint);
87 92
				tablePanel.addRow(true, pointList[i].mapPoint, pointList[i].pixelPoint, 0, 0, 0, 0, id);
88 93
			}
89
			layerPointsManager.calcPointsNumeration(tablePanel.getTable());
94
			layerPointsManager.calcPointsNumeration(tablePanel);
95
			tablePanel.updateErrors();
90 96
		} catch (IOException e) {
91 97
			RasterToolsUtil.messageBoxYesOrNot("error_salvando_rmf", null);
92 98
		} catch (NotInitializeException e) {
......
141 147
			}
142 148
			if(!RasterToolsUtil.messageBoxYesOrNot("eliminar_puntos", null))
143 149
				return;
144
			loadCSVPointList(f.getAbsolutePath(), layerPointsManager, tablePanel);			
150
			loadCSVPointList(f.getAbsolutePath(), layerPointsManager, tablePanel);
151
			tablePanel.updateErrors();
145 152
		}
146 153
	}
147 154
	
......
238 245
				line = in.readLine();
239 246
			}
240 247
			in.close();
241
			layerPointsManager.calcPointsNumeration(tablePanel.getTable());
248
			layerPointsManager.calcPointsNumeration(tablePanel);
242 249
		} catch(FileNotFoundException ex){
243 250
			//No salvamos el csv
244 251
		} catch(IOException ex){
trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/main/ApplicationControlsListener.java
180 180
			return;
181 181
		setEnableTableEvent(false);
182 182
		try{
183
			
184
			//-----------------------------------
185
			//Inserci?n de nuevo fila en la tabla
183 186
			if(e.getType() == TableModelEvent.INSERT) {
184
				tablePanel.getTable().setValueAt(new Integer(e.getFirstRow()), e.getFirstRow(), 1);
185
				for (int i = 2; i <= 5; i++) 
186
					tablePanel.getTable().setValueAt(new Double(0), e.getFirstRow(), i);
187 187
				long id = getPointManager().addPoint(new Point2D.Double(0, 0), new Point2D.Double(0, 0));
188
				tablePanel.getTable().setValueAt(new Long(id), e.getFirstRow(), tablePanel.getTable().getModel().getColumnCount() - 1);
189
				getPointManager().calcPointsNumeration(tablePanel.getTable());
188
				tablePanel.initializeRow(e.getFirstRow(), id);
189
				getPointManager().calcPointsNumeration(tablePanel);
190 190
				newPointCreated = true;
191 191
			}
192 192
			
193
			//-----------------------------
194
			//Eliminado de fila de la tabla
193 195
			if(e.getType() == TableModelEvent.DELETE) {
194 196
				for (int i = e.getLastRow(); i >= e.getFirstRow(); i--) 
195 197
					getPointManager().removePoint(i);
196
				getPointManager().calcPointsNumeration(tablePanel.getTable());
198
				getPointManager().calcPointsNumeration(tablePanel);
197 199
			}
198 200
			
201
			//-------------------------------------
202
			//Actualizaci?n de una fila de la tabla
199 203
			if(e.getType() == TableModelEvent.UPDATE) {
200
				getPointManager().calcPointsNumeration(tablePanel.getTable());
204
				getPointManager().calcPointsNumeration(tablePanel);
201 205
				//Revisamos el flag de activo de cada punto poniendo el valor que pone en la entrada de la tabla
202 206
				for (int i = 0; i < getPointManager().getPointList().size(); i++) {
203
					boolean active = ((Boolean)tablePanel.getTable().getModel().getValueAt(i, 0)).booleanValue();
207
					boolean active = ((Boolean)tablePanel.getValueAt(i, 0)).booleanValue();
204 208
					getPointManager().setVisiblePoint(active, i);
205 209
					
206 210
					//Para la funcionalidad de cambio de coordenadas desde la tabla: reasignamos el valor 
......
222 226
	 * Eventos de los botones del cuadro de opciones
223 227
	 */
224 228
	public void actionButtonPressed(ButtonsPanelEvent e) {
225
		//Bot?n de Aplicar y Aceptar. Asignamos las propiedades seleccionadas
229
		
230
		//---------------------------------------------------
231
		//Bot?n de Aplicar y Aceptar en el cuadro de opciones
226 232
		if (e.getButton() == ButtonsPanel.BUTTON_APPLY || e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
227 233
			if(optionsDialog != null) {
234
				//Asignamos las propiedades seleccionadas
228 235
				getOptions().setAlgorithm(optionsDialog.getAlgorithm());
229 236
				getOptions().setDegree(optionsDialog.getDegree());
230 237
				getOptions().setBackgroundColor(optionsDialog.getBackGroundColor());
......
239 246
			}
240 247
		}
241 248

  
242
		// Bot?n de Cerrar y Aceptar
249
		//--------------------------------------------------
250
		// Bot?n de Cerrar y Aceptar en el cuadro de opciones
243 251
		if (e.getButton() == ButtonsPanel.BUTTON_CANCEL || e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
244 252
			if(optionsDialog != null)
245 253
				PluginServices.getMDIManager().closeWindow(optionsDialog);
trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/main/Georeferencing.java
168 168
		closeAllWindows();
169 169
		
170 170
		//Inicializaci?n de la tabla
171
		table = new GCPTablePanel(0, posYViews, tableWidth, smallWindowsHeight);
171
		table = new GCPTablePanel(0, posYViews, tableWidth, smallWindowsHeight, this);
172 172
		buttonsListener = new ApplicationControlsListener(table, this);
173 173
		table.initialize(buttonsListener);
174 174
				
......
252 252
		}
253 253
		
254 254
		//Inicializamos el control de tabla
255
		table = new GCPTablePanel(smallWindowsWidth, posYViews, tableWidth, smallWindowsHeight);
255
		table = new GCPTablePanel(smallWindowsWidth, posYViews, tableWidth, smallWindowsHeight, this);
256 256
		buttonsListener = new ApplicationControlsListener(table, this);
257 257
		table.initialize(buttonsListener);
258 258
				
......
373 373
	 * inicial con las propiedades de georreferenciaci?n.
374 374
	 */
375 375
	public void actionButtonPressed(ButtonsPanelEvent e) {
376
		
377
		//-----------------
376 378
		// Bot?n de Aceptar
377 379
		if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
378 380
			if(initDialog != null) {
......
394 396
				}
395 397
			}
396 398
		}
399
		
400
		//----------------
397 401
		// Bot?n de Cerrar
398 402
		if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
399 403
			if(initDialog != null)
......
407 411
	 * la terminaci?n de la operaci?n de mover punto
408 412
	 */
409 413
	public void endAction(ToolEvent ev) {
414
		
415
		//-----------------
410 416
		//Operaci?n de zoom
411 417
		if(ev.getSource() instanceof ZoomCursorGraphicLayer) {
412 418
			try {	
......
424 430
			}
425 431
		}
426 432
		
433
		//-----------
427 434
		//Mover punto
428 435
		if(ev.getSource() instanceof GCPsGraphicLayer) {
429 436
			buttonsListener.setEnableTableEvent(false);
......
434 441
			Point2D pRaster = gPoint.getGeoPoint().pixelPoint;
435 442
			Point2D pMap = gPoint.getGeoPoint().mapPoint;
436 443
			try {
437
				table.getTable().setValueAt(new Double(pMap.getX()), gPoint.getGeoPoint().number, 2);
438
				table.getTable().setValueAt(new Double(pMap.getY()), gPoint.getGeoPoint().number, 3);
439
				table.getTable().setValueAt(new Double(pRaster.getX()), gPoint.getGeoPoint().number, 4);
440
				table.getTable().setValueAt(new Double(pRaster.getY()), gPoint.getGeoPoint().number, 5);
444
				table.updatePoint(	new Double(pMap.getX()), 
445
									new Double(pMap.getY()), 
446
									new Double(pRaster.getX()), 
447
									new Double(pRaster.getY()), 
448
									gPoint.getGeoPoint().number);
441 449
				table.getTable().getTable().getJTable().setRowSelectionInterval(gPoint.getGeoPoint().number, gPoint.getGeoPoint().number);
442 450
			} catch (NotInitializeException e) {
443 451
				RasterToolsUtil.messageBoxError("no_rows_selected", table, e);
......
449 457
			buttonsListener.setEnableTableEvent(true);
450 458
		}
451 459
		
460
		//------------------
452 461
		//Selecci?n de punto
453 462
		if(ev.getSource() instanceof SelectPointTool) {
454 463
			try {
......
458 467
				
459 468
				if(ev.getSource() == viewRasterSelectPointTool || ev.getSource() == zoomRasterSelectPointTool) {
460 469
					Point2D[] p = (Point2D[])((SelectPointTool)ev.getSource()).getResult();
461
					table.getTable().setValueAt(new Double(p[1].getX()), nPoint, 4);
462
					table.getTable().setValueAt(new Double(p[1].getY()), nPoint, 5);
470
					table.updateRasterPoint(new Double(p[1].getX()), new Double(p[1].getY()), nPoint);
463 471
					if(gp != null) {
464 472
						gp.pixelPoint = p[1];
465 473
						layersPointManager.redrawPoints();
......
467 475
				}
468 476
				if(ev.getSource() == viewMapSelectPointTool || ev.getSource() == zoomMapSelectPointTool) {
469 477
					Point2D[] p = (Point2D[])((SelectPointTool)ev.getSource()).getResult();
470
					table.getTable().setValueAt(new Double(p[1].getX()), nPoint, 2);
471
					table.getTable().setValueAt(new Double(p[1].getY()), nPoint, 3);
478
					table.updateMapPoint(new Double(p[1].getX()), new Double(p[1].getY()), nPoint);
472 479
					if(gp != null) {
473 480
						gp.mapPoint = p[1];
474 481
						layersPointManager.redrawPoints();
......
499 506
	 *  </UL>
500 507
	 */
501 508
	public void onTool(ToolEvent ev) {
509
		
510
		//---------------------------
502 511
		//Operaci?n de cursor de zoom 
503 512
		if(ev.getSource() instanceof ZoomCursorGraphicLayer) {
504 513
			layersPointManager.setActiveLayerPoints(false);
......
506 515
			return;
507 516
		}
508 517
		
518
		//-----------
509 519
		//Mover punto
510 520
		if(ev.getSource() instanceof GCPsGraphicLayer) {
511 521
			layersPointManager.setActiveLayerZoomCursor(false);
......
513 523
			return;
514 524
		}
515 525
		
526
		//------------------
516 527
		//Selecci?n de punto
517 528
		if(ev.getSource() instanceof SelectPointTool) {
518 529
			if(viewMap != null) {
......
529 540
			}
530 541
		}
531 542
		
543
		//-------------------------
532 544
		//Selecci?n de zoom ventana
533 545
		if(ev.getSource() instanceof ZoomRectangleTool) {
534 546
			if(viewMap != null) {
......
544 556
			table.getToolSelectPointButton().setSelected(false);
545 557
		}
546 558
		
559
		//---------------------------
547 560
		//Selecci?n de desplazamiento
548 561
		if(ev.getSource() instanceof PanTool) {
549 562
			if(viewMap != null) {
......
564 577
	 *  
565 578
	 */
566 579
	public void offTool(ToolEvent ev) {
580
		
581
		//-----------------
567 582
		//Operaci?n de zoom
568 583
		if(ev.getSource() instanceof ZoomCursorGraphicLayer) {
569 584
			layersPointManager.setActiveLayerPoints(true);
......
571 586
			return;
572 587
		}
573 588
		
589
		//-----------
574 590
		//Mover punto
575 591
		if(ev.getSource() instanceof GCPsGraphicLayer) {
576 592
			layersPointManager.setActiveLayerZoomCursor(true);
trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/main/LayersPointManager.java
21 21
import java.awt.geom.Point2D;
22 22
import java.util.ArrayList;
23 23

  
24
import javax.swing.table.DefaultTableModel;
25

  
24
import org.gvsig.georeferencing.ui.table.GCPTablePanel;
26 25
import org.gvsig.georeferencing.ui.zoom.ViewMapRequestManager;
27 26
import org.gvsig.georeferencing.ui.zoom.ViewRasterRequestManager;
28 27
import org.gvsig.georeferencing.ui.zoom.layers.GCPsGraphicLayer;
......
34 33
import org.gvsig.georeferencing.view.ViewDialog;
35 34
import org.gvsig.georeferencing.view.ZoomMapDialog;
36 35
import org.gvsig.georeferencing.view.ZoomRasterDialog;
37
import org.gvsig.gui.beans.table.TableContainer;
38 36
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
39 37
import org.gvsig.raster.datastruct.GeoPoint;
40 38

  
......
314 312
	}
315 313
	
316 314
	/**
315
	 * Obtiene un array con la lista de puntos 
316
	 * @return GeoPoint[] 
317
	 */
318
	public GeoPoint[] getGeoPoints() {
319
		ArrayList pointList = getPointList();
320
		GeoPoint[] gpList = new GeoPoint[pointList.size()]; 
321
		for (int i = 0; i < pointList.size(); i++)
322
			gpList[i] = ((GPGraphic)pointList.get(i)).getGeoPoint();
323
		return gpList;
324
	}
325
	
326
	/**
317 327
	 * Activa o desactiva la visualizaci?n de un punto.
318 328
	 * @param active true para activarlo y false para desactivarlo
319 329
	 * @param position Posici?n del punto
......
334 344
	 * a los GeoPuntos
335 345
	 * @throws NotInitializeException
336 346
	 */
337
	public void calcPointsNumeration(TableContainer table) throws NotInitializeException {
347
	public void calcPointsNumeration(GCPTablePanel table) throws NotInitializeException {
338 348
		ArrayList pointList = getPointList();
339
		DefaultTableModel model = table.getModel();
340 349
		
341 350
		for (int i = 0; i < table.getRowCount(); i++) { 
342 351
			table.setValueAt(new Integer(i), i, 1);
343
			long id = (long)((Long)model.getValueAt(i, model.getColumnCount() - 1)).longValue();
352
			long id = (long)((Long)table.getValueAt(i, table.getColumnCount() - 1)).longValue();
344 353
			
345 354
			if(i < pointList.size()) {
346 355
				for (int j = 0; j < pointList.size(); j++) {
trunk/extensions/extGeoreferencing/build.xml
54 54
  	<!-- Jars de las extensiones -->
55 55
  	<jar jarfile="${dist}/${plugin}.jar" basedir="${build}" 
56 56
  	    	includes="org/gvsig/georeferencing/**" />
57
  	  	
57
  	<copy file="lib/jama.jar" todir="${fmapLibs}"/>  	
58 58
  	<copy file="config/config.xml" todir="${dist}"/>
59 59
  	<copy file="build.number" todir="${dist}"/>
60 60
    <copy file="config/plugin.dtd" todir="${dist}"/>
trunk/extensions/extGeoreferencing/.classpath
12 12
	<classpathentry kind="src" path="src"/>
13 13
	<classpathentry kind="lib" path="/libFMap/lib/org.cresques.cts.jar"/>
14 14
	<classpathentry kind="lib" path="/libFMap/lib/org.gvsig.fmap.raster.jar" sourcepath="/extRasterTools-SE"/>
15
	<classpathentry kind="lib" path="/libFMap/lib/org.gvsig.raster.gui.jar"/>
15
	<classpathentry kind="lib" path="/libFMap/lib/org.gvsig.raster.gui.jar" sourcepath="/extRasterTools-SE/src"/>
16 16
	<classpathentry kind="lib" path="/_fwAndami/lib/org.gvsig.exceptions.jar" sourcepath="/libExceptions/src"/>
17 17
	<classpathentry kind="lib" path="/_fwAndami/lib/iver-utiles.jar" sourcepath="/libIverUtiles/src"/>
18 18
	<classpathentry kind="lib" path="/libFMap/lib/gdbms-0.8-SNAPSHOT.jar" sourcepath="/libGDBMS"/>

Also available in: Unified diff