Package VASSAL.tools.image.svg
Class SVGImageUtils
java.lang.Object
VASSAL.tools.image.svg.SVGImageUtils
public class SVGImageUtils extends Object
Utility methods for manipulating SVG images.
- Since:
- 3.1.0
- Author:
- Joel Uckelman
-
Method Summary
Modifier and Type Method Description static org.w3c.dom.svg.SVGDocumentgetDocument(String file, InputStream in)static List<String>getExternalReferences(String path)Conducts a recursive depth-first search for external references in the given SVG file.protected static List<String>getExternalReferences(String path, List<String> known)Conducts a recursive depth-first search for external references in the SVG file named by path.static DimensiongetImageSize(InputStream in)Returns the default dimensions of the SVG image.static DimensiongetImageSize(String file, InputStream in)Returns the default dimensions of the SVG image.static DimensiongetImageSize(org.w3c.dom.svg.SVGDocument doc)protected static voidrelativizeElement(Element e)static byte[]relativizeExternalReferences(String path)Rewrites external references contained in SVG files.
-
Method Details
-
getDocument
public static org.w3c.dom.svg.SVGDocument getDocument(String file, InputStream in) throws IOException- Throws:
IOException
-
getImageSize
Returns the default dimensions of the SVG image. Closes theInputStream.- Returns:
- the image dimensions
- Throws:
IOException- if the image cannot be read
-
getImageSize
- Throws:
IOException
-
getImageSize
Returns the default dimensions of the SVG image.- Returns:
- the image dimensions
- Throws:
IOException- if the image cannot be read
-
getExternalReferences
Conducts a recursive depth-first search for external references in the given SVG file.- Parameters:
path- the path of the file to check for external references- Throws:
IOException
-
getExternalReferences
protected static List<String> getExternalReferences(String path, List<String> known) throws IOExceptionConducts a recursive depth-first search for external references in the SVG file named by path. This is a helper function forgetExternalReferences(java.lang.String).- Parameters:
path- the path of the file to check for external referencesknown- the list of references already found- Throws:
IOException
-
relativizeExternalReferences
Rewrites external references contained in SVG files.- Parameters:
path- the path of the file to be processed- Throws:
IOException
-
relativizeElement
-