Revision 4922

View differences:

trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/saveRaster/ui/properties/SaveRasterPropsDialogPanel.java
64 64
     * @return void
65 65
     */
66 66
    public void initialize() {
67
    	super.initialize();
68
        this.setBounds(0, 0, 360, 230);
69

  
67
    	this.setLocation(new java.awt.Point(0,0));
68
        this.setSize(new java.awt.Dimension(360,230));
69
        super.initialize();
70 70
        //Ocultamos el bot?n de aplicar
71 71
        this.getApplyButton().setVisible(false);
72 72
    }
trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/saveRaster/operations/RasterizerLayer.java
184 184
					firstRead = false;
185 185
				}
186 186
				
187
				flayers.draw(image, g, viewPortBlock,new Cancellable() {
187
				Cancellable cancel = new Cancellable() {
188 188
					public boolean isCanceled() {
189 189
						return false;
190 190
					}
191
				},flayers.getFMap().getScaleView());
191

  
192
					public void setCanceled(boolean canceled) {
193
										
194
					}
195
				};
196
				
197
				flayers.draw(image, g, viewPortBlock, cancel, flayers.getFMap().getScaleView());
192 198
									
193 199
				//Si es el ?ltimo bloque vaciamos el historial de m?ximos y m?nimos
194 200
				if((contBlocks+1)==nBlocks){
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/dialogs/GeoreferencingDialog.java
303 303
			if(e.getSource() == bCancelar){
304 304
				cancel(theView);
305 305
			}
306
		}catch(Exception exc){
307
			return; 
308
		}
309
		
310
		//CARGAR PUNTOS
311
		if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBLoad()){
312
			JFileChooser chooser = new JFileChooser(lastPathLoad);
313
			chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
314
			FileFilter f = null;
315
			for(int i=0; i<this.fileFilters.length;i++){
316
				f = new SelectFileFilter(chooser, this.fileFilters[i]);
317
				chooser.addChoosableFileFilter(f);
318
			}
319
			int returnVal = chooser.showOpenDialog(this);
320
			if(returnVal == JFileChooser.APPROVE_OPTION){
321
			 	String fName = chooser.getSelectedFile().toString();
322
			 	FileFilter filter = chooser.getFileFilter();
323
			 	lastPathLoad = chooser.getCurrentDirectory().getAbsolutePath();
324 306
			
325
			 	if(getLyrPoints() == null)
326
			 		return;
327

  
328
			 	lyrGeoRaster.getFLyrPoints().saveState();
329
			 	getLyrPoints().XML2PointList(fName);
307
			//CARGAR PUNTOS
308
			if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBLoad()){
309
				loadPoints(theView);
330 310
			}
331
		}
332
		
333
		//SALVAR PUNTOS
334
		if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBSave()){
335
			JFileChooser chooser = new JFileChooser(lastPathSave);
336
			chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
337 311
			
338
			FileFilter f = null;
339
			for(int i=0; i<this.fileFilters.length;i++){
340
				f = new SelectFileFilter(chooser, this.fileFilters[i]);
341
				chooser.addChoosableFileFilter(f);
312
			//SALVAR PUNTOS
313
			if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBSave()){
314
				savePoints(theView);				
342 315
			}
343
			int returnVal = chooser.showOpenDialog(this);
344
			if(returnVal == JFileChooser.APPROVE_OPTION){
345
			 	String fName = chooser.getSelectedFile().toString();			 
346
			 	lastPathSave = chooser.getCurrentDirectory().getAbsolutePath();
347
			 	if(!fName.endsWith(".grf"))
348
			 		fName = fName + ".grf";
349
			 	if(this.checkFileExists(fName)){
350
				 	if(getLyrPoints() != null)
351
				 		getLyrPoints().PointList2XML(fName);
352
			 	}
353
			}
354 316
			
355
		}
356
		
357
		//EXPORTAR A ASCII
358
		if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBExportToAscii()){
359
			JFileChooser chooser = new JFileChooser(lastPathSave);
360
			chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
361
			
362
			FileFilter f = null;
363
			for(int i=0; i<this.fileFilters.length;i++){
364
				f = new SelectFileFilter(chooser, this.fileFilters[i]);
365
				chooser.addChoosableFileFilter(f);
317
			//EXPORTAR A ASCII
318
			if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBExportToAscii()){
319
				exportToASCII(theView);	
366 320
			}
367
			int returnVal = chooser.showOpenDialog(this);
368
			if(returnVal == JFileChooser.APPROVE_OPTION){
369
			 	String fName = chooser.getSelectedFile().toString();
370
			 	lastPathSave = chooser.getCurrentDirectory().getAbsolutePath();
371
			 	if(this.checkFileExists(fName)){
372
			 		if(getLyrPoints() != null)
373
			 			getLyrPoints().PointList2Ascii(fName);
374
			 	}
375
			}
376 321
			
377
		}
378
		
379
		//DESACTIVAR PANELES
380
		JCheckBox cb = this.conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive();
381
		if(e.getSource() == cb){
382
			if(cb.isSelected()){
383
				this.setEnabled(true);
384
				getLyrPoints().setPointActive(getSelectedPoint(), true);
385
			}else{
386
				this.setEnabled(false);
387
				getLyrPoints().setPointActive(getSelectedPoint(), false);
388
			}
389
			theView.getMapControl().getMapContext().invalidate();
390
			getZoomControlLeft().draw();
391
			getZoomControlRight().draw();
392
		}	
393
		
394
		//PROCESAR
395
		if(e.getSource() == this.getBProcesar()){
396
			if(this.getLyrPoints().getCountPoints() > 0){
397
					
398
				//Creamos el fichero de georreferenciaci?n
399
				GeoOperations go = new GeoOperations(getLyrPoints());
400
				go.createWorldFile( (int)getLyrGeoRaster().getWidth(), 
401
									(int)getLyrGeoRaster().getHeight(),
402
									getLyrGeoRaster().getSource().getFiles()[0].getName());
403
				
404
				FLayers lyrs = this.getLyrGeoRaster().getParentLayer(); 
405
				for(int i = 0; i < lyrs.getLayersCount();i++){
406
					if(this.getLyrGeoRaster().getName().equals(lyrs.getLayer(i).getName())){
407
						
408
						//Eliminamos la capa
409
						lyrs.removeLayer(i);
410
						File fich = new File(getLyrGeoRaster().getSource().getFiles()[0].getName());
411
						try{
412
							//Creamos la nueva capa GeoRaster y la a?adimos al TOC. 
413
							FLyrGeoRaster lyrGeoRaster = 
414
								FLyrGeoRaster.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()), 
415
														(RasterDriver)getLyrGeoRaster().getSource().getDriver(), 
416
														fich,
417
														getLyrGeoRaster().getProjection(),
418
														getLyrGeoRaster().getImageWidth(),
419
														getLyrGeoRaster().getImageHeight());
420
							getLyrPoints().setVisible(false);
421
							this.getLyrPoints().setLyrGeoRaster(lyrGeoRaster);
422
							lyrGeoRaster.setFLyrPoints(this.getLyrPoints());
423
							lyrGeoRaster.setGeoDialog(this);
424
							this.lyrGeoRaster = lyrGeoRaster;
425
							calcNewMiniExtent(theView);
426
							lyrs.addLayer(lyrGeoRaster);
427
														
428
							lyrGeoRaster.setActive(false);
429
							theView.getMapControl().getMapContext().invalidate();
430
														
431
							try{
432
								frame.setClosed(true);
433
							}catch(PropertyVetoException exc){}
434
																					
435
						}catch(DriverException exc){
436
							
437
						}
438
						break;
439
					}
440
				}
322
			//DESACTIVAR PANELES
323
			JCheckBox cb = this.conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive();
324
			if(e.getSource() == cb){
325
				deactivatePanel(theView, cb);
326
			}	
441 327
			
328
			//PROCESAR
329
			if(e.getSource() == this.getBProcesar()){
330
				process(theView);
442 331
			}
332
		}catch(Exception exc){
333
			return; 
443 334
		}		
444 335
	}
445 336
	
......
479 370
		}catch(PropertyVetoException exc){}
480 371
	}
481 372
	
373
	/**
374
	 * Funci?n que se ejecuta al pulsar el bot?n de cargar puntos 
375
	 * @param theView
376
	 */
377
	private void loadPoints(View theView)throws Exception{		
378
		JFileChooser chooser = new JFileChooser(lastPathLoad);
379
		chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
380
		FileFilter f = null;
381
		for(int i=0; i<this.fileFilters.length;i++){
382
			f = new SelectFileFilter(chooser, this.fileFilters[i]);
383
			chooser.addChoosableFileFilter(f);
384
		}
385
		int returnVal = chooser.showOpenDialog(this);
386
		if(returnVal == JFileChooser.APPROVE_OPTION){
387
		 	String fName = chooser.getSelectedFile().toString();
388
		 	FileFilter filter = chooser.getFileFilter();
389
		 	lastPathLoad = chooser.getCurrentDirectory().getAbsolutePath();
390
		
391
		 	if(getLyrPoints() == null)
392
		 		throw new Exception("LyrPoints not loaded.");
393

  
394
		 	lyrGeoRaster.getFLyrPoints().saveState();
395
		 	getLyrPoints().XML2PointList(fName);
396
		}
397
	}
482 398
	
483 399
	/**
400
	 * Funci?n que se ejecuta al pulsar el bot?n salvar puntos
401
	 * @param theView
402
	 */
403
	private void savePoints(View theView)throws Exception{
404
		if(getLyrPoints() == null)
405
			throw new Exception("LyrPoints not loaded.");
406
					
407
		JFileChooser chooser = new JFileChooser(lastPathSave);
408
		chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
409
		
410
		FileFilter f = null;
411
		for(int i=0; i<this.fileFilters.length;i++){
412
			f = new SelectFileFilter(chooser, this.fileFilters[i]);
413
			chooser.addChoosableFileFilter(f);
414
		}
415
		int returnVal = chooser.showOpenDialog(this);
416
		if(returnVal == JFileChooser.APPROVE_OPTION){
417
		 	String fName = chooser.getSelectedFile().toString();			 
418
		 	lastPathSave = chooser.getCurrentDirectory().getAbsolutePath();
419
		 	if(!fName.endsWith(".grf"))
420
		 		fName = fName + ".grf";
421
		 	if(this.checkFileExists(fName)){
422
			 	if(getLyrPoints() != null)
423
			 		getLyrPoints().PointList2XML(fName);
424
		 	}
425
		}
426
	}
427
	
428
	/**
429
	 * Funci?n que se ejecuta al pulsar el bot?n de export a ascii
430
	 * @param theView
431
	 */
432
	private void exportToASCII(View theView)throws Exception{
433
		if(getLyrPoints() == null)
434
			throw new Exception("LyrPoints not loaded.");
435
		
436
		JFileChooser chooser = new JFileChooser(lastPathSave);
437
		chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
438
		
439
		FileFilter f = null;
440
		for(int i=0; i<this.fileFilters.length;i++){
441
			f = new SelectFileFilter(chooser, this.fileFilters[i]);
442
			chooser.addChoosableFileFilter(f);
443
		}
444
		int returnVal = chooser.showOpenDialog(this);
445
		if(returnVal == JFileChooser.APPROVE_OPTION){
446
		 	String fName = chooser.getSelectedFile().toString();
447
		 	lastPathSave = chooser.getCurrentDirectory().getAbsolutePath();
448
		 	if(this.checkFileExists(fName)){
449
		 		if(getLyrPoints() != null)
450
		 			getLyrPoints().PointList2Ascii(fName);
451
		 	}
452
		}			
453
	}
454
	
455
	/**
456
	 * Funci?n que se ejecuta al pulsar el bot?n desactivar panel
457
	 * @param theView
458
	 */
459
	private void deactivatePanel(View theView, JCheckBox cb)throws Exception{
460
		if(getLyrPoints() == null)
461
			throw new Exception("LyrPoints not loaded.");
462
		if(cb.isSelected()){
463
			this.setEnabled(true);
464
			getLyrPoints().setPointActive(getSelectedPoint(), true);
465
		}else{
466
			this.setEnabled(false);
467
			getLyrPoints().setPointActive(getSelectedPoint(), false);
468
		}
469
		theView.getMapControl().getMapContext().invalidate();
470
		getZoomControlLeft().draw();
471
		getZoomControlRight().draw();		
472
	}
473
	
474
	/**
475
	 * Funci?n que se ejecuta al pulsar el bot?n procesar
476
	 * @param theView
477
	 */
478
	private void process(View theView)throws Exception{
479
		if(getLyrPoints() == null)
480
			throw new Exception("LyrPoints not loaded.");
481
		if(this.getLyrPoints().getCountPoints() > 0){
482
			
483
			//Creamos el fichero de georreferenciaci?n
484
			GeoOperations go = new GeoOperations(getLyrPoints());
485
			go.createWorldFile( (int)getLyrGeoRaster().getWidth(), 
486
								(int)getLyrGeoRaster().getHeight(),
487
								getLyrGeoRaster().getSource().getFiles()[0].getName());
488
			
489
			FLayers lyrs = this.getLyrGeoRaster().getParentLayer(); 
490
			for(int i = 0; i < lyrs.getLayersCount();i++){
491
				if(this.getLyrGeoRaster().getName().equals(lyrs.getLayer(i).getName())){
492
					
493
					//Eliminamos la capa
494
					lyrs.removeLayer(i);
495
					File fich = new File(getLyrGeoRaster().getSource().getFiles()[0].getName());
496
					try{
497
						//Creamos la nueva capa GeoRaster y la a?adimos al TOC. 
498
						FLyrGeoRaster lyrGeoRaster = 
499
							FLyrGeoRaster.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()), 
500
													(RasterDriver)getLyrGeoRaster().getSource().getDriver(), 
501
													fich,
502
													getLyrGeoRaster().getProjection(),
503
													getLyrGeoRaster().getImageWidth(),
504
													getLyrGeoRaster().getImageHeight());
505
						getLyrPoints().setVisible(false);
506
						this.getLyrPoints().setLyrGeoRaster(lyrGeoRaster);
507
						lyrGeoRaster.setFLyrPoints(this.getLyrPoints());
508
						lyrGeoRaster.setGeoDialog(this);
509
						this.lyrGeoRaster = lyrGeoRaster;
510
						calcNewMiniExtent(theView);
511
						lyrs.addLayer(lyrGeoRaster);
512
													
513
						lyrGeoRaster.setActive(false);
514
						theView.getMapControl().getMapContext().invalidate();
515
													
516
						try{
517
							frame.setClosed(true);
518
						}catch(PropertyVetoException exc){}
519
																				
520
					}catch(DriverException exc){
521
						
522
					}
523
					break;
524
				}
525
			}
526
		
527
		}
528
	}
529
	 
530
	/**
484 531
	 * Recalcula el extent de la mini-imagen que corresponde a los puntos en coordenadas
485 532
	 * pixel.Para esto calcula el nuevo centro a partir de la capa y con la distancia entre
486 533
	 * el nuevo centro y el viejo desplaza el extent completo de la mini-imagen.
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/panels/ZoomControlPanel.java
27 27

  
28 28
import com.iver.andami.PluginServices;
29 29
import com.iver.cit.gvsig.fmap.DriverException;
30
import com.iver.cit.gvsig.fmap.MapControl;
31 30
import com.iver.cit.gvsig.fmap.ViewPort;
32 31
import com.iver.cit.gvsig.fmap.layers.FLayers;
33 32
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster;
......
35 34
import com.iver.cit.gvsig.fmap.operations.Cancellable;
36 35
import com.iver.cit.gvsig.gui.View;
37 36
import com.iver.cit.gvsig.gui.dialogs.GeoreferencingDialog;
38
import com.iver.cit.gvsig.utils.MathUtils;
39 37

  
40 38
/**
41 39
 * Panel que contiene los controles de zoom de la vista para 
......
388 386
												"images/icoBlue.png")).getImage();
389 387
		//**********************End Vars******************************
390 388
	    
389
	    //**********************Classes*******************************
390
	    class CancellableClass implements Cancellable{
391
	    	private boolean cancel = false;
392
       		public void setCanceled(boolean canceled) {
393
       			this.cancel = canceled;
394
       		}
395
       		
396
			public boolean isCanceled() {
397
				return this.cancel;
398
			}
399
       	}
400
	    //**********************End Classes***************************
401
	    
391 402
	    //**********************Methods*******************************
392 403
	    /**
393 404
	     * 
......
505 516
			       	Forzamos un draw de las capas para dibujar la vista sobre el control de las miniimagenes.
506 517
			       	Como la capa gr?fica est? en FMap esta no aparece en el dibujado de FLayers por los que 
507 518
			       	forzaremos el pintado tambi?n de la capa de puntos sobre nuestro control*/
508
			       	
519
			       	Cancellable cancellable = new CancellableClass();
509 520
			        if(zoomControl.getDialog().isEnlarge()){
510 521
			        	if(zoomControl.getNumberPoint() != -1){
511
					       	flayers.draw(null, (Graphics2D) dbGraphics, newViewPort,new Cancellable() {
512
					       		public boolean isCanceled() {
513
									return false;
514
								}
515
					       	},flayers.getFMap().getScaleView());
516
					       	zoomControl.getLyrPoints().draw(null, (Graphics2D) dbGraphics, newViewPort,new Cancellable() {
517
					       		public boolean isCanceled() {
518
									return false;
519
								}
520
					       	},flayers.getFMap().getScaleView());
522
					       	flayers.draw(null, (Graphics2D) dbGraphics, newViewPort,cancellable ,flayers.getFMap().getScaleView());
523
					       	zoomControl.getLyrPoints().draw(null, (Graphics2D) dbGraphics, newViewPort, cancellable, flayers.getFMap().getScaleView());
521 524
			        	}
522 525
			        }
523 526
			        	
524
			        flayers.draw(null, gTmp, newViewPort,new Cancellable() {
525
			        	public boolean isCanceled() {
526
							return false;
527
						}
528
			        },flayers.getFMap().getScaleView());
529
			    	zoomControl.getLyrPoints().draw(null, gTmp, newViewPort,new Cancellable() {
530
			       		public boolean isCanceled() {
531
							return false;
532
						}
533
			       	},flayers.getFMap().getScaleView());
527
			        flayers.draw(null, gTmp, newViewPort, cancellable, flayers.getFMap().getScaleView());
528
			    	zoomControl.getLyrPoints().draw(null, gTmp, newViewPort, cancellable, flayers.getFMap().getScaleView());
534 529
			      
535 530
			       }
536 531
		     }catch (DriverException e) {
......
627 622
		public void mouseMoved(MouseEvent arg0) {
628 623
			if(	isEnableEvent() && 
629 624
				zoomControl.getLyrPoints() != null &&
630
				zoomControl.getLyrPoints().getCountPoints() > 0){
625
				zoomControl.getLyrPoints().getCountPoints() > 0 &&
626
				this.newViewPort != null &&
627
				this.newViewPort.getExtent() != null){
628
				
631 629
				double newWCPointX = this.newViewPort.getExtent().getMinX() + ((arg0.getX() * this.newViewPort.getExtent().getWidth()) / this.getWidth());
632 630
				int ptoSelectY = (int)(this.getHeight() - arg0.getY());
633 631
				double newWCPointY = this.newViewPort.getExtent().getMinY() + ((ptoSelectY * this.newViewPort.getExtent().getHeight()) / this.getHeight());

Also available in: Unified diff