Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.graphics.shading

pack-priv abstract Class TriangleBasedShadingContext

extends ShadingContext
Class Inheritance
Known Direct Subclasses
org.apache.pdfbox.pdmodel.graphics.shading.GouraudShadingContext, org.apache.pdfbox.pdmodel.graphics.shading.PatchMeshesShadingContext
Imports
java.awt.Point, .Rectangle, java.awt.geom.AffineTransform, java.awt.image.ColorModel, .Raster, .WritableRaster, java.io.IOException, java.util.List, .Map, org.apache.pdfbox.util.Matrix

Intermediate class extended by the shading types 4,5,6 and 7 that contains the common methods used by these classes.
Authors
Shaola Ren, Tilman Hausherr

Field Summary

Modifier and TypeField and Description
private int[][]
private int
private int

Constructor Summary

AccessConstructor and Description
pack-priv
TriangleBasedShadingContext(PDShading
the shading type to be used
shading
,
ColorModel
the color model to be used
cm
,
AffineTransform
transformation for user to device space
xform
,
Matrix
the pattern matrix concatenated with that of the parent content stream
matrix
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
private void
addLinePoints(Line line, int[][] array)

private void
addValueToArray(Point p, int value, int[][] array)

pack-priv abstract Map<Point, Integer>

Returns:

a Hash table which contains all the points' positions and colors of one image
calcPixelTable
(Rectangle deviceBounds)
Deprecated the map was replaced with an array due to a better performance

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)
Deprecated the map was replaced with an array due to a better performance

Get the points from the triangles, calculate their color and add point-color mappings.

protected int[][]
calcPixelTable(List<ShadedTriangle> triangleList, int[][] array, Rectangle deviceBounds)

Get the points from the triangles, calculate their color and add point-color mappings.

pack-priv abstract int[][]

Returns:

an array which contains all the points' positions and colors of one image
calcPixelTableArray
(Rectangle deviceBounds)

Calculate every point and its color and store them in a two-dimensional array.

protected final void
createPixelTable(Rectangle deviceBounds)

Creates the pixel table.

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.

public final Raster
getRaster(int
the x coordinate of the area in device space for which colors are generated.
x
,
int
the y coordinate of the area in device space for which colors are generated.
y
,
int
the width of the area in device space
w
,
int
the height of the area in device space
h
)

Implements java.awt.PaintContext.getRaster.

Returns a Raster containing the colors generated for the graphics operation.

private int
getValueFromArray(int x, int y)

pack-priv abstract boolean
isDataEmpty()

Returns true if the shading has an empty data stream.

Inherited from org.apache.pdfbox.pdmodel.graphics.shading.ShadingContext:
convertToRGBdisposegetBackgroundgetColorModelgetRgbBackgroundgetShadinggetShadingColorSpace

Field Detail

pixelTableArrayback to summary
private int[][] pixelTableArray
xOffsetback to summary
private int xOffset
yOffsetback to summary
private int yOffset

Constructor Detail

TriangleBasedShadingContextback to summary
pack-priv TriangleBasedShadingContext(PDShading shading, ColorModel cm, AffineTransform xform, Matrix matrix) throws IOException

Constructor.

Parameters
shading:PDShading

the shading type to be used

cm:ColorModel

the color model to be used

xform:AffineTransform

transformation for user to device space

matrix:Matrix

the pattern matrix concatenated with that of the parent content stream

Exceptions
IOException:
if there is an error getting the color space or doing background color conversion.

Method Detail

addLinePointsback to summary
private void addLinePoints(Line line, int[][] array) throws IOException
addValueToArrayback to summary
private void addValueToArray(Point p, int value, int[][] array)
calcPixelTableback to summary
pack-priv abstract Map<Point, Integer> calcPixelTable(Rectangle deviceBounds) throws IOException

Deprecated

the map was replaced with an array due to a better performance

Calculate every point and its color and store them in a Hash table.

Returns:Map<Point, Integer>

a Hash table which contains all the points' positions and colors of one image

Annotations
@Deprecated
calcPixelTableback to summary
protected void calcPixelTable(List<ShadedTriangle> triangleList, Map<Point, Integer> map, Rectangle deviceBounds) throws IOException

Deprecated

the map was replaced with an array due to a better performance

Get the points from the triangles, calculate their color and add point-color mappings.

Annotations
@Deprecated
calcPixelTableback to summary
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.

calcPixelTableArrayback to summary
pack-priv abstract int[][] calcPixelTableArray(Rectangle deviceBounds) throws IOException

Calculate every point and its color and store them in a two-dimensional array.

Returns:int[][]

an array which contains all the points' positions and colors of one image

createPixelTableback to summary
protected final void createPixelTable(Rectangle deviceBounds) throws IOException

Creates the pixel table.

evalFunctionAndConvertToRGBback to summary
private int evalFunctionAndConvertToRGB(float[] values) throws IOException

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.

getRasterback to summary
public final Raster getRaster(int x, int y, int w, int h)

Implements java.awt.PaintContext.getRaster.

Doc from java.awt.PaintContext.getRaster.

Returns a Raster containing the colors generated for the graphics operation.

Parameters
x:int

the x coordinate of the area in device space for which colors are generated.

y:int

the y coordinate of the area in device space for which colors are generated.

w:int

the width of the area in device space

h:int

the height of the area in device space

Returns:Raster

a Raster representing the specified rectangular area and containing the colors generated for the graphics operation.

Annotations
@Override
getValueFromArrayback to summary
private int getValueFromArray(int x, int y)
isDataEmptyback to summary
pack-priv abstract boolean isDataEmpty()

Returns true if the shading has an empty data stream.