## org.apache.fop.pdf
Class PDFShading

    java.lang.Object
      |
      +--org.apache.fop.pdf.PDFObject
            |
            +--org.apache.fop.pdf.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
`protected boolean` `antiAlias` Optional: A flag whether or not to filter the shading function to prevent aliasing artifacts.
`protected java.util.Vector` `background` The background color.
`protected java.util.Vector` `bBox` Optional: A Vector specifying the clipping rectangle
`protected int` `bitsPerComponent` Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each color coordinate.
`protected int` `bitsPerCoordinate` Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each vertex coordinate.
`protected int` `bitsPerFlag` Required for Type 4,5,6, and 7: Specifies the number of bits used to represent the edge flag for each vertex.
`protected ColorSpace` `colorSpace` A ColorSpace representing the colorspace.
`protected java.util.Vector` `coords` Required for Type 2: An Array of four numbers specifying the starting and ending coordinate pairs Required for Type 3: An Array of six numbers [x0,y0,r0,x1,y1,r1] specifying the centers and radii of the starting and ending circles.
`protected java.util.Vector` `decode` Required for Type 4,5,6, and 7: Array of Doubles which specifies how to decode coordinate and color component values.
`protected java.util.Vector` `domain` Optional for Type 1: Array of four numbers, xmin, xmax, ymin, ymax.
`protected java.util.Vector` `extend` Required for Type 2+3: An Array of two boolean values specifying whether to extend the start and end colors past the start and end points, respectively.
`protected PDFFunction` `function` Required for Type 1, 2, and 3: The object of the color mapping function (usually type 2 or 3).
`protected java.util.Vector` `matrix` Optional for Type 1: A transformation matrix
`protected java.lang.String` `shadingName` The name of the Shading e.g.
`protected int` `shadingType` Required: The Type of shading (1,2,3,4,5,6,7)
`protected int` `verticesPerRow` Required for Type 5:The number of vertices in each "row" of the lattice; it must be greater than or equal to 2.

Fields inherited from class org.apache.fop.pdf.PDFObject
`generation, number`

Constructor Summary
`PDFShading(int theNumber, java.lang.String theShadingName, int theShadingType, ColorSpace theColorSpace, java.util.Vector theBackground, java.util.Vector theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, int theBitsPerFlag, java.util.Vector theDecode, PDFFunction theFunction)` Constructor for Type 4,6, or 7
`PDFShading(int theNumber, java.lang.String theShadingName, int theShadingType, ColorSpace theColorSpace, java.util.Vector theBackground, java.util.Vector theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, java.util.Vector theDecode, int theVerticesPerRow, PDFFunction theFunction)` Constructor for type 5
`PDFShading(int theNumber, java.lang.String theShadingName, int theShadingType, ColorSpace theColorSpace, java.util.Vector theBackground, java.util.Vector theBBox, boolean theAntiAlias, java.util.Vector theDomain, java.util.Vector theMatrix, PDFFunction theFunction)` Constructor for type function based shading
`PDFShading(int theNumber, java.lang.String theShadingName, int theShadingType, ColorSpace theColorSpace, java.util.Vector theBackground, java.util.Vector theBBox, boolean theAntiAlias, java.util.Vector theCoords, java.util.Vector theDomain, PDFFunction theFunction, java.util.Vector theExtend)` Constructor for Type 2 and 3

Method Summary
`java.lang.String` `getName()`
`byte[]` `toPDF()` represent as PDF.

Methods inherited from class org.apache.fop.pdf.PDFObject
`getNumber, output, referencePDF`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### shadingName

    protected java.lang.String shadingName

  The name of the Shading e.g. "Shading1"

### shadingType

    protected int shadingType

  Required: The Type of shading (1,2,3,4,5,6,7)

### colorSpace

    protected ColorSpace colorSpace

  A ColorSpace representing the colorspace. "DeviceRGB" is an example.

### background

    protected java.util.Vector background

  The background color. Since shading is opaque, this is very rarely used.

### bBox

    protected java.util.Vector bBox

  Optional: A Vector specifying the clipping rectangle

### antiAlias

    protected boolean antiAlias

  Optional: A flag whether or not to filter the shading function to prevent aliasing artifacts. Default is false.

### domain

    protected java.util.Vector domain

  Optional for Type 1: Array of four numbers, xmin, xmax, ymin, ymax. Default is [0 1 0 1] Optional for Type 2: An array of two numbers between which the blend varies between start and end points. Default is 0, 1. Optional for Type 3: An array of two numbers between which the blend varies between start and end points. Default is 0, 1.

### matrix

    protected java.util.Vector matrix

  Optional for Type 1: A transformation matrix

### function

    protected PDFFunction function

  Required for Type 1, 2, and 3: The object of the color mapping function (usually type 2 or 3). Optional for Type 4,5,6, and 7: When it's nearly the same thing.

### coords

    protected java.util.Vector coords

  Required for Type 2: An Array of four numbers specifying the starting and ending coordinate pairs Required for Type 3: An Array of six numbers [x0,y0,r0,x1,y1,r1] specifying the centers and radii of the starting and ending circles.

### extend

    protected java.util.Vector extend

  Required for Type 2+3: An Array of two boolean values specifying whether to extend the start and end colors past the start and end points, respectively. Default is false, false.

### bitsPerCoordinate

    protected int bitsPerCoordinate

  Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each vertex coordinate. Allowed to be 1,2,4,8,12,16,24, or 32.

### bitsPerFlag

    protected int bitsPerFlag

  Required for Type 4,5,6, and 7: Specifies the number of bits used to represent the edge flag for each vertex. Allowed to be 2,4,or 8, while the Edge flag itself is allowed to be 0,1 or 2.

### decode

    protected java.util.Vector decode

  Required for Type 4,5,6, and 7: Array of Doubles which specifies how to decode coordinate and color component values. Each type has a differing number of decode array members, so check the spec. Page 303 in PDF Spec 1.3

### bitsPerComponent

    protected int bitsPerComponent

  Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each color coordinate. Allowed to be 1,2,4,8,12, or 16

### verticesPerRow

    protected int verticesPerRow

  Required for Type 5:The number of vertices in each "row" of the lattice; it must be greater than or equal to 2.

Constructor Detail

### PDFShading

    public PDFShading(int theNumber,
                      java.lang.String theShadingName,
                      int theShadingType,
                      ColorSpace theColorSpace,
                      java.util.Vector theBackground,
                      java.util.Vector theBBox,
                      boolean theAntiAlias,
                      java.util.Vector theDomain,
                      java.util.Vector theMatrix,
                      PDFFunction theFunction)

  Constructor for type function based shading
  Parameters:
    `theNumber` - The object number of this PDF object
    `theShadingName` - The name of the shading pattern. Can be anything without spaces. "Shading1" or "Sh1" are good examples.
    `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` - Vector 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 vector of Doubles specifying the domain.
    `theMatrix` - Vector 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(int theNumber,
                      java.lang.String theShadingName,
                      int theShadingType,
                      ColorSpace theColorSpace,
                      java.util.Vector theBackground,
                      java.util.Vector theBBox,
                      boolean theAntiAlias,
                      java.util.Vector theCoords,
                      java.util.Vector theDomain,
                      PDFFunction theFunction,
                      java.util.Vector theExtend)

  Constructor for Type 2 and 3
  Parameters:
    `theNumber` - The object number of this PDF object.
    `theShadingName` - The name of the shading pattern. Can be anything without spaces. "Shading1" or "Sh1" are good examples.
    `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` - Vector 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` - Vector of four (type 2) or 6 (type 3) Double
    `theDomain` - Vector of Doubles specifying the domain
    `theFunction` - the Stitching (PDFfunction type 3) function, even if it's stitching a single function
    `theExtend` - Vector 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(int theNumber,
                      java.lang.String theShadingName,
                      int theShadingType,
                      ColorSpace theColorSpace,
                      java.util.Vector theBackground,
                      java.util.Vector theBBox,
                      boolean theAntiAlias,
                      int theBitsPerCoordinate,
                      int theBitsPerComponent,
                      int theBitsPerFlag,
                      java.util.Vector theDecode,
                      PDFFunction theFunction)

  Constructor for Type 4,6, or 7
  Parameters:
    `theNumber` - The object number of this PDF object.
    `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.
    `theShadingName` - The name of the shading pattern. Can be anything without spaces. "Shading1" or "Sh1" are good examples.
    `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` - Vector 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` - Vector of Doubles see PDF 1.3 spec pages 303 to 312.
    `theFunction` - the PDFFunction

### PDFShading

    public PDFShading(int theNumber,
                      java.lang.String theShadingName,
                      int theShadingType,
                      ColorSpace theColorSpace,
                      java.util.Vector theBackground,
                      java.util.Vector theBBox,
                      boolean theAntiAlias,
                      int theBitsPerCoordinate,
                      int theBitsPerComponent,
                      java.util.Vector theDecode,
                      int theVerticesPerRow,
                      PDFFunction theFunction)

  Constructor for type 5
  Parameters:
    `theShadingType` - 5 for lattice-Form Gouraud shaded-triangle mesh
    `theShadingName` - The name of the shading pattern. Can be anything without spaces. "Shading1" or "Sh1" are good examples.
    `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` - Vector 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` - Vector 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
    `theNumber` - the object number of this PDF object.

Method Detail

### getName

    public java.lang.String getName()

### toPDF

    public byte[] 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 © 1999-2001 Apache Software Foundation. All Rights Reserved.