|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.PDFPattern
public final class PDFPattern
Create a new "pattern" fill to paint with. A PDFPattern can be passed
into the PDFStyle.setFillColor(java.awt.Paint)
method to cause any shapes or
text painted with that style to be filled with the specified pattern.
Patterns can either be created by passing in a PDFCanvas
,
or by loading a named duotone or color pattern from a file (duotone
patterns require a background and foreground color to be specified,
whereas color patterns already include this information).
Several patterns are supplied with the default distribution. They include
Brick | A "brick-wall" pattern |
---|---|
Check | A chequered-square pattern |
Grid | A grid pattern |
Spot | A spot pattern, like the half-toning pattern used in newspapers |
Star | A 5-pointed star pattern |
Stripexxx | A stripe pattern. xxx is the angle of the strripes - eg. "000" for vertical stripes, "045" or "060" for diagonal and so on |
Users may create their own patterns and store them in a file for use by the library. The
file is a standard PropertyResourceBundle
file, with the following attributes
(all mandatory):
type
must be the word "color" for color patterns or "duotone" for duotone patternswidth
is the width of the pattern before it repeats, as a floatheight
is the height of the pattern before it repeats, as a floataction
is the raw PDF graphics state instructions to write to the stream. So, for example, "1 1 1 rg 0 0 300 200 re f 1 0 0 rg 0 100 300 200 re f
" would draw the Indonesian flag (it's a simple example). Duotone patterns should not include any color commands, whereas color patterns must set the fill and/or line colors before they're used.
PDFPattern pattern = new PDFPattern("com.yourcompany.yourpattern", 0, 0, 300, 200);
Field Summary |
---|
Fields inherited from interface java.awt.Transparency |
---|
BITMASK, OPAQUE, TRANSLUCENT |
Constructor Summary | |
---|---|
PDFPattern(PDFCanvas canvas,
float x1,
float y1,
float x2,
float y2)
Create a pattern from the specified PDFCanvas . |
|
PDFPattern(String pattern,
float x1,
float y1,
float x2,
float y2,
Color fg,
Color bg)
Create a PDFPattern from a known, named duotone pattern. |
Method Summary | |
---|---|
PDFPattern |
brightnessClone(float delta,
float min,
float max)
|
PaintContext |
createContext(ColorModel cm,
Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform xform,
RenderingHints hints)
Required as part of the Paint contract. |
Paint |
getShaded(float delta,
float min,
float max)
This method is required when painting patterns using the graph library. |
int |
getTransparency()
Required as part of the Paint contract. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PDFPattern(PDFCanvas canvas, float x1, float y1, float x2, float y2)
PDFCanvas
. The
two parameters specify where on the page to start tiling the
canvas from.
canvas
- the PDFCanvas to use as the source of the patternx1
- the left edge of the patterns reference tile on the pagey1
- the bottom edge of the patterns reference tile on the pagex2
- the left edge of the patterns reference tile on the pagey2
- the bottom edge of the patterns reference tile on the pagepublic PDFPattern(String pattern, float x1, float y1, float x2, float y2, Color fg, Color bg) throws MissingResourceException
Create a PDFPattern from a known, named duotone pattern. The pattern will
be resized so that the rectangle (x1, y1, x2, y2
) on the page
will contain one complete copy of the pattern - drawing it outside this
rectangle will tile it appropriately. For simpler patterns that don't
have to be positioned exactly, often x1
and y1
are 0, and x2
and y2
specify your choice for the
width and height of the pattern.
Patterns created with this constructor are two-color or "duotone" patterns. A background and foreground color must be supplied, which may be translucent
pattern
- the name of the pattern to load - either one of the predefined patterns (see above), or the fully-qualified name of a PropertyResourceBundle
to load.x1
- the left edge of the patterns reference tile on the pagey1
- the bottom edge of the patterns reference tile on the pagex2
- the right edge of the patterns reference tile on the pagey2
- the top edge of the patterns reference tile on the pagefg
- the foreground color to usebg
- the background color to use
MissingResourceException
- if the specified pattern cannot be found.Method Detail |
---|
public int getTransparency()
Paint
contract. Returns Transparency.OPAQUE
.
getTransparency
in interface Transparency
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
Paint
contract. This method is only needed
when drawing a Paint to an AWT canvas, so it's not implemented and throws
an error if called.
createContext
in interface Paint
public Paint getShaded(float delta, float min, float max)
public PDFPattern brightnessClone(float delta, float min, float max)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |