for (ColorMapEntry ce : colorMapEntries)
if (ce != null)
cmapLegendBuilder.addColorMapEntry(ce);
// check the additional options before proceeding
cmapLegendBuilder.checkAdditionalOptions();
// instantiate the creator
ColorMapLegendCreator cMapLegendCreator = cmapLegendBuilder.create();
return new BufferedImageLegendGraphic(cMapLegendCreator.getLegend());
}