org.apache.fop.pdf

Class PDFPattern

Implemented Interfaces:
PDFWritable

public class PDFPattern
extends PDFPathPaint

class representing a PDF Function. PDF Functions represent parameterized mathematical formulas and sampled representations with arbitrary resolution. Functions are used in two areas: device-dependent rasterization information for halftoning and transfer functions, and color specification for smooth shading (a PDF 1.3 feature). All PDF Functions have a FunctionType (0,2,3, or 4), a Domain, and a Range.

Field Summary

protected List
bBox
List of Doubles representing the Bounding box rectangle
protected StringBuffer
extGState
TODO use PDFGState String representing the extended Graphics state.
protected List
matrix
List of Doubles representing the Transformation matrix.
protected int
paintType
1 for colored pattern, 2 for uncolored
protected StringBuffer
patternDataStream
The stream of a pattern
protected String
patternName
The name of the pattern such as "Pa1" or "Pattern1"
protected int
patternType
Either one (1) for tiling, or two (2) for shading.
protected PDFResources
resources
The resources associated with this pattern
protected PDFShading
shading
The Shading object comprising the Type 2 pattern
protected int
tilingType
1 for constant spacing, 2 for no distortion, and 3 for fast rendering
protected double
xStep
Horizontal spacing
protected List
xUID
List of Integers represetning the Extended unique Identifier
protected double
yStep
Vertical spacing

Fields inherited from class org.apache.fop.pdf.PDFPathPaint

colorSpace

Fields inherited from class org.apache.fop.pdf.PDFObject

DATE_FORMAT, log

Constructor Summary

PDFPattern(int thePatternType, PDFShading theShading, List theXUID, StringBuffer theExtGState, List theMatrix)
Create a type 2 pattern (smooth shading)
PDFPattern(PDFResources theResources, int thePatternType, int thePaintType, int theTilingType, List theBBox, double theXStep, double theYStep, List theMatrix, List theXUID, StringBuffer thePatternDataStream)
Create a tiling pattern (type 1).

Method Summary

boolean
equals(Object obj)
Check if this pattern is equal to another.
String
getColorSpaceOut(boolean fillNotStroke)
Get the PDF command for setting to this pattern.
String
getName()
Get the name of the pattern
protected int
output(OutputStream stream)
represent as PDF.
void
setName(String name)
Sets the name of the pattern.
byte[]
toPDF()
Output PDF bytes, not used.

Methods inherited from class org.apache.fop.pdf.PDFPathPaint

getColorSpace, getColorSpaceOut, setColorSpace

Methods inherited from class org.apache.fop.pdf.PDFObject

encode, encodeString, encodeText, formatDateTime, formatObject, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, hasObjectNumber, makeReference, output, referencePDF, setDocument, setObjectNumber, toInlinePDFString, toPDF, toPDFString

Field Details

bBox

protected List bBox
List of Doubles representing the Bounding box rectangle

extGState

protected StringBuffer extGState
TODO use PDFGState String representing the extended Graphics state. Probably will never be used like this.

matrix

protected List matrix
List of Doubles representing the Transformation matrix.

paintType

protected int paintType
1 for colored pattern, 2 for uncolored

patternDataStream

protected StringBuffer patternDataStream
The stream of a pattern

patternName

protected String patternName
The name of the pattern such as "Pa1" or "Pattern1"

patternType

protected int patternType
Either one (1) for tiling, or two (2) for shading.

resources

protected PDFResources resources
The resources associated with this pattern

shading

protected PDFShading shading
The Shading object comprising the Type 2 pattern

tilingType

protected int tilingType
1 for constant spacing, 2 for no distortion, and 3 for fast rendering

xStep

protected double xStep
Horizontal spacing

xUID

protected List xUID
List of Integers represetning the Extended unique Identifier

yStep

protected double yStep
Vertical spacing

Constructor Details

PDFPattern

public PDFPattern(int thePatternType,
                  PDFShading theShading,
                  List theXUID,
                  StringBuffer theExtGState,
                  List theMatrix)
Create a type 2 pattern (smooth shading)
Parameters:
thePatternType - the type of the pattern, which is 2, smooth shading
theShading - the PDF Shading object that comprises this pattern
theXUID - optional:the extended unique Identifier if used.
theExtGState - optional: the extended graphics state, if used.
theMatrix - Optional:List of Doubles that specify the matrix.

PDFPattern

public PDFPattern(PDFResources theResources,
                  int thePatternType,
                  int thePaintType,
                  int theTilingType,
                  List theBBox,
                  double theXStep,
                  double theYStep,
                  List theMatrix,
                  List theXUID,
                  StringBuffer thePatternDataStream)
Create a tiling pattern (type 1).
Parameters:
theResources - the resources associated with this pattern
thePatternType - the type of pattern, which is 1 for tiling.
thePaintType - 1 or 2, colored or uncolored.
theTilingType - 1, 2, or 3, constant spacing, no distortion, or faster tiling
theBBox - List of Doubles: The pattern cell bounding box
theXStep - horizontal spacing
theYStep - vertical spacing
theMatrix - Optional List of Doubles transformation matrix
theXUID - Optional vector of Integers that uniquely identify the pattern
thePatternDataStream - The stream of pattern data to be tiled.

Method Details

equals

public boolean equals(Object obj)
Check if this pattern is equal to another.
Parameters:
obj - the object to compare against
Returns:
true if the patterns are equal

getColorSpaceOut

public String getColorSpaceOut(boolean fillNotStroke)
Get the PDF command for setting to this pattern.
Overrides:
getColorSpaceOut in interface PDFPathPaint
Parameters:
fillNotStroke - if true fill otherwise stroke
Returns:
the PDF string for setting the pattern

getName

public String getName()
Get the name of the pattern
Returns:
String representing the name of the pattern.

output

protected int output(OutputStream stream)
            throws IOException
represent as PDF. Whatever the FunctionType is, the correct representation spits out. The sets of required and optional attributes are different for each type, but if a required attribute's object was constructed as null, then no error is raised. Instead, the malformed PDF that was requested by the construction is dutifully output. This policy should be reviewed.
Overrides:
output in interface PDFObject
Parameters:
stream - the stream to write to
Returns:
the PDF string.

setName

public void setName(String name)
Sets the name of the pattern.
Parameters:
name - the name of the pattern. Can be anything without spaces. "Pattern1" or "Pa1" are good examples.

toPDF

public byte[] toPDF()
Output PDF bytes, not used.
Overrides:
toPDF in interface PDFObject
Returns:
returns null

Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.