Class ArrowIcon

java.lang.Object
com.moneydance.awt.ArrowIcon
All Implemented Interfaces:
javax.swing.Icon

public class ArrowIcon
extends java.lang.Object
implements javax.swing.Icon

ArrowIcon is an icon with given arrow shape, defined by the direction, enable status, and size (length and width).

Here's a diagram:

      A
      |\
      | \
      C--E
      | /
      |/
      B
 

where distance C - E is the length of the arrow, while distance A - B is the width of the arrow. A width of zero is not allowed, but a length of zero is allowed and creates a bar of the specified width.

When a triangle shape is selected, the ArrowHead class is used to draw the triangle.

Author:
Kevin Menningen
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int EAST
    The arrow should point to the east.
    static int NORTH
    The arrow should point to the north.
    static int SOUTH
    The arrow should point to the south.
    static int WEST
    The arrow should point to the west.
  • Constructor Summary

    Constructors 
    Constructor Description
    ArrowIcon​(int direction, boolean isEnabled)
    Create an ArrowIcon with the given direction and enablement status and the default size and length.
    ArrowIcon​(int direction, boolean isEnabled, int length, int width)
    Create an ArrowIcon with given direction, enable status, shape, and size.
  • Method Summary

    Modifier and Type Method Description
    int getDirection()
    Get the arrow icon direction.
    int getIconHeight()
    Returns the icon's height.
    int getIconWidth()
    Returns the icon's width.
    void paintIcon​(java.awt.Component comp, java.awt.Graphics graphics, int xValue, int yValue)
    Draw the icon.
    void setEnabled​(boolean isEnabled)
    Set the enable status.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ArrowIcon

      public ArrowIcon​(int direction, boolean isEnabled)
      Create an ArrowIcon with the given direction and enablement status and the default size and length.
      Parameters:
      direction - Direction of the arrow, could be SwingConstants.SOUTH, SwingConstants.NORTH, SwingConstants.EAST, or SwingConstants.WEST
      isEnabled - Represents the enable status of the ArrowIcon. Paint in foreground text color if true, or disabled color if false.
    • ArrowIcon

      public ArrowIcon​(int direction, boolean isEnabled, int length, int width)

      Create an ArrowIcon with given direction, enable status, shape, and size. To get the real height and width of the icon need to use getIconHeight() and getIconWidth().

      Parameters:
      direction - direction of the arrow, could be SwingConstants.SOUTH, SwingConstants.NORTH, SwingConstants.EAST, or SwingConstants.WEST
      isEnabled - Represents the enable status of the ArrowIcon. Paint in foreground text color if true, or disabled color if false.
      length - The length of the icon, see the class notes. If less than zero, length is set to zero.
      width - The width of the icon, see the class notes. If less than one, width is set to one.
  • Method Details

    • paintIcon

      public void paintIcon​(java.awt.Component comp, java.awt.Graphics graphics, int xValue, int yValue)
      Draw the icon.
      Specified by:
      paintIcon in interface javax.swing.Icon
      Parameters:
      comp - Component parameter.
      graphics - Graphics.
      xValue - Left position.
      yValue - Top position.
    • getIconWidth

      public int getIconWidth()
      Returns the icon's width.
      Specified by:
      getIconWidth in interface javax.swing.Icon
      Returns:
      an int specifying the fixed width of the icon.
    • getIconHeight

      public int getIconHeight()
      Returns the icon's height.
      Specified by:
      getIconHeight in interface javax.swing.Icon
      Returns:
      an int specifying the fixed height of the icon.
    • getDirection

      public int getDirection()
      Get the arrow icon direction.
      Returns:
      arrow direction. SwingConstants.SOUTH, SwingConstants.NORTH, SwingConstants.EAST, or SwingConstants.WEST.
    • setEnabled

      public void setEnabled​(boolean isEnabled)
      Set the enable status.
      Parameters:
      isEnabled - true if enabled, false otherwise.