Package org.apache.fop.pdf
Class PDFPattern
java.lang.Object
org.apache.fop.pdf.PDFObject
org.apache.fop.pdf.PDFPathPaint
org.apache.fop.pdf.PDFPattern
- All Implemented Interfaces:
PDFWritable
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
FieldsModifier and TypeFieldDescriptionprotected List
List of Doubles representing the Bounding box rectangleprotected StringBuffer
TODO use PDFGState String representing the extended Graphics state.protected List
List of Doubles representing the Transformation matrix.protected int
1 for colored pattern, 2 for uncoloredprotected StringBuffer
The stream of a patternprotected String
The name of the pattern such as "Pa1" or "Pattern1"protected int
Either one (1) for tiling, or two (2) for shading.protected PDFResources
The resources associated with this patternprotected PDFShading
The Shading object comprising the Type 2 patternprotected int
1 for constant spacing, 2 for no distortion, and 3 for fast renderingprotected double
Horizontal spacingprotected List
List of Integers represetning the Extended unique Identifierprotected double
Vertical spacingFields inherited from class org.apache.fop.pdf.PDFPathPaint
colorSpace
-
Constructor Summary
ConstructorsConstructorDescriptionPDFPattern
(int thePatternType, PDFShading shading, 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
Modifier and TypeMethodDescriptionprotected boolean
contentEquals
(PDFObject obj) Check if the other PDFObject has the same content as the current object.getColorSpaceOut
(boolean fillNotStroke) Get the PDF command for setting to this pattern.getName()
Get the name of the patternint
output
(OutputStream stream) represent as PDF.void
Sets the name of the pattern.byte[]
toPDF()
Output PDF bytes, not used.Methods inherited from class org.apache.fop.pdf.PDFPathPaint
getColorSpace, setColorSpace
Methods inherited from class org.apache.fop.pdf.PDFObject
encode, encodeBinaryToHexString, encodeString, encodeText, formatObject, getChildren, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, getParent, hasObjectNumber, makeReference, outputInline, referencePDF, setDocument, setObjectNumber, setObjectNumber, setObjectNumber, setParent, toPDFString
-
Field Details
-
resources
The resources associated with this pattern -
patternType
protected int patternTypeEither one (1) for tiling, or two (2) for shading. -
patternName
The name of the pattern such as "Pa1" or "Pattern1" -
paintType
protected int paintType1 for colored pattern, 2 for uncolored -
tilingType
protected int tilingType1 for constant spacing, 2 for no distortion, and 3 for fast rendering -
bBox
List of Doubles representing the Bounding box rectangle -
xStep
protected double xStepHorizontal spacing -
yStep
protected double yStepVertical spacing -
shading
The Shading object comprising the Type 2 pattern -
xUID
List of Integers represetning the Extended unique Identifier -
extGState
TODO use PDFGState String representing the extended Graphics state. Probably will never be used like this. -
matrix
List of Doubles representing the Transformation matrix. -
patternDataStream
The stream of a pattern
-
-
Constructor Details
-
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 patternthePatternType
- 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 tilingtheBBox
- List of Doubles: The pattern cell bounding boxtheXStep
- horizontal spacingtheYStep
- vertical spacingtheMatrix
- Optional List of Doubles transformation matrixtheXUID
- Optional vector of Integers that uniquely identify the patternthePatternDataStream
- The stream of pattern data to be tiled.
-
PDFPattern
public PDFPattern(int thePatternType, PDFShading shading, List theXUID, StringBuffer theExtGState, List theMatrix) Create a type 2 pattern (smooth shading)- Parameters:
thePatternType
- the type of the pattern, which is 2, smooth shadingshading
- the Shading object that comprises this patterntheXUID
- optional:the extended unique Identifier if used.theExtGState
- optional: the extended graphics state, if used.theMatrix
- Optional:List of Doubles that specify the matrix.
-
-
Method Details
-
getName
Get the name of the pattern- Returns:
- String representing the name of the pattern.
-
setName
Sets the name of the pattern.- Parameters:
name
- the name of the pattern. Can be anything without spaces. "Pattern1" or "Pa1" are good examples.
-
getColorSpaceOut
Get the PDF command for setting to this pattern.- Overrides:
getColorSpaceOut
in classPDFPathPaint
- Parameters:
fillNotStroke
- if true fill otherwise stroke- Returns:
- the PDF string for setting the pattern
-
output
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 classPDFObject
- Parameters:
stream
- the stream to write to- Returns:
- the PDF string.
- Throws:
IOException
- if there is an error writing to the stream
-
toPDF
public byte[] toPDF()Output PDF bytes, not used. -
contentEquals
Check if the other PDFObject has the same content as the current object.Note: This function has a contract which is less binding than
Object.equals(Object)
. Whereas equals would require all values to be identical, this method is not required to check everything. In the case of PDFObjects, this means that the overriding function does not have to check forPDFObject.getObjectID()
.- Overrides:
contentEquals
in classPDFObject
- Parameters:
obj
- object to compare to.- Returns:
- true if the other object has the same content.
-