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.
  • Constructor Details

    • 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 rotate
      rotate - 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 rotate
      degrees - 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 rotate
      degrees - the degrees of rotation
      circularIcon - treat the icon as circular so its size doesn't change
  • Method Details

    • 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:
      setDegrees in interface AnimatedIcon
      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:
      getIconWidth in interface Icon
      Returns:
      the width of the icon in pixels.
    • getIconHeight

      public int getIconHeight()
      Gets the height of this icon.
      Specified by:
      getIconHeight in interface Icon
      Returns:
      the height of the icon in pixels.
    • paintIcon

      public void paintIcon(Component c, Graphics g, int x, int y)
      Paint the icons of this compound icon at the specified location
      Specified by:
      paintIcon in interface Icon
      Parameters:
      c - The component on which the icon is painted
      g - the graphics context
      x - the X coordinate of the icon's top-left corner
      y - the Y coordinate of the icon's top-left corner