Home
Categories
Dictionnary
Download
Project Details
Changes Log
FAQ
License

Testing the usage of the converter


    1  Usage
    2  Script definition
    3  Script example
       3.1  Simple example
       3.2  StyleSheet example

It is possible to test the usage of the converter with a script setting the Node structure.

The associated application is available as the org.jfxonverter.app.JFXConverterApp. Note that is is only available in the IDE (the associated code is not distributed in the jfxConverter.jar library).

Usage

The application allows to execute a Groovy script defining a Node structure and convert the structure to a SVG, EPS, or PPT image. Starting the application will present the following window:





To use this application: Note that the "Convert" button is only available after the script file has been chosen:


Script definition

The script must have a public Node getContent() method. A context object is available giving access to the following methods:

Script example

Simple example

The following script creates a rectangle and a line:
      import javafx.scene.*;
      import javafx.scene.layout.*;
      import javafx.scene.shape.*;
      import javafx.scene.paint.*;

      public Node getContent() {
      Pane pane = new Pane();
      Rectangle rect = new Rectangle(0, 0, 200, 200);
      rect.setFill(Color.YELLOW);
      rect.setStyle("-fx-fill: green; -fx-rotate: 45;");
      Line line = new Line(0, 0, 200, 200);
      line.setStroke(Color.RED);
      pane.getChildren().add(rect);
      pane.getChildren().add(line);
      return pane;
      }      

StyleSheet example

The following example returns a Pane and specifies the StyleSheet of the Pane defined in a CSS file in the same directory as the script file:

      import javafx.scene.*;
      import javafx.scene.layout.*;
      import javafx.scene.shape.*;
      import javafx.scene.paint.*;

      public Node getContent() {
      Pane pane = new Pane();
      String path = context.getCSS("pane.css");
      pane.getStylesheets().add(path);
      pane.getStyleClass().add("paneStyle");
      return pane;
      }      


Categories: general

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