List of usage examples for org.apache.pdfbox.pdmodel.graphics.color PDIndexed getBaseColorSpace
public PDColorSpace getBaseColorSpace()
From source file:net.padaf.preflight.graphics.color.DeviceColorSpaceHelper.java
License:Apache License
/** * Indexed color space is authorized only if the BaseColorSpace is a DeviceXXX * color space. In all other cases the given list is updated with a * ValidationError (ERROR_GRAPHIC_INVALID_PATTERN_COLOR_SPACE_FORBIDDEN) and * returns false.//from www. j ava 2 s . co m */ protected boolean processIndexedColorSpace(PDColorSpace pdcs, List<ValidationError> result) { PDIndexed indexed = (PDIndexed) pdcs; try { if (iccpw == null) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_MISSING, "DestOutputProfile is missing")); return false; } PDColorSpace based = indexed.getBaseColorSpace(); ColorSpaces cs = ColorSpaces.valueOf(based.getName()); switch (cs) { case DeviceCMYK: case DeviceCMYK_SHORT: case DeviceRGB: case DeviceRGB_SHORT: case DeviceGray: case DeviceGray_SHORT: return processAllColorSpace(based, result); default: result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_FORBIDDEN, cs.getLabel() + " ColorSpace is forbidden")); return false; } } catch (IOException e) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read Indexed Color Space : " + e.getMessage())); return false; } }
From source file:net.padaf.preflight.graphics.color.StandardColorSpaceHelper.java
License:Apache License
/** * Method called by the processAllColorSpace if the ColorSpace to check is * Indexed. Because this kind of ColorSpace can have a Base color space, the * processAllColorSpace is called to check this base color space. (Indexed and * Pattern can't be a Base color space)//from w w w . j a v a2 s. c om * * @param pdcs * the color space object to check. * @param result * the list of error to update if the validation fails. * @return true if the color space is valid, false otherwise. */ protected boolean processIndexedColorSpace(PDColorSpace pdcs, List<ValidationError> result) { PDIndexed indexed = (PDIndexed) pdcs; try { if (iccpw == null) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_MISSING, "DestOutputProfile is missing")); return false; } PDColorSpace based = indexed.getBaseColorSpace(); ColorSpaces cs = ColorSpaces.valueOf(based.getName()); if (cs == ColorSpaces.Indexed || cs == ColorSpaces.Indexed_SHORT) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_INDEXED, "Indexed color space can't be used as Base color space")); return false; } if (cs == ColorSpaces.Pattern) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_INDEXED, "Pattern color space can't be used as Base color space")); return false; } return processAllColorSpace(based, result); } catch (IOException e) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read Indexed color space : " + e.getMessage())); return false; } }
From source file:org.apache.padaf.preflight.graphics.color.DeviceColorSpaceHelper.java
License:Apache License
/** * Indexed color space is authorized only if the BaseColorSpace is a DeviceXXX * color space. In all other cases the given list is updated with a * ValidationError (ERROR_GRAPHIC_INVALID_PATTERN_COLOR_SPACE_FORBIDDEN) and * returns false.// ww w .java2s .c om */ protected boolean processIndexedColorSpace(PDColorSpace pdcs, List<ValidationError> result) { PDIndexed indexed = (PDIndexed) pdcs; try { PDColorSpace based = indexed.getBaseColorSpace(); ColorSpaces cs = ColorSpaces.valueOf(based.getName()); switch (cs) { case Indexed: case Indexed_SHORT: case Pattern: result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_FORBIDDEN, cs.getLabel() + " ColorSpace is forbidden")); return false; default: return processAllColorSpace(based, result); } } catch (IOException e) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read Indexed Color Space : " + e.getMessage())); return false; } }
From source file:org.apache.padaf.preflight.graphics.color.StandardColorSpaceHelper.java
License:Apache License
/** * Method called by the processAllColorSpace if the ColorSpace to check is * Indexed. Because this kind of ColorSpace can have a Base color space, the * processAllColorSpace is called to check this base color space. (Indexed and * Pattern can't be a Base color space)// w w w . ja v a 2s. c om * * @param pdcs * the color space object to check. * @param result * the list of error to update if the validation fails. * @return true if the color space is valid, false otherwise. */ protected boolean processIndexedColorSpace(PDColorSpace pdcs, List<ValidationError> result) { PDIndexed indexed = (PDIndexed) pdcs; try { PDColorSpace based = indexed.getBaseColorSpace(); ColorSpaces cs = ColorSpaces.valueOf(based.getName()); if (cs == ColorSpaces.Indexed || cs == ColorSpaces.Indexed_SHORT) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_INDEXED, "Indexed color space can't be used as Base color space")); return false; } if (cs == ColorSpaces.Pattern) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_INDEXED, "Pattern color space can't be used as Base color space")); return false; } return processAllColorSpace(based, result); } catch (IOException e) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read Indexed color space : " + e.getMessage())); return false; } }