Class RotatedIcon
- java.lang.Object
-
- org.bidib.wizard.mvc.common.view.icon.RotatedIcon
-
- All Implemented Interfaces:
Icon,AnimatedIcon
public class RotatedIcon extends Object implements AnimatedIcon
The RotatedIcon allows you to change the orientation of an Icon by rotating the Icon before it is painted. This class supports the following orientations:- DOWN - rotated 90 degrees
- UP (default) - rotated -90 degrees
- UPSIDE_DOWN - rotated 180 degrees
- ABOUT_CENTER - the icon is rotated by the specified degrees about its center.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRotatedIcon.Rotate
-
Constructor Summary
Constructors Constructor Description RotatedIcon(Icon icon)Convenience constructor to create a RotatedIcon that is rotated DOWN.RotatedIcon(Icon icon, double degrees)Create a RotatedIcon.RotatedIcon(Icon icon, double degrees, boolean circularIcon)Create a RotatedIcon.RotatedIcon(Icon icon, RotatedIcon.Rotate rotate)Create a RotatedIcon
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetDegrees()Gets the degrees of rotation.IcongetIcon()Gets the Icon to be rotatedintgetIconHeight()Gets the height of this icon.intgetIconWidth()Gets the width of this icon.RotatedIcon.RotategetRotate()Gets the Rotate enum which indicates the direction of rotationbooleanisCircularIcon()Is the image circular or rectangular? Only used for Rotate.ABOUT_CENTER.voidpaintIcon(Component c, Graphics g, int x, int y)Paint the icons of this compound icon at the specified locationvoidsetCircularIcon(boolean circularIcon)Set the Icon as circular or rectangular.voidsetDegrees(double degrees)Set the degrees of rotation.
-
-
-
Constructor Detail
-
RotatedIcon
public RotatedIcon(Icon icon)
Convenience constructor to create a RotatedIcon that is rotated DOWN.- Parameters:
icon- the Icon to rotate
-
RotatedIcon
public RotatedIcon(Icon icon, RotatedIcon.Rotate rotate)
Create a RotatedIcon- Parameters:
icon- the Icon to rotaterotate- the direction of rotation
-
RotatedIcon
public RotatedIcon(Icon icon, double degrees)
Create a RotatedIcon. The icon will rotate about its center. This constructor will automatically set the Rotate enum to ABOUT_CENTER.- Parameters:
icon- the Icon to rotatedegrees- the degrees of rotation
-
RotatedIcon
public RotatedIcon(Icon icon, double degrees, boolean circularIcon)
Create a RotatedIcon. The icon will rotate about its center. This constructor will automatically set the Rotate enum to ABOUT_CENTER.- Parameters:
icon- the Icon to rotatedegrees- the degrees of rotationcircularIcon- treat the icon as circular so its size doesn't change
-
-
Method Detail
-
getIcon
public Icon getIcon()
Gets the Icon to be rotated- Returns:
- the Icon to be rotated
-
getRotate
public RotatedIcon.Rotate getRotate()
Gets the Rotate enum which indicates the direction of rotation- Returns:
- the Rotate enum
-
getDegrees
public double getDegrees()
Gets the degrees of rotation. Only used for Rotate.ABOUT_CENTER.- Returns:
- the degrees of rotation
-
setDegrees
public void setDegrees(double degrees)
Set the degrees of rotation. Only used for Rotate.ABOUT_CENTER. This method only sets the degress of rotation, it will not cause the Icon to be repainted. You must invoke repaint() on any component using this icon for it to be repainted.- Specified by:
setDegreesin interfaceAnimatedIcon- Parameters:
degrees- the degrees of rotation
-
isCircularIcon
public boolean isCircularIcon()
Is the image circular or rectangular? Only used for Rotate.ABOUT_CENTER. When true, the icon width/height will not change as the Icon is rotated.- Returns:
- true for a circular Icon, false otherwise
-
setCircularIcon
public void setCircularIcon(boolean circularIcon)
Set the Icon as circular or rectangular. Only used for Rotate.ABOUT_CENTER. When true, the icon width/height will not change as the Icon is rotated.- Parameters:
circularIcon- true for a circular Icon, false otherwise
-
getIconWidth
public int getIconWidth()
Gets the width of this icon.- Specified by:
getIconWidthin interfaceIcon- Returns:
- the width of the icon in pixels.
-
getIconHeight
public int getIconHeight()
Gets the height of this icon.- Specified by:
getIconHeightin interfaceIcon- Returns:
- the height of the icon in pixels.
-
-