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

pack-priv abstract Class PDTriangleBasedShadingType

extends PDShading
Class Inheritance
Known Direct Subclasses
org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType4, org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType5
Imports
java.awt.geom.AffineTransform, .Point2D, .Rectangle2D, java.io.IOException, java.util.List, javax.imageio.stream.ImageInputStream, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.cos.COSArray, .COSDictionary, .COSName, org.apache.pdfbox.pdmodel.common.PDRange, org.apache.pdfbox.util.Matrix

Common resources for shading types 4,5,6 and 7

Field Summary

Modifier and TypeField and Description
private int
private int
private COSArray
private static final Log
private int
Inherited from org.apache.pdfbox.pdmodel.graphics.shading.PDShading:
SHADING_TYPE1SHADING_TYPE2SHADING_TYPE3SHADING_TYPE4SHADING_TYPE5SHADING_TYPE6SHADING_TYPE7

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract List<ShadedTriangle>
public int

Returns:

the number of bits per component
getBitsPerComponent
()

The bits per component of this shading.

public int

Returns:

the number of bits per coordinate
getBitsPerCoordinate
()

The bits per coordinate of this shading.

public Rectangle2D
getBounds(AffineTransform
the affine transformation
xform
,
Matrix
the pattern matrix
matrix
)

Overrides org.apache.pdfbox.pdmodel.graphics.shading.PDShading.getBounds.

Calculate a bounding rectangle around the areas of this shading context.

public PDRange

Returns:

the decode parameter range or null if none is set
getDecodeForParameter
(int
the function parameter number
paramNum
)

Get the decode for the input parameter.

private COSArray

Returns:

the decode array
getDecodeValues
()

Returns all decode values as COSArray.

public int

Returns:

number of color components of this shading
getNumberOfColorComponents
()

The number of color components of this shading.

protected float

Returns:

interpolated value
interpolate
(float
src value
src
,
long
max src value (2^bits-1)
srcMax
,
float
min dst value
dstMin
,
float
max dst value
dstMax
)

Calculate the interpolation, see p.345 pdf spec 1.7.

protected Vertex

Returns:

a new vertex with the flag and the interpolated values
readVertex
(ImageInputStream
bit input stream
input
,
long
max value for source coordinate (2^bits-1)
maxSrcCoord
,
long
max value for source color (2^bits-1)
maxSrcColor
,
PDRange
dest range for X
rangeX
,
PDRange
dest range for Y
rangeY
,
PDRange[]
dest range array for colors
colRangeTab
,
Matrix
the pattern matrix concatenated with that of the parent content stream
matrix
,
AffineTransform
the affine transformation
xform
)

Read a vertex from the bit input stream performs interpolations.

public void
setBitsPerComponent(int
the number of bits per component
bitsPerComponent
)

Set the number of bits per component.

public void
setBitsPerCoordinate(int
the number of bits per coordinate
bitsPerCoordinate
)

Set the number of bits per coordinate.

public void
setDecodeValues(COSArray
the new decode values
decodeValues
)

This will set the decode values.

Inherited from org.apache.pdfbox.pdmodel.graphics.shading.PDShading:
createevalFunctionevalFunctiongetAntiAliasgetBackgroundgetBBoxgetColorSpacegetCOSObjectgetFunctiongetShadingTypegetTypesetAntiAliassetBackgroundsetBBoxsetColorSpacesetFunctionsetFunctionsetShadingTypetoPaint

Field Detail

bitsPerColorComponentback to summary
private int bitsPerColorComponent
bitsPerCoordinateback to summary
private int bitsPerCoordinate
decodeback to summary
private COSArray decode
LOGback to summary
private static final Log LOG
numberOfColorComponentsback to summary
private int numberOfColorComponents

Constructor Detail

PDTriangleBasedShadingTypeback to summary
pack-priv PDTriangleBasedShadingType(COSDictionary shadingDictionary)

Method Detail

collectTrianglesback to summary
pack-priv abstract List<ShadedTriangle> collectTriangles(AffineTransform xform, Matrix matrix) throws IOException
getBitsPerComponentback to summary
public int getBitsPerComponent()

The bits per component of this shading. This will return -1 if one has not been set.

Returns:int

the number of bits per component

getBitsPerCoordinateback to summary
public int getBitsPerCoordinate()

The bits per coordinate of this shading. This will return -1 if one has not been set.

Returns:int

the number of bits per coordinate

getBoundsback to summary
public Rectangle2D getBounds(AffineTransform xform, Matrix matrix) throws IOException

Overrides org.apache.pdfbox.pdmodel.graphics.shading.PDShading.getBounds.

Doc from org.apache.pdfbox.pdmodel.graphics.shading.PDShading.getBounds.

Calculate a bounding rectangle around the areas of this shading context.

Parameters
xform:AffineTransform

the affine transformation

matrix:Matrix

the pattern matrix

Returns:Rectangle2D

Bounding rectangle or null, if not supported by this shading type.

Annotations
@Override
Exceptions
IOException:
if the bounds could not be created
getDecodeForParameterback to summary
public PDRange getDecodeForParameter(int paramNum)

Get the decode for the input parameter.

Parameters
paramNum:int

the function parameter number

Returns:PDRange

the decode parameter range or null if none is set

getDecodeValuesback to summary
private COSArray getDecodeValues()

Returns all decode values as COSArray.

Returns:COSArray

the decode array

getNumberOfColorComponentsback to summary
public int getNumberOfColorComponents() throws IOException

The number of color components of this shading.

Returns:int

number of color components of this shading

Exceptions
IOException:
if the data could not be read
interpolateback to summary
protected float interpolate(float src, long srcMax, float dstMin, float dstMax)

Calculate the interpolation, see p.345 pdf spec 1.7.

Parameters
src:float

src value

srcMax:long

max src value (2^bits-1)

dstMin:float

min dst value

dstMax:float

max dst value

Returns:float

interpolated value

readVertexback to summary
protected Vertex readVertex(ImageInputStream input, long maxSrcCoord, long maxSrcColor, PDRange rangeX, PDRange rangeY, PDRange[] colRangeTab, Matrix matrix, AffineTransform xform) throws IOException

Read a vertex from the bit input stream performs interpolations.

Parameters
input:ImageInputStream

bit input stream

maxSrcCoord:long

max value for source coordinate (2^bits-1)

maxSrcColor:long

max value for source color (2^bits-1)

rangeX:PDRange

dest range for X

rangeY:PDRange

dest range for Y

colRangeTab:PDRange[]

dest range array for colors

matrix:Matrix

the pattern matrix concatenated with that of the parent content stream

xform:AffineTransform

the affine transformation

Returns:Vertex

a new vertex with the flag and the interpolated values

Exceptions
IOException:
if something went wrong
setBitsPerComponentback to summary
public void setBitsPerComponent(int bitsPerComponent)

Set the number of bits per component.

Parameters
bitsPerComponent:int

the number of bits per component

setBitsPerCoordinateback to summary
public void setBitsPerCoordinate(int bitsPerCoordinate)

Set the number of bits per coordinate.

Parameters
bitsPerCoordinate:int

the number of bits per coordinate

setDecodeValuesback to summary
public void setDecodeValues(COSArray decodeValues)

This will set the decode values.

Parameters
decodeValues:COSArray

the new decode values