Example usage for org.apache.pdfbox.pdmodel.graphics.color PDSeparation getAlternateColorSpace

List of usage examples for org.apache.pdfbox.pdmodel.graphics.color PDSeparation getAlternateColorSpace

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.graphics.color PDSeparation getAlternateColorSpace.

Prototype

public PDColorSpace getAlternateColorSpace() 

Source Link

Document

Returns the colorant name.

Usage

From source file:net.padaf.preflight.graphics.color.StandardColorSpaceHelper.java

License:Apache License

/**
 * Method called by the processAllColorSpace if the ColorSpace to check is
 * Separation. Because this kind of ColorSpace can have an alternate color
 * space, the processAllColorSpace is called to check this alternate color
 * space. (Indexed, Separation, DeviceN and Pattern can't be a Base color
 * space)/*  w  w w . ja v a 2 s  .c o m*/
 * 
 * @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 processSeparationColorSpace(PDColorSpace pdcs, List<ValidationError> result) {
    PDSeparation separation = (PDSeparation) pdcs;
    try {
        if (iccpw == null) {
            result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_MISSING,
                    "DestOutputProfile is missing"));
            return false;
        }

        PDColorSpace altCol = separation.getAlternateColorSpace();
        if (altCol != null) {
            ColorSpaces acs = ColorSpaces.valueOf(altCol.getName());
            switch (acs) {
            case Separation:
            case DeviceN:
            case Pattern:
            case Indexed:
            case Indexed_SHORT:
                result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_ALTERNATE,
                        acs.getLabel() + " color space can't be used as alternate color space"));
                return false;
            default:
                return processAllColorSpace(altCol, result);
            }
        }

        return true;
    } catch (IOException e) {
        result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE,
                "Unable to read Separation 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
 * Separation. Because this kind of ColorSpace can have an alternate color
 * space, the processAllColorSpace is called to check this alternate color
 * space. (Indexed, Separation, DeviceN and Pattern can't be a Base color
 * space)// w  w w. j  a va2 s. c  o  m
 * 
 * @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 processSeparationColorSpace(PDColorSpace pdcs, List<ValidationError> result) {
    PDSeparation separation = (PDSeparation) pdcs;
    try {

        PDColorSpace altCol = separation.getAlternateColorSpace();
        if (altCol != null) {
            ColorSpaces acs = ColorSpaces.valueOf(altCol.getName());
            switch (acs) {
            case Separation:
            case DeviceN:
            case Pattern:
            case Indexed:
            case Indexed_SHORT:
                result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_ALTERNATE,
                        acs.getLabel() + " color space can't be used as alternate color space"));
                return false;
            default:
                return processAllColorSpace(altCol, result);
            }
        }

        return true;
    } catch (IOException e) {
        result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE,
                "Unable to read Separation color space : " + e.getMessage()));
        return false;
    }
}