Package org.apache.fop.render
Class AbstractGenericSVGHandler
java.lang.Object
org.apache.fop.render.AbstractGenericSVGHandler
- All Implemented Interfaces:
RendererContextConstants
,XMLHandler
- Direct Known Subclasses:
AFPSVGHandler
,Java2DSVGHandler
,PCLSVGHandler
,PDFSVGHandler
,PSSVGHandler
public abstract class AbstractGenericSVGHandler
extends Object
implements XMLHandler, RendererContextConstants
Generic XML handler for SVG. Uses Apache Batik for SVG processing and simply paints to
a Graphics2DAdapter and thus ultimatively to Graphics2D interface that is presented.
To use this class, subclass it and implement the missing methods (supportsRenderer, for example).
-
Field Summary
Fields inherited from interface org.apache.fop.render.RendererContextConstants
FOREIGN_ATTRIBUTES, HANDLER_CONFIGURATION, HEIGHT, OUTPUT_STREAM, PAGE_VIEWPORT, WIDTH, XPOS, YPOS
Fields inherited from interface org.apache.fop.render.XMLHandler
HANDLE_ALL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.batik.gvt.GraphicsNode
buildGraphicsNode
(FOUserAgent userAgent, org.apache.batik.bridge.BridgeContext ctx, Document doc) Builds the GVT root.protected org.apache.xmlgraphics.java2d.Graphics2DImagePainter
createGraphics2DImagePainter
(org.apache.batik.gvt.GraphicsNode root, org.apache.batik.bridge.BridgeContext ctx, Dimension imageSize) Creates a graphics 2D image painter implementationprotected String
getDocumentURI
(Document doc) Gets the document URI from a Document instance if possible.protected Dimension
getImageSize
(RendererContext.RendererContextWrapper wrappedContext) Returns the image sizevoid
handleXML
(RendererContext context, Document doc, String ns) Handle an external xml document inside a Foreign Object Area.protected void
renderSVGDocument
(RendererContext rendererContext, Document doc) Render the SVG document.protected void
updateRendererContext
(RendererContext context) Override this method to update the renderer context if it needs special settings for certain conditions.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.fop.render.XMLHandler
supportsRenderer
-
Constructor Details
-
AbstractGenericSVGHandler
public AbstractGenericSVGHandler()
-
-
Method Details
-
handleXML
Handle an external xml document inside a Foreign Object Area.
This may throw an exception if for some reason it cannot be handled. The caller is expected to deal with this exception.
The implementation may convert the XML document internally to another XML dialect (SVG, for example) and call renderXML() on the AbstractRenderer again (which can be retrieved through the RendererContext).
- Specified by:
handleXML
in interfaceXMLHandler
- Parameters:
context
- The RendererContext (contains the user agent)doc
- A DOM containing the foreign object to be processedns
- The Namespace of the foreign object- Throws:
Exception
- If an error occurs during processing.
-
createGraphics2DImagePainter
protected org.apache.xmlgraphics.java2d.Graphics2DImagePainter createGraphics2DImagePainter(org.apache.batik.gvt.GraphicsNode root, org.apache.batik.bridge.BridgeContext ctx, Dimension imageSize) Creates a graphics 2D image painter implementation- Parameters:
root
- the batik graphics node rootctx
- the batik bridge contextimageSize
- the image size- Returns:
- a new graphics 2D image painter implementation
-
buildGraphicsNode
protected org.apache.batik.gvt.GraphicsNode buildGraphicsNode(FOUserAgent userAgent, org.apache.batik.bridge.BridgeContext ctx, Document doc) Builds the GVT root.- Parameters:
userAgent
- the user agentctx
- the batik bridge contextdoc
- the document- Returns:
- a built GVT root tree
-
getImageSize
Returns the image size- Parameters:
wrappedContext
- renderer context wrapper- Returns:
- the image size
-
renderSVGDocument
Render the SVG document.- Parameters:
rendererContext
- the renderer contextdoc
- the SVG document- Throws:
IOException
- In case of an I/O error while painting the image
-
getDocumentURI
Gets the document URI from a Document instance if possible.- Parameters:
doc
- the Document- Returns:
- the URI or null
-
updateRendererContext
Override this method to update the renderer context if it needs special settings for certain conditions.- Parameters:
context
- the renderer context
-
getNamespace
- Specified by:
getNamespace
in interfaceXMLHandler
- Returns:
- the XML namespace for the XML dialect this XMLHandler supports, null if all XML content is handled by this instance.
-