Revision 2311 org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/properties/DataStoreColorInterpretation.java
DataStoreColorInterpretation.java | ||
---|---|---|
51 | 51 |
} |
52 | 52 |
|
53 | 53 |
/** |
54 |
* Creates an object of this class from a bands renderer array. |
|
55 |
*/ |
|
56 |
public DataStoreColorInterpretation(int[] renderBands) { |
|
57 |
if(renderBands == null || renderBands.length == 0) { |
|
58 |
this.colorInterpretation = new String[0]; |
|
59 |
return; |
|
60 |
} |
|
61 |
|
|
62 |
this.colorInterpretation = new String[renderBands.length]; |
|
63 |
for (int i = 0; i < renderBands.length; i++) { |
|
64 |
switch (renderBands[i]) { |
|
65 |
case 0: |
|
66 |
colorInterpretation[i] = RED_BAND; |
|
67 |
break; |
|
68 |
case 1: |
|
69 |
colorInterpretation[i] = GREEN_BAND; |
|
70 |
break; |
|
71 |
case 2: |
|
72 |
colorInterpretation[i] = BLUE_BAND; |
|
73 |
break; |
|
74 |
case 3: |
|
75 |
colorInterpretation[i] = ALPHA_BAND; |
|
76 |
break; |
|
77 |
} |
|
78 |
} |
|
79 |
for (int i = 0; i < colorInterpretation.length; i++) { |
|
80 |
if(colorInterpretation[i] == null) |
|
81 |
colorInterpretation[i] = UNDEF_BAND; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 | 54 |
* Constructor que asigna los valores de interpretaci?n de color |
87 | 55 |
*/ |
88 | 56 |
public DataStoreColorInterpretation(String[] colorInterp) { |
... | ... | |
114 | 82 |
} |
115 | 83 |
|
116 | 84 |
/** |
117 |
* Obtiene una interpretaci?n de color RGB |
|
85 |
* Obtiene una interpretaci?n de color ARGB
|
|
118 | 86 |
* @return DatasetColorInterpretation |
119 | 87 |
*/ |
120 |
public static DataStoreColorInterpretation createARGBInterpretation() {
|
|
88 |
public static DataStoreColorInterpretation createRGBAInterpretation() {
|
|
121 | 89 |
return new DataStoreColorInterpretation(new String[]{RED_BAND, GREEN_BAND, BLUE_BAND, ALPHA_BAND}); |
122 | 90 |
} |
123 | 91 |
|
... | ... | |
146 | 114 |
colorInterpretation = new String[values]; |
147 | 115 |
} |
148 | 116 |
|
117 |
public boolean hasInterpretation() { |
|
118 |
if(colorInterpretation == null || colorInterpretation.length < 3) |
|
119 |
return false; |
|
120 |
for (int i = 0; i < colorInterpretation.length; i++) { |
|
121 |
if( colorInterpretation[i].equals(RED_BAND) || |
|
122 |
colorInterpretation[i].equals(GREEN_BAND) || |
|
123 |
colorInterpretation[i].equals(BLUE_BAND) || |
|
124 |
colorInterpretation[i].equals(RED_GREEN_BAND) || |
|
125 |
colorInterpretation[i].equals(RED_BLUE_BAND) || |
|
126 |
colorInterpretation[i].equals(GRAY_BAND) || |
|
127 |
colorInterpretation[i].equals(PAL_BAND)) |
|
128 |
return true; |
|
129 |
} |
|
130 |
return false; |
|
131 |
} |
|
132 |
|
|
149 | 133 |
public boolean isBGR() { |
150 | 134 |
if(colorInterpretation != null) { |
151 | 135 |
if (colorInterpretation.length == 3 && |
... | ... | |
168 | 152 |
return false; |
169 | 153 |
} |
170 | 154 |
|
171 |
public boolean isARGB() {
|
|
155 |
public boolean isRGBA() {
|
|
172 | 156 |
if(colorInterpretation != null) { |
173 | 157 |
if (colorInterpretation.length == 4 && |
174 | 158 |
isInterpretationDefinedAsColor(0) && |
... | ... | |
317 | 301 |
return true; |
318 | 302 |
} |
319 | 303 |
|
320 |
public int[] getRenderBandsFromColorInterpretation() {
|
|
304 |
public int[] buildRenderBands() {
|
|
321 | 305 |
if(colorInterpretation == null) |
322 | 306 |
return null; |
323 | 307 |
int[] renderBands = new int[]{-1, -1, -1, -1}; |
... | ... | |
330 | 314 |
renderBands[2] = i; |
331 | 315 |
if(colorInterpretation[i].equals(GRAY_BAND)) |
332 | 316 |
renderBands[0] = renderBands[1] = renderBands[2] = i; |
317 |
if(colorInterpretation[i].equals(RED_GREEN_BAND)) |
|
318 |
renderBands[0] = renderBands[1] = i; |
|
319 |
if(colorInterpretation[i].equals(RED_BLUE_BAND)) |
|
320 |
renderBands[0] = renderBands[2] = i; |
|
321 |
if(colorInterpretation[i].equals(GREEN_BLUE_BAND)) |
|
322 |
renderBands[1] = renderBands[2] = i; |
|
333 | 323 |
} |
334 | 324 |
|
335 | 325 |
//Ojo! esto no puede hacerse en el bucle anterior pq no detectaria bien casos |
Also available in: Unified diff