Package hec.swing.svg

Class SVGData

java.lang.Object
hec.swing.svg.SVGData
All Implemented Interfaces:
AutoCloseable

public class SVGData extends Object implements AutoCloseable
Contains a copy of SVG Data extracted from an SVGGraphics context. Is an AutoCloseable to encourage closing it, which allows the memory used by the SVG to be freed, as this could be several megabytes with large or complex SVGs.
  • Method Details

    • getSvgAsString

      public String getSvgAsString() throws IOException
      Convert the SVG Data to a String.
      Returns:
      A string containing valid SVG data
      Throws:
      IOException - When the SVGData has already been closed
    • writeSVGToFile

      public void writeSVGToFile(Path filePath) throws IOException
      Write the SVG data to a file on disk
      Parameters:
      filePath - The path to write with. It should end with '.svg', but if it doesn't, .svg will be appended.
      Throws:
      IOException - If the SVGData has already been closed or an IOException occurs writing to disk
    • copySVGToClipboard

      public void copySVGToClipboard() throws IOException
      Attempts to copy the SVGData to the system clipboard.
      Throws:
      IOException - If the SVGData has already been closed.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable