Package com.nomagic.ui
Class DoubleSizeImageIcon
- java.lang.Object
-
- javax.swing.ImageIcon
-
- com.nomagic.ui.ScalableImageIcon
-
- com.nomagic.ui.DoubleSizeImageIcon
-
- All Implemented Interfaces:
ResizableIcon
,java.io.Serializable
,java.lang.Cloneable
,javax.accessibility.Accessible
,javax.swing.Icon
@OpenApiAll public class DoubleSizeImageIcon extends ScalableImageIcon
Icon combines two other icons and chooses which one to paint depending on graphics scaling. Large icon will be used if painting rectangle size is larger than size of small icon.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
DoubleSizeImageIcon.MultiResolutionIconLoader
-
Nested classes/interfaces inherited from class com.nomagic.ui.ScalableImageIcon
ScalableImageIcon.AbstractImageLoader
-
-
Field Summary
Fields Modifier and Type Field Description private ResizableIcon
largeIcon
private javax.swing.Icon
smallIcon
-
Constructor Summary
Constructors Constructor Description DoubleSizeImageIcon(javax.swing.Icon smallIcon, ResizableIcon largeIcon)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ResizableIcon
getLargeIcon()
private static int
getScaledSize(int size, double graphicsScale)
javax.swing.Icon
getSmallIcon()
private boolean
isGraphicsScaled(java.awt.geom.AffineTransform transform, int width, int height)
void
paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
void
paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y, int w, int h)
Draw the icon in the given bounds.-
Methods inherited from class com.nomagic.ui.ScalableImageIcon
clone, create, doNotScale, getIconHeight, getIconWidth, getImage, getLocation, getURL, internalGetIcon, internalSetLoader, internalSuperGetImage, setImage, toImageIcon, toImageIcon, toImageIcon
-
-
-
-
Field Detail
-
largeIcon
@CheckForNull private final ResizableIcon largeIcon
-
smallIcon
private final javax.swing.Icon smallIcon
-
-
Constructor Detail
-
DoubleSizeImageIcon
public DoubleSizeImageIcon(javax.swing.Icon smallIcon, @CheckForNull ResizableIcon largeIcon)
Constructor.- Parameters:
smallIcon
- small iconlargeIcon
- large icon
-
-
Method Detail
-
paintIcon
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y, int w, int h)
Description copied from interface:ResizableIcon
Draw the icon in the given bounds. Icon implementations may use the Component argument to get properties useful for painting, e.g. the foreground or background color.- Specified by:
paintIcon
in interfaceResizableIcon
- Overrides:
paintIcon
in classScalableImageIcon
- Parameters:
c
- the given component.g
- the graphics to paint on.x
- x coordinate.y
- y coordinate.w
- width to paint.h
- height to paint.
-
isGraphicsScaled
private boolean isGraphicsScaled(@CheckForNull java.awt.geom.AffineTransform transform, int width, int height)
- Parameters:
transform
- graphics transformwidth
- width to paintheight
- height to paint- Returns:
- true if icon is being painted on scaled graphics
-
getScaledSize
private static int getScaledSize(int size, double graphicsScale)
-
getLargeIcon
@CheckForNull public ResizableIcon getLargeIcon()
-
getSmallIcon
public javax.swing.Icon getSmallIcon()
-
paintIcon
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
- Specified by:
paintIcon
in interfacejavax.swing.Icon
- Overrides:
paintIcon
in classScalableImageIcon
-
-