Revision 3084

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/SaveRasterPropsDialog.java
17 17

  
18 18
/**
19 19
 * Dialogo para abrir fichero.
20
 * @author Nacho Brodin <brodin_ign@gva.es>
20
 * @author Nacho Brodin (brodin_ign@gva.es)
21 21
 */
22 22
public class SaveRasterPropsDialog extends JDialog {
23 23
	
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/ProgressSaveRasterDialog.java
126 126
						r.printStackTrace();
127 127
				}
128 128
				
129
			}else if (fName.endsWith(".tif")) {	
129
			}else if (	fName.endsWith(".tif") ) {	
130 130
				//System.out.println("Salvando fichero "+fName+" a formato Tif");
131 131
				try{
132
								
132
					String drvName = null;
133
					String end = fName.substring(fName.lastIndexOf("."), fName.length()); 
134
					if(end.equals(".tif"))
135
						drvName = "GTiff";
133 136
					RasterizerLayer p = new RasterizerLayer(layers, vp, sizeBlock, mapCtrl);
134 137
					p.setProgressBar(window.getJProgressBar());
135 138
					Extent ex = new Extent(vp.getAdjustedExtent());
......
143 146
												ex.minY(), 
144 147
												3, 
145 148
												sizeBlock,
146
												"GTiff");
149
												drvName);
147 150
				    //Si han sido modificadas las propiedades se asignan los valores modificados
148
				    String[] prp = driverProps.getProperties("tif");
151
				    String[] prp = driverProps.getProperties(end);
149 152
				    if(prp!=null)
150 153
						writer.setProps(prp);
151 154
					((GdalWriter)writer).dataWrite();
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/SaveRasterDialog.java
67 67

  
68 68
/**
69 69
 * Dialogo para abrir fichero.
70
 * @author Nacho Brodin <brodin_ign@gva.es>
70
 * @author Nacho Brodin (brodin_ign@gva.es)
71 71
 */
72 72
//public class SaveRasterDialog extends JDialog{
73 73
public class SaveRasterDialog extends SaveRasterDialogPanel implements View {
......
246 246
				writerProps.setProps(driverProps.getProperties("tif"));
247 247
			}
248 248
		}
249
					
249
				
250 250
		frameSaveRasterProps = new SaveRasterPropsDialog(writerProps);
251 251
		frameSaveRasterProps.setParentDialog(this);
252 252
		frameSaveRasterProps.show();
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/MrSidFile.java
305 305
     * @throws MrSIDException Lanzada si ocurre un error en la lectura de la escena
306 306
     */
307 307
    public void readScene(int[] line) throws MrSIDException {
308
        //int a = 0;
309 308
        int x = (int) currentViewX;
310 309
        int y = (int) currentViewY;
311 310
        int SceneWidth;
......
335 334
            if (pixel == null) {
336 335
                pixel = new LTIPixel(eColorSpace, nbands, eSampleType);
337 336
            }
337
            
338
            LTISceneBuffer buffer = null;
339
			
340
            boolean  hecho = false;
341
			while (!hecho){
342
				LTIScene scene = new LTIScene(x, y, SceneWidth, SceneHeight,
343
						zoomoverview);
338 344

  
339
            LTIScene scene = new LTIScene(x, y, SceneWidth, SceneHeight,
340
                                          zoomoverview);
345
				// Este deber?a ser el constructor con ventana
346
				buffer = new LTISceneBuffer(pixel, SceneWidth,
347
						SceneHeight, true);
341 348

  
342
            // Este deber?a ser el constructor con ventana
343
            LTISceneBuffer buffer = new LTISceneBuffer(pixel, SceneWidth,
344
                                                       SceneHeight, true);
345

  
346
            ((LTIImageStage) this).read(scene, buffer);
347

  
349
				hecho = true;
350
				try {
351
					((LTIImageStage) this).read(scene, buffer);
352
					hecho = true;
353
				} catch (MrSIDException ex) {
354
					SceneWidth--;
355
					SceneHeight--;
356
					hecho = false;
357
				}
358
			}
359
			
348 360
            if ((dataType == LTIDataType.LTI_DATATYPE_UINT8) ||
349 361
                    (dataType == LTIDataType.LTI_DATATYPE_SINT8) ||
350 362
                    (dataType == LTIDataType.LTI_DATATYPE_SINT16) ||
......
493 505
     */
494 506
    public MrSidFile(IProjection proj, String fName) {
495 507
        super(proj, fName);
508
        
496 509
        extent = new Extent();
497 510

  
498 511
        try {
......
667 680
                           ")");
668 681
        System.out.println("   NumBands = (" + file.nbands + ")");
669 682

  
670
        file.pintaInfo();
683
        //file.pintaInfo();
671 684
        file.pintaPaleta();
672 685
    }
673 686

  
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/EcwFile.java
99 99
            load();
100 100
            bandCount = file.numBands;
101 101

  
102
            /*if ( bandCount > 2) {
102
            if ( bandCount > 2) {
103 103
                    setBand(RED_BAND,   0);
104 104
                    setBand(GREEN_BAND, 1);
105 105
                    setBand(BLUE_BAND,  2);
106 106
            } else
107
                    setBand(RED_BAND|GREEN_BAND|BLUE_BAND, 0);*/
107
                    setBand(RED_BAND|GREEN_BAND|BLUE_BAND, 0);
108 108
        } catch (Exception e) {
109 109
            bErrorOnOpen = true;
110 110
            errorMessage = e.getMessage();
......
124 124
        double maxX;
125 125
        double maxY;
126 126

  
127
        /*System.out.println("ECW size = ("+file.width+","+file.height+")\n"+
128
                " inc=("+file.cellIncrementX+","+file.cellIncrementY+")\n"+
129
                " datum='"+file.datum+"', proyeccion='"+file.projection+"'");*/
127
        if(file.cellIncrementY > 0)
128
        	file.cellIncrementY = -file.cellIncrementY;
129
        
130 130
        minX = file.originX;
131 131
        maxY = file.originY;
132 132
        maxX = file.originX +
133 133
               ((double) (file.width - 1) * file.cellIncrementX);
134 134
        minY = file.originY +
135 135
               ((double) (file.height - 1) * file.cellIncrementY);
136
        if (file.cellIncrementY > 0) {
137
        	double swap = minY;
138
        	minY = maxY;
139
        	maxY = swap;
140
        }
136
        
141 137
        extent = new Extent(minX, minY, maxX, maxY);
142
        //System.out.println(extent);
138
      
143 139

  
144 140
        return this;
145 141
    }
......
180 176
    
181 177
    private void setFileView(int numBands, int [] bandList, ChunkFrame f)
182 178
    	throws JNCSFileNotOpenException, JNCSInvalidSetViewException {
183
    	double minY = f.v.minY();
184
    	double maxY = f.v.maxY();
185
    	if (file.cellIncrementY > 0) {
186
        	double swap = minY;
187
        	minY = maxY;
188
        	maxY = swap;
189
        }
179

  
190 180
        file.setView(file.numBands, bandList, f.v.minX(),
191
            	maxY, f.v.maxX(), minY, f.width, f.height);
181
        		f.v.maxY(), f.v.maxX(), f.v.minY(), f.width, f.height);
192 182
    }
193 183

  
194 184
    /**
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/raster/LinearEnhancementFilter.java
23 23
 */
24 24
package org.cresques.io.raster;
25 25

  
26
import java.io.File;
26 27

  
28

  
27 29
/**
28 30
 * Clase base para los filtros de realzado lineal. Lee el m?nimo y m?xmo de la clase
29 31
 * RasterStats que ser?n calculados por PercentTailTrimFilter o ComputeMinMaxFilter dependiendo
......
53 55
     * @see org.cresques.io.raster.IRasterFilter#pre()
54 56
     */
55 57
    public void pre() {
56
        if (removeExtrema) { //Si est? activado eliminar extremos gastamos el 2? m?ximo/m?nimo
58
    	 if (removeExtrema) { //Si est? activado eliminar extremos gastamos el 2? m?ximo/m?nimo
57 59

  
58 60
            if ((filename != null) && !filename.equals("")) {
59 61
                for (int i = 0; i < stats.history.size(); i++) {
60 62
                    RasterStats.History history = (RasterStats.History) stats.history.get(i);
61

  
62
                    if (history.file.equals(filename.substring((filename.lastIndexOf("/") +
63
                    if (history.file.equals(filename.substring((filename.lastIndexOf(File.separator) +
63 64
                                                                   1),
64 65
                                                                   filename.length()))) {
65 66
                        this.minBandValue = history.secMin;
......
78 79
                for (int i = 0; i < stats.history.size(); i++) {
79 80
                    RasterStats.History history = (RasterStats.History) stats.history.get(i);
80 81

  
81
                    if (history.file.equals(filename.substring((filename.lastIndexOf("/") +
82
                    if (history.file.equals(filename.substring((filename.lastIndexOf(File.separator) +
82 83
                                                                   1),
83 84
                                                                   filename.length()))) {
84 85
                        this.minBandValue = history.min;
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GeoRasterFile.java
74 74
	private static TreeMap supportedExtensions = null;
75 75
	protected Component updatable = null;
76 76
	protected boolean doTransparency = false;
77
	
77 78
	/**
78
	 * Variable que puede tener un valor si se le asigna el extent
79
	 * de la vista. Esto es util para cargar imagenes sin georreferenciar
80
	 * ya que podemos asignar el extent que queramos para ajustarnos a una 
81
	 * vista concreta
82
	 */
83
	private Extent tempExtent = null;
84
		
85
	/**
86 79
	 * Filtro para raster.
87 80
	 * Permite eliminar la franja inutil alrededor de un raster girado o de
88 81
	 * un mosaico de borde irregular.
......
120 113

  
121 114
	static {
122 115
		supportedExtensions = new TreeMap();
123
		//if (System.getProperty("os.name").toUpperCase().startsWith("WIN")) {
124
			supportedExtensions.put("ecw",  EcwFile.class);
125
		//}
126
		supportedExtensions.put("tif",  TifGeoRefFile.class);
127
		supportedExtensions.put("tiff", TifGeoRefFile.class);
116
		supportedExtensions.put("ecw",  EcwFile.class);
117
		supportedExtensions.put("jp2",  EcwFile.class);
118
		
119
		supportedExtensions.put("tif",  GdalFile.class);
120
		supportedExtensions.put("tiff", GdalFile.class);
128 121
		//supportedExtensions.put("jpg",  TifGeoRefFile.class);
129 122
		supportedExtensions.put("jpg",  GdalFile.class);
130 123
		//supportedExtensions.put("png",  TifGeoRefFile.class);
......
439 432
	abstract public byte[] getWindow(int ulX, int ulY, int sizeX, int sizeY, int band);
440 433
	abstract public int getBlockSize();
441 434
	
442
	/**
435
	/*
443 436
	 * Obtiene el extent temporal.
444 437
	 * @return Returns the tempExtent.
445
	 */
446
	public Extent getTempExtent() {
447
		return tempExtent;
448
	}
438
	 *
439
	public Extent getExtent() {
440
		return extent;
441
	}*/
449 442
	
450 443
	/**
451 444
	 * Asigna un extent temporal que puede coincidir con el de la vista. Esto es 
......
453 446
	 * que queramos para ajustarnos a una vista concreta
454 447
	 * @param tempExtent The tempExtent to set.
455 448
	 */
456
	public void setTempExtent(Extent tempExtent) {
457
		this.tempExtent = tempExtent;
449
	public void setExtent(Extent ext) {
450
		this.extent = ext;
458 451
	}
459 452
	
460
	/**
461
	 * Calcula un extent posible para la imagen a partir del extent de la vista
462
	 * @param w	Ancho de la imagen
463
	 * @param h Alto de la imagen
464
	 * @return	Extent para la imagen
465
	 */
466
	protected Extent calcTempExtent(double w, double h){
467
		double ulX = 0D, ulY = 0D, lrX = 0D, lrY = 0D;
468
		if(w > h){
469
			double widthView = tempExtent.maxX() - tempExtent.minX();
470
			ulX = tempExtent.minX() + (widthView / 4);
471
			lrX = ulX + (widthView / 2);
472
			double newAlto = ((h * (widthView / 2)) / w);
473
			double centroY = tempExtent.minY()+((tempExtent.maxY() - tempExtent.minY())/2);
474
			ulY = centroY - (newAlto / 2);
475
			lrY = centroY + (newAlto / 2);
476
		}else{
477
			double heightView = tempExtent.maxY() - tempExtent.minY();
478
			ulY = tempExtent.minY() + (heightView / 4);
479
			lrY = ulY + (heightView / 2);
480
			double newAncho = ((w * (heightView / 2)) / h);
481
			double centroX = tempExtent.minX()+((tempExtent.maxX() - tempExtent.minX())/2);
482
			ulX = centroX - (newAncho / 2);
483
			lrX = centroX + (newAncho / 2);
484
		}
485
		return new Extent(ulX, ulY, lrX, lrY);
486
	}
453
	/*
454
	 * Asigna  al flag que le dice al driver si tiene que coger el extent
455
	 * pasado desde el cliente.
456
	 * @param aExt Valor de un flag ASIGNED_EXTENT, IMAGE_EXTENT, ORDER  
457
	 *
458
	public void setExtentFlag(int aExt){
459
		this.assignedExtent = aExt;
460
	}*/
461
	
487 462
}
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GdalFile.java
34 34

  
35 35
import org.cresques.cts.ICoordTrans;
36 36
import org.cresques.cts.IProjection;
37
import org.cresques.io.GdalNative.Contour;
37 38
import org.cresques.io.raster.RasterBuf;
38 39
import org.cresques.px.Extent;
39 40

  
......
99 100
		if (true) { //ext.compareTo("sid") == 0) {
100 101
			String [] metadata = getMetadata();
101 102
			double ox=0D, oy=0D, resx=0D, resy=0D;
102
			 try{
103
			try{
103 104
				GeoTransform trans = getGeoTransform();
104 105
				ox = trans.adfgeotransform[0];
105 106
				oy = trans.adfgeotransform[3];
......
113 114
	  			esq.add(new Point2D.Double(ox, oy+resy*height));
114 115
	  			esq.add(new Point2D.Double(ox+resx*width, oy+resy*height));
115 116
			 }catch(GdalException exc){
116
			 	esq = null;
117
			 	esq.add(new Point2D.Double(0, 0));
118
			 	esq.add(new Point2D.Double(width, 0));
119
			 	esq.add(new Point2D.Double(0, height));
120
			 	esq.add(new Point2D.Double(width, height));
117 121
			 }
118 122
		} else  { //version.startsWith("1")) {
119 123
  			//double [] transParam = getGeoTransform();
......
424 428
		extent = new Extent();
425 429
		try {
426 430
			file = new GdalNative(fName);
431
			load();
427 432
			showOnOpen();
428
			load();
429 433
			bandCount = file.getRasterCount(); 
430 434
			if ( bandCount > 2) {
431 435
				setBand(RED_BAND,   0);
......
451 455
	 * Obtenemos o calculamos el extent de la imagen.
452 456
	 */
453 457
	public GeoFile load() {
458
	
459
		extent = new Extent(file.esq.minX, file.esq.minY, file.esq.maxX, file.esq.maxY);	
454 460
		
455
		//Si el extent temporal tiene alg?n valor usamos este para calcular el de la imagen	
456
		if(this.getTempExtent()!=null){
457
			extent = this.calcTempExtent(file.width, file.height);
458
			file.esq = file.new Contour();
459
  			file.esq.add(new Point2D.Double(extent.minX(), extent.minY()));
460
  			file.esq.add(new Point2D.Double(extent.minX()+(extent.maxX() - extent.minX()), extent.minY()));
461
  			file.esq.add(new Point2D.Double(extent.minX(), extent.minY()+(extent.maxY() - extent.minY())));
462
  			file.esq.add(new Point2D.Double(extent.minX()+(extent.maxX() - extent.minX()), extent.minY()+(extent.maxY() - extent.minY())));
463
		}else{ //usamos el de la imagen
464
			
465
			 //Si la imagen est? georreferenciada obtenemos el extent
466
			if(file.esq != null)
467
				extent = new Extent(file.esq.minX, file.esq.minY, file.esq.maxX, file.esq.maxY);
468
			else{//Si no est? georreferenciada nos inventamos el extent
469
				extent = new Extent(0, 0, file.width, file.height);
470
				file.esq = file.new Contour();
471
	  			file.esq.add(new Point2D.Double(0, 0));
472
	  			file.esq.add(new Point2D.Double(file.width, 0));
473
	  			file.esq.add(new Point2D.Double(0, file.height));
474
	  			file.esq.add(new Point2D.Double(file.width, file.height));
475
			}
476
		}
477 461
		return this;
478 462
	}
479 463
	
464
	/**
465
	 * Cierra el fichero de imagen
466
	 */
480 467
	public void close() {
481 468
		try {
482 469
			file.close();
......
486 473
		}
487 474
	}
488 475
	
476
	/**
477
	 * Asigna a cada banda R,G o B una banda de la imagen
478
	 */
489 479
	public void setBand(int flag, int bandNr) {
490 480
		super.setBand(flag, bandNr);
491 481
		if ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND) file.rBandNr = bandNr+1;
492 482
		if ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) file.gBandNr = bandNr+1;
493 483
		if ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) file.bBandNr = bandNr+1;
494 484
	}
495
	public void setView(Extent e) { v = new Extent(e); }
496
	public Extent getView() { return v; }
497 485
	
498
	public int getWidth() {	return file.width; }
499
	public int getHeight() { return file.height;}
486
	/**
487
	 * Asigna el extent de la vista actual
488
	 */
489
	public void setView(Extent e) { 
490
		v = new Extent(e); 
491
	}
492
	
493
	/**
494
	 * Obtiene extent de la vista actual
495
	 */
496
	public Extent getView() { 
497
		return v; 
498
	}
499
	
500
	/**
501
	 * Obtiene la anchura del fichero
502
	 */
503
	public int getWidth() {	
504
		return file.width; 
505
	}
506
	
507
	/**
508
	 * Obtiene la altura del fichero
509
	 */
510
	public int getHeight() { 
511
		return file.height;
512
	}
500 513

  
501 514
	/* (non-Javadoc)
502 515
	 * @see org.cresques.io.GeoRasterFile#reProject(org.cresques.cts.ICoordTrans)
......
505 518
		// TODO Auto-generated method stub
506 519
		
507 520
	}
521
	
508 522
	/* (non-Javadoc)
509
	 * @see org.cresques.io.GeoRasterFile#setTransparency(boolean)
510
	 * /
511
	public void setTransparency(boolean t) {
512
		// TODO Auto-generated method stub
513
	}
514
	public void setTransparency(int t) {
515
		// TODO Auto-generated method stub
516
	}*/
517
	/* (non-Javadoc)
518 523
	 * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans)
519 524
	 */
520 525
	public Image updateImage(int width, int height, ICoordTrans rp) {
521 526
		double dFileAspect, dWindowAspect;
522 527
		int line, pRGBArray[] = null;
523 528
		Image image = null;
524

  
529
			
525 530
		// Work out the correct aspect for the setView call.
526 531
		dFileAspect = (double)v.width()/(double)v.height();
527 532
		dWindowAspect = (double)width /(double)height;
......
566 571
		double dFileAspect, dWindowAspect;
567 572
		int line, pRGBArray[][] = null;
568 573
		RasterBuf raster = null;
569

  
574
				
570 575
		// Work out the correct aspect for the setView call.
571 576
		dFileAspect = (double)v.width()/(double)v.height();
572 577
		dWindowAspect = (double)width /(double)height;
......
722 727
		
723 728
		double dFileAspect, dWindowAspect;
724 729
		int line, pRGBArray[] = null;
725

  
730
				
726 731
		// Work out the correct aspect for the setView call.
727 732
		dFileAspect = (double)v.width()/(double)v.height();
728 733
		dWindowAspect = (double)width /(double)height;
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java
172 172
        this.component = component;
173 173

  
174 174
        setExtent(geoFile[0].getExtent());
175
        geoFile[0].setView(view); //geoFile.getExtent());
176
        extentOrig = extent;
177
        bandSwitch.addFile(eFile);
178

  
179
        if (geoFile[0].getBandCount() >= 3) {
180
            setBand(GeoRasterFile.RED_BAND, 0);
181
            setBand(GeoRasterFile.GREEN_BAND, 1);
182
            setBand(GeoRasterFile.BLUE_BAND, 2);
183
        } else if (geoFile[0].getBandCount() == 2) {
184
            setBand(GeoRasterFile.RED_BAND, 0);
185
            setBand(GeoRasterFile.GREEN_BAND, 1);
186
            setBand(GeoRasterFile.BLUE_BAND, 1);
187
        } else if (geoFile[0].getBandCount() == 1) {
188
            //setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0);
189
            setBand(GeoRasterFile.RED_BAND, 0);
190
            setBand(GeoRasterFile.GREEN_BAND, 0);
191
            setBand(GeoRasterFile.BLUE_BAND, 0);
175
        if(view != null){
176
	        geoFile[0].setView(view); //geoFile.getExtent());
177
	        extentOrig = extent;
178
	        bandSwitch.addFile(eFile);
179
	
180
	        if (geoFile[0].getBandCount() >= 3) {
181
	            setBand(GeoRasterFile.RED_BAND, 0);
182
	            setBand(GeoRasterFile.GREEN_BAND, 1);
183
	            setBand(GeoRasterFile.BLUE_BAND, 2);
184
	        } else if (geoFile[0].getBandCount() == 2) {
185
	            setBand(GeoRasterFile.RED_BAND, 0);
186
	            setBand(GeoRasterFile.GREEN_BAND, 1);
187
	            setBand(GeoRasterFile.BLUE_BAND, 1);
188
	        } else if (geoFile[0].getBandCount() == 1) {
189
	            //setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0);
190
	            setBand(GeoRasterFile.RED_BAND, 0);
191
	            setBand(GeoRasterFile.GREEN_BAND, 0);
192
	            setBand(GeoRasterFile.BLUE_BAND, 0);
193
	        }
192 194
        }
193 195
    }
194 196

  
......
619 621
     */
620 622
    public void setExtent(Extent e) {
621 623
        super.extent = e;
622
        pts = new Vector();
623
        pts.add(proj.createPoint(e.minX(), e.minY()));
624
        pts.add(proj.createPoint(e.maxX(), e.minY()));
625
        pts.add(proj.createPoint(e.maxX(), e.maxY()));
626
        pts.add(proj.createPoint(e.minX(), e.maxY()));
624
        if(e != null){
625
	        pts = new Vector();
626
	        pts.add(proj.createPoint(e.minX(), e.minY()));
627
	        pts.add(proj.createPoint(e.maxX(), e.minY()));
628
	        pts.add(proj.createPoint(e.maxX(), e.maxY()));
629
	        pts.add(proj.createPoint(e.minX(), e.maxY()));
630
        }
627 631
    }
628 632

  
629 633
    /**
......
827 831
                System.out.println("Dibujando PxRaster: " +
828 832
                                   ((t2 - t1) / 1000D) + ", secs.");
829 833
            } else if ((geoFile != null) && (geoFile.length == 1)) { // Una solo fichero
834
        
830 835
                geoImage = bandSwitch.getBandR().getGeoRasterFile().updateImage(wImg,
831 836
                                                                                hImg,
832 837
                                                                                rp,
......
1244 1249
            }
1245 1250
        }
1246 1251
    }
1252
	/**
1253
	 * @return Returns the vName.
1254
	 */
1255
	public String getVName() {
1256
		return vName;
1257
	}
1258
	/**
1259
	 * @param name The vName to set.
1260
	 */
1261
	public void setVName(String name) {
1262
		vName = name;
1263
	}
1247 1264
}
trunk/libraries/libCq CMS for java.old/.classpath
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3 3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="src" path="src-dvp"/>
5 4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6 5
	<classpathentry kind="lib" path="lib/geojava.jar"/>
7 6
	<classpathentry kind="lib" path="lib/jmgeoraster.jar"/>
8 7
	<classpathentry kind="lib" path="lib/geotiff-jai.jar"/>
9
	<classpathentry kind="lib" path="lib/geoapi-SNAPSHOT.jar"/>
10 8
	<classpathentry sourcepath="C:/downloads/java/tar/javatar-2.5/source" kind="lib" path="lib/tar.jar"/>
11 9
	<classpathentry sourcepath="/jni-libgdal/src" kind="lib" path="lib/jmrsid.jar"/>
12 10
	<classpathentry kind="lib" path="lib/jecw.jar"/>
......
16 14
	<classpathentry kind="lib" path="lib/gt2-main.jar"/>
17 15
	<classpathentry kind="lib" path="lib/jgdal.jar"/>
18 16
	<classpathentry kind="lib" path="lib/jogr.jar"/>
17
	<classpathentry kind="lib" path="lib/geoapi-2.0.jar"/>
19 18
	<classpathentry kind="output" path="bin"/>
20 19
</classpath>
trunk/libraries/libCq CMS for java.old/src-test/org/cresques/io/raster/PruebaFilter.java
1
/*
2
 * Created on 22-feb-2005
3
 */
4
package org.cresques.io.raster;
5

  
6
import java.awt.Image;
7

  
8

  
9
public abstract class PruebaFilter extends RasterFilter {
10
	
11
	protected RasterBuf 		rasterBuf = null;
12
	
13
    public void pre(){
14
    	rasterBuf = new RasterBuf(RasterBuf.TYPE_INT, width, height, 3, null); 
15
    }
16
	public PruebaFilter(){
17
		super();
18
	}	
19

  
20
}
21

  
0 22

  
trunk/libraries/libCq CMS for java.old/src-test/org/cresques/io/raster/PruebaShortFilter.java
1
/*
2
 * Created on 22-feb-2005
3
 */
4
package org.cresques.io.raster;
5

  
6
import java.awt.Image;
7

  
8
/**
9
 * Calcula el m?ximo y el m?nimo de un raster.
10
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
11
 */
12
public class PruebaShortFilter extends PruebaFilter {
13
	
14
	public PruebaShortFilter(){
15
		super();
16
	}
17
			
18
	public void pre(){
19
		//Obtenci?n de par?metros
20
		
21
		this.raster = (RasterBuf)params.get("raster");
22
				
23
		height = raster.getHeight();
24
		width = raster.getWidth();
25
		super.pre();
26
	}
27
	
28
	public void process(int x, int y) {
29
		raster.getElemInt(x, y, px);
30
		this.rasterBuf.setElemInt(x, y, px);
31
		
32
	}
33
	
34
	public int getInRasterDataType(){
35
		//return raster.getDataType();
36
		return RasterBuf.TYPE_SHORT;
37
	}
38
	
39
	public int getOutRasterDataType(){
40
		//return raster.getDataType();
41
		return RasterBuf.TYPE_SHORT;
42
	}
43
	
44
	public Object getResult(String name){
45
		if(name.equals("raster"))
46
			return rasterBuf;
47
		else 
48
			return null;
49
	}
50
	
51
	public void processLine(int y){};
52
	public void post(){};
53

  
54
}
55

  
0 56

  
trunk/libraries/libCq CMS for java.old/src-test/org/cresques/io/raster/PruebaImageFilter.java
1
/*
2
 * Created on 25-feb-2005
3
 */
4
package org.cresques.io.raster;
5

  
6
import java.awt.Image;
7
import java.awt.Point;
8
import java.awt.image.BufferedImage;
9

  
10
/**
11
 * Clase base para los filtros de calculo de m?ximo y m?nimo en sus diferentes 
12
 * tipos de datos.
13
 */ 
14
public class PruebaImageFilter extends PruebaFilter {
15

  
16
	public PruebaImageFilter(){
17
		super();
18
	}
19
	
20
	public void pre(){
21
		//Obtenci?n de par?metros
22

  
23
		this.image = (Image)params.get("raster");
24
				
25
		height = image.getHeight(null);
26
		width = image.getWidth(null);
27
		
28
		super.pre();
29
		
30
	}
31
	
32
	public void process(int x, int y) {
33
		int px = ((BufferedImage) image).getRGB(x,y);
34
		int []px3 = {(px & 0xff0000) >> 16, (px & 0x00ff00) >> 8, (px & 0x0000ff)};
35
		this.rasterBuf.setElemInt(x, y, px3);
36
	}
37
	
38
	public int getInRasterDataType(){
39
		return RasterBuf.TYPE_IMAGE;
40
	}
41
	
42
	public int getOutRasterDataType(){
43
		return RasterBuf.TYPE_SHORT;
44
	}
45
	
46
	public void post(){
47
		image = null;
48
	};
49
	
50
	public Object getResult(String name){
51
		if(name.equals("raster"))
52
			return rasterBuf;
53
		else return null;
54
	}
55
	
56
	public void processLine(int y){};
57
	
58
}
59

  
60

  
0 61

  
trunk/libraries/libCq CMS for java.old/src-test/org/cresques/io/raster/PruebasRasterStack.java
1
package org.cresques.io.raster;
2

  
3
public class PruebasRasterStack{
4
	
5
	private PruebaStackManager 	stackManager = null;
6
	
7
	public PruebasRasterStack(PruebaStackManager stackManager){
8
		this.stackManager = stackManager;
9
		
10
		int[][] r = {{0,15}};
11
		stackManager.addTransparencyFilter(	r, null, null, 0x10, 0xff, 0xff, 0xff);
12
		int[][] s = {{0,10}, {1,5}};
13
		stackManager.addTransparencyFilter(	r, s, null, 0x10, 0xff, 0xff, 0xff);
14
		stackManager.addPruebaFilter();
15
		stackManager.removeFilter(4);
16
		stackManager.addPruebaFilter();
17
		stackManager.removeFilter(4);
18
		stackManager.addTransparencyFilter(	r, s, null, 0x10, 0xff, 0xff, 0xff);
19
		stackManager.removeFilter(0);
20
		stackManager.addPruebaFilter();
21
		stackManager.addTransparencyFilter(	r, s, null, 0x10, 0xff, 0xff, 0xff);
22
		stackManager.addEnhancedFilter();
23
		stackManager.addTailFilter( 0.1, 0.5);
24
		stackManager.removeFilter(3);
25
		stackManager.removeFilter(1);
26
	}
27
	
28
	public void setRasterFilterStackManager(PruebaStackManager stackManager){
29
		this.stackManager = stackManager;
30
	}
31
	
32
}
0 33

  
trunk/libraries/libCq CMS for java.old/src-test/org/cresques/io/raster/PruebaStackManager.java
1
package org.cresques.io.raster;
2

  
3
import java.util.ArrayList;
4

  
5
import org.cresques.io.raster.PercentTailTrimFilter;
6

  
7
public class PruebaStackManager extends RasterFilterStackManager implements StackManager{
8
	
9
	public final static int		prueba = 4;
10
	
11
	public PruebaStackManager(RasterFilterStack filterStack){
12
		super(filterStack);
13
		addTypeFilter("prueba", PruebaStackManager.prueba, 3);
14
		super.register(this);
15
	}
16
	 
17
	/**
18
	 * Filtro de pruebas. 
19
	 */
20
	public void addPruebaFilter(){
21
		RasterFilter filtro = null;
22
		switch(filterStack.getDataTypeInFilter(PruebaStackManager.prueba)){
23
			case RasterBuf.TYPE_IMAGE:filtro = new PruebaImageFilter();break;
24
			case RasterBuf.TYPE_SHORT:
25
			case RasterBuf.TYPE_USHORT:
26
			case RasterBuf.TYPE_INT:filtro = new PruebaShortFilter();break;
27
		}
28
		filterStack.addFilter(PruebaStackManager.prueba, filtro);
29
		super.controlTypes();
30
	}
31
	
32
	public int getType(RasterFilter rasterFilter){
33
		if(rasterFilter instanceof PruebaFilter)
34
			return PruebaStackManager.prueba;
35
					
36
		return super.getType(rasterFilter);
37
	}
38
	
39
	public ArrayList getStringsFromStack(){
40
		if(rf instanceof PruebaFilter){
41
			filterList.add("filter.prueba.active=true");
42
		}
43
	}
44
	
45
	public void createStackFromStrings(ArrayList f, Integer pos){
46
		if(fil.startsWith("filter.prueba.active") && getValue(fil).equals("true")){
47
			filters.remove(pos.intValue());
48
			this.addPruebaFilter();
49
			filteri = -1;
50
		}
51
	}
52
	
53
}
0 54

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/RasterFileAdapter.java
218 218
	public File getFile() {
219 219
		return file;
220 220
	}
221
	
222
	/**
223
	 * Asina el extent de la vista para imagenes sin informaci?n de
224
	 * georeferenciaci?n.
225
	 * @param extent	Asigna el extent
226
	 */
227
	public void setTempExtent(ViewPort vp){
228
		getFileDriver().setTempExtent(vp);
229
	}
230
	
221
		
231 222
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerFactory.java
282 282
		} else {
283 283
			capa.setSource(adapter);
284 284
			capa.setProjection(proj);
285
			capa.setTempExtent(vp);
285
			//capa.setTempExtent(vp);
286 286
			try {
287 287
				capa.load();
288 288
			} catch (DriverIOException e) {
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/RasterOperations.java
121 121
	 * @return
122 122
	 */
123 123
	public ArrayList getAttributes();
124
	
125
	/**
126
	 * Asigna el extent de la vista para colocar imagenes sin georeferenciar
127
	 * @param extent
128
	 */
129
	public void setTempExtent(ViewPort vp);
130
	
124
		
131 125
	public double getMaxX();
132 126
	public double getMaxY();
133 127
	public double getMinX();
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrRaster.java
54 54
import java.util.ArrayList;
55 55

  
56 56
import org.cresques.cts.IProjection;
57
import org.cresques.io.raster.RasterBuf;
57 58
import org.cresques.io.raster.RasterFilterStack;
59
import org.cresques.io.raster.RasterStats;
60
import org.cresques.io.raster.RasterStats.History;
58 61
import org.cresques.px.Extent;
59 62

  
60 63
import com.hardcode.driverManager.Driver;
......
430 433
	 */
431 434
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale)
432 435
		throws DriverException {
436
		
433 437
		if (isVisible() && isWithinScale(scale)){	
434 438
		isPrinting = true;
435 439
		if (!mustTilePrint) {
......
441 445
	        // del BufferedImage ni caso, cuando se imprime viene con null
442 446
			Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, g.getClipRect());
443 447
			tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
448
			
449
			//Si es la primera lectura salvamos los valores de m?ximo y m?nimo para la aplicaci?n
450
			//de realce si la imagen es de 16 bits.
451
			
452
			RasterStats stats = getSource().getFilterStack().getStats();
453
			if(stats != null)
454
				stats.history.add(stats.new History(getName(), stats.minBandValue, stats.maxBandValue, stats.secondMinBandValue, stats.secondMaxBandValue));	
455
					
456
			
444 457
			for (int tileNr=0; tileNr < tiles.getNumTiles(); tileNr++) {
445 458
	    		// Parte que dibuja
446 459
	    		try {
......
451 464
					e.printStackTrace();
452 465
				}
453 466
	        }
467
			
468
			if(stats != null){
469
				getSource().getFilterStack().getStats().history.clear();
470
				stats = getSource().getFilterStack().getStats();
471
			}
472
						
454 473
		}
455 474
	    isPrinting = false;
456 475
		}
......
462 481
	        // a hacer lo mismo que hace EcwFile: chunkear.
463 482
	        // Llamamos a drawView con cuadraditos m?s peque?os
464 483
	        // del BufferedImage ni caso, cuando se imprime viene con null
484
		
465 485
	        int numW, numH;
466 486
	        int stepX, stepY;
467 487
	        int xProv, yProv, wProv, hProv;
......
566 586
		this.getSource().setBand(flag, nBand);
567 587
	}
568 588
	
569
	/**
570
	 * Asina el extent de la vista para imagenes sin informaci?n de
571
	 * georeferenciaci?n.
572
	 * @param extent	Asigna el extent
573
	 */
574
	public void setTempExtent(ViewPort vp){
575
		((RasterFileAdapter) source).setTempExtent(vp);
576
	}
577 589
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/RasterDriver.java
223 223
	 * @return valor de pixel
224 224
	 */
225 225
	public int[] getPixel(double wcx, double wcy);
226
	
227
	/**
228
	 * Asina el extent de la vista para imagenes sin informaci?n de
229
	 * georeferenciaci?n.
230
	 * @param extent	Asigna el extent
231
	 */
232
	public void setTempExtent(ViewPort vp);
233
		
226
			
234 227
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/raster/CmsRasterDriver.java
125 125
	    	}
126 126

  
127 127
			rasterFile = GeoRasterFile.openFile(proj, fName);
128
			if(tempExtent != null)
129
				rasterFile.setTempExtent(tempExtent);
128
			
130 129
			rasterFile.load();
131 130
			
132 131
			createPxRaster();
......
141 140
	public void initialize(IProjection proj) throws IOException {
142 141
		this.proj = proj;
143 142
		rasterFile = GeoRasterFile.openFile(proj, file.getAbsolutePath());
144
		if(tempExtent != null)
145
			rasterFile.setTempExtent(tempExtent);
143
		
146 144
		rasterFile.load();
147 145
		
148 146
		createPxRaster();
......
399 397
	public GeoRasterFile [] getFiles(){
400 398
		return raster.getFiles();
401 399
	}
402
	
403
	/**
404
	 * Asina el extent de la vista para imagenes sin informaci?n de
405
	 * georeferenciaci?n.
406
	 * @param extent	Asigna el extent
407
	 */
408
	public void setTempExtent(ViewPort vp){
409
		tempExtent = new Extent(vp.getAdjustedExtent());
410
		if(rasterFile != null)
411
			rasterFile.setTempExtent(tempExtent);
412
	}
413
	
400
		
414 401
}

Also available in: Unified diff