Package docking.util

Class BadgedIcon

  • All Implemented Interfaces:
    javax.swing.Icon

    public class BadgedIcon
    extends java.lang.Object
    implements javax.swing.Icon
    An icon that allows sub-icons to be added at key perimeter locations. Each position can be manipulated independently, adding and removing icons as desired. Additionally, each position can be toggled enabled or disabled, or visible or invisible.
    • Constructor Detail

      • BadgedIcon

        public BadgedIcon​(javax.swing.Icon baseIcon)
      • BadgedIcon

        public BadgedIcon​(javax.swing.Icon baseIcon,
                          boolean enabled)
      • BadgedIcon

        public BadgedIcon​(javax.swing.Icon baseIcon,
                          boolean enabled,
                          int width,
                          int height)
    • Method Detail

      • addBadge

        public BadgedIcon addBadge​(javax.swing.Icon badge,
                                   BadgedIcon.BadgePosition position)
        Add an icon at the specified location
        Parameters:
        badge - The icon
        position - Where to place the image
        Returns:
        a reference to this object
      • setBadge

        public BadgedIcon setBadge​(javax.swing.Icon badge,
                                   BadgedIcon.BadgePosition position)
        Replace the existing icon with the provided icon at the specified location
        Parameters:
        badge - The icon
        position - Where to place the image
        Returns:
        a reference to this object
      • removeBadge

        public BadgedIcon removeBadge​(BadgedIcon.BadgePosition position)
        Remove the badge from the specified location
        Parameters:
        position - Where to place the image
        Returns:
        a reference to this object
      • setBadgeEnabled

        public void setBadgeEnabled​(BadgedIcon.BadgePosition position,
                                    boolean enabled)
        Set the enablement of the badge at the specified location
        Parameters:
        position - Which icon to modify
        enabled - True if the image should be shown 'enabled', false otherwise
        See Also:
        isBadgeEnabled(BadgePosition)
      • setBadgeVisisble

        public void setBadgeVisisble​(BadgedIcon.BadgePosition position,
                                     boolean visible)
        Set the visibility status of the badge at the specified location
        Parameters:
        position - Which icon to modify
        visible - True if the badge should be visible, false otherwise
        See Also:
        isBadgeVisible(BadgePosition)
      • getIconHeight

        public int getIconHeight()
        Specified by:
        getIconHeight in interface javax.swing.Icon
        See Also:
        Icon.getIconHeight()
      • getIconWidth

        public int getIconWidth()
        Specified by:
        getIconWidth in interface javax.swing.Icon
        See Also:
        Icon.getIconWidth()
      • isEnabled

        public boolean isEnabled()
        Determine the overall enablement appearance state.
        Returns:
        true if the if the entire icon is rendered as 'enabled'; false otherwise.
      • setEnabled

        public void setEnabled​(boolean enabled)
        Set the 'enabled' appearance of the entire icon. Preserves the underlying enablement state of badges, though the entire icon looks disabled if setEnabled(true) is called.
        Parameters:
        enabled -
      • getBadges

        public javax.swing.Icon[] getBadges​(BadgedIcon.BadgePosition pos)
        Return array of Icons that were added to this BadgedIcon.
      • paintIcon

        public void paintIcon​(java.awt.Component c,
                              java.awt.Graphics g,
                              int x,
                              int y)
        Specified by:
        paintIcon in interface javax.swing.Icon
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object