This page is from the outdated yFiles for Java 2.13 documentation. You can find the most up-to-date documentation for all yFiles products on the yFiles documentation overview page.
Please see the following links for more information about the yFiles product family of diagramming programming libraries and corresponding yFiles products for modern web apps, for cross-platform Java(FX) applications, and for applications for the Microsoft .NET environment.
Class
SVGIOHandler from the extension
package provides the yFiles library with export support for the SVG file
format.
It is a direct subclass of abstract class
IOHandler
from package
y.io
of the yFiles
library, see also Figure 11.1, “SVG output handler class hierarchy”.
The code fragment in Example 11.1, “Instantiating a SVGIOHandler” shows how to instantiate
and use a SVGIOHandler to export the content of a given
Graph2DView to a SVG-encoded file.
Class SVGZIOHandler
can be used
in a similar manner to write Zip-compressed SVG files which are up to 50 times
smaller than their uncompressed counterparts.
Example 11.1. Instantiating a SVGIOHandler
public void exportSVG(Graph2DView view) { // Instantiate a SVG output handler and export the view's content. try { IOHandler ioh = new SVGIOHandler(); double tmpPDT = view.getPaintDetailThreshold(); view.setPaintDetailThreshold(0.0); ioh.write(view.getGraph2D(), "MySVG.svg"); view.setPaintDetailThreshold(tmpPDT); } catch (IOException ioEx) { // Something went wrong. Complain. } }
Besides exporting the content of a Graph2DView to SVG, the ySVG extension
package also enables to directly use SVG content for the representation of a
graph's nodes.
Either of the classes
SVGNodeRealizer or
SVGPainter
can be used to
this end.
Both use an SVGModel
that
holds the actual SVG content:
Copyright ©2004-2016, yWorks GmbH. All rights reserved. |