Package org.apache.xmlgraphics.java2d.ps
Class AbstractPSDocumentGraphics2D
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
org.apache.xmlgraphics.java2d.AbstractGraphics2D
org.apache.xmlgraphics.java2d.ps.PSGraphics2D
org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
EPSDocumentGraphics2D
,PSDocumentGraphics2D
This class is a wrapper for the PSGraphics2D that
is used to create a full document around the PostScript rendering from
PSGraphics2D.
- Version:
- $Id$
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected Shape
protected AffineTransform
protected int
protected boolean
protected float
protected float
protected int
protected static final Integer
Fields inherited from class org.apache.xmlgraphics.java2d.ps.PSGraphics2D
clippingDisabled, currentColour, customTextHandler, fallbackTextHandler, gen, pathHashCache, rootG2D, startCache
Fields inherited from class org.apache.xmlgraphics.java2d.AbstractGraphics2D
gc, inPossibleRecursion, textAsShapes
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractPSDocumentGraphics2D
(boolean textAsShapes, OutputStream stream, int width, int height) Create a new AbstractPSDocumentGraphics2D.This constructor supports the create method -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Closes the current page.void
finish()
The rendering process has finished.int
Returns the number of pages generated so far.void
nextPage()
Closes the current page and prepares to start a new one.void
This method is used by AbstractPSDocumentGraphics2D to prepare a new page if necessary.void
setBackgroundColor
(Color col) Set the background of the PostScript document.void
setupDocument
(OutputStream stream, int width, int height) Setup the document.void
setViewportDimension
(float w, float h) Set the dimensions of the document that will be drawn.protected void
Starts a new page.protected abstract void
Writes the file header.protected abstract void
Writes the page header for a page.protected abstract void
Writes the page trailer for a page.protected void
Writes the ProcSets ending up in the prolog to the PostScript file.Methods inherited from class org.apache.xmlgraphics.java2d.ps.PSGraphics2D
applyPaint, applyStroke, applyStroke, buildBufferedImage, copyArea, create, disableClipping, dispose, doDrawing, draw, drawImage, drawImage, drawImage, drawImage, drawRenderableImage, drawRenderedImage, drawString, establishColor, fill, getCustomTextHandler, getDeviceConfiguration, getFallbackTextHandler, getFontMetrics, getPSGenerator, handleIOException, processPathIterator, processPathIteratorCached, processPathIteratorToString, processShape, setCustomTextHandler, setGraphicContext, setPSGenerator, setXORMode, shouldBeClipped, writeClip
Methods inherited from class org.apache.xmlgraphics.java2d.AbstractGraphics2D
addRenderingHints, clearRect, clip, clipRect, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, drawString, drawString, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, getBackground, getClip, getClipBounds, getColor, getComposite, getFont, getFontRenderContext, getGraphicContext, getPaint, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, rotate, rotate, scale, setBackground, setClip, setClip, setColor, setComposite, setFont, setPaint, setPaintMode, setRenderingHint, setRenderingHints, setStroke, setTransform, shear, transform, translate, translate
Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
Methods inherited from class java.awt.Graphics
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
-
Field Details
-
ZERO
-
width
protected int width -
height
protected int height -
viewportWidth
protected float viewportWidth -
viewportHeight
protected float viewportHeight -
pagecount
protected int pagecount -
pagePending
protected boolean pagePending -
initialClip
-
initialTransform
-
-
Constructor Details
-
AbstractPSDocumentGraphics2D
public AbstractPSDocumentGraphics2D(boolean textAsShapes, OutputStream stream, int width, int height) throws IOException Create a new AbstractPSDocumentGraphics2D. This is used to create a new PostScript document of the given height and width. The resulting document is written to the stream after rendering.- Parameters:
textAsShapes
- set this to true so that text will be rendered using curves and not the font.stream
- the stream that the final document should be written to.width
- the width of the documentheight
- the height of the document- Throws:
IOException
- an io exception if there is a problem writing to the output stream
-
AbstractPSDocumentGraphics2D
This constructor supports the create method- Parameters:
g
- the PostScript document graphics to make a copy of
-
-
Method Details
-
setupDocument
Setup the document.- Parameters:
stream
- the output stream to write the documentwidth
- the width of the pageheight
- the height of the page- Throws:
IOException
- an io exception if there is a problem writing to the output stream
-
writeFileHeader
Writes the file header.- Throws:
IOException
- if an I/O error occurs
-
setViewportDimension
Set the dimensions of the document that will be drawn. This is useful if the dimensions of the document are different from the PostScript document that is to be created. The result is scaled so that the document fits correctly inside the PostScript document.- Parameters:
w
- the width of the pageh
- the height of the page- Throws:
IOException
- in case of an I/O problem
-
setBackgroundColor
Set the background of the PostScript document. This is used to set the background for the PostScript document Rather than leaving it as the default white.- Parameters:
col
- the background colour to fill
-
getPageCount
public int getPageCount()Returns the number of pages generated so far.- Returns:
- the number of pages
-
nextPage
Closes the current page and prepares to start a new one.- Throws:
IOException
- if an I/O error occurs
-
closePage
Closes the current page.- Throws:
IOException
- if an I/O error occurs
-
writePageHeader
Writes the page header for a page.- Throws:
IOException
- In case an I/O error occurs
-
writePageTrailer
Writes the page trailer for a page.- Throws:
IOException
- In case an I/O error occurs
-
writeProcSets
Writes the ProcSets ending up in the prolog to the PostScript file. Override to add your own ProcSets if so desired.- Throws:
IOException
- In case an I/O error occurs
-
preparePainting
public void preparePainting()This method is used by AbstractPSDocumentGraphics2D to prepare a new page if necessary.- Overrides:
preparePainting
in classPSGraphics2D
-
startPage
Starts a new page.- Throws:
IOException
- if an I/O error occurs
-
finish
The rendering process has finished. This should be called after the rendering has completed as there is no other indication it is complete. This will then write the results to the output stream.- Throws:
IOException
- an io exception if there is a problem writing to the output stream
-