Class PDTriangleBasedShadingType

java.lang.Object
org.apache.pdfbox.pdmodel.graphics.shading.PDShading
org.apache.pdfbox.pdmodel.graphics.shading.PDTriangleBasedShadingType
All Implemented Interfaces:
COSObjectable
Direct Known Subclasses:
PDShadingType4, PDShadingType5

abstract class PDTriangleBasedShadingType extends PDShading
Common resources for shading types 4,5,6 and 7
  • Field Details

    • decode

      private COSArray decode
    • LOG

      private static final org.apache.commons.logging.Log LOG
    • bitsPerCoordinate

      private int bitsPerCoordinate
    • bitsPerColorComponent

      private int bitsPerColorComponent
    • numberOfColorComponents

      private int numberOfColorComponents
  • Constructor Details

    • PDTriangleBasedShadingType

      PDTriangleBasedShadingType(COSDictionary shadingDictionary)
  • Method Details

    • getBitsPerComponent

      public int getBitsPerComponent()
      The bits per component of this shading. This will return -1 if one has not been set.
      Returns:
      the number of bits per component
    • setBitsPerComponent

      public void setBitsPerComponent(int bitsPerComponent)
      Set the number of bits per component.
      Parameters:
      bitsPerComponent - the number of bits per component
    • getBitsPerCoordinate

      public int getBitsPerCoordinate()
      The bits per coordinate of this shading. This will return -1 if one has not been set.
      Returns:
      the number of bits per coordinate
    • setBitsPerCoordinate

      public void setBitsPerCoordinate(int bitsPerCoordinate)
      Set the number of bits per coordinate.
      Parameters:
      bitsPerCoordinate - the number of bits per coordinate
    • getNumberOfColorComponents

      public int getNumberOfColorComponents() throws IOException
      The number of color components of this shading.
      Returns:
      number of color components of this shading
      Throws:
      IOException
    • getDecodeValues

      private COSArray getDecodeValues()
      Returns all decode values as COSArray.
      Returns:
      the decode array
    • setDecodeValues

      public void setDecodeValues(COSArray decodeValues)
      This will set the decode values.
      Parameters:
      decodeValues - the new decode values
    • getDecodeForParameter

      public PDRange getDecodeForParameter(int paramNum)
      Get the decode for the input parameter.
      Parameters:
      paramNum - the function parameter number
      Returns:
      the decode parameter range or null if none is set
    • interpolate

      protected float interpolate(float src, long srcMax, float dstMin, float dstMax)
      Calculate the interpolation, see p.345 pdf spec 1.7.
      Parameters:
      src - src value
      srcMax - max src value (2^bits-1)
      dstMin - min dst value
      dstMax - max dst value
      Returns:
      interpolated value
    • readVertex

      protected Vertex readVertex(ImageInputStream input, long maxSrcCoord, long maxSrcColor, PDRange rangeX, PDRange rangeY, PDRange[] colRangeTab, Matrix matrix, AffineTransform xform) throws IOException
      Read a vertex from the bit input stream performs interpolations.
      Parameters:
      input - bit input stream
      maxSrcCoord - max value for source coordinate (2^bits-1)
      maxSrcColor - max value for source color (2^bits-1)
      rangeX - dest range for X
      rangeY - dest range for Y
      colRangeTab - dest range array for colors
      matrix - the pattern matrix concatenated with that of the parent content stream
      Returns:
      a new vertex with the flag and the interpolated values
      Throws:
      IOException - if something went wrong
    • collectTriangles

      abstract List<ShadedTriangle> collectTriangles(AffineTransform xform, Matrix matrix) throws IOException
      Throws:
      IOException
    • getBounds

      public Rectangle2D getBounds(AffineTransform xform, Matrix matrix) throws IOException
      Description copied from class: PDShading
      Calculate a bounding rectangle around the areas of this shading context.
      Overrides:
      getBounds in class PDShading
      Returns:
      Bounding rectangle or null, if not supported by this shading type.
      Throws:
      IOException