Package org.apache.padaf.preflight.graphics.color

Examples of org.apache.padaf.preflight.graphics.color.ColorSpaceHelper


    COSDocument doc = this.documentHandler.getDocument().getDocument();
    COSBase csInlinedBase = dict.getItem(COSName
        .getPDFName(STREAM_DICTIONARY_KEY_COLOR_SPACE));

    ColorSpaceHelper csHelper = null;
    if (csInlinedBase != null) {

      if (COSUtils.isString(csInlinedBase, doc)) {
        // ---- In InlinedImage only DeviceGray/RGB/CMYK and restricted Indexed
        // color spaces
        // are allowed.
        String colorSpace = COSUtils.getAsString(csInlinedBase, doc);
        ColorSpaces cs = null;

        try {
          cs = ColorSpaces.valueOf(colorSpace);
        } catch (IllegalArgumentException e) {
          // ---- The color space is unknown.
          // ---- Try to access the resources dictionary, the color space can be
          // a reference.
          PDColorSpace pdCS = (PDColorSpace) this.getColorSpaces().get(
              colorSpace);
          if (pdCS != null) {
            cs = ColorSpaces.valueOf(pdCS.getName());
            csHelper = ColorSpaceHelperFactory.getColorSpaceHelper(pdCS,
                documentHandler, ColorSpaceRestriction.ONLY_DEVICE);
          }
        }

        if (cs == null) {
          throwContentStreamException("The ColorSpace is unknown",
              ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
        }
      }

      if (csHelper == null) {
        csHelper = ColorSpaceHelperFactory.getColorSpaceHelper(csInlinedBase,
            documentHandler, ColorSpaceRestriction.ONLY_DEVICE);
      }
      List<ValidationError> errors = new ArrayList<ValidationError>();
      try {
        if (!csHelper.validate(errors)) {
          ValidationError ve = errors.get(0);
          throwContentStreamException(ve.getDetails(), ve.getErrorCode());
        }
      } catch (ValidationException e) {
        throw new IOException(e.getMessage());
View Full Code Here


    } else {
      throwContentStreamException("The operand doesn't have the expected type",
          ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
    }

    ColorSpaceHelper csHelper = null;
    ColorSpaces cs = null;
    try {
      cs = ColorSpaces.valueOf(colorSpaceName);
    } catch (IllegalArgumentException e) {
      // ---- The color space is unknown.
      // ---- Try to access the resources dictionary, the color space can be a
      // reference.
      PDColorSpace pdCS = (PDColorSpace) this.getColorSpaces().get(
          colorSpaceName);
      if (pdCS != null) {
        cs = ColorSpaces.valueOf(pdCS.getName());
        csHelper = ColorSpaceHelperFactory.getColorSpaceHelper(pdCS,
            documentHandler, ColorSpaceRestriction.NO_RESTRICTION);
      }
    }

    if (cs == null) {
      throwContentStreamException("The ColorSpace is unknown",
          ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
    }

    if (csHelper == null) {
      csHelper = ColorSpaceHelperFactory.getColorSpaceHelper(COSName
          .getPDFName(colorSpaceName), documentHandler,
          ColorSpaceRestriction.NO_RESTRICTION);
    }

    List<ValidationError> errors = new ArrayList<ValidationError>();
    try {
      if (!csHelper.validate(errors)) {
        ValidationError ve = errors.get(0);
        throwContentStreamException(ve.getDetails(), ve.getErrorCode());
      }
    } catch (ValidationException e) {
      //      throw new IOException(e.getMessage(), e); java 6
View Full Code Here

      if (bitsPerCompValue != 1 ) {
        result.add(new ValidationError(ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY, "ImageMask entry is true, BitsPerComponent must be 1."));
      }

    } else {
      ColorSpaceHelper csh = ColorSpaceHelperFactory.getColorSpaceHelper(csImg, handler, ColorSpaceRestriction.NO_PATTERN);
      csh.validate(result);
    }
  }
View Full Code Here

      return false;
    }

    COSBase csImg = shadingDict.getItem(COSName
        .getPDFName(XOBJECT_DICTIONARY_KEY_COLOR_SPACE));
    ColorSpaceHelper csh = ColorSpaceHelperFactory.getColorSpaceHelper(csImg,
        documentHandler, ColorSpaceRestriction.NO_PATTERN);
    return csh.validate(errors);
  }
View Full Code Here

TOP

Related Classes of org.apache.padaf.preflight.graphics.color.ColorSpaceHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.