Home
Categories
Dictionnary
Download
Project Details
Changes Log
FAQ
License

SVG driver


    1  Dependencies
    2  SVGDriverUtils Utility class
       2.1  Adding additional processing to Nodes
       2.2  Adding a title to the SVG document
    3  Usage example

The SVG driver allows to serialize JavaFX content as a SVG file.

Dependencies

You should use the jfxConverter-svg.jar in addition to the jfxConverter.jar. Note that the PowerPoint driver uses the Apache Batik library.

SVGDriverUtils Utility class

The SVGDriverUtils encapsulate the usage of the converter. for example:

      SVGDriverUtils svgUtils = new SVGDriverUtils();
      svgUtils.convert(node, file);      

Adding additional processing to Nodes

To add additional processing to Nodes:

      SVGDriverUtils pptUtils = new SVGDriverUtils();
      svgUtils.convert(node, file, true);      

Adding a title to the SVG document

A title will be added to the output SVG document by default, but it is possible to specify it by using:
      SVGDriverUtils svgUtils = new SVGDriverUtils();
      svgUtils.convert(node, title, file);      

or:

      SVGDriverUtils svgUtils = new SVGDriverUtils();
      svgUtils.convert(node, title, file, true);      

Usage example

      // create the Scene graph
      JFXInvoker invoker = JFXInvoker.getInstance();
      invoker.invokeBlocking(new Runnable() {
        @Override
        public void run() {
          StackPane root = new StackPane();
          Scene scene = new Scene(root, 300, 250);
          Stage stage = new Stage();
          stage.setScene(scene);
          start(stage);
      
          Line line = new Line(0, 0, 200, 200);
          line.setStroke(Color.RED);     
         
          root.getChildren().add(line);
          primaryStage.show();
        }
      });
      
      // perform the conversion
      SVGDriverUtils svgUtils = new SVGDriverUtils();
      svgUtils.convert(node, file);


Categories: drivers

Copyright 2016-2018 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence