Package ca.cgjennings.graphics.shapes
Class SVGVectorImage
- java.lang.Object
-
- ca.cgjennings.graphics.shapes.AbstractVectorImage
-
- ca.cgjennings.graphics.shapes.SVGVectorImage
-
- All Implemented Interfaces:
VectorImage
public class SVGVectorImage extends AbstractVectorImage
A vector image whose content is loaded from an SVG source file. Most SVG 1.1 files should be compatible; scripting and animation are not supported since theVectorImage
class represents a static image rather than a dynamic, interactive object.This class requires that the
SVG_IMAGE_SUPPORT
core component be installed, as that plug-in contains support code necessary to render the SVG content. If that library is not installed, but theSVGVectorImage
constructor is called from the event dispatch thread (EDT), then the user will be given the opportunity to immediately download and install the missing component. If the user chooses not to, or if the constructor is called from a thread other than the EDT, then aMissingCoreComponentException
exception will be thrown from the constructor.- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Field Summary
-
Fields inherited from class ca.cgjennings.graphics.shapes.AbstractVectorImage
ih, iw, tx, ty
-
-
Constructor Summary
Constructors Constructor Description SVGVectorImage(java.io.File file)
Creates a vector image from SVG content stored in a file.SVGVectorImage(java.net.URL location)
Creates a vector image from SVG content stored at a URL.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
finalize()
Deprecated.static boolean
isSupported()
Returnstrue
if the SVG core library is installed.protected void
render(java.awt.Graphics2D g)
Renders the vector image into the specified graphics context.-
Methods inherited from class ca.cgjennings.graphics.shapes.AbstractVectorImage
createRasterImage, createRasterImage, getHeight, getWidth, paint, paint, paint
-
-
-
-
Constructor Detail
-
SVGVectorImage
public SVGVectorImage(java.io.File file) throws java.io.IOException
Creates a vector image from SVG content stored in a file.- Parameters:
file
- the file to load content from- Throws:
java.io.IOException
- if an I/O error occurs while loading the contentjava.lang.IllegalArgumentException
- if the vector content is invalidCoreComponents.MissingCoreComponentException
- if the SVG support library is not installed and the user chooses not to install it
-
SVGVectorImage
public SVGVectorImage(java.net.URL location) throws java.io.IOException
Creates a vector image from SVG content stored at a URL.- Parameters:
location
- the URL to load content from- Throws:
java.io.IOException
- if an I/O error occurs while loading the contentjava.lang.IllegalArgumentException
- if the vector content is invalidCoreComponents.MissingCoreComponentException
- if the SVG support library is not installed and the user chooses not to install it
-
-
Method Detail
-
render
protected void render(java.awt.Graphics2D g)
Description copied from class:AbstractVectorImage
Renders the vector image into the specified graphics context. The upper left corner of the image should be at (-tx, -ty) and cover an area with widthAbstractVectorImage.iw
and heightAbstractVectorImage.ih
. Any changes to the state of the graphics context (stroke, paint, clip, etc.) must be restored before the method returns.- Specified by:
render
in classAbstractVectorImage
- Parameters:
g
- the graphics context to render the image into
-
finalize
@Deprecated protected void finalize() throws java.lang.Throwable
Deprecated.- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
isSupported
public static boolean isSupported()
Returnstrue
if the SVG core library is installed. Note that it is not required to call this before attempting to create an SVG image. If possible, the SVG core will be loaded on demand (see the class description for details).- Returns:
true
if SVG image file support is available
-
-