Class PatchMeshesShadingContext
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.shading.ShadingContext
-
- org.apache.pdfbox.pdmodel.graphics.shading.TriangleBasedShadingContext
-
- org.apache.pdfbox.pdmodel.graphics.shading.PatchMeshesShadingContext
-
- All Implemented Interfaces:
java.awt.PaintContext
- Direct Known Subclasses:
Type6ShadingContext,Type7ShadingContext
abstract class PatchMeshesShadingContext extends TriangleBasedShadingContext
This class is extended in Type6ShadingContext and Type7ShadingContext. This was done as part of GSoC2014, Tilman Hausherr is the mentor.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.commons.logging.LogLOGprivate java.util.List<Patch>patchListpatch list-
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.shading.TriangleBasedShadingContext
bitsPerColorComponent, bitsPerCoordinate, numberOfColorComponents
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPatchMeshesShadingContext(PDShadingType6 shading, java.awt.image.ColorModel colorModel, java.awt.geom.AffineTransform xform, Matrix matrix, java.awt.Rectangle deviceBounds, int controlPoints)Constructor creates an instance to be used for fill operations.
-
Method Summary
All Methods Instance Methods Abstract 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.(package private) java.util.List<Patch>collectPatches(PDShadingType6 shadingType, java.awt.geom.AffineTransform xform, Matrix matrix, int controlPoints)Create a patch list from a data stream, the returned list contains all the patches contained in the data stream.voiddispose()(package private) abstract PatchgeneratePatch(java.awt.geom.Point2D[] points, float[][] color)Create a patch using control points and 4 corner color values, in Type6ShadingContext, a CoonsPatch is returned; in Type6ShadingContext, a TensorPatch is returned.private floatinterpolate(float x, long maxValue, float rangeMin, float rangeMax)Get a point coordinate on a line by linear interpolation.protected booleanisDataEmpty()Returns true if the shading has an empty data stream.protected PatchreadPatch(javax.imageio.stream.ImageInputStream input, boolean isFree, java.awt.geom.Point2D[] implicitEdge, float[][] implicitCornerColor, long maxSrcCoord, long maxSrcColor, PDRange rangeX, PDRange rangeY, PDRange[] colRange, Matrix matrix, java.awt.geom.AffineTransform xform, int controlPoints)Read a single patch from a data stream, a patch contains information of its coordinates and color parameters.-
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
-
patchList
private java.util.List<Patch> patchList
patch list
-
-
Constructor Detail
-
PatchMeshesShadingContext
protected PatchMeshesShadingContext(PDShadingType6 shading, java.awt.image.ColorModel colorModel, java.awt.geom.AffineTransform xform, Matrix matrix, java.awt.Rectangle deviceBounds, int controlPoints) 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 streamdeviceBounds- device boundscontrolPoints- number of control points, 12 for type 6 shading and 16 for type 7 shading- Throws:
java.io.IOException- if something went wrong
-
-
Method Detail
-
collectPatches
final java.util.List<Patch> collectPatches(PDShadingType6 shadingType, java.awt.geom.AffineTransform xform, Matrix matrix, int controlPoints) throws java.io.IOException
Create a patch list from a data stream, the returned list contains all the patches contained in the data stream.- Parameters:
shadingType- the shading typexform- transformation for user to device spacematrix- the pattern matrix concatenated with that of the parent content streamcontrolPoints- number of control points, 12 for type 6 shading and 16 for type 7 shading- Returns:
- the obtained patch list
- Throws:
java.io.IOException- when something went wrong
-
readPatch
protected Patch readPatch(javax.imageio.stream.ImageInputStream input, boolean isFree, java.awt.geom.Point2D[] implicitEdge, float[][] implicitCornerColor, long maxSrcCoord, long maxSrcColor, PDRange rangeX, PDRange rangeY, PDRange[] colRange, Matrix matrix, java.awt.geom.AffineTransform xform, int controlPoints) throws java.io.IOException
Read a single patch from a data stream, a patch contains information of its coordinates and color parameters.- Parameters:
input- the image source data streamisFree- whether this is a free patchimplicitEdge- implicit edge when a patch is not free, otherwise it's not usedimplicitCornerColor- implicit colors when a patch is not free, otherwise it's not usedmaxSrcCoord- the maximum coordinate value calculated from source datamaxSrcColor- the maximum color value calculated from source datarangeX- range for coordinate xrangeY- range for coordinate ycolRange- range for colormatrix- the pattern matrix concatenated with that of the parent content streamxform- transformation for user to device spacecontrolPoints- number of control points, 12 for type 6 shading and 16 for type 7 shading- Returns:
- a single patch
- Throws:
java.io.IOException- when something went wrong
-
generatePatch
abstract Patch generatePatch(java.awt.geom.Point2D[] points, float[][] color)
Create a patch using control points and 4 corner color values, in Type6ShadingContext, a CoonsPatch is returned; in Type6ShadingContext, a TensorPatch is returned.- Parameters:
points- 12 or 16 control pointscolor- 4 corner colors- Returns:
- a patch instance
-
interpolate
private float interpolate(float x, long maxValue, float rangeMin, float rangeMax)Get a point coordinate on a line by linear interpolation.
-
calcPixelTable
protected java.util.Map<java.awt.Point,java.lang.Integer> calcPixelTable(java.awt.Rectangle deviceBounds) throws java.io.IOExceptionDescription copied from class:TriangleBasedShadingContextCalculate every point and its color and store them in a Hash table.- Specified by:
calcPixelTablein 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:
disposein interfacejava.awt.PaintContext- Overrides:
disposein classTriangleBasedShadingContext
-
isDataEmpty
protected boolean isDataEmpty()
Description copied from class:TriangleBasedShadingContextReturns true if the shading has an empty data stream.- Specified by:
isDataEmptyin classTriangleBasedShadingContext
-
-