Revision 11390
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/cutting/WriterBufferServer.java | ||
---|---|---|
22 | 22 |
import org.gvsig.raster.dataset.IBuffer; |
23 | 23 |
import org.gvsig.raster.dataset.IDataWriter; |
24 | 24 |
|
25 |
import com.iver.andami.PluginServices; |
|
26 |
|
|
25 | 27 |
/** |
26 |
* Sirve los datos desde un IBuffer para el driver de escritura de bloques de |
|
27 |
* cach?. |
|
28 |
* <P> |
|
29 |
* Sirve los datos desde un IBuffer para el driver de escritura. El driver |
|
30 |
* de escritura que va a volcar un IBuffer a imagen en disco va solicitando |
|
31 |
* los datos por bloques a medida que va salvando los anteriores. Esta clase |
|
32 |
* es la encargada de hacer la divisi?n en bloques del buffer a volcar e ir |
|
33 |
* sirviendolos a medida que el driver pide m?s datos. |
|
34 |
* </P> |
|
35 |
* <P> |
|
36 |
* Implementa el interfaz IDataWriter que es el que define m?todos necesarios |
|
37 |
* para el driver. |
|
38 |
* Adem?s es una tarea incrementable por lo que deber? implementar el interfaz |
|
39 |
* IIncrementable para poder mostrar el dialogo de incremento de tarea. |
|
40 |
* </P> |
|
28 | 41 |
* |
29 | 42 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
30 | 43 |
*/ |
... | ... | |
32 | 45 |
private IBuffer buffer = null; |
33 | 46 |
private int row = 0; |
34 | 47 |
private int block = 0; |
48 |
private int percent = 0; |
|
49 |
private int increment = 0; |
|
35 | 50 |
|
51 |
/** |
|
52 |
* Constructor vacio |
|
53 |
*/ |
|
36 | 54 |
public WriterBufferServer() { |
37 | 55 |
} |
38 | 56 |
|
57 |
/** |
|
58 |
* Constructor. Asigna el buffer de datos. |
|
59 |
* @param buffer IBuffer |
|
60 |
*/ |
|
39 | 61 |
public WriterBufferServer(IBuffer buffer) { |
40 | 62 |
setBuffer(buffer); |
41 | 63 |
} |
42 | 64 |
|
65 |
/** |
|
66 |
* Asigna el buffer de datos. |
|
67 |
* @param buffer IBuffer |
|
68 |
*/ |
|
43 | 69 |
public void setBuffer(IBuffer buffer) { |
44 | 70 |
this.buffer = buffer; |
45 | 71 |
} |
46 | 72 |
|
73 |
/* |
|
74 |
* (non-Javadoc) |
|
75 |
* @see org.gvsig.raster.dataset.IDataWriter#readARGBData(int, int, int) |
|
76 |
*/ |
|
47 | 77 |
public int[] readARGBData(int sizeX, int sizeY, int nBand) { |
48 | 78 |
return null; |
49 | 79 |
} |
50 | 80 |
|
81 |
/** |
|
82 |
* Acciones de inicializaci?n para la lectura de de un bloque |
|
83 |
* @param sizeY Tama?o en Y del bloque |
|
84 |
*/ |
|
85 |
private void initRead(int sizeY) { |
|
86 |
if(row == 0) { |
|
87 |
block = sizeY; |
|
88 |
increment = (int)Math.ceil((double)buffer.getHeight() / (double)sizeY); |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
51 | 92 |
/* |
52 | 93 |
* (non-Javadoc) |
53 | 94 |
* @see org.gvsig.raster.dataset.IDataWriter#readByteData(int, int) |
54 | 95 |
*/ |
55 | 96 |
public byte[][] readByteData(int sizeX, int sizeY) { |
56 |
if(row == 0)
|
|
57 |
block = sizeY;
|
|
97 |
initRead(sizeY);
|
|
98 |
percent += increment;
|
|
58 | 99 |
int len = buffer.getWidth() * sizeY; |
59 | 100 |
byte[][] b = new byte[buffer.getBandCount()][len]; |
60 | 101 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
... | ... | |
70 | 111 |
* @see org.gvsig.raster.dataset.IDataWriter#readShortData(int, int) |
71 | 112 |
*/ |
72 | 113 |
public short[][] readShortData(int sizeX, int sizeY) { |
73 |
if(row == 0)
|
|
74 |
block = sizeY;
|
|
114 |
initRead(sizeY);
|
|
115 |
percent += increment;
|
|
75 | 116 |
int len = buffer.getWidth() * sizeY; |
76 | 117 |
short[][] b = new short[buffer.getBandCount()][len]; |
77 | 118 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
... | ... | |
87 | 128 |
* @see org.gvsig.raster.dataset.IDataWriter#readIntData(int, int) |
88 | 129 |
*/ |
89 | 130 |
public int[][] readIntData(int sizeX, int sizeY) { |
90 |
if(row == 0)
|
|
91 |
block = sizeY;
|
|
131 |
initRead(sizeY);
|
|
132 |
percent += increment;
|
|
92 | 133 |
int len = buffer.getWidth() * sizeY; |
93 | 134 |
int[][] b = new int[buffer.getBandCount()][len]; |
94 | 135 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
... | ... | |
104 | 145 |
* @see org.gvsig.raster.dataset.IDataWriter#readFloatData(int, int) |
105 | 146 |
*/ |
106 | 147 |
public float[][] readFloatData(int sizeX, int sizeY) { |
107 |
if(row == 0)
|
|
108 |
block = sizeY;
|
|
148 |
initRead(sizeY);
|
|
149 |
percent += increment;
|
|
109 | 150 |
int len = buffer.getWidth() * sizeY; |
110 | 151 |
float[][] b = new float[buffer.getBandCount()][len]; |
111 | 152 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
... | ... | |
121 | 162 |
* @see org.gvsig.raster.dataset.IDataWriter#readDoubleData(int, int) |
122 | 163 |
*/ |
123 | 164 |
public double[][] readDoubleData(int sizeX, int sizeY) { |
124 |
if(row == 0)
|
|
125 |
block = sizeY;
|
|
165 |
initRead(sizeY);
|
|
166 |
percent += increment;
|
|
126 | 167 |
int len = buffer.getWidth() * sizeY; |
127 | 168 |
double[][] b = new double[buffer.getBandCount()][len]; |
128 | 169 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
... | ... | |
133 | 174 |
return b; |
134 | 175 |
} |
135 | 176 |
|
177 |
/* |
|
178 |
* (non-Javadoc) |
|
179 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getLabel() |
|
180 |
*/ |
|
136 | 181 |
public String getLabel() { |
137 |
return "";
|
|
182 |
return PluginServices.getText(this, "generando_recorte") + "...";
|
|
138 | 183 |
} |
139 | 184 |
|
185 |
/* |
|
186 |
* (non-Javadoc) |
|
187 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getLog() |
|
188 |
*/ |
|
140 | 189 |
public String getLog() { |
141 |
return ""; |
|
190 |
int b = 0; |
|
191 |
if(block != 0) |
|
192 |
b = (int)(row / block); |
|
193 |
return PluginServices.getText(this, "generando_bloque") + "..." + b; |
|
142 | 194 |
} |
143 | 195 |
|
196 |
/* |
|
197 |
* (non-Javadoc) |
|
198 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getPercent() |
|
199 |
*/ |
|
144 | 200 |
public int getPercent() { |
145 |
return 0;
|
|
201 |
return Math.min(percent, 100);
|
|
146 | 202 |
} |
147 | 203 |
|
204 |
/* |
|
205 |
* (non-Javadoc) |
|
206 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getTitle() |
|
207 |
*/ |
|
148 | 208 |
public String getTitle() { |
149 |
return "";
|
|
209 |
return PluginServices.getText(this, "incremento_recorte");
|
|
150 | 210 |
} |
151 | 211 |
} |
Also available in: Unified diff