Class GouraudShadingContext
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.shading.ShadingContext
-
- org.apache.pdfbox.pdmodel.graphics.shading.TriangleBasedShadingContext
-
- org.apache.pdfbox.pdmodel.graphics.shading.GouraudShadingContext
-
- All Implemented Interfaces:
java.awt.PaintContext
- Direct Known Subclasses:
Type4ShadingContext
,Type5ShadingContext
abstract class GouraudShadingContext extends TriangleBasedShadingContext
Shades Gouraud triangles for Type4ShadingContext and Type5ShadingContext.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.commons.logging.Log
LOG
private java.util.List<ShadedTriangle>
triangleList
triangle list.-
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.shading.TriangleBasedShadingContext
bitsPerColorComponent, bitsPerCoordinate, numberOfColorComponents
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GouraudShadingContext(PDShading shading, java.awt.image.ColorModel colorModel, java.awt.geom.AffineTransform xform, Matrix matrix)
Constructor creates an instance to be used for fill operations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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.void
dispose()
private float
interpolate(float src, long srcMax, float dstMin, float dstMax)
Calculate the interpolation, see p.345 pdf spec 1.7.protected boolean
isDataEmpty()
Returns true if the shading has an empty data stream.protected Vertex
readVertex(javax.imageio.stream.ImageInputStream input, long maxSrcCoord, long maxSrcColor, PDRange rangeX, PDRange rangeY, PDRange[] colRangeTab, Matrix matrix, java.awt.geom.AffineTransform xform)
Read a vertex from the bit input stream performs interpolations.(package private) void
setTriangleList(java.util.List<ShadedTriangle> triangleList)
-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.shading.TriangleBasedShadingContext
calcPixelTable, createPixelTable, getColorModel, getRaster
-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.shading.ShadingContext
convertToRGB, getBackground, getRgbBackground, getShading, getShadingColorSpace
-
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
triangleList
private java.util.List<ShadedTriangle> triangleList
triangle list.
-
-
Constructor Detail
-
GouraudShadingContext
protected GouraudShadingContext(PDShading shading, java.awt.image.ColorModel colorModel, java.awt.geom.AffineTransform xform, Matrix matrix) throws java.io.IOException
Constructor creates an instance to be used for fill operations.- Parameters:
shading
- the shading type to be usedcolorModel
- 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 something went wrong
-
-
Method Detail
-
readVertex
protected Vertex readVertex(javax.imageio.stream.ImageInputStream input, long maxSrcCoord, long maxSrcColor, PDRange rangeX, PDRange rangeY, PDRange[] colRangeTab, Matrix matrix, java.awt.geom.AffineTransform xform) throws java.io.IOException
Read a vertex from the bit input stream performs interpolations.- Parameters:
input
- bit input streammaxSrcCoord
- max value for source coordinate (2^bits-1)maxSrcColor
- max value for source color (2^bits-1)rangeX
- dest range for XrangeY
- dest range for YcolRangeTab
- dest range array for colorsmatrix
- the pattern matrix concatenated with that of the parent content stream- Returns:
- a new vertex with the flag and the interpolated values
- Throws:
java.io.IOException
- if something went wrong
-
setTriangleList
final void setTriangleList(java.util.List<ShadedTriangle> triangleList)
-
calcPixelTable
protected java.util.Map<java.awt.Point,java.lang.Integer> calcPixelTable(java.awt.Rectangle deviceBounds) throws java.io.IOException
Description copied from class:TriangleBasedShadingContext
Calculate every point and its color and store them in a Hash table.- Specified by:
calcPixelTable
in classTriangleBasedShadingContext
- Returns:
- a Hash table which contains all the points' positions and colors of one image
- Throws:
java.io.IOException
-
dispose
public void dispose()
- Specified by:
dispose
in interfacejava.awt.PaintContext
- Overrides:
dispose
in classTriangleBasedShadingContext
-
interpolate
private float interpolate(float src, long srcMax, float dstMin, float dstMax)
Calculate the interpolation, see p.345 pdf spec 1.7.- Parameters:
src
- src valuesrcMax
- max src value (2^bits-1)dstMin
- min dst valuedstMax
- max dst value- Returns:
- interpolated value
-
isDataEmpty
protected boolean isDataEmpty()
Description copied from class:TriangleBasedShadingContext
Returns true if the shading has an empty data stream.- Specified by:
isDataEmpty
in classTriangleBasedShadingContext
-
-