Class TriangleBasedShadingContext
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.shading.ShadingContext
-
- org.apache.pdfbox.pdmodel.graphics.shading.TriangleBasedShadingContext
-
- All Implemented Interfaces:
java.awt.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 Summary
Fields Modifier and Type Field Description private int[][]pixelTableArrayprivate intxOffsetprivate intyOffset
-
Constructor Summary
Constructors Constructor Description TriangleBasedShadingContext(PDShading shading, java.awt.image.ColorModel cm, java.awt.geom.AffineTransform xform, Matrix matrix)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private voidaddLinePoints(Line line, int[][] array)private voidaddValueToArray(java.awt.Point p, int value, int[][] array)(package private) abstract java.util.Map<java.awt.Point,java.lang.Integer>calcPixelTable(java.awt.Rectangle deviceBounds)Deprecated.the map was replaced with an array due to a better performanceprotected int[][]calcPixelTable(java.util.List<ShadedTriangle> triangleList, int[][] array, java.awt.Rectangle deviceBounds)Get the points from the triangles, calculate their color and add point-color mappings.protected voidcalcPixelTable(java.util.List<ShadedTriangle> triangleList, java.util.Map<java.awt.Point,java.lang.Integer> map, java.awt.Rectangle deviceBounds)Deprecated.the map was replaced with an array due to a better performance(package private) abstract int[][]calcPixelTableArray(java.awt.Rectangle deviceBounds)Calculate every point and its color and store them in a two-dimensional array.protected voidcreatePixelTable(java.awt.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.java.awt.image.RastergetRaster(int x, int y, int w, int h)private intgetValueFromArray(int x, int y)(package private) abstract booleanisDataEmpty()Returns 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
-
-
-
-
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 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:
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.IOExceptionCreates the pixel table.- Throws:
java.io.IOException
-
calcPixelTable
@Deprecated abstract java.util.Map<java.awt.Point,java.lang.Integer> calcPixelTable(java.awt.Rectangle deviceBounds) throws java.io.IOExceptionDeprecated.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:
java.io.IOException
-
calcPixelTableArray
abstract int[][] calcPixelTableArray(java.awt.Rectangle deviceBounds) throws java.io.IOExceptionCalculate 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:
java.io.IOException
-
calcPixelTable
@Deprecated 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
Deprecated.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:
java.io.IOException
-
calcPixelTable
protected int[][] calcPixelTable(java.util.List<ShadedTriangle> triangleList, int[][] array, 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
-
addLinePoints
private void addLinePoints(Line line, int[][] array) throws java.io.IOException
- Throws:
java.io.IOException
-
addValueToArray
private void addValueToArray(java.awt.Point p, int value, int[][] array)
-
getValueFromArray
private int getValueFromArray(int x, int y)
-
evalFunctionAndConvertToRGB
private int evalFunctionAndConvertToRGB(float[] values) throws java.io.IOExceptionConvert 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.
-
getRaster
public final java.awt.image.Raster getRaster(int x, int y, int w, int h)
-
-