Module xaos.ui

Class SVG

  • All Implemented Interfaces:
    Styleable, EventTarget

    public class SVG
    extends Group
    SVGContent represents SVG content.

    SVGContent is a Group, therefore is able to be added to any scene graph:

     URL url = ...;
     SVG svg = SVG.load(url);
    
     container.getChildren.add(svg);

    The getNode(String) method returns the Node object represented by the given identifier. When loading the following SVG file, a Rectangle object is returned by getNode(String) method for the "rect" identifier.

     <?xml version="1.0" encoding="iso-8859-1"?>
     <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
     <svg version="1.1" id="layer_1"
                        xmlns="http://www.w3.org/2000/svg"
                        xmlns:xlink="http://www.w3.org/1999/xlink"
                        x="0px" y="0px" width="300px" height="200px"
                        viewBox="0 0 300 200"
                        style="enable-background:new 0 0 300 200;"
                        xml:space="preserve">
       <rect id="rect"
             x="100" y="50"
             width="100" height="80"
             style="fill:#FFFFFF; stroke:#000000;"/>
     </svg>

    The getGroup(String) method returns the Group object represented by the given identifier. When loading the following SVG file, a Group object is returned by getGroup(String) method for the "group" identifier.

     <?xml version="1.0" encoding="iso-8859-1"?>
     <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
     <svg version="1.1" xmlns="http://www.w3.org/2000/svg"
                        xmlns:xlink="http://www.w3.org/1999/xlink"
                        x="0px" y="0px" width="200px" height="200px" viewBox="0 0 200 200"
                        style="enable-background:new 0 0 200 200;" xml:space="preserve">
       <g id="group">
         <circle style="fill:#FF0000;stroke:#000000;" cx="100" cy="100" r="50"/>
       </g>
     </svg>

    Note: There are many SVG elements not yet (fully) supported.

    Author:
    claudio.rosati@esss.se
    See Also:
    SVGLoader