|
Flying Saucer Project Release ${app.version} | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xhtmlrenderer.simple.Graphics2DRenderer
public class Graphics2DRenderer
Graphics2DRenderer supports headless rendering of XHTML documents, and is useful for rendering documents directly to images.
Graphics2DRenderer supports the XHTMLPanel.setDocument(Document),
Container.layout(), and XHTMLPanel#render() methods from
XHTMLPanel, as well as easy-to-use static utility methods.
For example, to render a document in an image that is 600 pixels wide use the
renderToImageAutoSize(String,int,int) method like this:
BufferedImage img = Graphics2DRenderer.renderToImage( "test.xhtml", width);
| Constructor Summary | |
|---|---|
Graphics2DRenderer()
Creates a new renderer with no document specified. |
|
| Method Summary | |
|---|---|
java.awt.Rectangle |
getMinimumSize()
Returns the size image needed to render the document without anything going off the side. |
XHTMLPanel |
getPanel()
Returns the panel used internally for rendering. |
SharedContext |
getSharedContext()
Gets the SharedContext for layout and rendering. |
void |
layout(java.awt.Graphics2D g2,
java.awt.Dimension dim)
Lay out the document with the specified dimensions, without rendering. |
void |
render(java.awt.Graphics2D g2)
Renders the document to the given canvas. |
static java.awt.image.BufferedImage |
renderToImage(java.lang.String url,
int width,
int height)
A static utility method to automatically create an image from a document; the image supports transparency. |
static java.awt.image.BufferedImage |
renderToImage(java.lang.String url,
int width,
int height,
int bufferedImageType)
A static utility method to automatically create an image from a document. |
static java.awt.image.BufferedImage |
renderToImageAutoSize(java.lang.String url,
int width)
A static utility method to automatically create an image from a document, where height is determined based on document content. |
static java.awt.image.BufferedImage |
renderToImageAutoSize(java.lang.String url,
int width,
int bufferedImageType)
A static utility method to automatically create an image from a document, where height is determined based on document content. |
void |
setDocument(org.w3c.dom.Document doc,
java.lang.String base_url)
Sets the document to render, lays it out, and renders it. |
void |
setDocument(java.lang.String url)
Set the document to be rendered, lays it out, and renders it. |
void |
setSharedContext(SharedContext ctx)
Sets the SharedContext for rendering. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Graphics2DRenderer()
| Method Detail |
|---|
public void layout(java.awt.Graphics2D g2,
java.awt.Dimension dim)
g2 - the canvas to layout on.dim - dimensions of the container for the documentpublic void render(java.awt.Graphics2D g2)
g2 - Canvas to render to.public void setDocument(java.lang.String url)
url - the URL for the document to render.
public void setDocument(org.w3c.dom.Document doc,
java.lang.String base_url)
doc - the Document to renderbase_url - base URL for relative links within the Document.public void setSharedContext(SharedContext ctx)
ctx - The new renderingContext valuepublic java.awt.Rectangle getMinimumSize()
public SharedContext getSharedContext()
public XHTMLPanel getPanel()
public static java.awt.image.BufferedImage renderToImage(java.lang.String url,
int width,
int height)
renderToImage(String, int, int, int).
url - URL for the document to render.width - Width in pixels of the layout containerheight - Height in pixels of the layout container
public static java.awt.image.BufferedImage renderToImage(java.lang.String url,
int width,
int height,
int bufferedImageType)
url - URL for the document to render.width - Width in pixels of the layout containerheight - Height in pixels of the layout containerbufferedImageType - On of the pre-defined image types for a java.awt.image.BufferedImage, such
as TYPE_INT_ARGB or TYPE_INT_RGB.
public static java.awt.image.BufferedImage renderToImageAutoSize(java.lang.String url,
int width)
setDocument(String)
and then getMinimumSize(). The rendered image supports transparency.
url - java.net.URL for the document to render.width - Width in pixels of the layout container
public static java.awt.image.BufferedImage renderToImageAutoSize(java.lang.String url,
int width,
int bufferedImageType)
setDocument(String)
and then getMinimumSize().
url - java.net.URL for the document to render.width - Width in pixels of the layout containerbufferedImageType - On of the pre-defined image types for a java.awt.image.BufferedImage, such
as TYPE_INT_ARGB or TYPE_INT_RGB.
|
Flying Saucer Project Release ${app.version} | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||