public class PDFGraphics2D extends VectorGraphics2D
Graphics2D
implementation that saves all operations to a string
in the Portable Document Format (PDF).VectorGraphics2D.FontRendering
Modifier and Type | Field and Description |
---|---|
protected static String |
FONT_RESOURCE_PREFIX
Prefix string for PDF font resource ids.
|
protected static String |
IMAGE_RESOURCE_PREFIX
Prefix string for PDF image resource ids.
|
protected static double |
MM_IN_UNITS
Constant to convert values from millimeters to PostScript®/PDF units (1/72th inch).
|
protected static String |
TRANSPARENCY_RESOURCE_PREFIX
Prefix string for PDF transparency resource ids.
|
Constructor and Description |
---|
PDFGraphics2D(double x,
double y,
double width,
double height)
Constructor that initializes a new
PDFGraphics2D instance. |
Modifier and Type | Method and Description |
---|---|
byte[] |
getBytes()
Encodes the painted data into a sequence of bytes.
|
protected String |
getFontResource(Font font)
Returns the resource describing the specified font.
|
protected String |
getFooter()
Returns a string of the footer to end a document.
|
protected String |
getImageResource(BufferedImage bufferedImg)
Returns the resource for the specified image data.
|
protected String |
getTransparencyResource(double a)
Returns the resource for the specified transparency level.
|
protected int |
peekObjId()
Returns the next PDF object id without incrementing.
|
void |
setClip(Shape clip) |
void |
setColor(Color c) |
void |
setStroke(Stroke s) |
String |
toString() |
protected void |
writeClosingDraw(Shape s)
Utility method for writing a tag closing fragment for drawing
operations.
|
protected void |
writeClosingFill(Shape s)
Utility method for writing a tag closing fragment for filling
operations.
|
protected void |
writeDict(Object... strs)
Write a PDF dictionary from the specified collection of objects.
|
protected void |
writeHeader()
Write the header to start a new document.
|
protected void |
writeImage(Image img,
int imgWidth,
int imgHeight,
double x,
double y,
double width,
double height)
Write the specified image to the document.
|
protected int |
writeObj(Object... strs)
Write a collection of elements to the document stream as PDF object.
|
protected void |
writeShape(Shape s)
Utility method for writing an arbitrary shape to.
|
protected void |
writeString(String str,
double x,
double y)
Write a text string to the document at a specified position.
|
addRenderingHints, clearRect, clip, clipRect, copyArea, create, dispose, draw, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRenderableImage, drawRenderedImage, drawRoundRect, drawString, drawString, drawString, drawString, fill, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, getBackground, getBounds, getClip, getClipBounds, getColor, getComposite, getDeviceConfiguration, getFont, getFontMetrics, getFontRenderContext, getFontRendering, getPaint, getRasteredImageSizeMaximum, getRenderingHint, getRenderingHints, getResolution, getStroke, getTransform, hit, isDistorted, isTransformed, rotate, rotate, scale, setAffineTransform, setBackground, setClip, setComposite, setFont, setFontRendering, setPaint, setPaintMode, setRasteredImageSizeMaximum, setRenderingHint, setRenderingHints, setResolution, setTransform, setXORMode, shear, size, transform, translate, translate, write, writeln
draw3DRect, fill3DRect
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip
protected static final String FONT_RESOURCE_PREFIX
protected static final String IMAGE_RESOURCE_PREFIX
protected static final String TRANSPARENCY_RESOURCE_PREFIX
protected static final double MM_IN_UNITS
public PDFGraphics2D(double x, double y, double width, double height)
PDFGraphics2D
instance.
The document dimension must be specified as parameters.protected void writeString(String str, double x, double y)
VectorGraphics2D
writeString
in class VectorGraphics2D
str
- Text to be rendered.x
- Horizontal position in document units.y
- Vertical position in document units.public void setStroke(Stroke s)
setStroke
in class VectorGraphics2D
protected void writeImage(Image img, int imgWidth, int imgHeight, double x, double y, double width, double height)
VectorGraphics2D
writeImage
in class VectorGraphics2D
img
- Image to be rendered.imgWidth
- Number of pixels in horizontal direction.imgHeight
- Number of pixels in vertical directionx
- Horizontal position in document units where the
upper left corner of the image should be placed.y
- Vertical position in document units where the
upper left corner of the image should be placed.width
- Width of the image in document units.height
- Height of the image in document units.public void setColor(Color c)
setColor
in class VectorGraphics2D
public void setClip(Shape clip)
setClip
in class VectorGraphics2D
protected void writeHeader()
VectorGraphics2D
writeHeader
in class VectorGraphics2D
protected void writeDict(Object... strs)
strs
- Objects to be written to dictionaryprotected int writeObj(Object... strs)
strs
- Objects to be written to the document stream.protected int peekObjId()
protected String getTransparencyResource(double a)
a
- Transparency level.protected String getImageResource(BufferedImage bufferedImg)
bufferedImg
- Image object with data.protected String getFontResource(Font font)
font
- Font to be described.protected void writeClosingDraw(Shape s)
writeClosingDraw
in class VectorGraphics2D
s
- Shape that should be drawn.protected void writeClosingFill(Shape s)
writeClosingFill
in class VectorGraphics2D
s
- Shape that should be filled.protected void writeShape(Shape s)
writeShape
in class VectorGraphics2D
s
- Shape to be written.protected String getFooter()
VectorGraphics2D
getFooter
in class VectorGraphics2D
public String toString()
toString
in class VectorGraphics2D
public byte[] getBytes()
VectorGraphics2D
getBytes
in class VectorGraphics2D
Copyright © 2010-2013. All Rights Reserved.