Revision 6316 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider.legend/src/main/java/org/gvsig/raster/gdal/provider/legend/RasterGdalGetColorTable.java
RasterGdalGetColorTable.java | ||
---|---|---|
66 | 66 |
|
67 | 67 |
ColorInterpretation colorInterpretation =(ColorInterpretation)rasterGdalProvider. |
68 | 68 |
invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null); |
69 |
for (int i = 0; i < gdalDataSet.getRasterCount(); i++) {
|
|
70 |
if (ColorInterpretation.PALETTE_BAND.equals(colorInterpretation.get(i))){
|
|
71 |
// Bands begin in 1 instead of 0
|
|
72 |
int bandNumber = i + 1;
|
|
69 |
for (int bandNumber = 1; bandNumber <= gdalDataSet.getRasterCount(); bandNumber++) {
|
|
70 |
//Band in GDAL begins in 1, meanwhile we begin in 0
|
|
71 |
int indexColorInterpretation=bandNumber-1;
|
|
72 |
if (ColorInterpretation.PALETTE_BAND.equals(colorInterpretation.get(indexColorInterpretation))){
|
|
73 | 73 |
Band gdalBand=gdalDataSet.GetRasterBand(bandNumber); |
74 | 74 |
org.gdal.gdal.ColorTable gdalBandColorTable = gdalBand.GetColorTable(); |
75 | 75 |
if (gdalBandColorTable!=null){ |
76 | 76 |
List<ColorTableClass> colorTableClasses=new ArrayList<ColorTableClass>(); |
77 | 77 |
|
78 |
for (int j=0;j<gdalBandColorTable.GetCount();j++){
|
|
79 |
String className=j+"";
|
|
80 |
double value=((byte)j);
|
|
78 |
for (int i=0;i<gdalBandColorTable.GetCount();i++){
|
|
79 |
String className=i+"";
|
|
80 |
double value=((byte)i);
|
|
81 | 81 |
double interpolation=50.0; |
82 |
Color color=gdalBandColorTable.GetColorEntry(j);
|
|
82 |
Color color=gdalBandColorTable.GetColorEntry(i);
|
|
83 | 83 |
ColorTableClass colorTableClass = legendManager.createColorTableClass(className, value, interpolation, color); |
84 | 84 |
colorTableClasses.add(colorTableClass); |
85 | 85 |
} |
... | ... | |
89 | 89 |
//FIXME: De momento devolvemos el primero solo. |
90 | 90 |
return colorTable; |
91 | 91 |
} |
92 |
else { |
|
93 |
List<ColorTableClass> colorTableClasses=new ArrayList<ColorTableClass>(); |
|
94 |
double[] minMax=new double[2]; |
|
95 |
gdalBand.ComputeRasterMinMax(minMax); |
|
96 |
Double increment=(minMax[1]-minMax[0])/256; |
|
97 |
|
|
98 |
for (int i=0;i<255;i++){ |
|
99 |
String className=i+""; |
|
100 |
double value=((minMax[0]+(i*increment))); |
|
101 |
double interpolation=50.0; |
|
102 |
int intARGB = ((i & 0xFF) << 24) | // alpha |
|
103 |
((i & 0xFF) << 16) | // red |
|
104 |
((i & 0xFF) << 8) | // green |
|
105 |
((i & 0xFF) << 0); // blue |
|
106 |
Color color=new Color(intARGB); |
|
107 |
ColorTableClass colorTableClass = legendManager.createColorTableClass(className, value, interpolation, color); |
|
108 |
colorTableClasses.add(colorTableClass); |
|
109 |
} |
|
110 |
String colorTableName = rasterGdalProvider.getName() + "_color_table"; |
|
111 |
colorTable = legendManager.createColorTable(colorTableName, |
|
112 |
colorTableClasses, true); |
|
113 |
//FIXME: De momento devolvemos el primero solo. |
|
114 |
return colorTable; |
|
115 |
} |
|
92 | 116 |
} |
93 | 117 |
|
94 | 118 |
} |
Also available in: Unified diff