Revision 4216

View differences:

trunk/extensions/extRasterTools/src/com/iver/cit/gvsig/rasterTools/saveRaster/gui/ProgressSaveRasterDialog.java
51 51

  
52 52
import org.cresques.cts.IProjection;
53 53
import org.cresques.io.GeoRasterWriter;
54
import org.cresques.ui.raster.ProgressSaveRasterPanel;
55 54

  
56 55
import com.iver.andami.PluginServices;
57 56
import com.iver.andami.ui.mdiManager.View;
......
61 60
import com.iver.cit.gvsig.fmap.layers.FLayers;
62 61
import com.iver.cit.gvsig.fmap.rasterTools.saveRaster.operations.SaveRasterThread;
63 62
import com.iver.cit.gvsig.rasterTools.saveRaster.gui.SaveRasterDialog.DriverProperties;
63
import com.iver.cit.gvsig.rasterTools.saveRaster.gui.toolListeners.ProgressBarListener;
64 64

  
65 65
/**
66 66
 * @author Nacho Brodin <brodin_ign@gva.es>
67 67
 */
68 68
public class ProgressSaveRasterDialog extends ProgressSaveRasterPanel implements View{
69
	
70

  
71 69
	private ViewPort 					vp = null;
72 70
	private SaveRasterThread			threadSave = null;
71
	private	ProgressBarListener			progressBarListener = null;
73 72
	
74 73
	
75 74
	
......
92 91
		vp.setBackColor(mapCtrl.getViewPort().getBackColor());
93 92
		vp.setImageSize(dimension);
94 93
		vp.setExtent(ext);
95
		
94
		 
96 95
		threadSave = new SaveRasterThread(mapCtrl, layers, dimension, vp, this);
96
		progressBarListener = new ProgressBarListener(threadSave, this);
97 97
	}
98 98
	
99 99
	/**
100 100
	 * Asigna los textos a los paneles en el idioma seleccionado
101 101
	 */	
102 102
	private void setTranslation(){
103
		this.lwait.setText(PluginServices.getText(this,"espere"));
103
		this.getLabelWait().setText(PluginServices.getText(this,"espere"));
104 104
	}
105 105
	
106 106
	/**
trunk/extensions/extRasterTools/src/com/iver/cit/gvsig/rasterTools/saveRaster/gui/ProgressSaveRasterPanel.java
28 28
import javax.swing.JLabel;
29 29
import javax.swing.JPanel;
30 30
import javax.swing.JProgressBar;
31
import java.awt.GridBagLayout;
32
import java.awt.GridBagConstraints;
33
import java.awt.FlowLayout;
34
import javax.swing.JButton;
31 35

  
32 36

  
33 37
/**
......
36 40
 */
37 41
public class ProgressSaveRasterPanel extends JPanel {
38 42
    final private static long serialVersionUID = -3370601314380922368L;
39
    private JPanel jPanel = null;
43
    private JPanel pGeneral = null;
40 44
    private JProgressBar jProgressBar = null;
41 45

  
46
    private JPanel pBar = null;
47
    private JPanel pCancel = null;
48
	private JPanel pCurrentElement = null;
49
	private JPanel pWait = null;
50
	private JLabel lWait = null;
51
	private JButton bCancel = null;
52
	private JLabel lCurrentElement = null;
53
	private JPanel pPercent = null;
54
	private JLabel lPercent = null;
55
	
42 56
    /**
43
     * Variable accesible para la traducci?n
44
     */
45
    public JLabel lwait = null;
46
    private JPanel jPanel2 = null;
47
    private JPanel jPanel1 = null;
48

  
49
    /**
50 57
     * This method initializes
51 58
     *
52 59
     */
......
61 68
     * @return void
62 69
     */
63 70
    private void initialize() {
64
        this.setSize(369, 106);
65
        this.add(getJPanel(), null);
71
        this.setSize(375, 130);
72
        this.setPreferredSize(new java.awt.Dimension(364,125));
73
        this.add(getPGeneral(), null);
66 74
    }
67 75

  
68 76
    /**
......
70 78
     *
71 79
     * @return javax.swing.JPanel
72 80
     */
73
    private JPanel getJPanel() {
74
        if (jPanel == null) {
75
            lwait = new JLabel();
76
            jPanel = new JPanel();
77
            jPanel.setLayout(new BorderLayout());
78
            jPanel.setPreferredSize(new java.awt.Dimension(354, 70));
79
            lwait.setText("Por favor, espere ...");
80
            jPanel.add(lwait, java.awt.BorderLayout.NORTH);
81
            jPanel.add(getJPanel2(), java.awt.BorderLayout.SOUTH);
82
            jPanel.add(getJPanel1(), java.awt.BorderLayout.CENTER);
81
    private JPanel getPGeneral() {
82
        if (pGeneral == null) {
83
            GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
84
            gridBagConstraints3.gridx = 0;
85
            gridBagConstraints3.gridy = 0;
86
            GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
87
            gridBagConstraints21.gridx = 0;
88
            gridBagConstraints21.gridy = 2;
89
            GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
90
            gridBagConstraints11.gridx = 0;
91
            gridBagConstraints11.gridy = 3;
92
            GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
93
            gridBagConstraints1.gridx = 0;
94
            gridBagConstraints1.ipadx = -6;
95
            gridBagConstraints1.gridy = 1;
96
            pGeneral = new JPanel();
97
            pGeneral.setLayout(new GridBagLayout());
98
            pGeneral.setPreferredSize(new java.awt.Dimension(360,120));
99
            pGeneral.add(getPBar(), gridBagConstraints1);
100
            pGeneral.add(getPCancel(), gridBagConstraints11);
101
            pGeneral.add(getPCurrentElement(), gridBagConstraints21);
102
            pGeneral.add(getPWait(), gridBagConstraints3);
83 103
        }
84 104

  
85
        return jPanel;
105
        return pGeneral;
86 106
    }
87 107

  
88 108
    /**
......
107 127
     *
108 128
     * @return javax.swing.JPanel
109 129
     */
110
    private JPanel getJPanel2() {
111
        if (jPanel2 == null) {
112
            jPanel2 = new JPanel();
113
            jPanel2.add(getJProgressBar(), null);
130
    private JPanel getPBar() {
131
        if (pBar == null) {
132
            pBar = new JPanel();
133
            pBar.add(getJProgressBar(), null);
114 134
        }
115 135

  
116
        return jPanel2;
136
        return pBar;
117 137
    }
118 138

  
119 139
    /**
120
     * This method initializes jPanel1
121
     *
122
     * @return javax.swing.JPanel
123
     */
124
    private JPanel getJPanel1() {
125
        if (jPanel1 == null) {
126
            jPanel1 = new JPanel();
127
        }
140
	 * This method initializes jPanel	
141
	 * 	
142
	 * @return javax.swing.JPanel	
143
	 */
144
	private JPanel getPCancel() {
145
		if (pCancel == null) {
146
			FlowLayout flowLayout1 = new FlowLayout();
147
			flowLayout1.setAlignment(java.awt.FlowLayout.CENTER);
148
			pCancel = new JPanel();
149
			pCancel.setLayout(flowLayout1);
150
			pCancel.setPreferredSize(new java.awt.Dimension(350,30));
151
			pCancel.add(getBCancel(), null);
152
		}
153
		return pCancel;
154
	}
128 155

  
129
        return jPanel1;
130
    }
156
	/**
157
	 * This method initializes jPanel	
158
	 * 	
159
	 * @return javax.swing.JPanel	
160
	 */
161
	private JPanel getPCurrentElement() {
162
		if (pCurrentElement == null) {
163
			lCurrentElement = new JLabel();
164
			lCurrentElement.setText("");
165
			lCurrentElement.setPreferredSize(new java.awt.Dimension(340,15));
166
			FlowLayout flowLayout2 = new FlowLayout();
167
			flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
168
			pCurrentElement = new JPanel();
169
			pCurrentElement.setLayout(flowLayout2);
170
			pCurrentElement.setPreferredSize(new java.awt.Dimension(350,25));
171
			pCurrentElement.add(lCurrentElement, null);
172
		}
173
		return pCurrentElement;
174
	}
175

  
176
	/**
177
	 * This method initializes jPanel	
178
	 * 	
179
	 * @return javax.swing.JPanel	
180
	 */
181
	private JPanel getPWait() {
182
		if (pWait == null) {
183
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
184
			gridBagConstraints2.gridx = 1;
185
			gridBagConstraints2.gridy = 0;
186
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
187
			gridBagConstraints.insets = new java.awt.Insets(2,2,2,2);
188
			gridBagConstraints.gridy = 0;
189
			gridBagConstraints.gridx = 0;
190
			lWait = new JLabel();
191
			lWait.setText("Por favor, espere,...");
192
			pWait = new JPanel();
193
			pWait.setLayout(new GridBagLayout());
194
			pWait.setPreferredSize(new java.awt.Dimension(350,25));
195
			pWait.add(lWait, gridBagConstraints);
196
			pWait.add(getPPercent(), gridBagConstraints2);
197
		}
198
		return pWait;
199
	}
200

  
201
	/**
202
	 * This method initializes jButton	
203
	 * 	
204
	 * @return javax.swing.JButton	
205
	 */
206
	public JButton getBCancel() {
207
		if (bCancel == null) {
208
			bCancel = new JButton();
209
			bCancel.setPreferredSize(new java.awt.Dimension(110,20));
210
			bCancel.setText("Cancelar");
211
		}
212
		return bCancel;
213
	}
214

  
215
	/**
216
	 * This method initializes jPanel	
217
	 * 	
218
	 * @return javax.swing.JPanel	
219
	 */
220
	private JPanel getPPercent() {
221
		if (pPercent == null) {
222
			lPercent = new JLabel();
223
			lPercent.setText("0%");
224
			lPercent.setPreferredSize(new java.awt.Dimension(35,15));
225
			FlowLayout flowLayout = new FlowLayout();
226
			flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
227
			pPercent = new JPanel();
228
			pPercent.setLayout(flowLayout);
229
			pPercent.setPreferredSize(new java.awt.Dimension(230,25));
230
			pPercent.add(lPercent, null);
231
		}
232
		return pPercent;
233
	}
234
	
235
	/**
236
	 * Obtiene la etiqueta del mensaje de espera
237
	 * @return JLabel que representa la etiqueta del mensaje de espera
238
	 */
239
	public JLabel getLabelWait(){
240
		return lWait;
241
	}
242
	
243
	/**
244
	 * Obtiene la etiqueta que marca el porcentaje
245
	 * @return JLabel que representa la etiqueta que marca el porcentaje
246
	 */
247
	public JLabel getLabelPercent(){
248
		return lPercent;
249
	}
250
	
251
	/**
252
	 * Obtiene la etiqueta del elemento actualmente analizado
253
	 * @return JLabel que representa la etiqueta del elemento actualmente analizado
254
	 */
255
	public JLabel getLabelCurrentElement(){
256
		return lCurrentElement;
257
	}
258
	
131 259
} //  @jve:decl-index=0:visual-constraint="10,10"
trunk/extensions/extRasterTools/src/com/iver/cit/gvsig/rasterTools/saveRaster/gui/toolListeners/ProgressBarListener.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package com.iver.cit.gvsig.rasterTools.saveRaster.gui.toolListeners;
25

  
26
import java.awt.event.ActionEvent;
27
import java.awt.event.ActionListener;
28
import java.awt.event.KeyEvent;
29
import java.awt.event.KeyListener;
30

  
31
import com.iver.andami.PluginServices;
32
import com.iver.cit.gvsig.fmap.rasterTools.saveRaster.operations.SaveRasterThread;
33
import com.iver.cit.gvsig.rasterTools.saveRaster.gui.ProgressSaveRasterDialog;
34
import com.iver.cit.gvsig.rasterTools.saveRaster.gui.ProgressSaveRasterPanel;
35

  
36

  
37
/**
38
 * Clase encargada de manejar los eventos del los controles de la 
39
 * barra de progreso de salvar a raster
40
 * @author Nacho Brodin (brodin_ign@gva.es)
41
 */
42
public class ProgressBarListener implements ActionListener, KeyListener {
43
    final private static long 			serialVersionUID = -3370601314380922368L;
44
    private SaveRasterThread			saver = null;
45
    private ProgressSaveRasterDialog	panel = null;
46

  
47
    public ProgressBarListener(SaveRasterThread saver, ProgressSaveRasterDialog panel){
48
    	this.saver = saver;
49
    	this.panel = panel;
50
    	panel.getBCancel().addKeyListener(this);
51
    	panel.getBCancel().addActionListener(this);
52
    }
53
    
54
	public void keyPressed(KeyEvent e) {
55
		// TODO Auto-generated method stub
56
		
57
	}
58

  
59
	public void keyReleased(KeyEvent e) {
60
		// TODO Auto-generated method stub
61
		
62
	}
63

  
64
	public void keyTyped(KeyEvent e) {
65
		// TODO Auto-generated method stub
66
		
67
	}
68

  
69
	public void actionPerformed(ActionEvent e) {
70
		if(e.getSource() == panel.getBCancel()){
71
			saver.stopThread();
72
			PluginServices.getMDIManager().closeView(panel);
73
		}	
74
	}
75
   
76
}
77

  
0 78

  
trunk/extensions/extRasterTools/src/com/iver/cit/gvsig/fmap/rasterTools/saveRaster/operations/RasterizerLayer.java
64 64
import com.iver.cit.gvsig.fmap.layers.FLayers;
65 65
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
66 66
import com.iver.cit.gvsig.fmap.operations.Cancellable;
67
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
67
import com.iver.cit.gvsig.rasterTools.saveRaster.gui.ProgressSaveRasterPanel;
68 68

  
69 69
/**
70 70
 * @author Nacho Brodin <brodin_ign@gva.es>
......
76 76
 */
77 77
public class RasterizerLayer extends Rasterizer{
78 78
	
79
	private ViewPort		viewPort = null;
80
	private ViewPort		viewPortBlock = null;
81
	private FLayers			flayers = null;
82
	private Color			backgroundColor = null;
83
	private JProgressBar	progressBar = null;
84
	private double			incrProgressBar = 0;
85
	private boolean			firstRead = true;
86
    private int 			nBlocks = 0;
87
    private double 			percentMax = 100.0D;
88
    private double			incrTemp = 0;
79
	private ViewPort				viewPort = null;
80
	private ViewPort				viewPortBlock = null;
81
	private FLayers					flayers = null;
82
	private Color					backgroundColor = null;
83
	private ProgressSaveRasterPanel	progressBar = null;
84
	private double					incrProgressBar = 0;
85
	private boolean					firstRead = true;
86
    private int 					nBlocks = 0;
87
    private double 					percentMax = 100.0D;
88
    private double					incrTemp = 0;
89 89
 	
90 90
	/**
91 91
	 * Calculo del viewPort
......
225 225
			calcViewPort(viewPortBlock);			
226 226
			
227 227
			if(progressBar != null){
228
				this.incrTemp = (incrTemp - ((int)incrTemp)) + progressBar.getValue() + incrProgressBar;
229
				if(((int)incrTemp) !=  progressBar.getValue())
230
					progressBar.setValue((int)incrTemp);	
231
				//System.out.println("===>progressBar.getValue()="+incrProgressBar+" "+incrTemp+" "+Math.floor(incrTemp)+" "+progressBar.getValue());
228
				this.incrTemp = (incrTemp - ((int)incrTemp)) + progressBar.getJProgressBar().getValue() + incrProgressBar;
229
				if(((int)incrTemp) !=  progressBar.getJProgressBar().getValue()){
230
					progressBar.getJProgressBar().setValue((int)incrTemp);
231
					if(incrTemp <= 100)
232
						progressBar.getLabelPercent().setText(((int)incrTemp)+"%");
233
				}
232 234
			}
233 235
			
234 236
			contBlocks++;
......
242 244
	 * Asigna la barra de progreso
243 245
	 * @param bar Barra de progreso
244 246
	 */
245
	public void setProgressBar(JProgressBar bar, double percentMax){
246
		this.progressBar = bar;
247
	public void setProgressBar(ProgressSaveRasterPanel progress, double percentMax){
248
		this.progressBar = progress;
247 249
		if(percentMax != 0){
248 250
			this.percentMax = percentMax;
249 251
			incrProgressBar = percentMax/((double)nBlocks);
trunk/extensions/extRasterTools/src/com/iver/cit/gvsig/fmap/rasterTools/saveRaster/operations/SaveRasterThread.java
86 86
	private double[]					maxPercentBarList = new double[1];;
87 87
	private int 						compresion = 1;
88 88
	private DriverProperties 			driverProps = null;
89
	
89

  
90 90
		
91 91
	public SaveRasterThread(MapControl mapCtrl, 
92 92
							FLayers layers, 
......
106 106
		RasterizerLayer p = new RasterizerLayer(layers, vp, sizeBlock, mapCtrl);
107 107
		
108 108
		//Asignamos la barra de progreso
109
		p.setProgressBar(window.getJProgressBar(), maxPercentBarList[0]);
109
		p.setProgressBar(window, maxPercentBarList[0]);
110 110
		
111 111
		//Creamos el driver
112 112
		Extent ex = new Extent(vp.getAdjustedExtent());
......
132 132
	}
133 133
	
134 134
	/**
135
	 *Detiene la compresi?n
136
	 */
137
	synchronized public void stopThread(){
138
		writer.writeClose();
139
	}
140
	
141
	/**
135 142
	 * Asigna el objeto que contiene las propiedades
136 143
	 * @param driverProps
137 144
	 */
trunk/extensions/extRasterTools/.project
12 12
		</buildCommand>
13 13
	</buildSpec>
14 14
	<natures>
15
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
15 16
		<nature>org.eclipse.jdt.core.javanature</nature>
17
		<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
16 18
	</natures>
17 19
</projectDescription>

Also available in: Unified diff