com.kitfox.svg.app.beans
Class SVGIcon

java.lang.Object
  extended by com.kitfox.svg.app.beans.SVGIcon
All Implemented Interfaces:
javax.swing.Icon

public class SVGIcon
extends java.lang.Object
implements javax.swing.Icon

Author:
kitfox

Field Summary
static int INTERP_BICUBIC
           
static int INTERP_BILINEAR
           
static int INTERP_NEAREST_NEIGHBOR
           
static long serialVersionUID
           
 
Constructor Summary
SVGIcon()
          Creates a new instance of SVGIcon
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener p)
           
 boolean getAntiAlias()
           
 int getIconHeight()
           
 int getIconWidth()
           
 int getInterpolation()
           
 java.awt.Dimension getPreferredSize()
           
 SVGUniverse getSvgUniverse()
           
 java.net.URI getSvgURI()
           
 boolean getUseAntiAlias()
          Deprecated.  
 boolean isClipToViewbox()
          clipToViewbox will set a clip box equivilant to the SVG's viewbox before rendering.
 boolean isScaleToFit()
          If this SVG document has a viewbox, if scaleToFit is set, will scale the viewbox to match the preferred size of this icon
 void paintIcon(java.awt.Component comp, java.awt.Graphics gg, int x, int y)
          Draws the icon to the specified component.
 void removePropertyChangeListener(java.beans.PropertyChangeListener p)
           
 void setAntiAlias(boolean antiAlias)
           
 void setClipToViewbox(boolean clipToViewbox)
           
 void setInterpolation(int interpolation)
           
 void setPreferredSize(java.awt.Dimension preferredSize)
           
 void setScaleToFit(boolean scaleToFit)
           
 void setSvgResourcePath(java.lang.String resourcePath)
          Loads an SVG document from the classpath.
 void setSvgUniverse(SVGUniverse svgUniverse)
           
 void setSvgURI(java.net.URI svgURI)
          Loads an SVG document from a URI.
 void setUseAntiAlias(boolean antiAlias)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

INTERP_NEAREST_NEIGHBOR

public static final int INTERP_NEAREST_NEIGHBOR
See Also:
Constant Field Values

INTERP_BILINEAR

public static final int INTERP_BILINEAR
See Also:
Constant Field Values

INTERP_BICUBIC

public static final int INTERP_BICUBIC
See Also:
Constant Field Values
Constructor Detail

SVGIcon

public SVGIcon()
Creates a new instance of SVGIcon

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener p)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener p)

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface javax.swing.Icon
Returns:
height of this icon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface javax.swing.Icon
Returns:
width of this icon

paintIcon

public void paintIcon(java.awt.Component comp,
                      java.awt.Graphics gg,
                      int x,
                      int y)
Draws the icon to the specified component.

Specified by:
paintIcon in interface javax.swing.Icon
Parameters:
comp - - Component to draw icon to. This is ignored by SVGIcon, and can be set to null; only gg is used for drawing the icon
gg - - Graphics context to render SVG content to
x - - X coordinate to draw icon
y - - Y coordinate to draw icon

getSvgUniverse

public SVGUniverse getSvgUniverse()
Returns:
the universe this icon draws it's SVGDiagrams from

setSvgUniverse

public void setSvgUniverse(SVGUniverse svgUniverse)

getSvgURI

public java.net.URI getSvgURI()
Returns:
the uni of the document being displayed by this icon

setSvgURI

public void setSvgURI(java.net.URI svgURI)
Loads an SVG document from a URI.

Parameters:
svgURI - - URI to load document from

setSvgResourcePath

public void setSvgResourcePath(java.lang.String resourcePath)
Loads an SVG document from the classpath. This function is equivilant to setSvgURI(new URI(getClass().getResource(resourcePath).toString());

Parameters:
resourcePath - - resource to load

isScaleToFit

public boolean isScaleToFit()
If this SVG document has a viewbox, if scaleToFit is set, will scale the viewbox to match the preferred size of this icon


setScaleToFit

public void setScaleToFit(boolean scaleToFit)

getPreferredSize

public java.awt.Dimension getPreferredSize()

setPreferredSize

public void setPreferredSize(java.awt.Dimension preferredSize)

getUseAntiAlias

public boolean getUseAntiAlias()
Deprecated. 

Returns:
true if antiAliasing is turned on.

setUseAntiAlias

public void setUseAntiAlias(boolean antiAlias)
Deprecated. 

Parameters:
antiAlias - true to use antiAliasing.

getAntiAlias

public boolean getAntiAlias()
Returns:
true if antiAliasing is turned on.

setAntiAlias

public void setAntiAlias(boolean antiAlias)
Parameters:
antiAlias - true to use antiAliasing.

getInterpolation

public int getInterpolation()
Returns:
interpolation used in rescaling images

setInterpolation

public void setInterpolation(int interpolation)
Parameters:
interpolation - Interpolation value used in rescaling images. Should be one of INTERP_NEAREST_NEIGHBOR - Fastest, one pixel resampling, poor quality INTERP_BILINEAR - four pixel resampling INTERP_BICUBIC - Slowest, nine pixel resampling, best quality

isClipToViewbox

public boolean isClipToViewbox()
clipToViewbox will set a clip box equivilant to the SVG's viewbox before rendering.


setClipToViewbox

public void setClipToViewbox(boolean clipToViewbox)