






































|
The goal of the JSVGCanvas is to provide a Swing component that can
used to display SVG documents. With the JSVGCanvas , you can easily
display an SVG document (from a URI or a DOM tree) and manipulate it - such as
rotating, zooming, panning, selecting text, or activating hyperlinks. First this
document explains how to create a JSVGCanvas and integrate it in a Swing
application. Then, it descibes some advanced features such as the listener
mecanism used to track all events that occured while displaying or manipulating
an SVG document.
|
Each time you set a URI or a SVG DOM tree to the JSVGCanvas (using the
setURI or setSVGDocument method), the specified
document is first parsed (in case of a URI), built, and finally rendered. The
proper way to be notified of those different phases is to implement a listener
and attach it to the component. There are three types of listener:
SVGDocumentLoaderListener -
This listener provides a set of methods that can be used to track
SVGDocumentLoaderEvent events. It describes the loading phase:
contructing an SVG DOM tree using an SVG file.
GVTTreeBuilderListener -
This listener provides a set of methods that can be used to track
GVTTreeBuilderEvent events. It describes the building phase:
contructing a GVT (Graphics Vector Toolkit) tree using an SVG DOM tree. The GVT
tree will then be used to render the document.
GVTTreeRendererListener -
This listener provides a set of methods that can be used to track
GVTTreeRendererEvent events. It describes the rendering phase:
constructing an image using a GVT tree.
Those listeners give a complete description of the different steps of those
three phases (including error states). Adapter classes are available to ease the
creation of new listener implementation.
You can assume that the JSVGCanvas has completed its job (parsing, building and
rendering) when the gvtRenderingCompleted method call is called and
following a setURI or a setSVGDocument method call.
|
The JSVGCanvas provides a set of build-in interactors that let the users
manipulate the displayed document - including zoom, pan and rotate. Interactors
are dedicated to user inputs. If you want to add new behaviors to the
JSVGCanvas, you can implement the Interactor interface. Then, you
can register this new interactor to the component using the
getInteractors().add method.
|
|
|