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
Intermediate class extended by the shading types 4,5,6 and 7 that contains the common methods
used by these classes.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTriangleBasedShadingContext
(PDShading shading, ColorModel cm, AffineTransform xform, Matrix matrix) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncalcPixelTable
(Rectangle deviceBounds) Calculate every point and its color and store them in a Hash table.protected void
calcPixelTable
(List<ShadedTriangle> triangleList, Map<Point, Integer> map, Rectangle deviceBounds) Get the points from the triangles, calculate their color and add point-color mappings.protected final void
createPixelTable
(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.final ColorModel
final Raster
getRaster
(int x, int y, int w, int h) (package private) abstract boolean
Returns true if the shading has an empty data stream.Methods inherited from class org.apache.pdfbox.pdmodel.graphics.shading.ShadingContext
convertToRGB, getBackground, getRgbBackground, getShading, getShadingColorSpace
-
Field Details
-
pixelTable
-
-
Constructor Details
-
TriangleBasedShadingContext
TriangleBasedShadingContext(PDShading shading, ColorModel cm, AffineTransform xform, Matrix matrix) throws IOException Constructor.- Parameters:
shading
- the shading type to be usedcm
- the color model to be usedxform
- transformation for user to device spacematrix
- 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
Creates the pixel table.- Throws:
IOException
-
calcPixelTable
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 IOExceptionGet the points from the triangles, calculate their color and add point-color mappings.- Throws:
IOException
-
evalFunctionAndConvertToRGB
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
- Specified by:
getColorModel
in interfacePaintContext
- Overrides:
getColorModel
in classShadingContext
-
dispose
public void dispose()- Specified by:
dispose
in interfacePaintContext
- Overrides:
dispose
in classShadingContext
-
getRaster
- Specified by:
getRaster
in interfacePaintContext
-