Package hec.swing.svg
Class SVGData
java.lang.Object
hec.swing.svg.SVGData
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptionvoidclose()voidAttempts to copy the SVGData to the system clipboard.Convert the SVG Data to a String.voidwriteSVGToFile(Path filePath) Write the SVG data to a file on disk
-
Method Details
-
getSvgAsString
Convert the SVG Data to a String.- Returns:
- A string containing valid SVG data
- Throws:
IOException- When the SVGData has already been closed
-
writeSVGToFile
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
Attempts to copy the SVGData to the system clipboard.- Throws:
IOException- If the SVGData has already been closed.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-