Package com.iizix.prop.image
Class SVGInfo
java.lang.Object
com.iizix.prop.image.SVGInfo
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 Summary
FieldsMethod Summary
Modifier and TypeMethodDescriptionstatic SVGInfo
Creates the SVG inform from the SVG definition.static SVGInfo
fromDefinition
(File file) Creates the SVG inform from the SVG definition.static SVGInfo
fromString
(String string) Creates the SVG information from a String, used typically for iizi SVG URN's.double
Gets the width of the SVG.getKStringSVG
(double cx, double cy) Returns the SVG definition string.getKStringSVG
(KStringHTMLImageTag source) Returns the SVG definition string.Returns the SVG used in the HTML.double
getWidth()
Gets the width of the SVG.Gets the XML string.boolean
Returns the a viewbox is present in XML SVG.void
setScale
(int cx, int cy) Sets the requested scaled width and height.void
Updates the requested size from the definition.
Field Details
width
public final double widthThe width of the SVG.height
public final double heightThe height of the SVG.
Method Details
fromDefinition
Creates the SVG inform from the SVG definition.- Parameters:
file
- The file.- Returns:
- The SVG information if complete, null if not defined properly.
fromString
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
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
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
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
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
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
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.