Revision 36621
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/test-images/float.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<Statistics> |
|
4 |
<BandCount>1</BandCount> |
|
5 |
<Band> |
|
6 |
<Max>2410.0</Max> |
|
7 |
<Min>514.0</Min> |
|
8 |
<SecondMax>2407.0</SecondMax> |
|
9 |
<SecondMin>514.0009765625</SecondMin> |
|
10 |
<MaxRGB>0.0</MaxRGB> |
|
11 |
<MinRGB>0.0</MinRGB> |
|
12 |
<SecondMaxRGB>0.0</SecondMaxRGB> |
|
13 |
<SecondMinRGB>255.0</SecondMinRGB> |
|
14 |
<Mean>1410.9055247992521</Mean> |
|
15 |
<Variance>182468.80240074173</Variance> |
|
16 |
</Band> |
|
17 |
</Statistics> |
|
18 |
<FLyrGeoRaster> |
|
19 |
<Projection></Projection> |
|
20 |
<Extent> |
|
21 |
<X>262846.525725</X> |
|
22 |
<Y>4464275.0</Y> |
|
23 |
<RotationX>0.0</RotationX> |
|
24 |
<RotationY>0.0</RotationY> |
|
25 |
<PixelSizeX>25.0</PixelSizeX> |
|
26 |
<PixelSizeY>-25.0</PixelSizeY> |
|
27 |
<Width>15025.0</Width> |
|
28 |
<Height>10250.0</Height> |
|
29 |
</Extent> |
|
30 |
<Dimension> |
|
31 |
<ImagePxWidth>601.0</ImagePxWidth> |
|
32 |
<ImagePxHeight>410.0</ImagePxHeight> |
|
33 |
</Dimension> |
|
34 |
</FLyrGeoRaster> |
|
35 |
</RasterMetaFile> |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/test-images/bilinear.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<FLyrGeoRaster> |
|
4 |
<Projection></Projection> |
|
5 |
<Extent> |
|
6 |
<X>265346.52</X> |
|
7 |
<Y>4461775.0</Y> |
|
8 |
<RotationX>0.0</RotationX> |
|
9 |
<RotationY>0.0</RotationY> |
|
10 |
<PixelSizeX>12.5</PixelSizeX> |
|
11 |
<PixelSizeY>-12.5</PixelSizeY> |
|
12 |
<Width>0.0</Width> |
|
13 |
<Height>0.0</Height> |
|
14 |
</Extent> |
|
15 |
<Dimension> |
|
16 |
<ImagePxWidth>200.0</ImagePxWidth> |
|
17 |
<ImagePxHeight>200.0</ImagePxHeight> |
|
18 |
</Dimension> |
|
19 |
</FLyrGeoRaster> |
|
20 |
<ColorInterpretation> |
|
21 |
<BandCount>1</BandCount> |
|
22 |
<Band>Gray</Band> |
|
23 |
</ColorInterpretation> |
|
24 |
</RasterMetaFile> |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/test-images/distInversa.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<FLyrGeoRaster> |
|
4 |
<Projection></Projection> |
|
5 |
<Extent> |
|
6 |
<X>265346.52</X> |
|
7 |
<Y>4461775.0</Y> |
|
8 |
<RotationX>0.0</RotationX> |
|
9 |
<RotationY>0.0</RotationY> |
|
10 |
<PixelSizeX>12.5</PixelSizeX> |
|
11 |
<PixelSizeY>-12.5</PixelSizeY> |
|
12 |
<Width>0.0</Width> |
|
13 |
<Height>0.0</Height> |
|
14 |
</Extent> |
|
15 |
<Dimension> |
|
16 |
<ImagePxWidth>200.0</ImagePxWidth> |
|
17 |
<ImagePxHeight>200.0</ImagePxHeight> |
|
18 |
</Dimension> |
|
19 |
</FLyrGeoRaster> |
|
20 |
<ColorInterpretation> |
|
21 |
<BandCount>1</BandCount> |
|
22 |
<Band>Gray</Band> |
|
23 |
</ColorInterpretation> |
|
24 |
</RasterMetaFile> |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/test-images/bSpline.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<FLyrGeoRaster> |
|
4 |
<Projection></Projection> |
|
5 |
<Extent> |
|
6 |
<X>265346.52</X> |
|
7 |
<Y>4461775.0</Y> |
|
8 |
<RotationX>0.0</RotationX> |
|
9 |
<RotationY>0.0</RotationY> |
|
10 |
<PixelSizeX>12.5</PixelSizeX> |
|
11 |
<PixelSizeY>-12.5</PixelSizeY> |
|
12 |
<Width>0.0</Width> |
|
13 |
<Height>0.0</Height> |
|
14 |
</Extent> |
|
15 |
<Dimension> |
|
16 |
<ImagePxWidth>200.0</ImagePxWidth> |
|
17 |
<ImagePxHeight>200.0</ImagePxHeight> |
|
18 |
</Dimension> |
|
19 |
</FLyrGeoRaster> |
|
20 |
<ColorInterpretation> |
|
21 |
<BandCount>1</BandCount> |
|
22 |
<Band>Gray</Band> |
|
23 |
</ColorInterpretation> |
|
24 |
</RasterMetaFile> |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>extRasterTools-SE</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>de.loskutov.FileSync.FSBuilder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
</buildSpec> |
|
19 |
<natures> |
|
20 |
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature> |
|
21 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
22 |
<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature> |
|
23 |
</natures> |
|
24 |
</projectDescription> |
|
0 | 25 |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/package.info | ||
---|---|---|
1 |
|
|
2 |
state=devel |
|
3 |
name=org.gvsig.rastertools |
|
4 |
official=true |
|
5 |
code=org.gvsig.rastertools |
|
6 |
operating-system=all |
|
7 |
architecture=all |
|
8 |
java-version=j1_5 |
|
9 |
gvSIG-version=1.12.0 |
|
10 |
version=1.12.0 |
|
11 |
type=plugin |
|
12 |
description=gvSIG basic extensions |
|
13 |
build=1402 |
|
14 |
buildNumber=1402 |
|
15 |
model-version=1.0.0 |
|
16 |
|
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/build.number | ||
---|---|---|
1 |
#Build Number for ANT. Do not edit! |
|
2 |
#Wed Sep 21 10:30:55 CEST 2011 |
|
3 |
build.number=1402 |
|
0 | 4 |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/src/org/gvsig/raster/ConfigurationEvent.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster; |
|
20 |
|
|
21 |
import java.util.EventObject; |
|
22 |
/** |
|
23 |
* Estado del evento de configuraci?n para las preferencias de Raster. |
|
24 |
* |
|
25 |
* @version 26/02/2008 |
|
26 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
27 |
*/ |
|
28 |
public class ConfigurationEvent extends EventObject { |
|
29 |
private static final long serialVersionUID = 7016236098872059L; |
|
30 |
private String key; |
|
31 |
private Object value; |
|
32 |
|
|
33 |
/** |
|
34 |
* Constructor de un ConfigurationEvent |
|
35 |
* @param source |
|
36 |
* @param key |
|
37 |
* @param value |
|
38 |
*/ |
|
39 |
public ConfigurationEvent(Object source, String key, Object value) { |
|
40 |
super(source); |
|
41 |
this.key = key; |
|
42 |
this.value = value; |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* @return the key |
|
47 |
*/ |
|
48 |
public String getKey() { |
|
49 |
return key; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* @return the value |
|
54 |
*/ |
|
55 |
public Object getValue() { |
|
56 |
return value; |
|
57 |
} |
|
58 |
} |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/src/org/gvsig/raster/UniqueProcessQueue.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster; |
|
20 |
|
|
21 |
import org.gvsig.raster.util.Queue; |
|
22 |
import org.gvsig.raster.util.RasterToolsUtil; |
|
23 |
|
|
24 |
/** |
|
25 |
* Cola de procesos de ejecuci?n exclusiva. Los procesos de esta lista se ir?n ejecutando |
|
26 |
* por orden de llegada impidiendo que se ejecuten dos al mismo tiempo. |
|
27 |
* |
|
28 |
* 16/05/2008 |
|
29 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
30 |
*/ |
|
31 |
public class UniqueProcessQueue implements IProcessActions { |
|
32 |
private static final int LAPSE_TIME = 1000; |
|
33 |
|
|
34 |
private Queue queue = new Queue(); |
|
35 |
private RasterProcess executionProcess = null; |
|
36 |
static private UniqueProcessQueue singleton = new UniqueProcessQueue(); |
|
37 |
|
|
38 |
/** |
|
39 |
* Dejamos el constructor privado para que nadie pueda referenciarlo |
|
40 |
*/ |
|
41 |
private UniqueProcessQueue() {} |
|
42 |
|
|
43 |
/** |
|
44 |
* Devuelve una instancia al unico objeto de UniqueProcessQueue que puede existir. |
|
45 |
* @return |
|
46 |
*/ |
|
47 |
static public UniqueProcessQueue getSingleton() { |
|
48 |
return singleton; |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* A?ade un proceso a la cola. |
|
53 |
* @param id Identificador del proceso |
|
54 |
* @param process Proceso |
|
55 |
*/ |
|
56 |
public synchronized void add(RasterProcess process) { |
|
57 |
queue.put(process); |
|
58 |
process.setUniqueProcessActions(this); |
|
59 |
|
|
60 |
//Decisi?n de arranque |
|
61 |
if(queue.size() >= 1 && executionProcess == null) |
|
62 |
start(); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* Pone en marcha el primer proceso de la lista |
|
67 |
*/ |
|
68 |
public void start() { |
|
69 |
nextProcess(); |
|
70 |
} |
|
71 |
|
|
72 |
private void nextProcess() { |
|
73 |
executionProcess = ((RasterProcess) queue.get()); |
|
74 |
if (executionProcess != null) |
|
75 |
executionProcess.start(); |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Evento de finalizaci?n de un proceso. Cuando un proceso acaba se |
|
80 |
* pone en marcha el siguiente de la lista si existe. Se asigna un tiempo de latencia para |
|
81 |
* la ejecuci?n del siguiente marcado por LAPSE_TIME. |
|
82 |
*/ |
|
83 |
public void end(Object param) { |
|
84 |
try { |
|
85 |
Thread.sleep(LAPSE_TIME); |
|
86 |
} catch (InterruptedException e) { |
|
87 |
RasterToolsUtil.debug("sleep Exception", null, e); |
|
88 |
} |
|
89 |
nextProcess(); |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* How many elements are there in this queue? |
|
94 |
*/ |
|
95 |
public int size() { |
|
96 |
return queue.size(); |
|
97 |
} |
|
98 |
|
|
99 |
/* |
|
100 |
* (non-Javadoc) |
|
101 |
* @see org.gvsig.raster.IProcessActions#interrupted() |
|
102 |
*/ |
|
103 |
public void interrupted() {} |
|
104 |
} |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/src/org/gvsig/raster/ConfigurationListener.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster; |
|
20 |
|
|
21 |
import java.util.EventListener; |
|
22 |
|
|
23 |
public interface ConfigurationListener extends EventListener { |
|
24 |
/** |
|
25 |
* Evento que se dispara cuando cambia un valor de configuracion. |
|
26 |
* @param e |
|
27 |
*/ |
|
28 |
public void actionConfigurationChanged(ConfigurationEvent e); |
|
29 |
} |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/src/org/gvsig/raster/util/Queue.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.util; |
|
20 |
|
|
21 |
/* |
|
22 |
* Created on 10-mar-2006 |
|
23 |
* |
|
24 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
25 |
* |
|
26 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
27 |
* |
|
28 |
* This program is free software; you can redistribute it and/or |
|
29 |
* modify it under the terms of the GNU General Public License |
|
30 |
* as published by the Free Software Foundation; either version 2 |
|
31 |
* of the License, or (at your option) any later version. |
|
32 |
* |
|
33 |
* This program is distributed in the hope that it will be useful, |
|
34 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
35 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
36 |
* GNU General Public License for more details. |
|
37 |
* |
|
38 |
* You should have received a copy of the GNU General Public License |
|
39 |
* along with this program; if not, write to the Free Software |
|
40 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
41 |
* |
|
42 |
* For more information, contact: |
|
43 |
*/ |
|
44 |
|
|
45 |
import java.util.Vector; |
|
46 |
|
|
47 |
/** |
|
48 |
* A simple FIFO queue class which causes the calling thread to wait if the |
|
49 |
* queue is empty and notifies threads that are waiting when it is not |
|
50 |
* empty. |
|
51 |
* |
|
52 |
* @author Anil V (akv@eng.sun.com) |
|
53 |
*/ |
|
54 |
public class Queue { |
|
55 |
private Vector vector = new Vector(); |
|
56 |
|
|
57 |
/** |
|
58 |
* Put the object into the queue. |
|
59 |
* |
|
60 |
* @param object |
|
61 |
* the object to be appended to the queue. |
|
62 |
*/ |
|
63 |
public synchronized void put(Object object) { |
|
64 |
vector.addElement(object); |
|
65 |
notify(); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Pull the first object out of the queue. Wait if the queue is empty. |
|
70 |
*/ |
|
71 |
public synchronized Object pull() { |
|
72 |
while (isEmpty()) |
|
73 |
try { |
|
74 |
wait(); |
|
75 |
} catch (InterruptedException ex) { |
|
76 |
} |
|
77 |
return get(); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* Get the first object out of the queue. Return null if the queue is |
|
82 |
* empty. |
|
83 |
*/ |
|
84 |
public synchronized Object get() { |
|
85 |
Object object = peek(); |
|
86 |
if (object != null) |
|
87 |
vector.removeElementAt(0); |
|
88 |
return object; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Peek to see if something is available. |
|
93 |
*/ |
|
94 |
public Object peek() { |
|
95 |
if (isEmpty()) |
|
96 |
return null; |
|
97 |
return vector.elementAt(0); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Is the queue empty? |
|
102 |
*/ |
|
103 |
public boolean isEmpty() { |
|
104 |
return vector.isEmpty(); |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* How many elements are there in this queue? |
|
109 |
*/ |
|
110 |
public int size() { |
|
111 |
return vector.size(); |
|
112 |
} |
|
113 |
} |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/src/org/gvsig/raster/util/ExtendedFileFilter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.util; |
|
20 |
|
|
21 |
import java.io.File; |
|
22 |
import java.util.ArrayList; |
|
23 |
|
|
24 |
import javax.swing.filechooser.FileFilter; |
|
25 |
|
|
26 |
import com.iver.andami.PluginServices; |
|
27 |
/** |
|
28 |
* ExtendedFileFilter es una clase para usarla junto a los JFileChooser. |
|
29 |
* Ofrece una funcionalidad simple para poder agregar extensiones de manera |
|
30 |
* comoda y rapida. Las descripciones ya las pone con un formato, asi que esto |
|
31 |
* es opcional poner una descripci?n especifica. |
|
32 |
* |
|
33 |
* Un ejemplo t?pico de como se usaria: |
|
34 |
* <pre> |
|
35 |
* // Usamos el JFileChooser de libUIComponents |
|
36 |
* JFileChooser chooser = new JFileChooser(this.getClass().toString(), (File) null); |
|
37 |
* // Desactivamos el modo de ver todos los ficheros |
|
38 |
* chooser.setAcceptAllFileFilterUsed(false); |
|
39 |
* // Activamos la multiseleccion |
|
40 |
* chooser.setMultiSelectionEnabled(true); |
|
41 |
* // Nos guardamos cada tipo de fichero en uno que contenga todos |
|
42 |
* ExtendedFileFilter allFilters = new ExtendedFileFilter(); |
|
43 |
* for (int i = 0; i < formats.length; i++) { |
|
44 |
* ExtendedFileFilter fileFilter = new ExtendedFileFilter(); |
|
45 |
* fileFilter.addExtension(formats[i]); |
|
46 |
* // Agregamos el filefilter al JFileChooser |
|
47 |
* chooser.addChoosableFileFilter(fileFilter); |
|
48 |
* // Agregamos el mismo filtro a un ExtendedFileFilter global |
|
49 |
* allFilters.addExtension(formats[i]); |
|
50 |
* } |
|
51 |
* // Poner una descripcion (OPCIONAL) para todos los ficheros. |
|
52 |
* allFilters.setDescription(PluginServices.getText(this, "todos_soportados")); |
|
53 |
* // Lo a?adimos |
|
54 |
* chooser.addChoosableFileFilter(allFilters); |
|
55 |
* // Y lo dejamos seleccionado por defecto |
|
56 |
* chooser.setFileFilter(allFilters); |
|
57 |
* </pre> |
|
58 |
* |
|
59 |
* @version 21/11/2007 |
|
60 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
61 |
*/ |
|
62 |
public class ExtendedFileFilter extends FileFilter { |
|
63 |
String description = null; |
|
64 |
|
|
65 |
ArrayList extensions = new ArrayList(); |
|
66 |
|
|
67 |
/** |
|
68 |
* Constructor de un ExtendedFileFilter |
|
69 |
*/ |
|
70 |
public ExtendedFileFilter() { |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Construye un ExtendedFileFilter con una extensi?n ya agregada |
|
75 |
* @param extension |
|
76 |
*/ |
|
77 |
public ExtendedFileFilter(String extension) { |
|
78 |
addExtension(extension); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* A?ade una extensi?n a la lista de extensiones soportadas |
|
83 |
* @param extension |
|
84 |
*/ |
|
85 |
public void addExtension(String extension) { |
|
86 |
if (extension == null) |
|
87 |
return; |
|
88 |
|
|
89 |
extensions.add(extension); |
|
90 |
} |
|
91 |
|
|
92 |
/* |
|
93 |
* (non-Javadoc) |
|
94 |
* @see javax.swing.filechooser.FileFilter#accept(java.io.File) |
|
95 |
*/ |
|
96 |
public boolean accept(File f) { |
|
97 |
if (f.isDirectory()) |
|
98 |
return true; |
|
99 |
|
|
100 |
String s = f.getName(); |
|
101 |
int i = s.lastIndexOf('.'); |
|
102 |
|
|
103 |
if (i > 0 && i < s.length() - 1) { |
|
104 |
String extension = s.substring(i + 1).toLowerCase(); |
|
105 |
for (int j = 0; j < extensions.size(); j++) { |
|
106 |
if (extensions.get(j).toString().toLowerCase().equals(extension)) |
|
107 |
return true; |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
return false; |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* Normaliza el nombre de un fichero, a?adiendo la extension si fuera |
|
116 |
* necesario |
|
117 |
* @param file |
|
118 |
* @return |
|
119 |
*/ |
|
120 |
public String getNormalizedFilename(File file) { |
|
121 |
String s = file.getName(); |
|
122 |
int i = s.lastIndexOf('.'); |
|
123 |
|
|
124 |
if (i > 0 && i < s.length() - 1) { |
|
125 |
String extension = s.substring(i + 1).toLowerCase(); |
|
126 |
for (int j = 0; j < extensions.size(); j++) { |
|
127 |
if (extensions.get(j).toString().toLowerCase().equals(extension)) |
|
128 |
return file.toString(); |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
return file.toString() + "." + extensions.get(0).toString().toLowerCase(); |
|
133 |
} |
|
134 |
|
|
135 |
/* |
|
136 |
* (non-Javadoc) |
|
137 |
* @see javax.swing.filechooser.FileFilter#getDescription() |
|
138 |
*/ |
|
139 |
public String getDescription() { |
|
140 |
String format1 = ""; |
|
141 |
String format2 = ""; |
|
142 |
for (int j = 0; j < extensions.size(); j++) { |
|
143 |
if (format1.length() != 0) { |
|
144 |
format1 = format1 + ", "; |
|
145 |
format2 = format2 + "; "; |
|
146 |
} |
|
147 |
// Files JPG, GIF, ... (*.jpg; *.gif ...) |
|
148 |
if (j >= 4) { |
|
149 |
format1 = "..."; |
|
150 |
format2 = "..."; |
|
151 |
break; |
|
152 |
} |
|
153 |
format1 = format1 + extensions.get(j).toString().toUpperCase(); |
|
154 |
format2 = format2 + "*." + extensions.get(j).toString().toLowerCase(); |
|
155 |
} |
|
156 |
if (description == null) |
|
157 |
return PluginServices.getText(this, "files") + " " + format1 + " (" + format2 + ")"; |
|
158 |
|
|
159 |
return description + " (" + format2 + ")"; |
|
160 |
} |
|
161 |
|
|
162 |
/** |
|
163 |
* Especifica la descripcion del item |
|
164 |
* @param description the description to set |
|
165 |
*/ |
|
166 |
public void setDescription(String description) { |
|
167 |
this.description = description; |
|
168 |
} |
|
169 |
|
|
170 |
/** |
|
171 |
* Borra una extension de la lista de extensiones |
|
172 |
* @param extension |
|
173 |
*/ |
|
174 |
public void removeExtension(String extension){ |
|
175 |
extensions.remove(extension); |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
179 |
* Borra todas las extensiones existentes |
|
180 |
*/ |
|
181 |
public void clearExtensions(){ |
|
182 |
extensions.clear(); |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* Devuelve una lista con las extensiones disponibles |
|
187 |
* @return |
|
188 |
*/ |
|
189 |
public ArrayList getExtensions(){ |
|
190 |
return extensions; |
|
191 |
} |
|
192 |
} |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/src/org/gvsig/raster/util/GenericBasePanel.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.util; |
|
20 |
|
|
21 |
/** |
|
22 |
* Clase no abstracta para instanciar un BasePanel generico |
|
23 |
* 18/08/2008 |
|
24 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
25 |
*/ |
|
26 |
public class GenericBasePanel extends BasePanel { |
|
27 |
private static final long serialVersionUID = 1L; |
|
28 |
|
|
29 |
/* |
|
30 |
* (non-Javadoc) |
|
31 |
* @see org.gvsig.raster.util.BasePanel#init() |
|
32 |
*/ |
|
33 |
protected void init() { |
|
34 |
} |
|
35 |
|
|
36 |
/* |
|
37 |
* (non-Javadoc) |
|
38 |
* @see org.gvsig.raster.util.BasePanel#translate() |
|
39 |
*/ |
|
40 |
protected void translate() { |
|
41 |
} |
|
42 |
} |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/src/org/gvsig/raster/util/ExternalCancellable.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2009 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.util; |
|
20 |
|
|
21 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask; |
|
22 |
import org.gvsig.raster.dataset.io.IExternalCancellable; |
|
23 |
|
|
24 |
public class ExternalCancellable implements IExternalCancellable { |
|
25 |
private IncrementableTask task = null; |
|
26 |
|
|
27 |
public ExternalCancellable(IncrementableTask task) { |
|
28 |
this.task = task; |
|
29 |
} |
|
30 |
|
|
31 |
/* |
|
32 |
* (non-Javadoc) |
|
33 |
* @see org.gvsig.raster.dataset.io.IExternalCancellable#processFinalize() |
|
34 |
*/ |
|
35 |
public void processFinalize() { |
|
36 |
if(task != null) |
|
37 |
task.processFinalize(); |
|
38 |
} |
|
39 |
} |
|
0 | 40 |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/src/org/gvsig/raster/util/BasePanel.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.util; |
|
20 |
|
|
21 |
import java.awt.Component; |
|
22 |
import java.awt.event.ActionListener; |
|
23 |
import java.awt.event.KeyListener; |
|
24 |
import java.awt.event.MouseListener; |
|
25 |
import java.util.ArrayList; |
|
26 |
|
|
27 |
import javax.swing.AbstractButton; |
|
28 |
import javax.swing.JPanel; |
|
29 |
|
|
30 |
/** |
|
31 |
* Clase base para los paneles gr?ficos. |
|
32 |
* |
|
33 |
* 17/07/2008 |
|
34 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
35 |
*/ |
|
36 |
public abstract class BasePanel extends JPanel { |
|
37 |
private static final long serialVersionUID = -8877600252349334979L; |
|
38 |
private boolean enableValueChangedEvent = true; |
|
39 |
|
|
40 |
public static final int KEYLISTENER = 0; |
|
41 |
public static final int ACTIONLISTENER = 1; |
|
42 |
public static final int MOUSELISTENER = 2; |
|
43 |
|
|
44 |
/** |
|
45 |
* Obtiene una instancia de una clase generica que hereda de BasePanel |
|
46 |
* @return BasePanel |
|
47 |
*/ |
|
48 |
public static BasePanel getInstance() { |
|
49 |
return new GenericBasePanel(); |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Obtiene la traducci?n de la cadena de texto |
|
54 |
* @param parent Ventana padre |
|
55 |
* @param text Cadena a traducir |
|
56 |
* @return Cadena de texto traducida |
|
57 |
*/ |
|
58 |
public String getText(Object parent, String text) { |
|
59 |
return RasterToolsUtil.getText(parent, text); |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Obtiene la traducci?n de la cadena de texto |
|
64 |
* @param text Cadena a traducir |
|
65 |
* @return Cadena de texto traducida |
|
66 |
*/ |
|
67 |
public String getText(String text) { |
|
68 |
return RasterToolsUtil.getText(this, text); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Asigna el valor para la activaci?n y desactivaci?n del evento de cambio de valor en |
|
73 |
* las cajas de texto. |
|
74 |
* @param enableValueChangedEvent |
|
75 |
*/ |
|
76 |
public void setEnableValueChangedEvent(boolean enableValueChangedEvent) { |
|
77 |
this.enableValueChangedEvent = enableValueChangedEvent; |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* Obtiene el valor para la activaci?n y desactivaci?n del evento de cambio de valor en |
|
82 |
* las cajas de texto. |
|
83 |
* @param enableValueChangedEvent |
|
84 |
*/ |
|
85 |
public boolean isEnableValueChangedEvent() { |
|
86 |
return this.enableValueChangedEvent; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Obtiene la lista de componentes del panel. Si dentro tiene alg?n BasePanel |
|
91 |
* consulta la lista de componentes de este y la devuelve. |
|
92 |
* @return |
|
93 |
*/ |
|
94 |
public ArrayList getComponentList() { |
|
95 |
ArrayList listComp = new ArrayList(); |
|
96 |
for (int i = 0; i < this.getComponentCount(); i++) { |
|
97 |
if(getComponent(i) instanceof BasePanel) { |
|
98 |
ArrayList list = ((BasePanel)getComponent(i)).getComponentList(); |
|
99 |
for (int j = 0; j < list.size(); j++) |
|
100 |
listComp.add(list.get(j)); |
|
101 |
} else |
|
102 |
listComp.add(getComponent(i)); |
|
103 |
} |
|
104 |
return listComp; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* Registra un listener en todos los componentes contenidos en este panel. |
|
109 |
* @param type Tipo de listener definido por las variables est?ticas en esta clase |
|
110 |
* @param listener Objeto listener del tipo correcto |
|
111 |
*/ |
|
112 |
public void registerListener(int type, Object listener) { |
|
113 |
ArrayList listComp = getComponentList(); |
|
114 |
if(type == KEYLISTENER) { |
|
115 |
if(listener instanceof KeyListener) { |
|
116 |
for (int i = 0; i < listComp.size(); i++) |
|
117 |
if(listComp.get(i) instanceof Component) |
|
118 |
((Component)listComp.get(i)).addKeyListener((KeyListener)listener); |
|
119 |
} |
|
120 |
} |
|
121 |
if(type == ACTIONLISTENER) { |
|
122 |
if(listener instanceof ActionListener) { |
|
123 |
for (int i = 0; i < listComp.size(); i++) |
|
124 |
if(listComp.get(i) instanceof AbstractButton) |
|
125 |
((AbstractButton)listComp.get(i)).addActionListener((ActionListener)listener); |
|
126 |
} |
|
127 |
} |
|
128 |
if(type == MOUSELISTENER) { |
|
129 |
if(listener instanceof MouseListener) { |
|
130 |
for (int i = 0; i < listComp.size(); i++) |
|
131 |
if(listComp.get(i) instanceof Component) |
|
132 |
((Component)listComp.get(i)).addMouseListener((MouseListener)listener); |
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* Traducci?n centralizada de los componentes de una panel |
|
139 |
*/ |
|
140 |
protected abstract void translate(); |
|
141 |
|
|
142 |
/** |
|
143 |
* Acciones de inicializaci?n |
|
144 |
*/ |
|
145 |
protected abstract void init(); |
|
146 |
} |
tags/v1_12_0_Build_1402/extensions/extRasterTools-SE/src/org/gvsig/raster/util/process/ClippingProcess.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.util.process; |
|
20 |
|
|
21 |
import java.awt.geom.AffineTransform; |
|
22 |
import java.awt.geom.Point2D; |
|
23 |
import java.io.File; |
|
24 |
import java.io.IOException; |
|
25 |
import java.util.ArrayList; |
|
26 |
|
|
27 |
import org.gvsig.fmap.raster.grid.roi.VectorialROI; |
|
28 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
|
29 |
import org.gvsig.fmap.raster.layers.IRasterLayerActions; |
|
30 |
import org.gvsig.raster.Configuration; |
|
31 |
import org.gvsig.raster.RasterProcess; |
|
32 |
import org.gvsig.raster.buffer.BufferFactory; |
|
33 |
import org.gvsig.raster.buffer.BufferInterpolation; |
|
34 |
import org.gvsig.raster.buffer.RasterBuffer; |
|
35 |
import org.gvsig.raster.buffer.WriterBufferServer; |
|
36 |
import org.gvsig.raster.dataset.GeoRasterWriter; |
|
37 |
import org.gvsig.raster.dataset.IBuffer; |
|
38 |
import org.gvsig.raster.dataset.IRasterDataSource; |
|
39 |
import org.gvsig.raster.dataset.InvalidSetViewException; |
|
40 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
|
41 |
import org.gvsig.raster.dataset.Params; |
|
42 |
import org.gvsig.raster.dataset.RasterDataset; |
|
43 |
import org.gvsig.raster.dataset.io.RasterDriverException; |
|
44 |
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
|
45 |
import org.gvsig.raster.dataset.serializer.RmfSerializerException; |
|
46 |
import org.gvsig.raster.datastruct.ColorTable; |
|
47 |
import org.gvsig.raster.datastruct.NoData; |
|
48 |
import org.gvsig.raster.grid.GridPalette; |
|
49 |
import org.gvsig.raster.grid.filter.RasterFilterList; |
|
50 |
import org.gvsig.raster.grid.filter.bands.ColorTableFilter; |
|
51 |
import org.gvsig.raster.util.ExternalCancellable; |
|
52 |
import org.gvsig.raster.util.RasterNotLoadException; |
|
53 |
import org.gvsig.raster.util.RasterToolsUtil; |
|
54 |
|
|
55 |
import com.iver.andami.PluginServices; |
|
56 |
import com.iver.cit.gvsig.ProjectExtension; |
|
57 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
58 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
59 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
|
60 |
import com.iver.cit.gvsig.project.documents.view.ProjectViewBase; |
|
61 |
/** |
|
62 |
* <code>ClippingProcess</code> es un proceso que usa un <code>Thread</code> |
|
63 |
* para aplicar un recorte a una capa y guardarlo en disco. Muestra una barra |
|
64 |
* de incremento informativa. |
|
65 |
* |
|
66 |
* @version 24/04/2007 |
|
67 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
68 |
*/ |
|
69 |
public class ClippingProcess extends RasterProcess { |
|
70 |
private String fileName = ""; |
|
71 |
private WriterBufferServer writerBufferServer = null; |
|
72 |
private FLyrRasterSE rasterSE = null; |
|
73 |
private AffineTransform affineTransform = new AffineTransform(); |
|
74 |
private boolean oneLayerPerBand = false; |
|
75 |
private int[] drawableBands = { 0, 1, 2 }; |
|
76 |
private int[] pValues = null; |
|
77 |
private GeoRasterWriter grw = null; |
|
78 |
private int interpolationMethod = BufferInterpolation.INTERPOLATION_Undefined; |
|
79 |
private String viewName = ""; |
|
80 |
private Params params = null; |
|
81 |
private DatasetColorInterpretation colorInterp = null; |
|
82 |
private ArrayList selectedRois = null; |
|
83 |
|
|
84 |
private double[] wcValues = null; |
|
85 |
|
|
86 |
/** |
|
87 |
* Variables de la resoluci?n de salida |
|
88 |
*/ |
|
89 |
private int resolutionWidth = 0; |
|
90 |
private int resolutionHeight = 0; |
|
91 |
|
|
92 |
private IBuffer buffer = null; |
|
93 |
private boolean showEndDialog = true; |
|
94 |
private ExternalCancellable cancellableObj = null; |
|
95 |
|
|
96 |
/** |
|
97 |
* Par?metros obligatorios al proceso: |
|
98 |
* <UL> |
|
99 |
* <LI>filename: Nombre del fichero de salida</LI> |
|
100 |
* <LI>datawriter: Escritor de datos</LI> |
|
101 |
* <LI>viewname: Nombre de la vista sobre la que se carga la capa al acabar el proceso</LI> |
|
102 |
* <LI>pixelcoordinates: Coordenadas pixel del recorte (ulx, uly, lrx, lry)</LI> |
|
103 |
* <LI>layer: Capa de entrada para el recorte</LI> |
|
104 |
* <LI>drawablebands: Bandas de entrada</LI> |
|
105 |
* <LI>onelayerperband: booleano que informa de si escribimos una banda por fichero de salida o todas en un fichero</LI> |
|
106 |
* <LI>interpolationmethod: M?todo de interpolaci?n.</LI> |
|
107 |
* <LI>affinetransform: Transformaci?n que informa al dataset de salida de su referencia geografica</LI> |
|
108 |
* <LI>resolution: Ancho y alto de la capa de salida</LI> |
|
109 |
* </UL> |
|
110 |
*/ |
|
111 |
public void init() { |
|
112 |
fileName = getStringParam("filename"); |
|
113 |
writerBufferServer = (WriterBufferServer) getParam("datawriter"); |
|
114 |
viewName = getStringParam("viewname"); |
|
115 |
pValues = getIntArrayParam("pixelcoordinates"); |
|
116 |
wcValues = getDoubleArrayParam("realcoordinates"); |
|
117 |
rasterSE = getLayerParam("layer"); |
|
118 |
drawableBands = getIntArrayParam("drawablebands"); |
|
119 |
oneLayerPerBand = getBooleanParam("onelayerperband"); |
|
120 |
interpolationMethod = getIntParam("interpolationmethod"); |
|
121 |
affineTransform = (AffineTransform)getParam("affinetransform"); |
|
122 |
colorInterp = (DatasetColorInterpretation)getParam("colorInterpretation"); |
|
123 |
selectedRois = (ArrayList)getParam("selectedrois"); |
|
124 |
if(getIntArrayParam("resolution") != null) { |
|
125 |
resolutionWidth = getIntArrayParam("resolution")[0]; |
|
126 |
resolutionHeight = getIntArrayParam("resolution")[1]; |
|
127 |
} |
|
128 |
params = (Params) getParam("driverparams"); |
|
129 |
showEndDialog = getBooleanParam("showenddialog"); |
|
130 |
Object obj = taskParams.get("cancellable"); |
|
131 |
if(obj != null) |
|
132 |
cancellableObj = (ExternalCancellable)obj; |
|
133 |
} |
|
134 |
|
|
135 |
/** |
|
136 |
* Salva la tabla de color al fichero rmf. |
|
137 |
* @param fName |
|
138 |
* @throws IOException |
|
139 |
*/ |
|
140 |
private void saveToRmf(String fileName) { |
|
141 |
RasterDataset rds = null; |
|
142 |
int limitNumberOfRequests = 20; |
|
143 |
while (rds == null && limitNumberOfRequests > 0) { |
|
144 |
try { |
|
145 |
rds = rasterSE.getDataSource().getDataset(0)[0]; |
|
146 |
} catch (IndexOutOfBoundsException e) { |
|
147 |
//En ocasiones, sobre todo con servicios remotos al pedir un datasource da una excepci?n de este tipo |
|
148 |
//se supone que es porque hay un refresco en el mismo momento de la petici?n por lo que como es m?s lento de |
|
149 |
//gestionar pilla a la capa sin datasources asociados ya que est? reasignandolo. Si volvemos a pedirlo debe |
|
150 |
//haberlo cargado ya. |
|
151 |
try { |
|
152 |
Thread.sleep(200); |
|
153 |
} catch (InterruptedException e1) { |
|
154 |
} |
|
155 |
} |
|
156 |
limitNumberOfRequests--; |
|
157 |
} |
|
158 |
|
|
159 |
if (rds == null) { |
|
160 |
//RasterToolsUtil.messageBoxError("error_load_layer", this, new Exception("Error writing RMF. limitNumberOfRequests=" + limitNumberOfRequests)); |
|
161 |
return; |
|
162 |
} |
|
163 |
|
|
164 |
RasterFilterList rasterFilterList = rasterSE.getRenderFilterList(); |
|
165 |
|
|
166 |
// Guardamos en el RMF el valor NoData |
|
167 |
if (Configuration.getValue("nodata_transparency_enabled", Boolean.FALSE).booleanValue()) { |
|
168 |
try { |
|
169 |
RasterDataset.saveObjectToRmfFile(fileName, NoData.class, new NoData(rasterSE.getNoDataValue(), rasterSE.getNoDataType(), rasterSE.getDataType()[0])); |
|
170 |
} catch (RmfSerializerException e) { |
|
171 |
RasterToolsUtil.messageBoxError("error_salvando_rmf", this, e); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
// Guardamos en el RMF la tabla de color |
|
176 |
ColorTableFilter colorTableFilter = (ColorTableFilter) rasterFilterList.getByName(ColorTableFilter.names[0]); |
|
177 |
if (colorTableFilter != null) { |
|
178 |
GridPalette gridPalette = new GridPalette((ColorTable) colorTableFilter.getColorTable().clone()); |
|
179 |
try { |
|
180 |
RasterDataset.saveObjectToRmfFile(fileName, ColorTable.class, (ColorTable) gridPalette); |
|
181 |
} catch (RmfSerializerException e) { |
|
182 |
RasterToolsUtil.messageBoxError("error_salvando_rmf", this, e); |
|
183 |
} |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
/** |
|
188 |
* Tarea de recorte |
|
189 |
*/ |
|
190 |
public void process() throws InterruptedException { |
|
191 |
IRasterDataSource dsetCopy = null; |
|
192 |
if(rasterSE != null) |
|
193 |
rasterSE.setReadingData(Thread.currentThread().toString()); |
|
194 |
|
|
195 |
try { |
|
196 |
long t2; |
|
197 |
long t1 = new java.util.Date().getTime(); |
|
198 |
|
|
199 |
insertLineLog(RasterToolsUtil.getText(this, "leyendo_raster")); |
|
200 |
|
|
201 |
dsetCopy = rasterSE.getDataSource().newDataset(); |
|
202 |
BufferFactory bufferFactory = new BufferFactory(dsetCopy); |
|
203 |
bufferFactory.setDrawableBands(drawableBands); |
|
204 |
|
|
205 |
if(interpolationMethod != BufferInterpolation.INTERPOLATION_Undefined) { |
|
206 |
try { |
|
207 |
if(pValues != null) { |
|
208 |
if (RasterBuffer.isBufferTooBig(new double[] { pValues[0], pValues[3], pValues[2], pValues[1] }, drawableBands.length)) |
|
209 |
bufferFactory.setReadOnly(true); |
|
210 |
bufferFactory.setAreaOfInterest(pValues[0], pValues[3], pValues[2] - pValues[0], pValues[1] - pValues[3]); |
|
211 |
} else if(wcValues != null) { |
|
212 |
//if (RasterBuffer.isBufferTooBig(new double[] { wcValues[0], wcValues[3], wcValues[2], wcValues[1] }, rasterSE.getCellSize(), drawableBands.length)) |
|
213 |
if(!rasterSE.isActionEnabled(IRasterLayerActions.REMOTE_ACTIONS)) |
|
214 |
bufferFactory.setReadOnly(true); |
|
215 |
bufferFactory.setAreaOfInterest(wcValues[0], wcValues[1], Math.abs(wcValues[0] - wcValues[2]), Math.abs(wcValues[1] - wcValues[3])); |
|
216 |
} |
|
217 |
} catch (InvalidSetViewException e) { |
|
218 |
RasterToolsUtil.messageBoxError("No se ha podido asignar la vista al inicial el proceso de recorte.", this, e); |
|
219 |
} |
|
220 |
buffer = bufferFactory.getRasterBuf(); |
|
221 |
|
|
222 |
insertLineLog(RasterToolsUtil.getText(this, "interpolando")); |
|
223 |
|
|
224 |
if(buffer != null) |
|
225 |
buffer = ((RasterBuffer) buffer).getAdjustedWindow(resolutionWidth, resolutionHeight, interpolationMethod); |
|
226 |
else { |
|
227 |
RasterToolsUtil.messageBoxError("El proceso de recorte ha fallado porque el buffer no conten?a datos.", this, new NullPointerException()); |
|
228 |
return; |
|
229 |
} |
|
230 |
} else { |
|
231 |
try { |
|
232 |
if (RasterBuffer.isBufferTooBig(new double[] { 0, 0, resolutionWidth, resolutionHeight }, drawableBands.length)) |
|
233 |
bufferFactory.setReadOnly(true); |
|
234 |
if(pValues != null) |
|
235 |
bufferFactory.setAreaOfInterest(pValues[0], pValues[3], Math.abs(pValues[2] - pValues[0]) + 1, Math.abs(pValues[1] - pValues[3]) + 1, resolutionWidth, resolutionHeight); |
|
236 |
else if(wcValues != null) |
|
237 |
bufferFactory.setAreaOfInterest(wcValues[0], wcValues[1], wcValues[2], wcValues[3], resolutionWidth, resolutionHeight); |
|
238 |
buffer = bufferFactory.getRasterBuf(); |
|
239 |
if(buffer == null) { |
|
240 |
RasterToolsUtil.messageBoxError("El proceso de recorte ha fallado porque el buffer no conten?a datos.", this, new NullPointerException()); |
|
241 |
return; |
|
242 |
} |
|
243 |
} catch (InvalidSetViewException e) { |
|
244 |
RasterToolsUtil.messageBoxError("No se ha podido asignar la vista al inicial el proceso de recorte.", this, e); |
|
245 |
} |
|
246 |
} |
|
247 |
//TODO: FUNCIONALIDAD: Poner los getWriter con la proyecci?n del fichero fuente |
|
248 |
|
|
249 |
|
|
250 |
if ((selectedRois != null) && (!bufferFactory.isReadOnly())) { |
|
251 |
if (selectedRois.size() > 0) { |
|
252 |
int despX = 0; |
|
253 |
int despY = 0; |
|
254 |
if (pValues != null) { |
|
255 |
despX = pValues[0]; |
|
256 |
despY = pValues[1]; |
|
257 |
} else if (wcValues != null) { |
|
258 |
despX = (int)dsetCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getX(); |
|
259 |
despY = (int)dsetCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getY(); |
|
260 |
} |
|
261 |
drawOnlyROIs(buffer, selectedRois, despX, despY); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
insertLineLog(RasterToolsUtil.getText(this, "salvando_imagen")); |
|
266 |
|
|
267 |
String finalFileName = ""; |
|
268 |
if (oneLayerPerBand) { |
|
269 |
long[] milis = new long[drawableBands.length]; |
|
270 |
String[] fileNames = new String[drawableBands.length]; |
|
271 |
for (int i = 0; i < drawableBands.length; i++) { |
|
272 |
fileNames[i] = fileName + "_B" + drawableBands[i] + ".tif"; |
|
273 |
writerBufferServer.setBuffer(buffer, i); |
|
274 |
Params p = null; |
|
275 |
if (params == null) |
|
276 |
p = GeoRasterWriter.getWriter(fileNames[i]).getParams(); |
|
277 |
else |
|
278 |
p = params; |
|
279 |
grw = GeoRasterWriter.getWriter(writerBufferServer, fileNames[i], 1, |
|
280 |
affineTransform, buffer.getWidth(), buffer.getHeight(), |
|
281 |
buffer.getDataType(), p, null); |
|
282 |
grw.setColorBandsInterpretation(new String[]{DatasetColorInterpretation.GRAY_BAND}); |
|
283 |
grw.setWkt(dsetCopy.getWktProjection()); |
|
284 |
grw.setCancellableRasterDriver(cancellableObj); |
|
285 |
grw.dataWrite(); |
|
286 |
grw.writeClose(); |
|
287 |
saveToRmf(fileNames[i]); |
|
288 |
t2 = new java.util.Date().getTime(); |
|
289 |
milis[i] = (t2 - t1); |
|
290 |
t1 = new java.util.Date().getTime(); |
|
291 |
} |
|
292 |
if (incrementableTask != null) { |
|
293 |
incrementableTask.processFinalize(); |
|
294 |
incrementableTask = null; |
|
295 |
} |
|
296 |
if(viewName != null) { |
|
297 |
if (RasterToolsUtil.messageBoxYesOrNot("cargar_toc", this)) { |
|
298 |
try { |
|
299 |
for (int i = 0; i < drawableBands.length; i++) { |
|
300 |
FLayer lyr = RasterToolsUtil.loadLayer(viewName, fileNames[i], null); |
|
301 |
if(lyr != null && lyr instanceof FLyrRasterSE) |
|
302 |
((FLyrRasterSE)lyr).setRois(rasterSE.getRois()); |
|
303 |
} |
|
304 |
} catch (RasterNotLoadException e) { |
|
305 |
RasterToolsUtil.messageBoxError("error_load_layer", this, e); |
|
306 |
} |
|
307 |
} |
|
308 |
} |
|
309 |
for (int i = 0; i < drawableBands.length; i++) { |
|
310 |
if (externalActions != null) |
|
311 |
externalActions.end(new Object[] { fileName + "_B" + drawableBands[i] + ".tif", new Long(milis[i]) }); |
|
312 |
} |
|
313 |
} else { |
|
314 |
if (isUsingFile(fileName)){ |
|
315 |
incrementableTask.hideWindow(); |
|
316 |
RasterToolsUtil.messageBoxError("error_opened_file", this); |
|
317 |
return; |
|
318 |
} |
|
319 |
File f = new File(fileName); |
|
320 |
if (f.exists()){ |
|
321 |
f.delete(); |
|
322 |
} |
|
323 |
f = null; |
|
324 |
writerBufferServer.setBuffer(buffer, -1); |
|
325 |
if (params == null) { |
|
326 |
finalFileName = fileName + ".tif"; |
|
327 |
params = GeoRasterWriter.getWriter(finalFileName).getParams(); |
|
328 |
} else |
|
329 |
finalFileName = fileName; |
|
330 |
grw = GeoRasterWriter.getWriter(writerBufferServer, finalFileName, |
|
331 |
buffer.getBandCount(), affineTransform, buffer.getWidth(), |
|
332 |
buffer.getHeight(), buffer.getDataType(), params, null); |
|
333 |
if(colorInterp != null) |
|
334 |
grw.setColorBandsInterpretation(colorInterp.getValues()); |
|
335 |
grw.setWkt(dsetCopy.getWktProjection()); |
|
336 |
grw.setCancellableRasterDriver(cancellableObj); |
|
337 |
grw.dataWrite(); |
|
338 |
grw.writeClose(); |
|
339 |
saveToRmf(finalFileName); |
|
340 |
t2 = new java.util.Date().getTime(); |
|
341 |
if (incrementableTask != null) { |
|
342 |
incrementableTask.processFinalize(); |
|
343 |
incrementableTask = null; |
|
344 |
} |
|
345 |
//Damos tiempo a parar el Thread del incrementable para que no se cuelgue la ventana |
|
346 |
//El tiempo es como m?nimo el de un bucle del run de la tarea incrementable |
|
347 |
Thread.sleep(600); |
|
348 |
cutFinalize(finalFileName, (t2 - t1)); |
|
349 |
} |
|
350 |
|
|
351 |
} catch (NotSupportedExtensionException e) { |
|
352 |
RasterToolsUtil.messageBoxError("error_not_suported_extension", this, e); |
|
353 |
} catch (RasterDriverException e) { |
|
354 |
RasterToolsUtil.messageBoxError("error_writer", this, e); |
|
355 |
} catch (IOException e) { |
|
356 |
RasterToolsUtil.messageBoxError("error_georasterwriter", this, e); |
Also available in: Unified diff