Spectrum spectrum;
try {
spectrum = Rainbow4J.readSpectrum(pageImage, new Rectangle(area.getLeft(), area.getTop(), area.getWidth(), area.getHeight()), PRECISION);
} catch (Exception e) {
throw new ValidationErrorException(String.format("Couldn't fetch spectrum for \"%s\"", objectName));
}
List<String> messages = new LinkedList<String>();
for (ColorRange colorRange : spec.getColorRanges()) {
Color color = colorRange.getColor();
int percentage = (int)spectrum.getPercentage(color.getRed(), color.getGreen(), color.getBlue(), TEST_RANGE);
if (!colorRange.getRange().holds(percentage)) {
messages.add(String.format("color %s on \"%s\" is %d%% %s", toHexColor(color), objectName, (int)percentage, colorRange.getRange().getErrorMessageSuffix("%")));
}
}