Revision 37962 trunk/libraries/libRaster/src/org/gvsig/raster/grid/render/ImageDrawer.java
ImageDrawer.java | ||
---|---|---|
26 | 26 |
import org.gvsig.raster.grid.GridTransparency; |
27 | 27 |
import org.gvsig.raster.process.RasterTask; |
28 | 28 |
import org.gvsig.raster.process.RasterTaskQueue; |
29 |
import org.gvsig.raster.util.Cancellable; |
|
30 |
|
|
29 | 31 |
/** |
30 | 32 |
* Objeto para la escritura de datos desde un buffer a un objeto Image. En este nivel de |
31 | 33 |
* renderizado no se gestiona extents, ni rotaciones ni coordenadas del mundo, solo la |
... | ... | |
61 | 63 |
* Si no hay tres bandas, por ejemplo una y el flag es true esta ser? replicada |
62 | 64 |
* en R, G y B, en caso de ser false la banda ser? dibujada en su posici?n (R, G o B) |
63 | 65 |
* y en las otras bandas se rellenar? con 0. |
66 |
* @param cancel |
|
64 | 67 |
* |
65 | 68 |
* @param transparentBand. Si es true la banda 4 es alpha y si es false no lo es. |
66 | 69 |
* |
67 | 70 |
* @return java.awt.Image con el buffer dibujado. |
68 | 71 |
* @throws InterruptedException |
69 | 72 |
*/ |
70 |
public Image drawBufferOverImageObject(boolean replicateBand, int[] renderBands) throws InterruptedException { |
|
73 |
public Image drawBufferOverImageObject(boolean replicateBand, int[] renderBands, Cancellable cancel) throws InterruptedException {
|
|
71 | 74 |
if (rasterBuf == null || width == 0 || height == 0) |
72 | 75 |
return null; |
73 | 76 |
|
... | ... | |
89 | 92 |
transparency.getAlphaBand() != null && |
90 | 93 |
(transparency.getAlphaBand().getDataType() != IBuffer.TYPE_BYTE)) |
91 | 94 |
transparency.setAlphaBand(convertToByte(transparency.getAlphaBand())); |
92 |
drawWithTransparency(image, data, (step != null)); |
|
95 |
drawWithTransparency(image, data, (step != null), cancel);
|
|
93 | 96 |
} else |
94 |
drawByte(image, data, (step != null)); |
|
97 |
drawByte(image, data, (step != null), cancel);
|
|
95 | 98 |
|
96 | 99 |
step = null; |
97 | 100 |
return image; |
... | ... | |
123 | 126 |
* @param supersampling true si se necesita supersamplear y false si no se necesita |
124 | 127 |
* @throws InterruptedException |
125 | 128 |
*/ |
126 |
private void drawByte(BufferedImage image, byte[] data, boolean supersampling) throws InterruptedException { |
|
129 |
private void drawByte(BufferedImage image, byte[] data, boolean supersampling, Cancellable cancel) throws InterruptedException {
|
|
127 | 130 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().toString()); |
128 | 131 |
|
129 | 132 |
if (supersampling) { |
... | ... | |
131 | 134 |
int[] c = new int[width]; |
132 | 135 |
calcSupersamplingStepsArrays(r, c); |
133 | 136 |
for (int row = 0; row < height; row++) { |
137 |
if (cancel.isCanceled()) |
|
138 |
return; |
|
134 | 139 |
for (int col = 0; col < width; col++) { |
135 | 140 |
try { |
136 | 141 |
rasterBuf.getElemByte(r[row], c[col], data); |
... | ... | |
146 | 151 |
task.manageEvent(task.getEvent()); |
147 | 152 |
} |
148 | 153 |
} else { |
154 |
|
|
149 | 155 |
for (int row = 0; row < rasterBuf.getHeight(); row++) { |
156 |
if (row % 200 == 0) |
|
157 |
if (cancel.isCanceled()) |
|
158 |
return; |
|
159 |
|
|
150 | 160 |
for (int col = 0; col < rasterBuf.getWidth(); col++) { |
151 | 161 |
try { |
152 | 162 |
rasterBuf.getElemByte(row, col, data); |
... | ... | |
169 | 179 |
* @param image BufferedImage sobre el que se dibuja |
170 | 180 |
* @param data buffer vacio. Se trata de un array de bytes donde cada elemento representa una banda. |
171 | 181 |
* @param supersampling true si se necesita supersamplear y false si no se necesita |
182 |
* @param cancel |
|
172 | 183 |
* @throws InterruptedException |
173 | 184 |
*/ |
174 |
private void drawWithTransparency(BufferedImage image, byte[] data, boolean supersampling) throws InterruptedException { |
|
185 |
private void drawWithTransparency(BufferedImage image, byte[] data, boolean supersampling, Cancellable cancel) throws InterruptedException {
|
|
175 | 186 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().toString()); |
176 | 187 |
int value = 0; |
177 | 188 |
GridTransparency transparency = rendering.getLastTransparency(); |
... | ... | |
181 | 192 |
int[] c = new int[width]; |
182 | 193 |
calcSupersamplingStepsArrays(r, c); |
183 | 194 |
for (int row = 0; row < height; row++) { |
195 |
if (cancel.isCanceled()) |
|
196 |
return; |
|
197 |
|
|
184 | 198 |
for (int col = 0; col < width; col++) { |
185 | 199 |
try { |
186 | 200 |
rasterBuf.getElemByte(r[row], c[col], data); |
... | ... | |
197 | 211 |
} |
198 | 212 |
} else { |
199 | 213 |
for (int row = 0; row < rasterBuf.getHeight(); row++) { |
214 |
if (cancel.isCanceled()) |
|
215 |
return; |
|
216 |
|
|
200 | 217 |
for (int col = 0; col < rasterBuf.getWidth(); col++) { |
201 | 218 |
try { |
202 | 219 |
rasterBuf.getElemByte(row, col, data); |
Also available in: Unified diff