org.foray.pdf.object
Class PDFShading

java.lang.Object
  extended by org.foray.pdf.object.PDFObject
      extended by org.foray.pdf.object.PDFShading

public class PDFShading
extends PDFObject

class representing a PDF Smooth Shading object. 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 shadingType (0,2,3, or 4), a Domain, and a Range.


Field Summary
static byte TYPE_AXIAL
          Constant indicating a shading type of "Axial shading".
static byte TYPE_COONS_PATCH_MESH
          Constant indicating a shading type of "Coons patch mesh".
static byte TYPE_FREE_GOURAD_TRIANGLE_MESH
          Constant indicating a shading type of "Free-form Gouraud-shaded triangle mesh".
static byte TYPE_FUNCTION_BASED
          Constant indicating a shading type of "Function-based shading".
static byte TYPE_LATTICE_GOURAD_TRIANGLE_MESH
          Constant indicating a shading type of "Lattice-form Gourad-shaded triangle mesh".
static byte TYPE_RADIAL
          Constant indicating a shading type of "Radial shading".
static byte TYPE_TENSOR_PRODUCT_PATCH_MESH
          Constant indicating a shading type of "Tensor-product-patch mesh".
 
Fields inherited from class org.foray.pdf.object.PDFObject
EOL, MSG_EOL, XREF_EOL
 
Constructor Summary
PDFShading(PDFDocument doc, int theShadingType, ColorSpace theColorSpace, List<Double> theBackground, List<Double> theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, int theBitsPerFlag, List<Double> theDecode, PDFFunction theFunction)
          Constructor for Type 4,6, or 7.
PDFShading(PDFDocument doc, int theShadingType, ColorSpace theColorSpace, List<Double> theBackground, List<Double> theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, List<Double> theDecode, int theVerticesPerRow, PDFFunction theFunction)
          Constructor for type 5.
PDFShading(PDFDocument doc, int theShadingType, ColorSpace theColorSpace, List<Double> theBackground, List<Double> theBBox, boolean theAntiAlias, List<Double> theDomain, List<Double> theMatrix, PDFFunction theFunction)
          Constructor for type function based shading.
PDFShading(PDFDocument doc, int theShadingType, ColorSpace theColorSpace, List<Double> theBackground, List<Double> theBBox, boolean theAntiAlias, List<Double> theCoords, List<Double> theDomain, PDFFunction theFunction, List<Boolean> theExtend)
          Constructor for Type 2 and 3.
 
Method Summary
 String getName()
          Returns the PDF name for this shading.
 String toPDF()
          represent as PDF.
 
Methods inherited from class org.foray.pdf.object.PDFObject
bufferToByteArray, byteArrayToStream, getCharsPerLine, getGeneration, getLogger, getNumber, getPDFDocument, output, pdfID, pdfReference, setNumber, stringToByteArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_FUNCTION_BASED

public static final byte TYPE_FUNCTION_BASED
Constant indicating a shading type of "Function-based shading".

See Also:
"PDF Reference, 3rd Edition, Table 4.25.", Constant Field Values

TYPE_AXIAL

public static final byte TYPE_AXIAL
Constant indicating a shading type of "Axial shading".

See Also:
"PDF Reference, 3rd Edition, Table 4.25.", Constant Field Values

TYPE_RADIAL

public static final byte TYPE_RADIAL
Constant indicating a shading type of "Radial shading".

See Also:
"PDF Reference, 3rd Edition, Table 4.25.", Constant Field Values

TYPE_FREE_GOURAD_TRIANGLE_MESH

public static final byte TYPE_FREE_GOURAD_TRIANGLE_MESH
Constant indicating a shading type of "Free-form Gouraud-shaded triangle mesh".

See Also:
"PDF Reference, 3rd Edition, Table 4.25.", Constant Field Values

TYPE_LATTICE_GOURAD_TRIANGLE_MESH

public static final byte TYPE_LATTICE_GOURAD_TRIANGLE_MESH
Constant indicating a shading type of "Lattice-form Gourad-shaded triangle mesh".

See Also:
"PDF Reference, 3rd Edition, Table 4.25.", Constant Field Values

TYPE_COONS_PATCH_MESH

public static final byte TYPE_COONS_PATCH_MESH
Constant indicating a shading type of "Coons patch mesh".

See Also:
"PDF Reference, 3rd Edition, Table 4.25.", Constant Field Values

TYPE_TENSOR_PRODUCT_PATCH_MESH

public static final byte TYPE_TENSOR_PRODUCT_PATCH_MESH
Constant indicating a shading type of "Tensor-product-patch mesh".

See Also:
"PDF Reference, 3rd Edition, Table 4.25.", Constant Field Values
Constructor Detail

PDFShading

public PDFShading(PDFDocument doc,
                  int theShadingType,
                  ColorSpace theColorSpace,
                  List<Double> theBackground,
                  List<Double> theBBox,
                  boolean theAntiAlias,
                  List<Double> theDomain,
                  List<Double> theMatrix,
                  PDFFunction theFunction)
Constructor for type function based shading.

Parameters:
doc - The parent PDF document.
theShadingType - The type of shading object, which should be 1 for function based shading.
theColorSpace - The colorspace is 'DeviceRGB' or something similar.
theBackground - An array of color components appropriate to the colorspace key specifying a single color value. This key is used by the f operator buy ignored by the sh operator.
theBBox - List of double's representing a rectangle in the coordinate space that is current at the time of shading is imaged. Temporary clipping boundary.
theAntiAlias - Whether or not to anti-alias.
theDomain - Optional List of Doubles specifying the domain.
theMatrix - List of Doubles specifying the matrix. If it's a pattern, then the matrix maps it to pattern space. If it's a shading, then it maps it to current user space. It's optional, the default is the identity matrix
theFunction - The PDF Function that maps an (x,y) location to a color.

PDFShading

public PDFShading(PDFDocument doc,
                  int theShadingType,
                  ColorSpace theColorSpace,
                  List<Double> theBackground,
                  List<Double> theBBox,
                  boolean theAntiAlias,
                  List<Double> theCoords,
                  List<Double> theDomain,
                  PDFFunction theFunction,
                  List<Boolean> theExtend)
Constructor for Type 2 and 3.

Parameters:
doc - The parent PDF document.
theShadingType - 2 or 3 for axial or radial shading
theColorSpace - "DeviceRGB" or similar.
theBackground - theBackground An array of color components appropriate to the colorspace key specifying a single color value. This key is used by the f operator buy ignored by the sh operator.
theBBox - List of double's representing a rectangle in the coordinate space that is current at the time of shading is imaged. Temporary clipping boundary.
theAntiAlias - Default is false
theCoords - List of four (type 2) or 6 (type 3) Double
theDomain - List of Doubles specifying the domain
theFunction - the Stitching (PDFfunction type 3) function, even if it's stitching a single function
theExtend - List of Booleans of whether to extend teh start and end colors past the start and end points. The default is [false, false]

PDFShading

public PDFShading(PDFDocument doc,
                  int theShadingType,
                  ColorSpace theColorSpace,
                  List<Double> theBackground,
                  List<Double> theBBox,
                  boolean theAntiAlias,
                  int theBitsPerCoordinate,
                  int theBitsPerComponent,
                  int theBitsPerFlag,
                  List<Double> theDecode,
                  PDFFunction theFunction)
Constructor for Type 4,6, or 7.

Parameters:
doc - The parent PDF document.
theShadingType - 4, 6, or 7 depending on whether it's Free-form gouraud-shaded triangle meshes, coons patch meshes, or tensor product patch meshes, respectively.
theColorSpace - "DeviceRGB" or similar.
theBackground - theBackground An array of color components appropriate to the colorspace key specifying a single color value. This key is used by the f operator buy ignored by the sh operator.
theBBox - List of double's representing a rectangle in the coordinate space that is current at the time of shading is imaged. Temporary clipping boundary.
theAntiAlias - Default is false
theBitsPerCoordinate - 1,2,4,8,12,16,24 or 32.
theBitsPerComponent - 1,2,4,8,12, and 16
theBitsPerFlag - 2,4,8.
theDecode - List of Doubles see PDF 1.3 spec pages 303 to 312.
theFunction - the PDFFunction

PDFShading

public PDFShading(PDFDocument doc,
                  int theShadingType,
                  ColorSpace theColorSpace,
                  List<Double> theBackground,
                  List<Double> theBBox,
                  boolean theAntiAlias,
                  int theBitsPerCoordinate,
                  int theBitsPerComponent,
                  List<Double> theDecode,
                  int theVerticesPerRow,
                  PDFFunction theFunction)
Constructor for type 5.

Parameters:
theShadingType - 5 for lattice-Form Gouraud shaded-triangle mesh
theColorSpace - "DeviceRGB" or similar.
theBackground - theBackground An array of color components appropriate to the colorspace key specifying a single color value. This key is used by the f operator buy ignored by the sh operator.
theBBox - List of double's representing a rectangle in the coordinate space that is current at the time of shading is imaged. Temporary clipping boundary.
theAntiAlias - Default is false
theBitsPerCoordinate - 1,2,4,8,12,16, 24, or 32
theBitsPerComponent - 1,2,4,8,12,24,32
theDecode - List of Doubles. See page 305 in PDF 1.3 spec.
theVerticesPerRow - number of vertices in each "row" of the lattice.
theFunction - The PDFFunction that's mapped on to this shape
doc - The parent PDF document.
Method Detail

getName

public String getName()
Returns the PDF name for this shading.

Returns:
the PDF name for this shading.

toPDF

public String toPDF()
represent as PDF. Whatever the shadingType 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.

Returns:
the PDF string.


Copyright © 2017. All rights reserved.