Package com.formdev.flatlaf.extras
Class FlatSVGIcon
- java.lang.Object
-
- javax.swing.ImageIcon
-
- com.formdev.flatlaf.extras.FlatSVGIcon
-
- All Implemented Interfaces:
com.formdev.flatlaf.FlatLaf.DisabledIconProvider,java.io.Serializable,javax.accessibility.Accessible,javax.swing.Icon
public class FlatSVGIcon extends javax.swing.ImageIcon implements com.formdev.flatlaf.FlatLaf.DisabledIconProviderAn icon that loads and paints SVG.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFlatSVGIcon.ColorFilter
-
Constructor Summary
Constructors Constructor Description FlatSVGIcon(java.lang.String name)Creates an SVG icon from the given resource name.FlatSVGIcon(java.lang.String name, float scale)Creates an SVG icon from the given resource name that is scaled by the given amount.FlatSVGIcon(java.lang.String name, float scale, java.lang.ClassLoader classLoader)Creates an SVG icon from the given resource name that is scaled by the given amount.FlatSVGIcon(java.lang.String name, int width, int height)Creates an SVG icon from the given resource name with the given width and height.FlatSVGIcon(java.lang.String name, int width, int height, java.lang.ClassLoader classLoader)Creates an SVG icon from the given resource name with the given width and height.FlatSVGIcon(java.lang.String name, java.lang.ClassLoader classLoader)Creates an SVG icon from the given resource name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FlatSVGIconderive(float scale)Creates a new icon with given scaling, which is derived from this icon.FlatSVGIconderive(int width, int height)Creates a new icon with given width and height, which is derived from this icon.javax.swing.IcongetDisabledIcon()Creates a new icon with disabled appearance, which is derived from this icon.intgetIconHeight()Returns the scaled height of the icon.intgetIconWidth()Returns the scaled width of the icon.java.awt.ImagegetImage()booleanhasFound()Returns whether the SVG file was found.voidpaintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
-
-
-
Constructor Detail
-
FlatSVGIcon
public FlatSVGIcon(java.lang.String name)
Creates an SVG icon from the given resource name.The SVG attributes
widthandheight(orviewBox) in the tag<svg>are used as icon size.- Parameters:
name- the name of the SVG resource (a '/'-separated path)- See Also:
ClassLoader.getResource(String)
-
FlatSVGIcon
public FlatSVGIcon(java.lang.String name, java.lang.ClassLoader classLoader)Creates an SVG icon from the given resource name. The SVG file is loaded from the given class loader.The SVG attributes
widthandheight(orviewBox) in the tag<svg>are used as icon size.- Parameters:
name- the name of the SVG resource (a '/'-separated path)classLoader- the class loader used to load the SVG resource- See Also:
ClassLoader.getResource(String)
-
FlatSVGIcon
public FlatSVGIcon(java.lang.String name, int width, int height)Creates an SVG icon from the given resource name with the given width and height.The icon is scaled if the given size is different to the size specified in the SVG file.
- Parameters:
name- the name of the SVG resource (a '/'-separated path)width- the width of the iconheight- the height of the icon- See Also:
ClassLoader.getResource(String)
-
FlatSVGIcon
public FlatSVGIcon(java.lang.String name, int width, int height, java.lang.ClassLoader classLoader)Creates an SVG icon from the given resource name with the given width and height. The SVG file is loaded from the given class loader.The icon is scaled if the given size is different to the size specified in the SVG file.
- Parameters:
name- the name of the SVG resource (a '/'-separated path)width- the width of the iconheight- the height of the iconclassLoader- the class loader used to load the SVG resource- See Also:
ClassLoader.getResource(String)
-
FlatSVGIcon
public FlatSVGIcon(java.lang.String name, float scale)Creates an SVG icon from the given resource name that is scaled by the given amount.The SVG attributes
widthandheight(orviewBox) in the tag<svg>are used as base icon size, which is multiplied by the given scale factor.- Parameters:
name- the name of the SVG resource (a '/'-separated path)scale- the amount by which the icon size is scaled- See Also:
ClassLoader.getResource(String)
-
FlatSVGIcon
public FlatSVGIcon(java.lang.String name, float scale, java.lang.ClassLoader classLoader)Creates an SVG icon from the given resource name that is scaled by the given amount. The SVG file is loaded from the given class loader.The SVG attributes
widthandheight(orviewBox) in the tag<svg>are used as base icon size, which is multiplied by the given scale factor.- Parameters:
name- the name of the SVG resource (a '/'-separated path)scale- the amount by which the icon size is scaledclassLoader- the class loader used to load the SVG resource- See Also:
ClassLoader.getResource(String)
-
-
Method Detail
-
derive
public FlatSVGIcon derive(int width, int height)
Creates a new icon with given width and height, which is derived from this icon.- Parameters:
width- the width of the new iconheight- the height of the new icon- Returns:
- a new icon
-
derive
public FlatSVGIcon derive(float scale)
Creates a new icon with given scaling, which is derived from this icon.- Parameters:
scale- the amount by which the icon size is scaled- Returns:
- a new icon
-
getDisabledIcon
public javax.swing.Icon getDisabledIcon()
Creates a new icon with disabled appearance, which is derived from this icon.- Specified by:
getDisabledIconin interfacecom.formdev.flatlaf.FlatLaf.DisabledIconProvider- Returns:
- a new icon
-
hasFound
public boolean hasFound()
Returns whether the SVG file was found.- Returns:
- whether the SVG file was found
-
getIconWidth
public int getIconWidth()
Returns the scaled width of the icon.- Specified by:
getIconWidthin interfacejavax.swing.Icon- Overrides:
getIconWidthin classjavax.swing.ImageIcon
-
getIconHeight
public int getIconHeight()
Returns the scaled height of the icon.- Specified by:
getIconHeightin interfacejavax.swing.Icon- Overrides:
getIconHeightin classjavax.swing.ImageIcon
-
paintIcon
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)- Specified by:
paintIconin interfacejavax.swing.Icon- Overrides:
paintIconin classjavax.swing.ImageIcon
-
getImage
public java.awt.Image getImage()
- Overrides:
getImagein classjavax.swing.ImageIcon
-
-