Class FlatAbstractIcon
java.lang.Object
com.formdev.flatlaf.icons.FlatAbstractIcon
- All Implemented Interfaces:
Icon, UIResource
- Direct Known Subclasses:
FlatAnimatedIcon, FlatAscendingSortIcon, FlatCapsLockIcon, FlatCheckBoxIcon, FlatCheckBoxMenuItemIcon, FlatClearIcon, FlatFileChooserDetailsViewIcon, FlatFileChooserHomeFolderIcon, FlatFileChooserListViewIcon, FlatFileChooserNewFolderIcon, FlatFileChooserUpFolderIcon, FlatFileViewComputerIcon, FlatFileViewDirectoryIcon, FlatFileViewFileIcon, FlatFileViewFloppyDriveIcon, FlatFileViewHardDriveIcon, FlatHelpButtonIcon, FlatInternalFrameAbstractIcon, FlatMenuArrowIcon, FlatMenuItemArrowIcon, FlatOptionPaneAbstractIcon, FlatRevealIcon, FlatSearchIcon, FlatTabbedPaneCloseIcon, FlatTreeClosedIcon, FlatTreeCollapsedIcon, FlatTreeLeafIcon, FlatTreeOpenIcon, FlatWindowAbstractIcon
Base class for icons that scales width and height, creates and initializes
a scaled graphics context for icon painting.
Subclasses do not need to scale icon painting.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the scaled icon height.intReturns the scaled icon width.floatgetScale()protected voidpaintBackground(Component c, Graphics2D g, int x, int y) Paints icon background.protected abstract voidpaintIcon(Component c, Graphics2D g) Paints icon.voidprotected intscale(int size) Multiplies the given value by the icon scale factorgetScale()and rounds the result.voidsetScale(float scale)
-
Field Details
-
width
protected final int widthUnscaled icon width. -
height
protected final int heightUnscaled icon height. -
color
-
-
Constructor Details
-
FlatAbstractIcon
-
-
Method Details
-
paintIcon
-
paintBackground
Paints icon background. Default implementation does nothing. Can be overridden to paint specific icon background.The bounds of the area to be filled are: x, y,
getIconWidth(),getIconHeight().In contrast to
paintIcon(Component, Graphics2D), the graphics contextgis not translated and not scaled.- Since:
- 3.5.2
-
paintIcon
-
getIconWidth
public int getIconWidth()Returns the scaled icon width.- Specified by:
getIconWidthin interfaceIcon
-
getIconHeight
public int getIconHeight()Returns the scaled icon height.- Specified by:
getIconHeightin interfaceIcon
-
getScale
public float getScale()- Since:
- 3.7
-
setScale
public void setScale(float scale) - Since:
- 3.7
-
scale
protected int scale(int size) Multiplies the given value by the icon scale factorgetScale()and rounds the result.If you want scale a
floatordoublevalue, simply use:myFloatValue *getScale().Do not use this method when painting icon in
paintIcon(Component, Graphics2D).- Since:
- 3.7
-