public class BoxRenderer
extends java.lang.Object
Renders an XML files, formatted with CSS, as an Box. Input is a document in the form of file or URL, and output is the root of the Box model. A BoxRenderer is not intended to be re-used for multiple document sources; just create new BoxRenderers for each one you need. BoxRenderer is not thread-safe. Standard usage pattern is
File xhtml = ... BoxRenderer rend = new BoxRenderer(xhtml); Box rootBox = rend.render();
The document is not loaded, and layout and render don't take place, until render()
is called.
Subsequent calls to render()
don't result in a reload; create a new BoxRenderer instance to do so.
As with RootPanel
, you can access the
SharedContext
instance that will be used by this renderer and change settings
to control the rendering process; use getSharedContext()
.
Not thread-safe.
ITextRenderer
Constructor and Description |
---|
BoxRenderer(java.io.File file,
int width)
Creates a new instance for a given File.
|
BoxRenderer(java.io.File file,
int width,
int height)
Creates a new instance for a given File.
|
BoxRenderer(java.lang.String url,
int width)
Renderer for a given URL (which is also used as the base) and a specified width; height is calculated
automatically.
|
BoxRenderer(java.lang.String url,
int width,
int height)
Renderer for a given URL and a specified width; height is calculated
automatically.
|
BoxRenderer(java.lang.String url,
java.lang.String baseurl,
int width)
Renderer for a given URL and a specified width; height is calculated
automatically.
|
BoxRenderer(java.lang.String url,
java.lang.String baseUrl,
int width,
int height)
Creates a new instance for a given URL.
|
Modifier and Type | Method and Description |
---|---|
LayoutContext |
getLayoutContext()
Returns the LayoutContext to be used by renderer.
|
SharedContext |
getSharedContext()
Returns the SharedContext to be used by renderer.
|
Box |
render()
Renders the XML document if necessary and returns the root Box.
|
void |
setRenderingHints(java.util.Map hints)
Sets the rendering hints to apply to the Graphics2D instance used by the renderer; see
Graphics2D.setRenderingHints(java.util.Map) . |
public BoxRenderer(java.lang.String url, java.lang.String baseUrl, int width, int height)
render()
is called for
the first time.url
- The location of the document to be rendered.baseUrl
- The base url for the document, against which relative paths are resolved.width
- Target width, in pixels, for the image; required to provide horizontal bounds for the layout.public BoxRenderer(java.io.File file, int width, int height) throws java.io.IOException
render()
is called for
the first time.file
- The file to be rendered.width
- Target width, in pixels, for the image; required to provide horizontal bounds for the layout.height
- Target height, in pixels, for the imagejava.io.IOException
public BoxRenderer(java.io.File file, int width) throws java.io.IOException
render()
is called for
the first time.file
- The file to be rendered.width
- Target width, in pixels, for the image; required to provide horizontal bounds for the layout.
Heght is calculated based on contentjava.io.IOException
public BoxRenderer(java.lang.String url, int width)
url
- The location of the document to be rendered.width
- Target width, in pixels, for the image; required to provide horizontal bounds for the layout.
Heght is calculated based on contentpublic BoxRenderer(java.lang.String url, java.lang.String baseurl, int width)
url
- The location of the document to be rendered.baseurl
- The base url for the document, against which relative paths are resolved.width
- Target width, in pixels, for the image; required to provide horizontal bounds for the layout.
Heght is calculated based on contentpublic BoxRenderer(java.lang.String url, int width, int height)
url
- The location of the document to be rendered.width
- Target width, in pixels, for the image; required to provide horizontal bounds for the layout.height
- Target height, in pixels, for the imagepublic void setRenderingHints(java.util.Map hints)
Graphics2D.setRenderingHints(java.util.Map)
. The Map need not specify values for all
properties; any settings in this map will be applied as override to the default settings, and will
not replace the entire Map for the Graphics2D instance.hints
- values to override in default rendering hints for Graphics2D we are rendering topublic SharedContext getSharedContext()
render()
is called to tune the rendering process.public LayoutContext getLayoutContext()
render()
is called to tune the rendering process.public Box render()