Revision 1437
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/test/java/org/gvsig/raster/cache/tile/TestThreadPool.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.cache.tile; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
|
|
26 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
27 |
import org.gvsig.raster.cache.tile.pool.ThreadPool; |
|
28 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
29 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
34 |
*/ |
|
35 |
public class TestThreadPool extends AbstractLibraryAutoInitTestCase { |
|
36 |
private static final int WIDTH = 3; |
|
37 |
private static final int HEIGHT = 3; |
|
38 |
private static final int DOWNLOAD_TIME = 500; |
|
39 |
|
|
40 |
public class MyDownloader implements Downloader { |
|
41 |
|
|
42 |
public Tile downloadTile(Tile tile) { |
|
43 |
//tile.getFile() -> Aqui se guarda el fichero descargado |
|
44 |
try { |
|
45 |
Thread.sleep(DOWNLOAD_TIME); |
|
46 |
} catch (InterruptedException e) { |
|
47 |
e.printStackTrace(); |
|
48 |
} |
|
49 |
return tile; |
|
50 |
} |
|
51 |
|
|
52 |
public Tile readTileFromDisk(Tile tile) throws TileGettingException { |
|
53 |
// TODO Auto-generated method stub |
|
54 |
return null; |
|
55 |
} |
|
56 |
|
|
57 |
/* |
|
58 |
* (non-Javadoc) |
|
59 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#cancelDownloading(boolean) |
|
60 |
*/ |
|
61 |
public void cancelDownloading(boolean cancel) { |
|
62 |
|
|
63 |
} |
|
64 |
|
|
65 |
public Object[] getCrashImage(int w, int h) { |
|
66 |
// TODO Auto-generated method stub |
|
67 |
return null; |
|
68 |
} |
|
69 |
|
|
70 |
public Object[] getDownloadingImage(int w, int h) { |
|
71 |
// TODO Auto-generated method stub |
|
72 |
return null; |
|
73 |
} |
|
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
public void start() { |
|
78 |
try { |
|
79 |
this.doSetUp(); |
|
80 |
} catch (Exception e) { |
|
81 |
e.printStackTrace(); |
|
82 |
} |
|
83 |
this.testStack(); |
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
87 |
protected void doSetUp() throws Exception { |
|
88 |
System.err.println("TestThreadPool running..."); |
|
89 |
} |
|
90 |
|
|
91 |
public void testStack() { |
|
92 |
ThreadPool pool = TileCacheLocator.getManager().createThreadPool(false); |
|
93 |
MyDownloader d = new MyDownloader(); |
|
94 |
|
|
95 |
for (int x = 0; x < HEIGHT; x++) { |
|
96 |
for (int y = 0; y < WIDTH; y++) { |
|
97 |
Tile t = TileCacheLocator.getManager().createTile(0, x, y); |
|
98 |
t.setSharedPipe(pool.getTilePipe()); |
|
99 |
t.setDownloader(d); |
|
100 |
t.setFile(new File("")); |
|
101 |
pool.addTask(t); |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
int nCollected = 0; |
|
106 |
while (nCollected < (WIDTH * HEIGHT)) { |
|
107 |
Tile tile = (Tile)pool.getTilePipe().getAtomicTask(); |
|
108 |
System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority()); |
|
109 |
nCollected ++; |
|
110 |
} |
|
111 |
if(pool != null) |
|
112 |
pool.destroyPool(); |
|
113 |
} |
|
114 |
|
|
115 |
} |
|
0 | 116 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/StatsValues.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer; |
|
2 |
|
|
3 |
/** |
|
4 |
* Interface implemented by a raster band with statistics |
|
5 |
* capabilities. |
|
6 |
* |
|
7 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
8 |
* |
|
9 |
*/ |
|
10 |
public interface StatsValues { |
|
11 |
/** |
|
12 |
* Get the maximun value |
|
13 |
* @return double |
|
14 |
*/ |
|
15 |
public double getMax(); |
|
16 |
|
|
17 |
/** |
|
18 |
* Set the maximun value |
|
19 |
* @param max |
|
20 |
*/ |
|
21 |
public void setMax(double max); |
|
22 |
|
|
23 |
/** |
|
24 |
* Get the minimun value |
|
25 |
* @return double |
|
26 |
*/ |
|
27 |
public double getMin(); |
|
28 |
|
|
29 |
/** |
|
30 |
* Set the minimun value |
|
31 |
* @param max |
|
32 |
*/ |
|
33 |
public void setMin(double min); |
|
34 |
|
|
35 |
/** |
|
36 |
* Get the second maximun value |
|
37 |
* @return double |
|
38 |
*/ |
|
39 |
public double getSecondMax(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Set the second maximun value |
|
43 |
* @param max |
|
44 |
*/ |
|
45 |
public void setSecondMax(double secondMax); |
|
46 |
|
|
47 |
/** |
|
48 |
* Get the second minimun value |
|
49 |
* @return double |
|
50 |
*/ |
|
51 |
public double getSecondMin(); |
|
52 |
|
|
53 |
/** |
|
54 |
* Set the second minimun value |
|
55 |
* @param max |
|
56 |
*/ |
|
57 |
public void setSecondMin(double secondMin); |
|
58 |
|
|
59 |
/** |
|
60 |
* Get the maximun value in a eight bits band. |
|
61 |
* A value of eight bits has a range betwen -127 and 128. |
|
62 |
* The maximun is readed in a range betwen 0 and 255. |
|
63 |
* @return |
|
64 |
*/ |
|
65 |
public double getMaxRGB(); |
|
66 |
|
|
67 |
/** |
|
68 |
* Set the maximun value in a eight bits band. |
|
69 |
* A value of eight bits has a range betwen -127 and 128. |
|
70 |
* The maximun is writed in a range betwen 0 and 255. |
|
71 |
* @return |
|
72 |
*/ |
|
73 |
public void setMaxRGB(double maxRGB); |
|
74 |
|
|
75 |
/** |
|
76 |
* Get the minimun value in a eight bits band. |
|
77 |
* A value of eight bits has a range betwen -127 and 128. |
|
78 |
* The minimun is readed in a range betwen 0 and 255. |
|
79 |
* @return |
|
80 |
*/ |
|
81 |
public double getMinRGB(); |
|
82 |
|
|
83 |
/** |
|
84 |
* Set the minimun value in a eight bits band. |
|
85 |
* A value of eight bits has a range betwen -127 and 128. |
|
86 |
* The minimun is readed in a range betwen 0 and 255. |
|
87 |
* @param minRGB |
|
88 |
*/ |
|
89 |
public void setMinRGB(double minRGB); |
|
90 |
|
|
91 |
/** |
|
92 |
* Get the second maximun value in a eight bits band. |
|
93 |
* A value of eight bits has a range betwen -127 and 128. |
|
94 |
* The second maximun is readed in a range betwen 0 and 255. |
|
95 |
* @return |
|
96 |
*/ |
|
97 |
public double getSecondMaxRGB(); |
|
98 |
|
|
99 |
/** |
|
100 |
* Set the second maximun value in a eight bits band. |
|
101 |
* A value of eight bits has a range betwen -127 and 128. |
|
102 |
* The second maximun is writed in a range betwen 0 and 255. |
|
103 |
* @return |
|
104 |
*/ |
|
105 |
public void setSecondMaxRGB(double secondMaxRGB); |
|
106 |
|
|
107 |
/** |
|
108 |
* Get the second minimun value in a eight bits band. |
|
109 |
* A value of eight bits has a range betwen -127 and 128. |
|
110 |
* The second minimun is readed in a range betwen 0 and 255. |
|
111 |
* @return |
|
112 |
*/ |
|
113 |
public double getSecondMinRGB(); |
|
114 |
|
|
115 |
/** |
|
116 |
* Set the second minimun value in a eight bits band. |
|
117 |
* A value of eight bits has a range betwen -127 and 128. |
|
118 |
* The second minimun is readed in a range betwen 0 and 255. |
|
119 |
* @param minRGB |
|
120 |
*/ |
|
121 |
public void setSecondMinRGB(double secondMinRGB); |
|
122 |
|
|
123 |
/** |
|
124 |
* Get the mean value in this band |
|
125 |
* @return |
|
126 |
*/ |
|
127 |
public double getMean(); |
|
128 |
|
|
129 |
/** |
|
130 |
* Get the mean value in this band |
|
131 |
* @param mean |
|
132 |
*/ |
|
133 |
public void setMean(double mean); |
|
134 |
|
|
135 |
} |
|
0 | 136 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidAccessException.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.exception; |
|
2 |
|
|
3 |
/** |
|
4 |
* Excepci?n lanzada cuando se detecta un acceso a un tipo de datos incorrecto |
|
5 |
* en un RasterBuffer. |
|
6 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
7 |
* |
|
8 |
*/ |
|
9 |
public class BufferInvalidAccessException extends Exception{ |
|
10 |
|
|
11 |
private static final long serialVersionUID = -3065331336250589153L; |
|
12 |
|
|
13 |
public BufferInvalidAccessException(String msg){ |
|
14 |
super(msg); |
|
15 |
} |
|
16 |
} |
|
0 | 17 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/ProcessInterruptedException.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.cache.buffer.exception; |
|
23 |
|
|
24 |
import org.gvsig.tools.exception.BaseException; |
|
25 |
|
|
26 |
/** |
|
27 |
* Excepci?n lanzada cuando se interrumpe un proceso |
|
28 |
* |
|
29 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
30 |
*/ |
|
31 |
public class ProcessInterruptedException extends BaseException { |
|
32 |
private static final long serialVersionUID = 666908550965442025L; |
|
33 |
|
|
34 |
public ProcessInterruptedException(Throwable e){ |
|
35 |
super(e.getMessage(), e, "", 0); |
|
36 |
} |
|
37 |
|
|
38 |
public ProcessInterruptedException(String msg){ |
|
39 |
super(msg, "", 0); |
|
40 |
} |
|
41 |
} |
|
0 | 42 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BandNotCompatibleException.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.exception; |
|
2 |
|
|
3 |
/** |
|
4 |
* This exception is throwed when a selected band is not compatible with other or |
|
5 |
* with a databuffer. |
|
6 |
* |
|
7 |
* 24/10/2008 |
|
8 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
9 |
*/ |
|
10 |
public class BandNotCompatibleException extends Exception { |
|
11 |
private static final long serialVersionUID = -4312548276663417111L; |
|
12 |
|
|
13 |
public BandNotCompatibleException(String msg) { |
|
14 |
super(msg); |
|
15 |
} |
|
16 |
} |
|
0 | 17 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/OperationNotSupportedException.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.exception; |
|
2 |
|
|
3 |
/** |
|
4 |
* This exception is throwed when a selected operation is not compatible with |
|
5 |
* the buffer |
|
6 |
* |
|
7 |
* 24/10/2008 |
|
8 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
9 |
*/ |
|
10 |
public class OperationNotSupportedException extends Exception { |
|
11 |
private static final long serialVersionUID = -4312548276663417111L; |
|
12 |
|
|
13 |
public OperationNotSupportedException(String message, Throwable cause) { |
|
14 |
super(message, cause); |
|
15 |
} |
|
16 |
|
|
17 |
public OperationNotSupportedException(String msg) { |
|
18 |
super(msg); |
|
19 |
} |
|
20 |
} |
|
0 | 21 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/InvalidPageNumberException.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.exception; |
|
2 |
|
|
3 |
/** |
|
4 |
* Excepci?n lanzada cuando el n?mero de p?gina al que se intenta acceder no es valido. |
|
5 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
6 |
* |
|
7 |
*/ |
|
8 |
public class InvalidPageNumberException extends Exception { |
|
9 |
private static final long serialVersionUID = -4312548276663417111L; |
|
10 |
|
|
11 |
public InvalidPageNumberException(String msg){ |
|
12 |
super(msg); |
|
13 |
} |
|
14 |
} |
|
0 | 15 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/HistogramException.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.cache.buffer.exception; |
|
23 |
/** |
|
24 |
* Excepci?n lanzada por errores en el calculo de histogramas. |
|
25 |
* |
|
26 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
27 |
*/ |
|
28 |
public class HistogramException extends Exception { |
|
29 |
private static final long serialVersionUID = 666908550965442025L; |
|
30 |
|
|
31 |
public HistogramException(String msg, Throwable e) { |
|
32 |
super(msg, e); |
|
33 |
} |
|
34 |
|
|
35 |
public HistogramException(String msg){ |
|
36 |
super(msg); |
|
37 |
} |
|
38 |
} |
|
0 | 39 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/WrongParameterException.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.exception; |
|
2 |
|
|
3 |
/** |
|
4 |
* This exception is throwed when a parameter of a function is wrong. |
|
5 |
* |
|
6 |
* 24/10/2008 |
|
7 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
8 |
*/ |
|
9 |
public class WrongParameterException extends Exception { |
|
10 |
private static final long serialVersionUID = -4312548276663417111L; |
|
11 |
|
|
12 |
public WrongParameterException(String msg) { |
|
13 |
super(msg); |
|
14 |
} |
|
15 |
} |
|
0 | 16 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.raster.cache.buffer.exception package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>Exceptions which are thrown by a wrong buffer access</p> |
|
11 |
|
|
12 |
<p> |
|
13 |
</p> |
|
14 |
|
|
15 |
</body> |
|
16 |
</html> |
|
0 | 17 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidException.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.exception; |
|
2 |
|
|
3 |
/** |
|
4 |
* Excepci?n lanzada cuando se detecta que un buffer de raster es incorrecto. |
|
5 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
6 |
* |
|
7 |
*/ |
|
8 |
public class BufferInvalidException extends Exception{ |
|
9 |
private static final long serialVersionUID = -1566113755637911586L; |
|
10 |
|
|
11 |
public BufferInvalidException(String msg){ |
|
12 |
super(msg); |
|
13 |
} |
|
14 |
} |
|
0 | 15 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.raster.cache.buffer package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>Basic API to access a buffer of raster data</p> |
|
11 |
|
|
12 |
<p> |
|
13 |
</p> |
|
14 |
|
|
15 |
</body> |
|
16 |
</html> |
|
0 | 17 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLocator.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.cache.buffer; |
|
23 |
|
|
24 |
import org.gvsig.tools.locator.BaseLocator; |
|
25 |
import org.gvsig.tools.locator.Locator; |
|
26 |
import org.gvsig.tools.locator.LocatorException; |
|
27 |
|
|
28 |
/** |
|
29 |
* This locator is the entry point for the Raster library, providing |
|
30 |
* access to all Raster services through the {@link BufferCacheManager} |
|
31 |
* . |
|
32 |
* |
|
33 |
* @author gvSIG team |
|
34 |
* @version $Id$ |
|
35 |
*/ |
|
36 |
public class BufferCacheLocator extends BaseLocator { |
|
37 |
public static final String MANAGER_NAME = "BufferCache.manager"; |
|
38 |
public static final String MANAGER_DESCRIPTION = "BufferCache Manager"; |
|
39 |
private static final String LOCATOR_NAME = "BufferCache.locator"; |
|
40 |
private static final BufferCacheLocator INSTANCE = new BufferCacheLocator(); |
|
41 |
|
|
42 |
/** |
|
43 |
* Return the singleton instance. |
|
44 |
* |
|
45 |
* @return the singleton instance |
|
46 |
*/ |
|
47 |
public static BufferCacheLocator getInstance() { |
|
48 |
return INSTANCE; |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Return the Locator's name. |
|
53 |
* |
|
54 |
* @return a String with the Locator's name |
|
55 |
*/ |
|
56 |
public final String getLocatorName() { |
|
57 |
return LOCATOR_NAME; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Return a reference to the RasterManager. |
|
62 |
* |
|
63 |
* @return a reference to the RasterManager |
|
64 |
* @throws LocatorException |
|
65 |
* if there is no access to the class or the class cannot be |
|
66 |
* instantiated |
|
67 |
* @see Locator#get(String) |
|
68 |
*/ |
|
69 |
public static BufferCacheManager getManager() throws LocatorException { |
|
70 |
return (BufferCacheManager) getInstance().get(MANAGER_NAME); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Registers the Class implementing the RasterManager interface. |
|
75 |
* |
|
76 |
* @param clazz |
|
77 |
* implementing the RasterManager interface |
|
78 |
*/ |
|
79 |
public static void registerManager( |
|
80 |
Class<? extends BufferCacheManager> clazz) { |
|
81 |
getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
82 |
} |
|
83 |
|
|
84 |
} |
|
0 | 85 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferInterpolation.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer; |
|
2 |
|
|
3 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
4 |
import org.gvsig.raster.cache.buffer.task.IncrementableTask; |
|
5 |
|
|
6 |
/** |
|
7 |
* Interface implemented by a buffer interpolation object |
|
8 |
* |
|
9 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
10 |
*/ |
|
11 |
public interface BufferInterpolation extends IncrementableTask { |
|
12 |
public final static int INTERPOLATION_Undefined = 0; |
|
13 |
public final static int INTERPOLATION_NearestNeighbour = 1; |
|
14 |
public final static int INTERPOLATION_Bilinear = 2; |
|
15 |
public final static int INTERPOLATION_InverseDistance = 3; |
|
16 |
public final static int INTERPOLATION_Bicubic = 4; |
|
17 |
public final static int INTERPOLATION_BSpline = 5; |
|
18 |
|
|
19 |
/** |
|
20 |
* Get the supersampled buffer on a IRasterBuffer |
|
21 |
* @return |
|
22 |
* @throws ProcessInterruptedException |
|
23 |
*/ |
|
24 |
public Buffer getSupersampledScrolledNearestNeighbour(double[] superSampStep, int w, int h) throws ProcessInterruptedException; |
|
25 |
|
|
26 |
public Buffer getSupersampledScrolledBilinearInterpolation(double[] superSampStep, int w, int h) throws ProcessInterruptedException; |
|
27 |
|
|
28 |
/** |
|
29 |
* Ajusta el raster al ancho y alto solicitado por el vecino m?s cercano. Promedia el valor de dos |
|
30 |
* pixeles contiguos. |
|
31 |
* @param w Nuevo ancho |
|
32 |
* @param h Nuevo alto |
|
33 |
*/ |
|
34 |
public Buffer adjustRasterNearestNeighbourInterpolation(int w, int h) throws ProcessInterruptedException; |
|
35 |
|
|
36 |
/** |
|
37 |
* Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci?n bilineal. Promedia |
|
38 |
* el valor de cuatro pixeles adyacentes. |
|
39 |
* <P> |
|
40 |
* Para cada pixel del raster A:(x, y) obtiene el B:(x + 1, y), C:(x, y + 1), D:(x + 1, y + 1) |
|
41 |
* Para cada valor del kernel se calcula un valor 'd' que es un peso dependiendo de su posici?n. |
|
42 |
* Este peso depende de la posici?n del pixel destino dentro del origen. La posici?n del pixel destino |
|
43 |
* en el origen es un valor decimal que puede ir de 0 a 1. Si est? muy pegado a la esquina superior |
|
44 |
* izquierda estar? cercano a 0 y si est? muy pegado a la esquina inferior derecha estar? cercano a 1. |
|
45 |
* Este valor est? representado por 'dx' y 'dy'. |
|
46 |
* </P> |
|
47 |
* <P> |
|
48 |
* Los pesos aplicados son a |
|
49 |
* <UL> |
|
50 |
* <LI>A (1-dx) * (1-dy)</LI> |
|
51 |
* <LI>B dx * (1-dy)</LI> |
|
52 |
* <LI>C (1-dx) * dy</LI> |
|
53 |
* <LI>D dx * dy</LI> |
|
54 |
* </UL> |
|
55 |
* La variable 'z' contiene el valor acumulado de cada peso por el valor del pixel. |
|
56 |
* La variable 'n' contiene el valor acumulado de los pesos de los cuatro pixeles. |
|
57 |
* El valor final del pixel ser? 'z/n', es decir un promedio del valor de los cuatro teniendo |
|
58 |
* en cuenta el peso de cada uno. |
|
59 |
* </P> |
|
60 |
* @param w Nuevo ancho del buffer de salida |
|
61 |
* @param h Nuevo alto del buffer de salida |
|
62 |
*/ |
|
63 |
public Buffer adjustRasterBilinearInterpolation(int w, int h) throws ProcessInterruptedException; |
|
64 |
|
|
65 |
/** |
|
66 |
* Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci?n de distancia inversa. |
|
67 |
* Asigna el valor de un pixel en funci?n inversa de la distancia. |
|
68 |
* <P> |
|
69 |
* Para cada pixel del raster A:(x, y) obtiene el B:(x + 1, y), C:(x, y + 1), D:(x + 1, y + 1) |
|
70 |
* Para cada valor del kernel se calcula un valor 'd' que es un peso dependiendo de su posici?n. |
|
71 |
* Este peso ser? dependiente de la posici?n del pixel destino dentro del origen. La posici?n del pixel destino |
|
72 |
* en el origen es un valor decimal que puede ir de 0 a 1. Si est? muy pegado a la esquina superior |
|
73 |
* izquierda estar? cercano a 0 y si est? muy pegado a la esquina inferior derecha estar? cercano a 1. |
|
74 |
* Este valor est? representado por 'dx' y 'dy'. En este caso, y a diferencia del m?todo |
|
75 |
* bilinear el peso vendr? representado por la inversa de la distancia entre la posici?n |
|
76 |
* dentro del pixel y el origen del mismo. |
|
77 |
* </P> |
|
78 |
* <P> |
|
79 |
* Los pesos aplicados son a |
|
80 |
* <UL> |
|
81 |
* <LI>A 1 / sqrt((1-dx) * (1-dy))</LI> |
|
82 |
* <LI>B 1 / sqrt(dx * (1-dy))</LI> |
|
83 |
* <LI>C 1 / sqrt((1-dx) * dy)</LI> |
|
84 |
* <LI>D 1 / sqrt(dx * dy)</LI> |
|
85 |
* </UL> |
|
86 |
* La variable 'z' contiene el valor acumulado de cada peso por el valor del pixel. |
|
87 |
* La variable 'n' contiene el valor acumulado de los pesos de los cuatro pixeles. |
|
88 |
* El valor final del pixel ser? 'z/n', es decir un promedio del valor de los cuatro teniendo |
|
89 |
* en cuenta el peso de cada uno. |
|
90 |
* </P> |
|
91 |
* @param w Nuevo ancho del buffer de salida |
|
92 |
* @param h Nuevo alto del buffer de salida |
|
93 |
*/ |
|
94 |
public Buffer adjustRasterInverseDistanceInterpolation(int w, int h) throws ProcessInterruptedException; |
|
95 |
/** |
|
96 |
* Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci?n BSpline. Promedia |
|
97 |
* el valor de cuatro pixeles adyacentes. |
|
98 |
* @param w Nuevo ancho |
|
99 |
* @param h Nuevo alto |
|
100 |
*/ |
|
101 |
public Buffer adjustRasterBSplineInterpolation(int w, int h) throws ProcessInterruptedException; |
|
102 |
|
|
103 |
/** |
|
104 |
* Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci?n de spline bicubica. |
|
105 |
* @param w Nuevo ancho |
|
106 |
* @param h Nuevo alto |
|
107 |
*/ |
|
108 |
public Buffer adjustRasterBicubicSplineInterpolation(int w, int h) throws ProcessInterruptedException; |
|
109 |
|
|
110 |
/** |
|
111 |
* Obtiene el porcentaje del proceso de interpolacion |
|
112 |
* @return |
|
113 |
*/ |
|
114 |
public int getPercent(); |
|
115 |
} |
|
0 | 116 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/IncrementableTask.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.task; |
|
2 |
|
|
3 |
/** |
|
4 |
* This interface defines methods for common tasks |
|
5 |
* |
|
6 |
* @version 07/05/2007 |
|
7 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
8 |
* |
|
9 |
*/ |
|
10 |
public interface IncrementableTask extends BaseIncrementableTask { |
|
11 |
/** |
|
12 |
* Devuelve el contenido del log del IncrementableTask |
|
13 |
* @return String |
|
14 |
*/ |
|
15 |
public String getLog(); |
|
16 |
|
|
17 |
/** |
|
18 |
* <p>Determines if this process can be canceled.</p> |
|
19 |
* |
|
20 |
* @return <code>true</code> if this process can be canceled, otherwise <code>false</code> |
|
21 |
*/ |
|
22 |
public boolean isCancelable(); |
|
23 |
|
|
24 |
/** |
|
25 |
* <p>Determines if this process can be paused.</p> |
|
26 |
* |
|
27 |
* @return <code>true</code> if this process can be paused, otherwise <code>false</code> |
|
28 |
*/ |
|
29 |
public boolean isPausable(); |
|
30 |
} |
|
0 | 31 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.raster.cache.buffer.task package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>Buffer tasks</p> |
|
11 |
|
|
12 |
<p> |
|
13 |
</p> |
|
14 |
|
|
15 |
</body> |
|
16 |
</html> |
|
0 | 17 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/TaskEventManager.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.task; |
|
2 |
|
|
3 |
import java.util.EventObject; |
|
4 |
|
|
5 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
6 |
|
|
7 |
|
|
8 |
/** |
|
9 |
* Service to send events to a task. To register a new event you have to |
|
10 |
* use the RasterManager |
|
11 |
* <code>TaskEventManager task = manager.createRasterTask(this);</code> |
|
12 |
* You can send events to the task |
|
13 |
* <code>task.sendEvent(new CancelEvent(this));</code> |
|
14 |
* If you want recover a registered task to send it a event you'll have |
|
15 |
* to use the RasterManager again. To get the task it will use the current |
|
16 |
* thread ID. |
|
17 |
* <code>TaskEventManager task = manager.getRasterTask()</code> |
|
18 |
* |
|
19 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
20 |
*/ |
|
21 |
public interface TaskEventManager { |
|
22 |
|
|
23 |
/** |
|
24 |
* Removes this task from the repository |
|
25 |
* @param |
|
26 |
*/ |
|
27 |
public void removeTask(); |
|
28 |
|
|
29 |
/** |
|
30 |
* Sets a event. |
|
31 |
* @param ev EventObject |
|
32 |
*/ |
|
33 |
public void setEvent(EventObject ev); |
|
34 |
|
|
35 |
/** |
|
36 |
* Obtiene el evento |
|
37 |
* @return EventObject |
|
38 |
*/ |
|
39 |
public EventObject getEvent(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Gesti?n de las se?ales. Este m?todo define las acciones por defecto para |
|
43 |
* cada se?al. No es necesario utilizar estas. Se puede en cada caso, hacer un m?todo |
|
44 |
* manageEvent en el que se gestione las acciones concretas de una se?al. |
|
45 |
* |
|
46 |
* @param ev Evento a gestionar |
|
47 |
*/ |
|
48 |
public void manageEvent(EventObject ev) throws ProcessInterruptedException; |
|
49 |
} |
|
0 | 50 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/Task.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.task; |
|
2 |
|
|
3 |
import java.util.EventObject; |
|
4 |
/** |
|
5 |
* A process have to contain a {@link Task} object. A process should be |
|
6 |
* registered when this starts and removed from the register when this finishes or |
|
7 |
* is canceled. This process has to do these actions. |
|
8 |
* |
|
9 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
10 |
*/ |
|
11 |
public interface Task { |
|
12 |
|
|
13 |
/** |
|
14 |
* Asigna el evento |
|
15 |
* @param ev EventObject |
|
16 |
*/ |
|
17 |
public void setEvent(EventObject ev); |
|
18 |
|
|
19 |
/** |
|
20 |
* Obtiene el evento |
|
21 |
* @return EventObject |
|
22 |
*/ |
|
23 |
public EventObject getEvent(); |
|
24 |
|
|
25 |
/** |
|
26 |
* Obtiene el identificador ?nico del proceso. |
|
27 |
* @return Identificador del proceso |
|
28 |
*/ |
|
29 |
public String getID(); |
|
30 |
|
|
31 |
/** |
|
32 |
* Gesti?n de las se?ales. Este m?todo define las acciones por defecto para |
|
33 |
* cada se?al. No es necesario utilizar estas. Se puede en cada caso, hacer un m?todo |
|
34 |
* manageEvent en el que se gestione las acciones concretas de una se?al. |
|
35 |
* |
|
36 |
* @param ev Evento a gestionar |
|
37 |
*/ |
|
38 |
public void manageEvent(EventObject ev) throws InterruptedException; |
|
39 |
} |
|
0 | 40 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/BaseIncrementableTask.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.task; |
|
2 |
|
|
3 |
/** |
|
4 |
* Base class for incrementable tasks |
|
5 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
6 |
*/ |
|
7 |
public interface BaseIncrementableTask { |
|
8 |
|
|
9 |
/** |
|
10 |
* Gets the increment |
|
11 |
* @return int |
|
12 |
*/ |
|
13 |
public int getPercent(); |
|
14 |
|
|
15 |
/** |
|
16 |
* Sets the increment of this task |
|
17 |
*/ |
|
18 |
public void setPercent(int value); |
|
19 |
} |
|
0 | 20 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/CancelEvent.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer.task; |
|
2 |
|
|
3 |
import java.util.EventObject; |
|
4 |
|
|
5 |
/** |
|
6 |
* Evento de cancelaci?n a los procesos registrados en RasterTaskQueue. |
|
7 |
* |
|
8 |
* @version 17/09/2007 |
|
9 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class CancelEvent extends EventObject { |
|
13 |
|
|
14 |
private static final long serialVersionUID = 7564626429497930401L; |
|
15 |
|
|
16 |
/** |
|
17 |
* Construye un CancelEvent |
|
18 |
* @param source |
|
19 |
*/ |
|
20 |
public CancelEvent(Object source) { |
|
21 |
super(source); |
|
22 |
} |
|
23 |
} |
|
0 | 24 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLibrary.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.cache.buffer; |
|
23 |
|
|
24 |
import org.gvsig.tools.library.AbstractLibrary; |
|
25 |
import org.gvsig.tools.library.LibraryException; |
|
26 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
27 |
|
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
32 |
*/ |
|
33 |
public class BufferCacheLibrary extends AbstractLibrary { |
|
34 |
|
|
35 |
public BufferCacheLibrary() { |
|
36 |
registerAsAPI(BufferCacheLibrary.class); |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
protected void doInitialize() throws LibraryException { |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected void doPostInitialize() throws LibraryException { |
|
45 |
BufferCacheManager manager = BufferCacheLocator.getManager(); |
|
46 |
if (manager == null) { |
|
47 |
throw new ReferenceNotRegisteredException( |
|
48 |
BufferCacheLocator.MANAGER_NAME, BufferCacheLocator |
|
49 |
.getInstance()); |
|
50 |
} |
|
51 |
} |
|
52 |
} |
|
0 | 53 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferDataSource.java | ||
---|---|---|
1 |
package org.gvsig.raster.cache.buffer; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
|
6 |
import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException; |
|
7 |
|
|
8 |
|
|
9 |
/** |
|
10 |
* Data Server for read only buffers. |
|
11 |
* 02/11/2008 |
|
12 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
13 |
*/ |
|
14 |
public interface BufferDataSource { |
|
15 |
/** |
|
16 |
* Get the path to image file |
|
17 |
* @return |
|
18 |
*/ |
|
19 |
public String[] getPath(); |
|
20 |
|
|
21 |
/** |
|
22 |
* Set the path to image file |
|
23 |
* @param path |
|
24 |
* path to the file |
|
25 |
*/ |
|
26 |
public void setPath(String[] path); |
|
27 |
|
|
28 |
/** |
|
29 |
* Set the path to image file |
|
30 |
* @param path |
|
31 |
* path to the file |
|
32 |
*/ |
|
33 |
public void setPath(String path); |
|
34 |
|
|
35 |
/** |
|
36 |
* Get the band selected to read for loadSelectedBand method |
|
37 |
* @return |
|
38 |
*/ |
|
39 |
public int getSelectedBand(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Set the band selected to read for loadSelectedBand method |
|
43 |
* @param band |
|
44 |
* band to the file |
|
45 |
*/ |
|
46 |
public void setSelectedBand(int path); |
|
47 |
|
|
48 |
/** |
|
49 |
* Get the width of the data source |
|
50 |
* @return |
|
51 |
*/ |
|
52 |
public int getWidth(); |
|
53 |
|
|
54 |
/** |
|
55 |
* Get the height of the data source |
|
56 |
* @return |
|
57 |
*/ |
|
58 |
public int getHeight(); |
|
59 |
|
|
60 |
/** |
|
61 |
* Get de number of bands |
|
62 |
* @return |
|
63 |
*/ |
|
64 |
public int getBandCount(); |
|
65 |
|
|
66 |
/** |
|
67 |
* Get the data type |
|
68 |
* @return |
|
69 |
*/ |
|
70 |
public int getDataType(); |
|
71 |
|
|
72 |
/** |
|
73 |
* Load a page with data. |
|
74 |
* @param rb |
|
75 |
* Page |
|
76 |
* @param stripe |
|
77 |
* Object with the information about data read. This contains positional information. |
|
78 |
* @throws IOException |
|
79 |
* @throws InterruptedException |
|
80 |
* @throws OperationNotSupportedException |
|
81 |
*/ |
|
82 |
public void loadPage(Buffer rb, PxTile stripe) throws IOException, ProcessInterruptedException, OperationNotSupportedException; |
|
83 |
|
|
84 |
/** |
|
85 |
* Load a one banded page with data. |
|
86 |
* @param rb |
|
87 |
* Page |
|
88 |
* @param stripe |
|
89 |
* Object with the information about data read. This contains positional information. |
|
90 |
* @param iBand |
|
91 |
* Band to load |
|
92 |
* @throws IOException |
|
93 |
* @throws InterruptedException |
|
94 |
* @throws OperationNotSupportedException |
|
95 |
*/ |
|
96 |
public void loadPage(Buffer rb, PxTile stripe, int iBand) throws IOException, ProcessInterruptedException, OperationNotSupportedException; |
|
97 |
|
|
98 |
/** |
|
99 |
* Load a page with data. Only is loaded the band selected in the variable "selectedBand" |
|
100 |
* @param rb |
|
101 |
* Page |
|
102 |
* @param stripe |
|
103 |
* Object with the information about data read. This contains positional information. |
|
104 |
* @throws IOException |
|
105 |
* @throws OperationNotSupportedException |
|
106 |
* @throws ProcessInterruptedException |
|
107 |
*/ |
|
108 |
public void loadSelectedBand(Buffer rb, PxTile stripe) throws IOException, OperationNotSupportedException, ProcessInterruptedException; |
|
109 |
|
|
110 |
/** |
|
111 |
* Load a page of cache from the hard disk |
|
112 |
* @param RasterMemoryBuffer Data buffer to load in memory |
|
113 |
* @param String File name |
|
114 |
*/ |
|
115 |
public void loadPage(Buffer buf, String file) throws InterruptedException; |
|
116 |
|
|
117 |
/** |
|
118 |
* Save a page of cache to the hard disk |
|
119 |
* @param RasterMemoryBuffer Data buffer to load in memory |
|
120 |
* @param String File name |
|
121 |
* @throws IOException |
|
122 |
*/ |
|
123 |
public void savePage(Buffer buf, String file)throws IOException; |
|
124 |
|
|
125 |
/** |
|
126 |
* Save a band of cache to the hard disk |
|
127 |
* @param RasterMemoryBuffer Data buffer to load in memory |
|
128 |
* @param String File name |
|
129 |
* @throws IOException |
|
130 |
*/ |
|
131 |
public void saveBand(Band buf, String file)throws IOException; |
|
132 |
|
|
133 |
/** |
|
134 |
* Elimina la fuente de datos de disco |
|
135 |
* @throws IOException |
|
136 |
*/ |
|
137 |
public void delete(String file)throws IOException; |
|
138 |
|
|
139 |
/** |
|
140 |
* Close the data source |
|
141 |
*/ |
|
142 |
public void close() throws IOException; |
|
143 |
|
|
144 |
/** |
|
145 |
* Change the name of a file |
|
146 |
* @param oldName |
|
147 |
* @param newName |
|
148 |
*/ |
|
149 |
public void changeFileName(String oldName, String newName); |
|
150 |
|
|
151 |
/** |
|
152 |
* Clone the datasource to be assigned to each band |
|
153 |
* @return |
|
154 |
*/ |
|
155 |
public BufferDataSource clone(); |
|
156 |
} |
|
0 | 157 |
org.gvsig.raster.cache/tags/buildNumber_33/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheManager.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.cache.buffer; |
|
23 |
|
|
24 |
import java.io.IOException; |
|
25 |
|
|
26 |
import org.gvsig.raster.cache.buffer.histogram.BufferHistogram; |
|
27 |
import org.gvsig.raster.cache.buffer.task.TaskEventManager; |
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* This class is responsible of the management of the library's business logic. |
|
35 |
* It is the library's main entry point, and provides all the services to manage |
|
36 |
* {@link BufferCacheService}s. |
|
37 |
* |
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
39 |
* @version $Id$ |
|
40 |
*/ |
|
41 |
public interface BufferCacheManager { |
|
42 |
public static int DONT_FORCE = 0; |
|
43 |
public static int MEMORY_BUFFER = 1; |
|
44 |
public static int BAND_CACHE = 2; |
|
45 |
public static int BAND_VERT_CACHE = 3; |
|
46 |
public static int READ_ONLY_CACHE = 4; |
|
47 |
|
|
48 |
/** |
|
49 |
* Valor noData por defecto para la librer?a. En caso de no tener un valor asociado |
|
50 |
* al raster se usar? este. |
|
51 |
*/ |
|
52 |
public static double defaultNoDataValue = -99999; |
|
53 |
public static boolean noDataValueEnable = false; |
|
54 |
|
|
55 |
//***************************************************** |
|
56 |
//BUFFER API |
|
57 |
//***************************************************** |
|
58 |
|
|
59 |
/** |
|
60 |
* Genera instancias del buffer de datos adecuado al tama?o del raster. Si no hay muchos datos |
|
61 |
* (menos de cacheMemorySize) crear? un buffer en memoria. Si hay m?s de esta cantidad |
|
62 |
* entonces crearemos un buffer cacheado (RasterCache). A partir de la cantidad se?alada |
|
63 |
* por multicacheMemorySize haremos un buffer cacheado donde cada p?gina no ocupa todo |
|
64 |
* el ancho del raster ya que este ser? muy grande. La gesti?n de una cache donde cada |
|
65 |
* pagina ha de partir una l?nea lleva una complejidad a?adida. |
|
66 |
* |
|
67 |
* @param params Par?metros de la carga |
|
68 |
* @return Objeto RasterBuffer |
|
69 |
*/ |
|
70 |
public Buffer createBuffer(BufferParam params); |
|
71 |
|
|
72 |
/** |
|
73 |
* Genera una instancia del buffer de solo lectura. Este buffer consta de una cache y unos apuntadores |
|
74 |
* a las p?ginas en disco. Cuando se accede a los datos se carga en memoria la p?gina pedida. |
|
75 |
* |
|
76 |
* @param file |
|
77 |
* File to read data |
|
78 |
*/ |
|
79 |
public Buffer createReadOnlyBuffer(String file); |
|
80 |
|
|
81 |
/** |
|
82 |
* Creates an instance of a memory buffer |
|
83 |
* |
|
84 |
* @param dataType Tipo de dato |
|
85 |
* @param width Ancho |
|
86 |
* @param height Alto |
|
87 |
* @param bandNr Banda |
|
88 |
* @param flag En caso de buffers de memoria este flag a true significa que se reserva la memoria |
|
89 |
* para el buffer de forma normal y si est? a false no se reserva por lo que la reserva deber? ser |
|
90 |
* posterior. |
|
91 |
*/ |
|
92 |
public Buffer createMemoryBuffer(int dataType, int width, int height, int bandNr, boolean malloc); |
|
93 |
|
|
94 |
/** |
|
95 |
* Creates an instance of a memory buffer |
|
96 |
* |
|
97 |
* @param params |
|
98 |
* Parameters to instantiate this buffer |
|
99 |
*/ |
|
100 |
public Buffer createMemoryBuffer(BufferParam params); |
|
101 |
|
|
102 |
/** |
|
103 |
* Creates a new instance of an interpolation object. |
|
104 |
* @param buf IRasterBuffer |
|
105 |
* @return IBufferInterpolation |
|
106 |
*/ |
|
107 |
public BufferInterpolation createInterpolation(Buffer buf); |
|
108 |
|
|
109 |
/** |
|
110 |
* Builds a new parameter object |
|
111 |
* @param x |
|
112 |
* Upper left X position |
|
113 |
* @param y |
|
114 |
* Upper left X position |
|
115 |
* @param w |
|
116 |
* Width |
|
117 |
* @param h |
|
118 |
* Height |
|
119 |
*/ |
|
120 |
public BufferParam createBufferParams(int w, int h); |
|
121 |
|
|
122 |
/** |
|
123 |
* Creates a parameter object for building a buffer. The buffer type is read-write. |
|
124 |
* This type could be changed after the creation of a {@link BufferParam} object. |
|
125 |
* @param w |
|
126 |
* Width |
|
127 |
* @param h |
|
128 |
* Height |
|
129 |
* @param bandCount |
|
130 |
* Number of bands |
|
131 |
* @param dataType |
|
132 |
* Type of data |
|
133 |
*/ |
|
134 |
public BufferParam createBufferParams(int w, int h, int bandCount, int dataType); |
|
135 |
|
|
136 |
/** |
|
137 |
* Creates a parameter object for building a buffer. For this call the buffer type |
|
138 |
* is read-only and the source will be a multifile. |
|
139 |
* @param files |
|
140 |
* File list in disk |
|
141 |
* @param x |
|
142 |
* initial pixel |
|
143 |
* @param y |
|
144 |
* initial pixel |
|
145 |
* @param w |
|
146 |
* Width in pixels |
|
147 |
* @param h |
|
148 |
* Height in pixels |
|
149 |
* @param bands |
|
150 |
* bands to render |
|
151 |
* @return {@link BufferParam} |
|
152 |
* @throws IOException |
|
153 |
*/ |
|
154 |
public BufferParam createBufferParams(String[] files, int x, int y, int w, int h, int[] bands) throws IOException; |
|
155 |
|
|
156 |
/** |
|
157 |
* Creates a parameter object for building a buffer. For this call the buffer type |
|
158 |
* is read-only. |
|
159 |
* @param file |
|
160 |
* File in disk |
|
161 |
* @param x |
|
162 |
* initial pixel |
|
163 |
* @param y |
|
164 |
* initial pixel |
|
165 |
* @param w |
|
166 |
* Width in pixels |
|
167 |
* @param h |
|
168 |
* Height in pixels |
|
169 |
* @param bands |
|
170 |
* bands to render |
|
171 |
* @return {@link BufferParam} |
|
172 |
* @throws IOException |
|
173 |
*/ |
|
174 |
public BufferParam createBufferParams(String file, int x, int y, int w, int h, int[] bands) throws IOException; |
|
175 |
|
|
176 |
/** |
|
177 |
* Creates a parameter object for building a buffer. For this call the buffer type |
|
178 |
* is read-only. |
|
179 |
* @param file |
|
180 |
* File in disk |
|
181 |
* @param x |
|
182 |
* initial pixel |
|
183 |
* @param y |
|
184 |
* initial pixel |
|
185 |
* @param w |
|
186 |
* Width in pixels |
|
187 |
* @param h |
|
188 |
* Height in pixels |
|
189 |
* @param bands |
|
190 |
* bands to render |
|
191 |
* @return {@link BufferParam} |
|
192 |
* @throws IOException |
|
193 |
*/ |
|
194 |
public BufferParam createBufferParams(String file, int x, int y, int w, int h) throws IOException; |
|
195 |
|
|
196 |
//***************************************************** |
|
197 |
//NODATA API |
|
198 |
//***************************************************** |
|
199 |
|
|
200 |
/** |
|
201 |
* Builds a new NoData object |
|
202 |
* @param noData |
Also available in: Unified diff