Revision 780
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/gui/wizard/PrepareLayerAskProjection.java | ||
---|---|---|
35 | 35 |
import org.gvsig.fmap.dal.DataStore; |
36 | 36 |
import org.gvsig.fmap.dal.DataStoreParameters; |
37 | 37 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
38 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
39 | 38 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
40 | 39 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
41 | 40 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
... | ... | |
50 | 49 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
51 | 50 |
import org.gvsig.raster.tools.app.basic.config.Configuration; |
52 | 51 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.proj.RasterProjectionActionsDialog; |
52 |
import org.gvsig.raster.tools.app.basic.raster.process.IProcessActions; |
|
53 | 53 |
import org.gvsig.raster.tools.app.basic.raster.process.RasterProcess; |
54 | 54 |
import org.gvsig.raster.tools.app.basic.tool.reproject.ReprojectProcess; |
55 | 55 |
import org.gvsig.tools.exception.BaseException; |
56 | 56 |
|
57 |
public class PrepareLayerAskProjection implements PrepareDataStoreParameters, PrepareLayer { |
|
57 |
public class PrepareLayerAskProjection implements PrepareDataStoreParameters, PrepareLayer, IProcessActions {
|
|
58 | 58 |
protected CRSUtils crsUtil = RasterLocator.getManager().getCRSUtils(); |
59 | 59 |
private boolean changeReprojectionOption = true; |
60 | 60 |
private int lastReprojectionOption = RasterDataParameters.DONT_CHANGE_PROJECTION; |
61 |
private ReprojectionQueue queue = ReprojectionQueue.getSingleton(); |
|
61 | 62 |
|
62 | 63 |
/* |
63 | 64 |
* (non-Javadoc) |
... | ... | |
174 | 175 |
|
175 | 176 |
if(!new File(uri).exists()) { |
176 | 177 |
RasterProcess process = new ReprojectProcess(); |
177 |
process.setCancelable(false); |
|
178 | 178 |
process.addParam("layer", lyrRaster); |
179 | 179 |
process.addParam("path", uri); |
180 | 180 |
process.addParam("projection", dstProj); |
181 | 181 |
process.addParam("srcprojection", srcProj); |
182 | 182 |
process.addParam("isintoc", false); |
183 |
process.execute(); |
|
183 |
|
|
184 |
//Despierta la cola que reproyecta im?genes |
|
185 |
synchronized (queue) { |
|
186 |
queue.add(process, this); |
|
187 |
queue.notify(); |
|
188 |
} |
|
189 |
|
|
190 |
//Se suspende hasta que la cola haya terminado |
|
191 |
try { |
|
192 |
synchronized (this) { |
|
193 |
this.wait(); |
|
194 |
} |
|
195 |
} catch (InterruptedException e) { |
|
196 |
} |
|
197 |
|
|
184 | 198 |
if(process.getResult() != null) { |
185 | 199 |
String uriStr = (String)((Object[])process.getResult())[0]; |
186 | 200 |
params.setURI(uriStr); |
... | ... | |
193 | 207 |
|
194 | 208 |
} catch (RasterDriverException e) { |
195 | 209 |
RasterToolsUtil.messageBoxError("Error creating layer", null, e); |
196 |
} catch (ProcessInterruptedException e) { |
|
197 |
} |
|
210 |
} |
|
198 | 211 |
} else if(repOption == RasterDataParameters.REPROJECT_VIEW) { |
199 | 212 |
//Esto se cambia en el prepare que tiene acceso al mapcontrol. Este prepare es a nivel de datos |
200 | 213 |
} |
201 | 214 |
return null; |
202 | 215 |
} |
203 | 216 |
|
217 |
public void end(Object param) { |
|
218 |
|
|
219 |
} |
|
204 | 220 |
|
205 | 221 |
/** |
206 | 222 |
* Compares two projections and show a dialog to the user to make a decision |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/gui/wizard/ReprojectionQueue.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.tools.app.basic.raster.gui.wizard; |
|
23 |
|
|
24 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
25 |
import org.gvsig.raster.tools.app.basic.raster.process.IProcessActions; |
|
26 |
import org.gvsig.raster.tools.app.basic.raster.process.RasterProcess; |
|
27 |
import org.gvsig.raster.util.Queue; |
|
28 |
|
|
29 |
/** |
|
30 |
* Cola de procesos de ejecuci?n exclusiva. Los procesos de esta lista se ir?n ejecutando |
|
31 |
* por orden de llegada impidiendo que se ejecuten dos al mismo tiempo. |
|
32 |
* |
|
33 |
* 16/05/2008 |
|
34 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
35 |
*/ |
|
36 |
public class ReprojectionQueue extends Thread { |
|
37 |
private Queue queue = new Queue(); |
|
38 |
private RasterProcess executionProcess = null; |
|
39 |
static private ReprojectionQueue singleton = null; |
|
40 |
|
|
41 |
/** |
|
42 |
* Devuelve una instancia al unico objeto de UniqueProcessQueue que puede existir. |
|
43 |
* @return |
|
44 |
*/ |
|
45 |
static public ReprojectionQueue getSingleton() { |
|
46 |
if(singleton == null) { |
|
47 |
singleton = new ReprojectionQueue(); |
|
48 |
synchronized (singleton) { |
|
49 |
singleton.start(); |
|
50 |
} |
|
51 |
} |
|
52 |
return singleton; |
|
53 |
} |
|
54 |
|
|
55 |
public void run() { |
|
56 |
//Cuando arranca el thread se duerme porque la cola est? vacia |
|
57 |
synchronized (this) { |
|
58 |
try { |
|
59 |
wait(); |
|
60 |
} catch (InterruptedException e) { |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
while(true) { |
|
65 |
if(queue.size() >= 1) { |
|
66 |
Object[] obj = (Object[])queue.get(); |
|
67 |
executionProcess = ((RasterProcess) obj[0]); |
|
68 |
if (executionProcess != null) { |
|
69 |
executionProcess.showIncrementableWindow(); |
|
70 |
try { |
|
71 |
executionProcess.execute(); |
|
72 |
} catch (ProcessInterruptedException e) { |
|
73 |
} |
|
74 |
executionProcess.getIncrementableTask().processFinalize(); |
|
75 |
|
|
76 |
//Despierta el objeto que llam? cuando termina el calculo |
|
77 |
//para que pueda recoger los resultados |
|
78 |
synchronized (obj[1]) { |
|
79 |
obj[1].notify(); |
|
80 |
} |
|
81 |
|
|
82 |
//Cuando la cola est? vacia se suspende el hilo. |
|
83 |
if(queue.size() <= 0) { |
|
84 |
synchronized (this) { |
|
85 |
try { |
|
86 |
this.wait(); |
|
87 |
} catch (InterruptedException e) { |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
} |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* A?ade un proceso a la cola. |
|
99 |
* @param id Identificador del proceso |
|
100 |
* @param process Proceso |
|
101 |
* @throws InterruptedException |
|
102 |
*/ |
|
103 |
public synchronized void add(RasterProcess process, IProcessActions obj) { |
|
104 |
queue.put(new Object[]{process, obj}); |
|
105 |
} |
|
106 |
|
|
107 |
} |
|
0 | 108 |
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/process/RasterProcess.java | ||
---|---|---|
60 | 60 |
/** |
61 | 61 |
* Crea la ventana de IncrementableTask |
62 | 62 |
*/ |
63 |
private IncrementableTask getIncrementableTask() {
|
|
63 |
public IncrementableTask getIncrementableTask() {
|
|
64 | 64 |
if (incrementableTask == null) { |
65 | 65 |
incrementableTask = new IncrementableTask(this); |
66 | 66 |
incrementableTask.addIncrementableListener(this); |
... | ... | |
79 | 79 |
/** |
80 | 80 |
* Muestra la ventana de IncrementableTask |
81 | 81 |
*/ |
82 |
private void showIncrementableWindow() {
|
|
82 |
public void showIncrementableWindow() {
|
|
83 | 83 |
if (progressActive) { |
84 | 84 |
getIncrementableTask().showWindow(); |
85 | 85 |
getIncrementableTask().start(); |
Also available in: Unified diff