Revision 4532

View differences:

trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GdalWriter.java
88 88
    private String[] 				params = null; //Par?metros de creaci?n del dataset.
89 89
    private GdalSupportOptions 		support = null;
90 90
    private boolean 				consulta = false;
91
    private	boolean					write = true; //Cuando est? a true se puede escribir en la imagen de salida. Si est? a false el proceso es interrumpido
91 92

  
92 93
    /**
93 94
     * Constructor para la obtenci?n de par?metros del driver
......
441 442
                    rband = dset_destino.getRasterBand(iBand + 1);
442 443

  
443 444
                    for (int iBlock = 0; iBlock < nBlocks; iBlock++) {
444
                        //leemos el bloque origen
445
                        buf.buffByte = currentRaster.getGeoFile().getWindow(0,
446
                                                                            iBlock * this.support.getBlockSize(),
447
                                                                            sizeWindowX,
448
                                                                            this.support.getBlockSize(),
449
                                                                            iBand +
450
                                                                            1);
451

  
452
                        //Escribimos el bloque destino
453
                        rband.writeRaster(0,
454
                                          iBlock * this.support.getBlockSize(),
455
                                          sizeWindowX,
456
                                          this.support.getBlockSize(), buf,
457
                                          Gdal.GDT_Byte);
445
                    	if(write){
446
	                        //leemos el bloque origen
447
	                        buf.buffByte = currentRaster.getGeoFile().getWindow(0,
448
	                                                                            iBlock * this.support.getBlockSize(),
449
	                                                                            sizeWindowX,
450
	                                                                            this.support.getBlockSize(),
451
	                                                                            iBand +
452
	                                                                            1);
453
	
454
	                        //Escribimos el bloque destino
455
	                        rband.writeRaster(0,
456
	                                          iBlock * this.support.getBlockSize(),
457
	                                          sizeWindowX,
458
	                                          this.support.getBlockSize(), buf,
459
	                                          Gdal.GDT_Byte);
460
                    	}else
461
                    		this.writeClose();
458 462
                    }
459 463
                }
460 464
            } else if (mode == Mode.dataWrite) {
461 465
                //for(int iBlock=1;iBlock<=nBlocks;iBlock++){
462 466
                for (int iBlock = 0; iBlock < nBlocks; iBlock++) {
463 467
                    int posicionY = iBlock * this.support.getBlockSize();
464
                    writeBands(buftmp, this.support.getBlockSize(), posicionY);
468
                    if(write)
469
                    	writeBands(buftmp, this.support.getBlockSize(), posicionY);
470
                    else
471
                    	this.writeClose();
465 472
                }
466 473
            }
467 474

  
......
469 476
                if (mode == Mode.fileWrite) {
470 477
                    for (int iBand = 0; iBand < this.nBands; iBand++) {
471 478
                        rband = dset_destino.getRasterBand(iBand + 1);
472

  
473
                        //leemos el bloque origen
474
                        buf.buffByte = currentRaster.getGeoFile().getWindow(0,
475
                                                                            nBlocks * this.support.getBlockSize(),
476
                                                                            sizeWindowX,
477
                                                                            anchoResto,
478
                                                                            iBand +
479
                                                                            1);
480

  
481
                        //Escribimos el bloque destino
482
                        rband.writeRaster(0,
483
                                          nBlocks * this.support.getBlockSize(),
484
                                          sizeWindowX, anchoResto, buf,
485
                                          Gdal.GDT_Byte);
479
                        if(write){
480
	                        //leemos el bloque origen
481
	                        buf.buffByte = currentRaster.getGeoFile().getWindow(0,
482
	                                                                            nBlocks * this.support.getBlockSize(),
483
	                                                                            sizeWindowX,
484
	                                                                            anchoResto,
485
	                                                                            iBand +
486
	                                                                            1);
487
	
488
	                        //Escribimos el bloque destino
489
	                        rband.writeRaster(0,
490
	                                          nBlocks * this.support.getBlockSize(),
491
	                                          sizeWindowX, anchoResto, buf,
492
	                                          Gdal.GDT_Byte);
493
                        }else
494
                        	this.writeClose();
486 495
                    }
487 496
                } else if (mode == Mode.dataWrite) {
488 497
                    int posicionY = nBlocks * this.support.getBlockSize();
489
                    writeBands(buftmp, anchoResto, posicionY);
498
                    if(write)
499
                    	writeBands(buftmp, anchoResto, posicionY);
500
                    else
501
                    	this.writeClose();
490 502
                }
491 503
            }
492 504
        } catch (GdalException e) {
......
571 583
     */
572 584
    public void writeClose() {
573 585
        try {
574
            dset_destino.close();
586
        	if(dset_destino != null)
587
        		dset_destino.close();
575 588
            oSRS = null;
576 589
        } catch (GdalException e) {
577 590
            e.printStackTrace();
......
582 595
     * Cancela el salvado de datos.
583 596
     */
584 597
    public void writeCancel() {
585
        this.writeClose();
598
       write = false; 
586 599
    }
587 600
    
588 601
    /**
......
676 689
    }
677 690

  
678 691
    /**
692
     * Obtiene el valor a la variable write que estar? a true cuando se est? escribiendo
693
     *  o puede escribirse la imagen de salida. El cancelar la operaci?n de escritura
694
     * pondr? esta variable a false deteniendose la escritura y cerrandose el dataset
695
     * de salida. 
696
     * @return True si puede escribirse y false si no puede
697
     */
698
    public boolean isWrite() {
699
		return write;
700
	}
701

  
702
    /**
703
     * Asigna el valor a la variable write que estar? a true cuando se est? escribiendo
704
     *  o puede escribirse la imagen de salida. El cancelar la operaci?n de escritura
705
     * pondr? esta variable a false deteniendose la escritura y cerrandose el dataset
706
     * de salida. 
707
     * @param write Variable booleana. True si puede escribirse y false si no puede
708
     */
709
	public void setWrite(boolean write) {
710
		this.write = write;
711
	}
712
	
713
    /**
679 714
     *
680 715
     * @author Nacho Brodin (brodin_ign@gva.es)
681 716
     *
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/JpegWriter.java
183 183
     * Cancela el salvado de datos.
184 184
     */
185 185
    public void writeCancel() {
186
    	gdalWriter.writeClose();
186
    	/*if(gdalWriter)
187
    	gdalWriter.writeClose();*/
187 188
    }
188 189
    
189 190
    /**
trunk/libraries/libCq CMS for java.old/src-test/org/cresques/ui/PruebaFrame.java
1
package org.cresques.ui;
2

  
3
import javax.swing.JFrame;
4

  
5
import org.cresques.ui.raster.TransparencyByPixelPanel;
6

  
7
public class PruebaFrame extends JFrame{
8

  
9
	public PruebaFrame(){
10
		this.setSize(353,158);
11
		TransparencyByPixelPanel tbp = new TransparencyByPixelPanel();
12
		this.getContentPane().add(tbp);
13
		tbp.setControlEnabled(true);
14
		this.show();
15
	}
16
	/**
17
	 * @param args
18
	 */
19
	public static void main(String[] args) {
20
		PruebaFrame f = new PruebaFrame();
21
	}
22

  
23
}
0 24

  
trunk/extensions/extRasterTools/src-test/EndInfoPanelTest.java
7 7
public class EndInfoPanelTest extends JFrame{
8 8

  
9 9
	public EndInfoPanelTest(){
10
		this.setSize(492,185);
10
		this.setSize(488,156);
11 11
		EndInfoDialog panel = new EndInfoDialog();
12 12
		
13 13
		this.getContentPane().add(panel);
trunk/extensions/extRasterTools/src/com/iver/cit/gvsig/rasterTools/saveRaster/ui/toolListeners/DataInputListener.java
246 246
    	if(	controlPanel.getRbMtsPixel().isSelected() && 
247 247
    		!controlPanel.getTMtsPixel().getText().equals("")){
248 248
    		double mtsPixel = Double.parseDouble(controlPanel.getTMtsPixel().getText());
249
    		calcSizeScale(mtsPixel, resolution);
249
    		if(controlPanel.getProjection().isProjected())
250
    			calcSizeScale(mtsPixel, resolution);
250 251
    	}
251 252
    }
252 253

  
......
363 364
    			controlPanel.getWidthInPixelsGeodesicas(), 
364 365
    			Integer.parseInt((String)controlPanel.getCbResolution().getSelectedItem()));
365 366

  
366
    	int widthPixels = (int)((scaleIntro * saveRaster.getWidth()) / scale);
367
    	int heightPixels = (int)((scaleIntro * saveRaster.getHeight()) / scale);
368
    	
369
    	saveRaster.getTancho().setText(String.valueOf(widthPixels));
370
        saveRaster.getTalto().setText(String.valueOf(heightPixels));*/
367
    	this.widthInPixels = (int)((scaleIntro * controlPanel.getWidthInPixelsGeodesicas()) / scale);
368
    	this.heightInPixels = (int)((scaleIntro * controlPanel.getHeightInPixelsGeodesicas()) / scale);
369
    	    
370
        mtsPerPixel = MathUtils.tailDecimals(((double)(widthMts / this.widthInPixels)), 5);
371
        
372
        controlPanel.getTMtsPixel().setText(String.valueOf(mtsPerPixel));
373
        this.setCorrectMeasure(this.widthInPixels, controlPanel.getTWidth());
374
        this.setCorrectMeasure(this.heightInPixels, controlPanel.getTHeight());*/    	
371 375
    }
372 376
    
373 377
    /**
......
388 392
        double heightInches = (heightMts / Double.parseDouble(controlPanel.getTScale().getText())) * MathUtils.INCHESMTR;
389 393

  
390 394
        //Ancho en pixeles = ppp * sizepulgadas
391
        int widthPixels = (int) (Integer.parseInt(controlPanel.getCbResolution().getSelectedItem().toString()) * widthInches);
392
        int heightPixels = (int) (Integer.parseInt(controlPanel.getCbResolution().getSelectedItem().toString()) * heightInches);
395
        this.widthInPixels = (int) (Integer.parseInt(controlPanel.getCbResolution().getSelectedItem().toString()) * widthInches);
396
        this.heightInPixels = (int) (Integer.parseInt(controlPanel.getCbResolution().getSelectedItem().toString()) * heightInches);
393 397
                 
394
        mtsPerPixel = (double)(widthMts / widthPixels);        
398
        mtsPerPixel = (double)(widthMts / this.widthInPixels);        
395 399
        //double mtsPixelH = wc_altomts/altoPixels;
396 400
       
397 401
        //recortamos a 5 decimales
398 402
        mtsPerPixel = MathUtils.tailDecimals(mtsPerPixel, 5);
399 403
        
400 404
        controlPanel.getTMtsPixel().setText(String.valueOf(mtsPerPixel));
401
        this.setCorrectMeasure(widthPixels, controlPanel.getTWidth());
402
        this.setCorrectMeasure(heightPixels, controlPanel.getTHeight());
403
        this.widthInPixels = widthPixels;
404
        this.heightInPixels = heightPixels;
405
        
405
        this.setCorrectMeasure(this.widthInPixels, controlPanel.getTWidth());
406
        this.setCorrectMeasure(this.heightInPixels, controlPanel.getTHeight());
407
                
406 408
        //int anchopixels =(int) (Toolkit.getDefaultToolkit().getScreenResolution() * anchopulgadas);
407 409
        //int altopixels = (int) (Toolkit.getDefaultToolkit().getScreenResolution() * altopulgadas);
408 410
    }
......
414 416
     */
415 417
    private void calcSizeScale(double mtsPixel, int resolution){        
416 418
        //N?mero de p?xeles de ancho y alto 
417
        int widthPixels = (int)(widthMts / mtsPixel);
418
        int heightPixels = (int)(heightMts / mtsPixel);
419
    	this.widthInPixels = (int)(widthMts / mtsPixel);
420
    	this.heightInPixels = (int)(heightMts / mtsPixel);
419 421
        
420 422
        //Obtenemos los mts/pixel reales ya que el n?mero de pixeles es entero deben redondearse
421
        mtsPerPixel = (double)(widthMts / widthPixels);
423
        mtsPerPixel = (double)(widthMts / widthInPixels);
422 424
        
423 425
        //recortamos a 5 decimales
424 426
        mtsPerPixel = MathUtils.tailDecimals(mtsPerPixel, 5);
425 427
        
426 428
        //Obtenemos el ancho y alto en pulgadas
427
        double widthInches = (double)(widthPixels / Integer.parseInt(controlPanel.getCbResolution().getSelectedItem().toString()));
428
        double heightInches = (double)(heightPixels / Integer.parseInt(controlPanel.getCbResolution().getSelectedItem().toString()));
429
        double widthInches = (double)(widthInPixels / Integer.parseInt(controlPanel.getCbResolution().getSelectedItem().toString()));
430
        double heightInches = (double)(heightInPixels / Integer.parseInt(controlPanel.getCbResolution().getSelectedItem().toString()));
429 431
        
430 432
        //Calculo de la escala
431 433
        int scale = (int)((widthMts * MathUtils.INCHESMTR) / widthInches);
432 434
        
433 435
        controlPanel.getTScale().setText(String.valueOf(scale));
434 436
        controlPanel.getTMtsPixel().setText(String.valueOf(mtsPerPixel));
435
        this.setCorrectMeasure(widthPixels, controlPanel.getTWidth());
436
        this.setCorrectMeasure(heightPixels, controlPanel.getTHeight());
437
        this.widthInPixels = widthPixels;
438
        this.heightInPixels = heightPixels;  
437
        this.setCorrectMeasure(widthInPixels, controlPanel.getTWidth());
438
        this.setCorrectMeasure(heightInPixels, controlPanel.getTHeight());
439 439
    }
440 440

  
441 441
    /**
......
492 492
     */
493 493
    public void actionPerformed(ActionEvent e) {
494 494
    	obj = e.getSource();
495
    
495
    	
496 496
        //Selector de Fichero sobre el cual se va a salvar a raster
497 497
        if (obj.equals(controlPanel.getBSelect())) {
498 498
            JFileChooser chooser = new JFileChooser("./");
......
567 567
    }
568 568

  
569 569
    public void mouseClicked(MouseEvent e) {
570
    	if( (obj.equals(controlPanel.getTHeight()) && e.getSource().equals(controlPanel.getTWidth())) ||
571
    		(obj.equals(controlPanel.getTWidth()) && e.getSource().equals(controlPanel.getTHeight())) )
572
    		return;
570 573
    	obj = e.getSource();
571 574
        this.recalcParams();
572 575
        enableButtons();
trunk/extensions/extRasterTools/src/com/iver/cit/gvsig/rasterTools/saveRaster/ui/toolListeners/SaveRasterListener.java
98 98
			dialog.setWidthInPixelsGeodesicas((int)Math.abs(fin.getX()-ini.getX()));
99 99
			dialog.setHeightInPixelsGeodesicas((int)Math.abs(fin.getY()-ini.getY()));
100 100
						
101
			int dec = 2;
102
			if(!vp.getProjection().isProjected())
103
				dec = 6;
104
						
101 105
			int indexPoint = String.valueOf(rect.getMaxX()).indexOf('.');
102
			dialog.getTInfDerX().setText(String.valueOf(rect.getMaxX()).substring(0,indexPoint+2));
106
			try{
107
				dialog.getTInfDerX().setText(String.valueOf(rect.getMaxX()).substring(0,indexPoint + dec));
108
			}catch(IndexOutOfBoundsException ex){
109
				dialog.getTInfDerX().setText(String.valueOf(rect.getMaxX()));
110
			}
111
			
103 112
			indexPoint = String.valueOf(rect.getMaxY()).indexOf('.');
104
			dialog.getTInfDerY().setText(String.valueOf(rect.getMinY()).substring(0,indexPoint+2));
113
			try{
114
				dialog.getTInfDerY().setText(String.valueOf(rect.getMinY()).substring(0,indexPoint + dec));
115
			}catch(IndexOutOfBoundsException ex){
116
				dialog.getTInfDerY().setText(String.valueOf(rect.getMinY()));
117
			}
118
			
105 119
			indexPoint = String.valueOf(rect.getMinX()).indexOf('.');
106
			dialog.getTSupIzqX().setText(String.valueOf(rect.getMinX()).substring(0,indexPoint+2));
120
			try{
121
				dialog.getTSupIzqX().setText(String.valueOf(rect.getMinX()).substring(0,indexPoint + dec));
122
			}catch(IndexOutOfBoundsException ex){
123
				dialog.getTSupIzqX().setText(String.valueOf(rect.getMinX()));
124
			}
125
			
107 126
			indexPoint = String.valueOf(rect.getMinY()).indexOf('.');
108
			dialog.getTSupIzqY().setText(String.valueOf(rect.getMaxY()).substring(0,indexPoint+2));
127
			try{
128
				dialog.getTSupIzqY().setText(String.valueOf(rect.getMaxY()).substring(0,indexPoint + dec));
129
			}catch(IndexOutOfBoundsException ex){
130
				dialog.getTSupIzqY().setText(String.valueOf(rect.getMaxY()));
131
			}
109 132
			
110 133
			PluginServices.getMDIManager().addView(saveRaster);
111 134
		}
trunk/extensions/extRasterTools/src/com/iver/cit/gvsig/rasterTools/saveRaster/ui/info/EndInfoDialog.java
20 20
	 */
21 21
	public EndInfoDialog(	){
22 22
		super();
23
		this.setSize(492, 185);
23
		this.setSize(488, 156);
24 24
		this.getBAccept().addActionListener(this);
25 25
		this.setTranslation();
26 26
	}
trunk/extensions/extRasterTools/src/com/iver/cit/gvsig/rasterTools/saveRaster/ui/info/EndInfoPanel.java
47 47
		gridBagConstraints2.gridx = 0;
48 48
		gridBagConstraints2.gridy = 1;
49 49
		this.setLayout(new GridBagLayout());
50
		this.setSize(482, 155);
51
		this.setPreferredSize(new java.awt.Dimension(472,90));
50
		this.setSize(482, 130);
51
		this.setPreferredSize(new java.awt.Dimension(472,75));
52 52
		this.add(getJPanel12(), gridBagConstraints4);
53 53
		this.add(getJPanel2(), gridBagConstraints2);
54 54
	}
......
175 175
	private JPanel getJPanel4() {
176 176
		if (jPanel == null) {
177 177
			jPanel = new JPanel();
178
			jPanel.setPreferredSize(new java.awt.Dimension(472,25));
178
			jPanel.setPreferredSize(new java.awt.Dimension(472,0));
179 179
		}
180 180
		return jPanel;
181 181
	}
......
202 202
			pMain = new JPanel();
203 203
			pMain.setLayout(new GridBagLayout());
204 204
			pMain.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1), "Estadisticas", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
205
			pMain.setPreferredSize(new java.awt.Dimension(482,100));
205 206
			pMain.add(getJPanel4(), gridBagConstraints3);
206 207
			pMain.add(getJPanel3(), gridBagConstraints11);
207 208
			pMain.add(getJPanel1(), gridBagConstraints1);
......
276 277
	public void setTime(long time){
277 278
		int days = 0, hours = 0, minuts = 0, seconds = (int)(time / 1000D);
278 279
		if(seconds >= 60){
279
			minuts = (int)(minuts / 60);
280
			seconds = (int)(time - (minuts * 60));
280
			minuts = (int)(seconds / 60);
281
			seconds = (int)(seconds - (minuts * 60));
281 282
			if(minuts >= 60){
282 283
				hours = (int)(minuts / 1024);
283 284
				minuts = (int)(minuts - (hours * 60));

Also available in: Unified diff