Class TriangleBasedShadingContext

java.lang.Object
org.apache.pdfbox.pdmodel.graphics.shading.ShadingContext
org.apache.pdfbox.pdmodel.graphics.shading.TriangleBasedShadingContext
All Implemented Interfaces:
PaintContext
Direct Known Subclasses:
GouraudShadingContext, PatchMeshesShadingContext

abstract class TriangleBasedShadingContext extends ShadingContext
Intermediate class extended by the shading types 4,5,6 and 7 that contains the common methods used by these classes.
  • Field Details

    • pixelTableArray

      private int[][] pixelTableArray
    • xOffset

      private int xOffset
    • yOffset

      private int yOffset
  • Constructor Details

    • TriangleBasedShadingContext

      TriangleBasedShadingContext(PDShading shading, ColorModel cm, AffineTransform xform, Matrix matrix) throws IOException
      Constructor.
      Parameters:
      shading - the shading type to be used
      cm - the color model to be used
      xform - transformation for user to device space
      matrix - the pattern matrix concatenated with that of the parent content stream
      Throws:
      IOException - if there is an error getting the color space or doing background color conversion.
  • Method Details

    • createPixelTable

      protected final void createPixelTable(Rectangle deviceBounds) throws IOException
      Creates the pixel table.
      Throws:
      IOException
    • calcPixelTable

      @Deprecated abstract Map<Point,Integer> calcPixelTable(Rectangle deviceBounds) throws IOException
      Deprecated.
      the map was replaced with an array due to a better performance
      Calculate every point and its color and store them in a Hash table.
      Returns:
      a Hash table which contains all the points' positions and colors of one image
      Throws:
      IOException
    • calcPixelTableArray

      abstract int[][] calcPixelTableArray(Rectangle deviceBounds) throws IOException
      Calculate every point and its color and store them in a two-dimensional array.
      Returns:
      an array which contains all the points' positions and colors of one image
      Throws:
      IOException
    • calcPixelTable

      @Deprecated protected void calcPixelTable(List<ShadedTriangle> triangleList, Map<Point,Integer> map, Rectangle deviceBounds) throws IOException
      Deprecated.
      the map was replaced with an array due to a better performance
      Get the points from the triangles, calculate their color and add point-color mappings.
      Throws:
      IOException
    • calcPixelTable

      protected int[][] calcPixelTable(List<ShadedTriangle> triangleList, int[][] array, Rectangle deviceBounds) throws IOException
      Get the points from the triangles, calculate their color and add point-color mappings.
      Throws:
      IOException
    • addLinePoints

      private void addLinePoints(Line line, int[][] array) throws IOException
      Throws:
      IOException
    • addValueToArray

      private void addValueToArray(Point p, int value, int[][] array)
    • getValueFromArray

      private int getValueFromArray(int x, int y)
    • evalFunctionAndConvertToRGB

      private int evalFunctionAndConvertToRGB(float[] values) throws IOException
      Convert color to RGB color value, using function if required, then convert from the shading color space to an RGB value, which is encoded into an integer.
      Throws:
      IOException
    • isDataEmpty

      abstract boolean isDataEmpty()
      Returns true if the shading has an empty data stream.
    • getRaster

      public final Raster getRaster(int x, int y, int w, int h)