Package com.sun.pdfview.pattern
Class PDFShader
- java.lang.Object
-
- com.sun.pdfview.pattern.PDFShader
-
- Direct Known Subclasses:
ShaderType2
public abstract class PDFShader extends java.lang.Object
A PDFShader fills a given region with a shading, such as a gradient.
Shading Dictionaries (section 4.6)
A shading dictionary specifies details of a particular gradient fill, including the type of shading to be used, the geometry of the area to be shaded, and the geometry of the gradient fill. Various shading types are available, depending on the value of the dictionary’s ShadingType entry:- Function-based shadings (type 1) define the color of every point in the domain using a mathematical function (not necessarily smooth or continuous).
- Axial shadings (type 2) define a color blend along a line between two points, optionally extended beyond the boundary points by continuing the boundary colors.
- Radial shadings (type 3) define a blend between two circles, optionally extended beyond the boundary circles by continuing the boundary colors. This type of shading is commonly used to represent three-dimensional spheres and cones.
- Free-form Gouraud-shaded triangle meshes (type 4) define a common construct used by many three-dimensional applications to represent complex colored and shaded shapes. Vertices are specified in free-form geometry.
- Lattice-form Gouraud-shaded triangle meshes (type 5) are based on the same geometrical construct as type 4 but with vertices specified as a pseudorectangular lattice.
- Coons patch meshes (type 6) construct a shading from one or more color patches, each bounded by four cubic Bézier curves.
- Tensor-product patch meshes (type 7) are similar to type 6 but with additional control points in each patch, affording greater control over color mapping.
Table 4.28 shows the entries that all shading dictionaries share in common; entries specific to particular shading types are described in the relevant sections below.
-
-
Field Summary
Fields Modifier and Type Field Description static int
AXIAL_SHADING
private PDFPaint
background
the background colorprivate java.awt.geom.Rectangle2D
bbox
the bounding box of the patternprivate PDFColorSpace
colorSpace
the colorspacestatic int
COONS_PATCH_MESH_SHADING
static int
FREE_FORM_SHADING
static int
FUNCTION_SHADING
static int
LATTICE_SHADING
static int
RADIAL_SHADING
static int
TENSOR_PRODUCTS_MESH_SHADING
private int
type
the type of the shading (1 through 7)
-
Constructor Summary
Constructors Modifier Constructor Description protected
PDFShader(int type)
Creates a new instance of PDFShader
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PDFPaint
getBackground()
Get the background colorjava.awt.geom.Rectangle2D
getBBox()
Get the bounding boxPDFColorSpace
getColorSpace()
Get the color spaceabstract PDFPaint
getPaint()
Returns paint that represents the selected shaderstatic PDFShader
getShader(PDFObject shaderObj, java.util.Map resources)
Parse a pdf shader into a shader objectint
getType()
Get the typeabstract void
parse(PDFObject shareObj)
Parse the shader-specific dataprotected void
setBackground(PDFPaint background)
Set the background colorprotected void
setBBox(java.awt.geom.Rectangle2D bbox)
Set the bounding boxprotected void
setColorSpace(PDFColorSpace colorSpace)
Set the color space
-
-
-
Field Detail
-
FUNCTION_SHADING
public static final int FUNCTION_SHADING
- See Also:
- Constant Field Values
-
AXIAL_SHADING
public static final int AXIAL_SHADING
- See Also:
- Constant Field Values
-
RADIAL_SHADING
public static final int RADIAL_SHADING
- See Also:
- Constant Field Values
-
FREE_FORM_SHADING
public static final int FREE_FORM_SHADING
- See Also:
- Constant Field Values
-
LATTICE_SHADING
public static final int LATTICE_SHADING
- See Also:
- Constant Field Values
-
COONS_PATCH_MESH_SHADING
public static final int COONS_PATCH_MESH_SHADING
- See Also:
- Constant Field Values
-
TENSOR_PRODUCTS_MESH_SHADING
public static final int TENSOR_PRODUCTS_MESH_SHADING
- See Also:
- Constant Field Values
-
type
private int type
the type of the shading (1 through 7)
-
colorSpace
private PDFColorSpace colorSpace
the colorspace
-
background
private PDFPaint background
the background color
-
bbox
private java.awt.geom.Rectangle2D bbox
the bounding box of the pattern
-
-
Method Detail
-
getShader
public static PDFShader getShader(PDFObject shaderObj, java.util.Map resources) throws java.io.IOException
Parse a pdf shader into a shader object- Throws:
java.io.IOException
-
getType
public int getType()
Get the type
-
getColorSpace
public PDFColorSpace getColorSpace()
Get the color space
-
setColorSpace
protected void setColorSpace(PDFColorSpace colorSpace)
Set the color space
-
getBackground
public PDFPaint getBackground()
Get the background color
-
setBackground
protected void setBackground(PDFPaint background)
Set the background color
-
getBBox
public java.awt.geom.Rectangle2D getBBox()
Get the bounding box
-
setBBox
protected void setBBox(java.awt.geom.Rectangle2D bbox)
Set the bounding box
-
parse
public abstract void parse(PDFObject shareObj) throws java.io.IOException
Parse the shader-specific data- Throws:
java.io.IOException
-
getPaint
public abstract PDFPaint getPaint()
Returns paint that represents the selected shader
-
-