Class SVGInfo


  • public class SVGInfo
    extends java.lang.Object
    Information about the SVG and its contents for HTML.

    To handle class definition renaming to make the SVG class names unique when the SVG is inlined in the HTML, the jStyleParser is used.

    Author:
    Christopher Mindus
    • Field Detail

      • width

        public final double width
        The width of the SVG.
      • height

        public final double height
        The height of the SVG.
    • Method Detail

      • fromDefinition

        public static SVGInfo fromDefinition​(java.io.File file)
        Creates the SVG inform from the SVG definition.
        Parameters:
        file - The file.
        Returns:
        The SVG information if complete, null if not defined properly.
      • fromString

        public static SVGInfo fromString​(java.lang.String string)
                                  throws java.io.IOException,
                                         org.xml.sax.SAXException
        Creates the SVG information from a String, used typically for iizi SVG URN's.
        Parameters:
        string - The string containing the SVG definition.
        Returns:
        The SVGInfo instance.
        Throws:
        java.io.IOException - For read errors.
        org.xml.sax.SAXException - For SAX parsing errors.
      • fromDefinition

        public static SVGInfo fromDefinition​(SVGDefinition def)
        Creates the SVG inform from the SVG definition.
        Parameters:
        def - The SVG definition.
        Returns:
        The SVG information if complete, null if not defined properly.
      • updateFromDefinition

        public void updateFromDefinition​(SVGDefinition def)
        Updates the requested size from the definition.
        Parameters:
        def - The definition.
      • setScale

        public void setScale​(int cx,
                             int cy)
        Sets the requested scaled width and height. If any of cx or cy is zero or smaller, the scaled size is reset to original size.
        Parameters:
        cx - The requested width.
        cy - The requested height.
      • getXMLString

        public java.lang.String getXMLString()
        Gets the XML string.
        Returns:
        The XML string that can be used to display the SVG as a preview in the Designer, or null for failures.
      • getWidth

        public double getWidth()
        Gets the width of the SVG.
        Returns:
        The width.
      • getHeight

        public double getHeight()
        Gets the width of the SVG.
        Returns:
        The width.
      • getSVGForHTML

        public java.lang.String getSVGForHTML()
        Returns the SVG used in the HTML.
        Returns:
        The SVG string for HTML, null for failures.
      • hasViewBox

        public boolean hasViewBox()
        Returns the a viewbox is present in XML SVG.
        Returns:
        true if present, false otherwise.
      • getKStringSVG

        public java.lang.String getKStringSVG​(ClientImageData cid,
                                              KStringHTMLImageTag source,
                                              IKStringInfoProvider provider)
        Appends the SVG definition to a KString tag.
        Parameters:
        cid - The client image data instance.
        source - The source KString tag.
        provider - The information provider.