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 Details

    • getDocument

      public static org.w3c.dom.svg.SVGDocument getDocument(String file, InputStream in) throws IOException
      Throws:
      IOException
    • getImageSize

      public static Dimension getImageSize(String file, InputStream in) throws IOException
      Returns the default dimensions of the SVG image. Closes the InputStream.
      Returns:
      the image dimensions
      Throws:
      IOException - if the image cannot be read
    • getViewBoxTransform

      public static AffineTransform getViewBoxTransform(org.w3c.dom.svg.SVGDocument doc) throws IOException
      Throws:
      IOException
    • getImageSize

      public static Dimension getImageSize(org.w3c.dom.svg.SVGDocument doc) throws IOException
      Throws:
      IOException
    • getImageSize

      public static Dimension getImageSize(InputStream in) throws IOException
      Returns the default dimensions of the SVG image.
      Returns:
      the image dimensions
      Throws:
      IOException - if the image cannot be read
    • getExternalReferences

      public static List<String> getExternalReferences(String path) throws IOException
      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 IOException
      Conducts a recursive depth-first search for external references in the SVG file named by path. This is a helper function for getExternalReferences(java.lang.String).
      Parameters:
      path - the path of the file to check for external references
      known - the list of references already found
      Throws:
      IOException
    • relativizeExternalReferences

      public static byte[] relativizeExternalReferences(String path) throws IOException
      Rewrites external references contained in SVG files.
      Parameters:
      path - the path of the file to be processed
      Throws:
      IOException
    • relativizeElement

      protected static void relativizeElement(Element e)