Class SVGInfo

java.lang.Object
com.iizix.prop.image.SVGInfo

public class SVGInfo extends 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. New code from tokyo.northside:jstyleparser:4.1.4, source on https://codeberg.org/miurahr/jstyleparser.

Author:
Christopher Mindus
  • Field Details

    • width

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

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

    • fromDefinition

      public static SVGInfo fromDefinition(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(String string) throws IOException, 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:
      IOException - For read errors.
      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 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 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 String getKStringSVG(KStringHTMLImageTag source)
      Returns the SVG definition string.
      Parameters:
      source - The source KString tag.
      Returns:
      The String to use as SVG, [em]SVG failed[/em] in case of failure.
    • getKStringSVG

      public String getKStringSVG(double cx, double cy)
      Returns the SVG definition string.
      Parameters:
      cx - Requested scaled width if larger than zero.
      cy - Requested scaled height if larger than zero.
      Returns:
      The SVG string, or null for failure.