Class TriangleBasedShadingContext

  • All Implemented Interfaces:
    java.awt.PaintContext
    Direct Known Subclasses:
    GouraudShadingContext, PatchMeshesShadingContext

    abstract class TriangleBasedShadingContext
    extends ShadingContext
    implements java.awt.PaintContext
    Intermediate class extended by the shading types 4,5,6 and 7 that contains the common methods used by these classes.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) abstract java.util.Map<java.awt.Point,​java.lang.Integer> calcPixelTable​(java.awt.Rectangle deviceBounds)
      Calculate every point and its color and store them in a Hash table.
      protected void calcPixelTable​(java.util.List<ShadedTriangle> triangleList, java.util.Map<java.awt.Point,​java.lang.Integer> map, java.awt.Rectangle deviceBounds)
      Get the points from the triangles, calculate their color and add point-color mappings.
      protected void createPixelTable​(java.awt.Rectangle deviceBounds)
      Creates the pixel table.
      void dispose()  
      private int evalFunctionAndConvertToRGB​(float[] values)
      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.
      java.awt.image.ColorModel getColorModel()  
      java.awt.image.Raster getRaster​(int x, int y, int w, int h)  
      (package private) abstract boolean isDataEmpty()
      Returns true if the shading has an empty data stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

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

        protected int bitsPerCoordinate
      • bitsPerColorComponent

        protected int bitsPerColorComponent
      • numberOfColorComponents

        protected int numberOfColorComponents
      • hasFunction

        private final boolean hasFunction
      • pixelTable

        private java.util.Map<java.awt.Point,​java.lang.Integer> pixelTable
    • Constructor Detail

      • TriangleBasedShadingContext

        TriangleBasedShadingContext​(PDShading shading,
                                    java.awt.image.ColorModel cm,
                                    java.awt.geom.AffineTransform xform,
                                    Matrix matrix)
                             throws java.io.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:
        java.io.IOException - if there is an error getting the color space or doing background color conversion.
    • Method Detail

      • createPixelTable

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

        abstract java.util.Map<java.awt.Point,​java.lang.Integer> calcPixelTable​(java.awt.Rectangle deviceBounds)
                                                                               throws java.io.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:
        java.io.IOException
      • calcPixelTable

        protected void calcPixelTable​(java.util.List<ShadedTriangle> triangleList,
                                      java.util.Map<java.awt.Point,​java.lang.Integer> map,
                                      java.awt.Rectangle deviceBounds)
                               throws java.io.IOException
        Get the points from the triangles, calculate their color and add point-color mappings.
        Throws:
        java.io.IOException
      • evalFunctionAndConvertToRGB

        private int evalFunctionAndConvertToRGB​(float[] values)
                                         throws java.io.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:
        java.io.IOException
      • isDataEmpty

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

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

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

        public final java.awt.image.Raster getRaster​(int x,
                                                     int y,
                                                     int w,
                                                     int h)
        Specified by:
        getRaster in interface java.awt.PaintContext