コード例 #1
0
  /**
   * Process the given tiling pattern. Allows the pattern matrix to be overridden for custom
   * rendering.
   *
   * @param tilingPattern the tiling pattern
   * @param color color to use, if this is an uncoloured pattern, otherwise null.
   * @param colorSpace color space to use, if this is an uncoloured pattern, otherwise null.
   * @param patternMatrix the pattern matrix, may be overridden for custom rendering.
   * @throws IOException if there is an error reading or parsing the tiling pattern content stream.
   */
  protected final void processTilingPattern(
      PDTilingPattern tilingPattern, PDColor color, PDColorSpace colorSpace, Matrix patternMatrix)
      throws IOException {
    PDResources parent = pushResources(tilingPattern);

    Matrix parentMatrix = initialMatrix;
    initialMatrix = Matrix.concatenate(initialMatrix, patternMatrix);

    // save the original graphics state
    Stack<PDGraphicsState> savedStack = saveGraphicsStack();

    // save a clean state (new clipping path, line path, etc.)
    Rectangle2D bbox = tilingPattern.getBBox().transform(patternMatrix).getBounds2D();
    PDRectangle rect =
        new PDRectangle(
            (float) bbox.getX(),
            (float) bbox.getY(),
            (float) bbox.getWidth(),
            (float) bbox.getHeight());
    graphicsStack.push(new PDGraphicsState(rect));

    // non-colored patterns have to be given a color
    if (colorSpace != null) {
      color = new PDColor(color.getComponents(), colorSpace);
      getGraphicsState().setNonStrokingColorSpace(colorSpace);
      getGraphicsState().setNonStrokingColor(color);
      getGraphicsState().setStrokingColorSpace(colorSpace);
      getGraphicsState().setStrokingColor(color);
    }

    // transform the CTM using the stream's matrix
    getGraphicsState().getCurrentTransformationMatrix().concatenate(patternMatrix);

    // clip to bounding box
    clipToRect(tilingPattern.getBBox());

    // processStreamOperators(tilingPattern);

    initialMatrix = parentMatrix;
    restoreGraphicsStack(savedStack);
    popResources(parent);
  }
コード例 #2
0
 /**
  * Process the given tiling pattern.
  *
  * @param tilingPattern the tiling pattern
  * @param color color to use, if this is an uncoloured pattern, otherwise null.
  * @param colorSpace color space to use, if this is an uncoloured pattern, otherwise null.
  * @throws IOException if there is an error reading or parsing the tiling pattern content stream.
  */
 protected final void processTilingPattern(
     PDTilingPattern tilingPattern, PDColor color, PDColorSpace colorSpace) throws IOException {
   processTilingPattern(tilingPattern, color, colorSpace, tilingPattern.getMatrix());
 }