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
FieldsModifier and TypeFieldDescriptionprivate int[][]private intprivate int -
Constructor Summary
ConstructorsConstructorDescriptionTriangleBasedShadingContext(PDShading shading, ColorModel cm, AffineTransform xform, Matrix matrix) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddLinePoints(Line line, int[][] array) private voidaddValueToArray(Point p, int value, int[][] array) calcPixelTable(Rectangle deviceBounds) Deprecated.the map was replaced with an array due to a better performanceprotected int[][]calcPixelTable(List<ShadedTriangle> triangleList, int[][] array, Rectangle deviceBounds) Get the points from the triangles, calculate their color and add point-color mappings.protected voidcalcPixelTable(List<ShadedTriangle> triangleList, Map<Point, Integer> map, Rectangle deviceBounds) Deprecated.the map was replaced with an array due to a better performance(package private) abstract int[][]calcPixelTableArray(Rectangle deviceBounds) Calculate every point and its color and store them in a two-dimensional array.protected final voidcreatePixelTable(Rectangle deviceBounds) Creates the pixel table.private intevalFunctionAndConvertToRGB(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 RastergetRaster(int x, int y, int w, int h) private intgetValueFromArray(int x, int y) (package private) abstract booleanReturns true if the shading has an empty data stream.Methods inherited from class org.apache.pdfbox.pdmodel.graphics.shading.ShadingContext
convertToRGB, dispose, getBackground, getColorModel, getRgbBackground, getShading, getShadingColorSpace
-
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 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
Deprecated.the map was replaced with an array due to a better performanceCalculate 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
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 IOExceptionDeprecated.the map was replaced with an array due to a better performanceGet 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
- Throws:
IOException
-
addValueToArray
-
getValueFromArray
private int getValueFromArray(int x, int y) -
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. -
getRaster
-