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 implements PaintContext
Intermediate class extended by the shading types 4,5,6 and 7 that contains the common methods used by these classes.
  • Field Details

  • 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

      abstract Map<Point,Integer> calcPixelTable(Rectangle deviceBounds) throws IOException
      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
    • calcPixelTable

      protected void calcPixelTable(List<ShadedTriangle> triangleList, Map<Point,Integer> map, Rectangle deviceBounds) throws IOException
      Get the points from the triangles, calculate their color and add point-color mappings.
      Throws:
      IOException
    • 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.
    • getColorModel

      public final ColorModel getColorModel()
      Specified by:
      getColorModel in interface PaintContext
      Overrides:
      getColorModel in class ShadingContext
    • dispose

      public void dispose()
      Specified by:
      dispose in interface PaintContext
      Overrides:
      dispose in class ShadingContext
    • getRaster

      public final Raster getRaster(int x, int y, int w, int h)
      Specified by:
      getRaster in interface PaintContext