use of org.geotools.styling.ColorMapImpl in project sldeditor by robward-scisys.
the class RasterReader method createRGBImageSymbol.
/**
* Creates the rgb image symbol.
*
* @param sym the sym
* @param cov the cov
* @param raster the raster
*/
private void createRGBImageSymbol(RasterSymbolizer sym, GridCoverage2D cov, WritableRaster raster) {
double dest;
List<Double> valueList = new ArrayList<Double>();
GridEnvelope2D gridRange2D = cov.getGridGeometry().getGridRange2D();
for (int x = 0; x < gridRange2D.getWidth(); x++) {
for (int y = 0; y < gridRange2D.getHeight(); y++) {
try {
dest = raster.getSampleDouble(x, y, 0);
if (!valueList.contains(dest)) {
valueList.add(dest);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
ColorMapImpl colourMap = new ColorMapImpl();
// Sort the unique sample values in ascending order
Collections.sort(valueList);
// Create colour amp entries in the colour map for all the sample values
for (Double value : valueList) {
ColorMapEntry entry = new ColorMapEntryImpl();
Literal colourExpression = ff.literal(ColourUtils.fromColour(ColourUtils.createRandomColour()));
entry.setColor(colourExpression);
entry.setQuantity(ff.literal(value.doubleValue()));
colourMap.addColorMapEntry(entry);
}
colourMap.setType(ColorMap.TYPE_VALUES);
sym.setColorMap(colourMap);
}
use of org.geotools.styling.ColorMapImpl in project sldeditor by robward-scisys.
the class ColourMapModel method getColourMap.
/**
* Gets the colour map.
*
* @return the colour map
*/
public ColorMap getColourMap() {
ColorMap colourMap = new ColorMapImpl();
for (ColourMapData data : colourMapList) {
ColorMapEntry entry = createColourMapEntry(data);
colourMap.addColorMapEntry(entry);
}
return colourMap;
}
Aggregations