BigInteger bits = new BigInteger("0");
final boolean preFilteringValuesPresent=preFilteringColor!=null;
int elementsCount = standardElements.length+(preFilteringValuesPresent?1:0);
int max=-1;
for (int i = 0; i < elementsCount; i++) {
final DefaultLinearPiecewiseTransform1DElement element =
i<standardElements.length?
(DefaultLinearPiecewiseTransform1DElement) standardElements[i]:
preFilteringElements[0];
final int elementMin=(int) element.getOutputMinimum();
final int elementMax=(int) element.getOutputMaximum();
for (int k = elementMin; k <= elementMax; k++)
bits = bits.setBit(k);
max = (int) Math.max(max, elementMax);
}
//zero based indexing
max++;
// /////////////////////////////////////////////////////////////////////
//
// Interpolate the colors in the color palette for standard values
//
// /////////////////////////////////////////////////////////////////////
int[] ARGB = new int[max];
int outMax=0,outMin=0;
for (int i = 0; i < elementsCount; i++) {
// I know that all the categories here are both
// ColorMapTransformElement and DefaultLinearPiecewiseTransform1DElement. The
// eventual NoDtaCategory as well.
final LinearColorMapElement element = i<standardElements.length? standardElements[i]:preFilteringElements[0];
// //
//
// Check if this category overlap with another one as far as
// the output value but with the same color. We already
// checked that they had the same color. If this happens we
// prevent the code from creating a new entry at the same
// place with the same color, no rocket science going on
// here!
//
// //
outMin = (int) element.getOutputMinimum();
outMax = (int) (element.getOutputMaximum());
//NOTE the second element is exclusive!!!
ColorUtilities.expand(element.getColors(), ARGB, outMin, outMax+1);
}
//create the prefiltering piecewise
this.preFilteringPiecewise=preFilteringElements==null?null:new DefaultPiecewiseTransform1D<LinearColorMapElement>(preFilteringElements);