Revision 6317
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.legend/org.gvsig.raster.lib.legend.api/src/main/java/org/gvsig/raster/lib/legend/api/ColorInterpretation.java | ||
---|---|---|
15 | 15 |
public static final String ALPHA_BAND = "Alpha"; |
16 | 16 |
public static final String GRAY_BAND = "Gray"; |
17 | 17 |
|
18 |
public static final String RED_GREEN_BAND = "Red_Green";
|
|
19 |
public static final String RED_BLUE_BAND = "Red_Blue";
|
|
20 |
public static final String GREEN_BLUE_BAND = "Green_Blue";
|
|
18 |
// public static final String RED_GREEN_BAND = "Red_Green"; // YELLOW_BAND?
|
|
19 |
// public static final String RED_BLUE_BAND = "Red_Blue"; // MAGENTA_BAND?
|
|
20 |
// public static final String GREEN_BLUE_BAND = "Green_Blue"; // CYAN_BAND?
|
|
21 | 21 |
|
22 | 22 |
public static final String HUE_BAND = "Hue"; |
23 | 23 |
public static final String SATURATION_BAND = "Saturation"; |
... | ... | |
199 | 199 |
public void addColorInterpretation(ColorInterpretation ci); |
200 | 200 |
|
201 | 201 |
/** |
202 |
* @return Returns an array with bands to render reading values of this |
|
203 |
* color interpretation object. Each element in the array represents |
|
204 |
* band in the destination buffer. The value in this position |
|
205 |
* represents |
|
206 |
* the source band which will be write in the destination buffer |
|
207 |
*/ |
|
208 |
public int[] buildRenderBands(); |
|
209 |
|
|
210 |
/** |
|
211 | 202 |
* Copy from the color interpretation received as parameter |
212 | 203 |
* |
213 | 204 |
* @param colorInterpretation |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.legend/org.gvsig.raster.lib.legend.impl/src/test/java/org/gvsig/raster/lib/legend/impl/DefaultColorInterpretationTest.java | ||
---|---|---|
218 | 218 |
assertEquals(colorInterpretationGray.getAlphaBand(), -1); |
219 | 219 |
} |
220 | 220 |
|
221 |
public void testBuildRenderBands() { |
|
222 |
|
|
223 |
int[] buildRenderBands = colorInterpretation.buildRenderBands(); |
|
224 |
assertEquals(2, buildRenderBands[0]); |
|
225 |
assertEquals(0, buildRenderBands[1]); |
|
226 |
assertEquals(1, buildRenderBands[2]); |
|
227 |
|
|
228 |
buildRenderBands = colorInterpretationGray.buildRenderBands(); |
|
229 |
assertEquals(0, buildRenderBands[0]); |
|
230 |
assertEquals(0, buildRenderBands[1]); |
|
231 |
assertEquals(0, buildRenderBands[2]); |
|
232 |
} |
|
233 |
|
|
234 | 221 |
public void testCopyFrom() { |
235 | 222 |
|
236 | 223 |
colorInterpretationGray.copyFrom(colorInterpretationRGB); |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.legend/org.gvsig.raster.lib.legend.impl/src/main/java/org/gvsig/raster/lib/legend/impl/DefaultColorInterpretation.java | ||
---|---|---|
27 | 27 |
public static final String PERSISTENCE_DESCRIPTION = |
28 | 28 |
"Persitence color interpretation definition description"; |
29 | 29 |
|
30 |
private static final String COLOR_INTERPRETATION_PERSISTENCE_FIELD = "colorInterpertation";
|
|
30 |
private static final String COLOR_INTERPRETATION_PERSISTENCE_FIELD = "colorInterpretation";
|
|
31 | 31 |
|
32 | 32 |
private String[] colorInterpretation = null; |
33 | 33 |
|
... | ... | |
40 | 40 |
|
41 | 41 |
/** |
42 | 42 |
* |
43 |
* @param colorInterpretations
|
|
43 |
* @param bandColorInterpretations
|
|
44 | 44 |
*/ |
45 |
public DefaultColorInterpretation(String[] colorInterpretations) {
|
|
45 |
public DefaultColorInterpretation(String[] bandColorInterpretations) {
|
|
46 | 46 |
|
47 |
for (int i = 0; i < colorInterpretations.length; i++) {
|
|
48 |
if (!isColorInterpretationValid(colorInterpretations[i])) {
|
|
47 |
for (int i = 0; i < bandColorInterpretations.length; i++) {
|
|
48 |
if (!isColorInterpretationValid(bandColorInterpretations[i])) {
|
|
49 | 49 |
throw new IllegalArgumentException(String.format( |
50 |
"%1s color interpretation is not valid", colorInterpretations[i]));
|
|
50 |
"%1s color interpretation is not valid", bandColorInterpretations[i]));
|
|
51 | 51 |
} |
52 | 52 |
} |
53 | 53 |
|
54 |
this.colorInterpretation = new String[colorInterpretations.length];
|
|
55 |
System.arraycopy(colorInterpretations, 0, this.colorInterpretation, 0,
|
|
54 |
this.colorInterpretation = new String[bandColorInterpretations.length];
|
|
55 |
System.arraycopy(bandColorInterpretations, 0, this.colorInterpretation, 0,
|
|
56 | 56 |
this.colorInterpretation.length); |
57 | 57 |
} |
58 | 58 |
|
... | ... | |
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
/** |
72 |
* @param colorInterpretation
|
|
72 |
* @param bandColorInterpretation
|
|
73 | 73 |
*/ |
74 |
public DefaultColorInterpretation(String colorInterpretation) {
|
|
74 |
public DefaultColorInterpretation(String bandColorInterpretation) {
|
|
75 | 75 |
|
76 |
if (colorInterpretation.equals(RGB)) {
|
|
76 |
if (bandColorInterpretation.equals(RGB)) {
|
|
77 | 77 |
this.colorInterpretation = new String[] { RED_BAND, GREEN_BAND, BLUE_BAND }; |
78 |
} else if (colorInterpretation.equals(BGR)) {
|
|
78 |
} else if (bandColorInterpretation.equals(BGR)) {
|
|
79 | 79 |
this.colorInterpretation = new String[] { BLUE_BAND, GREEN_BAND, RED_BAND }; |
80 |
} else if (colorInterpretation.equals(ARGB)) {
|
|
80 |
} else if (bandColorInterpretation.equals(ARGB)) {
|
|
81 | 81 |
this.colorInterpretation = new String[] { RED_BAND, GREEN_BAND, BLUE_BAND, ALPHA_BAND }; |
82 |
} else if (colorInterpretation.equals(GRAYSCALE)) {
|
|
82 |
} else if (bandColorInterpretation.equals(GRAYSCALE)) {
|
|
83 | 83 |
this.colorInterpretation = new String[] { GRAY_BAND }; |
84 |
}else if (colorInterpretation.equals(PALETTE)) {
|
|
84 |
}else if (bandColorInterpretation.equals(PALETTE)) {
|
|
85 | 85 |
this.colorInterpretation = new String[] { PALETTE_BAND }; |
86 |
}else if (colorInterpretation.equals(HSL)) {
|
|
86 |
}else if (bandColorInterpretation.equals(HSL)) {
|
|
87 | 87 |
this.colorInterpretation = new String[] { HUE_BAND, SATURATION_BAND, LIGHTNESS_BAND }; |
88 |
}else if (colorInterpretation.equals(CMYK)) {
|
|
88 |
}else if (bandColorInterpretation.equals(CMYK)) {
|
|
89 | 89 |
this.colorInterpretation = new String[] { CYAN_BAND, MAGENTA_BAND, YELLOW_BAND, BLACK_BAND }; |
90 |
}else if (colorInterpretation.equals(YCBCR)) {
|
|
90 |
}else if (bandColorInterpretation.equals(YCBCR)) {
|
|
91 | 91 |
this.colorInterpretation = new String[] { YCBCR_Y_BAND, YCBCR_CB_BAND, YCBCR_CR_BAND }; |
92 | 92 |
} |
93 | 93 |
|
... | ... | |
116 | 116 |
return this.colorInterpretation.length; |
117 | 117 |
} |
118 | 118 |
|
119 |
private boolean isColorInterpretationValid(String colorInterpretation) {
|
|
120 |
if (colorInterpretation.equals(RED_BAND)
|
|
121 |
|| colorInterpretation.equals(GREEN_BAND)
|
|
122 |
|| colorInterpretation.equals(BLUE_BAND)
|
|
123 |
|| colorInterpretation.equals(GRAY_BAND)
|
|
124 |
|| colorInterpretation.equals(PALETTE_BAND)
|
|
125 |
|| colorInterpretation.equals(HUE_BAND)
|
|
126 |
|| colorInterpretation.equals(SATURATION_BAND)
|
|
127 |
|| colorInterpretation.equals(LIGHTNESS_BAND)
|
|
128 |
|| colorInterpretation.equals(CYAN_BAND)
|
|
129 |
|| colorInterpretation.equals(MAGENTA_BAND)
|
|
130 |
|| colorInterpretation.equals(YELLOW_BAND)
|
|
131 |
|| colorInterpretation.equals(BLACK_BAND)
|
|
132 |
|| colorInterpretation.equals(YCBCR_Y_BAND)
|
|
133 |
|| colorInterpretation.equals(YCBCR_CB_BAND)
|
|
134 |
|| colorInterpretation.equals(YCBCR_CR_BAND)
|
|
135 |
|| colorInterpretation.equals(RED_BLUE_BAND) |
|
136 |
|| colorInterpretation.equals(RED_GREEN_BAND) |
|
137 |
|| colorInterpretation.equals(GREEN_BLUE_BAND) |
|
138 |
|| colorInterpretation.equals(ALPHA_BAND)) {
|
|
119 |
private boolean isColorInterpretationValid(String bandColorInterpretation) {
|
|
120 |
if (bandColorInterpretation.equals(RED_BAND)
|
|
121 |
|| bandColorInterpretation.equals(GREEN_BAND)
|
|
122 |
|| bandColorInterpretation.equals(BLUE_BAND)
|
|
123 |
|| bandColorInterpretation.equals(GRAY_BAND)
|
|
124 |
|| bandColorInterpretation.equals(PALETTE_BAND)
|
|
125 |
|| bandColorInterpretation.equals(HUE_BAND)
|
|
126 |
|| bandColorInterpretation.equals(SATURATION_BAND)
|
|
127 |
|| bandColorInterpretation.equals(LIGHTNESS_BAND)
|
|
128 |
|| bandColorInterpretation.equals(CYAN_BAND)
|
|
129 |
|| bandColorInterpretation.equals(MAGENTA_BAND)
|
|
130 |
|| bandColorInterpretation.equals(YELLOW_BAND)
|
|
131 |
|| bandColorInterpretation.equals(BLACK_BAND)
|
|
132 |
|| bandColorInterpretation.equals(YCBCR_Y_BAND)
|
|
133 |
|| bandColorInterpretation.equals(YCBCR_CB_BAND)
|
|
134 |
|| bandColorInterpretation.equals(YCBCR_CR_BAND)
|
|
135 |
// || colorInterpretation.equals(RED_BLUE_BAND)
|
|
136 |
// || colorInterpretation.equals(RED_GREEN_BAND)
|
|
137 |
// || colorInterpretation.equals(GREEN_BLUE_BAND)
|
|
138 |
|| bandColorInterpretation.equals(ALPHA_BAND)) {
|
|
139 | 139 |
return true; |
140 | 140 |
} |
141 | 141 |
return false; |
... | ... | |
150 | 150 |
if (colorInterpretation[i].equals(RED_BAND) |
151 | 151 |
|| colorInterpretation[i].equals(GREEN_BAND) |
152 | 152 |
|| colorInterpretation[i].equals(BLUE_BAND) |
153 |
|| colorInterpretation[i].equals(RED_GREEN_BAND) |
|
154 |
|| colorInterpretation[i].equals(RED_BLUE_BAND) |
|
155 |
|| colorInterpretation[i].equals(GREEN_BLUE_BAND) |
|
153 |
// || colorInterpretation[i].equals(RED_GREEN_BAND)
|
|
154 |
// || colorInterpretation[i].equals(RED_BLUE_BAND)
|
|
155 |
// || colorInterpretation[i].equals(GREEN_BLUE_BAND)
|
|
156 | 156 |
|| colorInterpretation[i].equals(PALETTE_BAND) |
157 | 157 |
|| colorInterpretation[i].equals(HUE_BAND) |
158 | 158 |
|| colorInterpretation[i].equals(SATURATION_BAND) |
... | ... | |
231 | 231 |
@Override |
232 | 232 |
public boolean isRGBA() { |
233 | 233 |
if (colorInterpretation != null) { |
234 |
if (colorInterpretation.length == 4 && isInterpretationDefinedAsColor(0)
|
|
235 |
&& isInterpretationDefinedAsColor(1) && isInterpretationDefinedAsColor(2)
|
|
236 |
&& isAlphaInterpretation(3)) {
|
|
234 |
if (colorInterpretation.length == 4 && colorInterpretation[0] == RED_BAND
|
|
235 |
&& colorInterpretation[1] == GREEN_BAND && colorInterpretation[2] == BLUE_BAND
|
|
236 |
&& colorInterpretation[3] == ALPHA_BAND) {
|
|
237 | 237 |
return true; |
238 | 238 |
} |
239 | 239 |
} |
... | ... | |
256 | 256 |
return false; |
257 | 257 |
} |
258 | 258 |
|
259 |
private boolean isInterpretationDefinedAsColor(int band) { |
|
260 |
return isColorInterpretation(band) |
|
261 |
|| isGrayInterpretation(band) |
|
262 |
|| isPaletteInterpretation(band); |
|
263 |
} |
|
264 |
|
|
265 | 259 |
@Override |
266 | 260 |
public boolean isColorInterpretation(int band) { |
267 | 261 |
return colorInterpretation[band].equals(RED_BAND) |
... | ... | |
355 | 349 |
|
356 | 350 |
} |
357 | 351 |
|
358 |
@Override |
|
359 |
public int[] buildRenderBands() { |
|
360 |
if (colorInterpretation == null) { |
|
361 |
return null; |
|
362 |
} |
|
363 |
int[] renderBands = new int[] { -1, -1, -1, -1 }; |
|
364 |
for (int i = 0; i < colorInterpretation.length; i++) { |
|
365 |
if (colorInterpretation[i].equals(RED_BAND)) { |
|
366 |
renderBands[0] = i; |
|
367 |
} |
|
368 |
if (colorInterpretation[i].equals(GREEN_BAND)) { |
|
369 |
renderBands[1] = i; |
|
370 |
} |
|
371 |
if (colorInterpretation[i].equals(BLUE_BAND)) { |
|
372 |
renderBands[2] = i; |
|
373 |
} |
|
374 |
if (colorInterpretation[i].equals(ALPHA_BAND)) { |
|
375 |
renderBands[3] = i; |
|
376 |
} |
|
377 |
if (colorInterpretation[i].equals(GRAY_BAND)||colorInterpretation[i].equals(PALETTE_BAND)) { |
|
378 |
renderBands[0] = renderBands[1] = renderBands[2] = i; |
|
379 |
} |
|
380 |
if (colorInterpretation[i].equals(RED_GREEN_BAND)) { |
|
381 |
renderBands[0] = renderBands[1] = i; |
|
382 |
} |
|
383 |
if (colorInterpretation[i].equals(RED_BLUE_BAND)) { |
|
384 |
renderBands[0] = renderBands[2] = i; |
|
385 |
} |
|
386 |
if (colorInterpretation[i].equals(GREEN_BLUE_BAND)) { |
|
387 |
renderBands[1] = renderBands[2] = i; |
|
388 |
} |
|
389 |
//HLS |
|
390 |
if (colorInterpretation[i].equals(HUE_BAND)) { |
|
391 |
renderBands[0] = i; |
|
392 |
} |
|
393 |
if (colorInterpretation[i].equals(SATURATION_BAND)) { |
|
394 |
renderBands[1] = i; |
|
395 |
} |
|
396 |
if (colorInterpretation[i].equals(LIGHTNESS_BAND)) { |
|
397 |
renderBands[2] = i; |
|
398 |
} |
|
399 |
//CMYK |
|
400 |
if (colorInterpretation[i].equals(CYAN_BAND)) { |
|
401 |
renderBands[0] = i; |
|
402 |
} |
|
403 |
if (colorInterpretation[i].equals(MAGENTA_BAND)) { |
|
404 |
renderBands[1] = i; |
|
405 |
} |
|
406 |
if (colorInterpretation[i].equals(YELLOW_BAND)) { |
|
407 |
renderBands[2] = i; |
|
408 |
} |
|
409 |
if (colorInterpretation[i].equals(BLACK_BAND)) { |
|
410 |
renderBands[3] = i; |
|
411 |
} |
|
412 |
//YCBCR |
|
413 |
if (colorInterpretation[i].equals(YCBCR_Y_BAND)) { |
|
414 |
renderBands[0] = i; |
|
415 |
} |
|
416 |
if (colorInterpretation[i].equals(YCBCR_CB_BAND)) { |
|
417 |
renderBands[1] = i; |
|
418 |
} |
|
419 |
if (colorInterpretation[i].equals(YCBCR_CR_BAND)) { |
|
420 |
renderBands[2] = i; |
|
421 |
} |
|
422 |
} |
|
423 |
return renderBands; |
|
424 |
} |
|
425 |
|
|
426 | 352 |
public static void registerDefinition() { |
427 | 353 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
428 | 354 |
DynStruct definition = manager.getDefinition(PERSISTENCE_DEFINITION); |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider/src/main/java/org/gvsig/raster/gdal/provider/RasterGdalFileSystemServerProvider.java | ||
---|---|---|
26 | 26 |
import java.io.FileInputStream; |
27 | 27 |
import java.io.IOException; |
28 | 28 |
import java.util.ArrayList; |
29 |
import java.util.Iterator; |
|
30 |
import java.util.Vector; |
|
29 | 31 |
|
30 | 32 |
import org.apache.commons.lang3.StringUtils; |
31 | 33 |
import org.gdal.gdal.Driver; |
32 | 34 |
import org.gdal.gdal.gdal; |
33 | 35 |
import org.gdal.gdalconst.gdalconstConstants; |
36 |
import org.slf4j.Logger; |
|
37 |
import org.slf4j.LoggerFactory; |
|
38 |
|
|
34 | 39 |
import org.gvsig.fmap.dal.DataServerExplorer; |
35 | 40 |
import org.gvsig.fmap.dal.DataStoreParameters; |
36 | 41 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
... | ... | |
52 | 57 |
public class RasterGdalFileSystemServerProvider extends AbstractFilesystemServerExplorerProvider |
53 | 58 |
implements FilesystemServerExplorerProvider, ResourceConsumer{ |
54 | 59 |
|
60 |
private static final Logger logger = LoggerFactory.getLogger(RasterGdalFileSystemServerProvider.class); |
|
55 | 61 |
protected FilesystemServerExplorerProviderServices serverExplorer; |
56 | 62 |
private ArrayList<String> acceptedExtensions; |
57 | 63 |
|
... | ... | |
123 | 129 |
|
124 | 130 |
@Override |
125 | 131 |
public boolean accept(File pathname) { |
126 |
if (pathname.getParentFile() != null && |
|
127 |
pathname.getParentFile().getName().equals("cellhd")) { |
|
128 |
if (pathname.getName().endsWith(".rmf") |
|
129 |
|| pathname.getName().endsWith(".rmf~")) { |
|
130 |
return false; |
|
131 |
} |
|
132 |
return true; |
|
133 |
} |
|
134 |
|
|
135 |
// Comprobamos que no sea un rmf propio, osea, que contenga xml |
|
136 |
if (pathname.getName().toLowerCase().endsWith(".rmf")) { |
|
137 |
FileInputStream reader = null; |
|
138 |
try { |
|
139 |
reader = new FileInputStream(pathname); |
|
140 |
String xml = ""; |
|
141 |
for (int i = 0; i < 6; i++) { |
|
142 |
xml += (char) reader.read(); |
|
143 |
} |
|
144 |
if (xml.equals("<?xml ")) { |
|
145 |
return false; |
|
146 |
} |
|
147 |
} catch (Exception e) { |
|
148 |
} finally { |
|
149 |
try { |
|
150 |
reader.close(); |
|
151 |
} catch (Exception e) { |
|
152 |
} |
|
153 |
} |
|
154 |
} |
|
155 |
String ext=pathname.getAbsolutePath(); |
|
156 |
if (ext.indexOf(".") != -1) { |
|
157 |
ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length()); |
|
158 |
} |
|
159 |
|
|
160 |
if (acceptedExtensions.contains(ext)){ |
|
161 |
return true; |
|
162 |
}else{ |
|
163 |
return false; |
|
164 |
} |
|
132 |
return gdal.IdentifyDriver(pathname.getAbsolutePath())!=null; |
|
165 | 133 |
} |
166 | 134 |
|
167 | 135 |
@Override |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/pom.xml | ||
---|---|---|
4 | 4 |
<parent> |
5 | 5 |
<groupId>org.gvsig</groupId> |
6 | 6 |
<artifactId>org.gvsig.desktop</artifactId> |
7 |
<version>2.0.151</version>
|
|
7 |
<version>2.0.153-SNAPSHOT</version>
|
|
8 | 8 |
</parent> |
9 | 9 |
<artifactId>org.gvsig.raster</artifactId> |
10 | 10 |
<packaging>pom</packaging> |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jimi/src/main/java/org/gvsig/fmap/dal/file/jimi/JimiRasterStoreProvider.java | ||
---|---|---|
174 | 174 |
private JimiRasterStoreProviderParameters getJimiParameters() { |
175 | 175 |
return (JimiRasterStoreProviderParameters) this.getParameters(); |
176 | 176 |
} |
177 |
|
|
177 |
|
|
178 | 178 |
@Override |
179 | 179 |
public BandDescriptor getBandDescriptor(int band) { |
180 | 180 |
if(band > this.getBands()){ |
... | ... | |
183 | 183 |
return getStoreServices().createBandDescriptor(band, |
184 | 184 |
new ArrayList<BandAttributeDescriptor>()); |
185 | 185 |
} |
186 |
|
|
186 |
|
|
187 | 187 |
@Override |
188 | 188 |
public int getBands() { |
189 | 189 |
return image.bands; |
... | ... | |
191 | 191 |
|
192 | 192 |
@Override |
193 | 193 |
public Buffer createBuffer(RasterQuery rasterQuery) throws BufferException { |
194 |
|
|
194 |
|
|
195 | 195 |
BufferManager bufferManager = BufferLocator.getBufferManager(); |
196 |
List<BandQuery> bands = rasterQuery.getBands(); |
|
197 |
int[] bandDataTypes = new int[bands.size()]; |
|
198 |
NoData[] bandNoData = new NoData[bands.size()]; |
|
199 |
|
|
196 |
int[] bandDataTypes; |
|
200 | 197 |
List<PageManager> pageManagers = new ArrayList<PageManager>(); |
201 |
for (BandQuery bandQuery : bands) { |
|
202 |
int band = bandQuery.getBand(); |
|
203 |
bandDataTypes[band] = image.dataType; |
|
204 |
bandNoData[band] = null; |
|
205 |
pageManagers.add(new MemoryImageBandPageManager(image, band)); |
|
198 |
NoData[] bandNoData; |
|
199 |
if (rasterQuery != null) { |
|
200 |
List<BandQuery> bands; |
|
201 |
bands = rasterQuery.getBands(); |
|
202 |
bandDataTypes = new int[bands.size()]; |
|
203 |
bandNoData = new NoData[bands.size()]; |
|
204 |
|
|
205 |
for (BandQuery bandQuery : bands) { |
|
206 |
int band = bandQuery.getBand(); |
|
207 |
bandDataTypes[band] = image.dataType; |
|
208 |
bandNoData[band] = null; |
|
209 |
pageManagers.add(new MemoryImageBandPageManager(image, band)); |
|
210 |
} |
|
211 |
} else { |
|
212 |
int bands = getBands(); |
|
213 |
bandDataTypes = new int[bands]; |
|
214 |
bandNoData = new NoData[bands]; |
|
215 |
for (int i = 0; i < bands; i++) { |
|
216 |
bandDataTypes[i] = image.dataType; |
|
217 |
bandNoData[i] = null; |
|
218 |
pageManagers.add(new MemoryImageBandPageManager(image, i)); |
|
219 |
} |
|
206 | 220 |
} |
207 | 221 |
|
208 | 222 |
Buffer buffer = |
... | ... | |
211 | 225 |
|
212 | 226 |
return buffer; |
213 | 227 |
} |
214 |
|
|
228 |
|
|
215 | 229 |
@Override |
216 | 230 |
public BandInfo getBandInfo(int band) { |
217 | 231 |
return null; |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.mapcontext.raster/org.gvsig.fmap.mapcontext.raster.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/impl/DefaultRasterLayer.java | ||
---|---|---|
37 | 37 |
import java.util.TreeSet; |
38 | 38 |
|
39 | 39 |
import org.cresques.cts.ICoordTrans; |
40 |
|
|
40 | 41 |
import org.gvsig.compat.print.PrintAttributes; |
41 | 42 |
import org.gvsig.fmap.dal.DataStore; |
42 | 43 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
62 | 63 |
import org.gvsig.metadata.exceptions.MetadataException; |
63 | 64 |
import org.gvsig.raster.lib.buffer.api.Band; |
64 | 65 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
66 |
import org.gvsig.raster.lib.legend.api.ColorInterpretation; |
|
65 | 67 |
import org.gvsig.raster.lib.legend.api.ColorTable; |
66 | 68 |
import org.gvsig.raster.lib.legend.api.ColorTableClass; |
67 | 69 |
import org.gvsig.raster.lib.legend.api.RasterLegend; |
68 | 70 |
import org.gvsig.tools.ToolsLocator; |
71 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
69 | 72 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
70 | 73 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
71 | 74 |
import org.gvsig.tools.exception.BaseException; |
72 | 75 |
import org.gvsig.tools.task.Cancellable; |
73 | 76 |
import org.gvsig.tools.task.SimpleTaskStatus; |
74 | 77 |
import org.gvsig.tools.task.TaskStatusManager; |
78 |
|
|
75 | 79 |
import org.slf4j.LoggerFactory; |
76 | 80 |
|
77 | 81 |
/** |
... | ... | |
93 | 97 |
|
94 | 98 |
/** |
95 | 99 |
* Creates a new DefaultRasterLayer |
96 |
* @throws LoadLayerException
|
|
100 |
* @throws LoadLayerException |
|
97 | 101 |
*/ |
98 | 102 |
public DefaultRasterLayer() throws LoadLayerException{ |
99 | 103 |
super(); |
... | ... | |
104 | 108 |
* @param store |
105 | 109 |
* @param legend |
106 | 110 |
*/ |
107 |
public DefaultRasterLayer(RasterStore store, RasterLegend legend){ |
|
111 |
public DefaultRasterLayer(RasterStore store, RasterLegend legend) {
|
|
108 | 112 |
super(); |
109 |
this.store=store; |
|
110 |
this.legend=legend; |
|
113 |
ToolsLocator.getDisposableManager().bind(store); |
|
114 |
this.store = store; |
|
115 |
this.legend = legend; |
|
111 | 116 |
} |
112 | 117 |
|
113 |
|
|
114 | 118 |
public void setLegend(RasterLegend legend) throws LegendLayerException { |
115 | 119 |
if (this.legend == legend) { |
116 | 120 |
return; |
... | ... | |
134 | 138 |
// callLegendChanged(e); |
135 | 139 |
} |
136 | 140 |
|
141 |
|
|
137 | 142 |
/** |
138 | 143 |
* Devuelve la Leyenda de la capa. |
139 | 144 |
* |
... | ... | |
151 | 156 |
|
152 | 157 |
@Override |
153 | 158 |
public void setDataStore(DataStore dataStore) throws LoadLayerException { |
154 |
if (this.store!=null){ |
|
155 |
throw new LoadLayerException("Store already created"); |
|
156 |
}else{ |
|
157 |
this.store=(RasterStore)dataStore; |
|
158 |
initLegend(); |
|
159 |
|
|
160 |
if (this.store != null) { |
|
161 |
ToolsLocator.getDisposableManager().release(this.store); |
|
162 |
DisposeUtils.disposeQuietly(this.store); |
|
159 | 163 |
} |
164 |
|
|
165 |
this.store = (RasterStore) dataStore; |
|
166 |
ToolsLocator.getDisposableManager().bind(dataStore); |
|
167 |
initLegend(); |
|
160 | 168 |
} |
161 | 169 |
|
162 | 170 |
/** |
... | ... | |
243 | 251 |
} |
244 | 252 |
|
245 | 253 |
RasterQuery rasterQuery = createRasterQuery(); |
254 |
ColorInterpretation colorInterpretation = legend.getColorInterpretation(); |
|
255 |
String[] renderBands = colorInterpretation.getValues();//.buildRenderBands(); |
|
256 |
for (int i = 0; i < renderBands.length; i++) { |
|
257 |
int band = colorInterpretation.getBand(renderBands[i]); |
|
258 |
rasterQuery.addBand(this.store.createBandQuery(band)); |
|
259 |
} |
|
246 | 260 |
|
247 | 261 |
try { |
248 | 262 |
|
... | ... | |
253 | 267 |
SimpleTaskStatus taskStatus = manager.createDefaultSimpleTaskStatus("Draw "+getDataStore().getName()); |
254 | 268 |
|
255 | 269 |
((RasterLegend) legend).draw(g, getRasterStore().getRasterSet(rasterQuery), viewPort, taskStatus); |
256 |
|
|
270 |
|
|
257 | 271 |
logger.debug("Layer " + this.getName() + " drawn in " |
258 | 272 |
+ (System.currentTimeMillis() - tini) + " milliseconds."); |
259 | 273 |
|
... | ... | |
393 | 407 |
|
394 | 408 |
@Override |
395 | 409 |
protected void doDispose() throws BaseException { |
396 |
// TODO Do nothing |
|
397 |
|
|
410 |
ToolsLocator.getDisposableManager().release(this.store); |
|
411 |
DisposeUtils.dispose(store); |
|
412 |
this.legend = null; |
|
413 |
this.baseQuery = null; |
|
398 | 414 |
} |
399 | 415 |
|
400 | 416 |
} |
Also available in: Unified diff