Class DecoratableIcon

  • All Implemented Interfaces:
    javax.swing.Icon

    public class DecoratableIcon
    extends java.lang.Object
    implements javax.swing.Icon
    An icon that can have an optional "decorations" icon beside of it.
    Version:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<javax.swing.Icon> decorations
      The "decoration" icons.
      private static int DEFAULT_WIDTH
      The width of a decoratable icon (16 + 8 + 8, - 8 for overlap).
      private boolean deprecated
      Whether this icon is for a "deprecated" item.
      private javax.swing.Icon mainIcon
      The "main" icon (the icon that is decorated).
      private int width
      The width of this icon.
    • Constructor Summary

      Constructors 
      Constructor Description
      DecoratableIcon​(int width, javax.swing.Icon mainIcon)
      Constructor.
      DecoratableIcon​(javax.swing.Icon mainIcon)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDecorationIcon​(javax.swing.Icon decoration)
      Adds a decoration icon.
      int getIconHeight()
      int getIconWidth()
      void paintIcon​(java.awt.Component c, java.awt.Graphics g, int x, int y)
      void setDeprecated​(boolean deprecated)
      Sets whether this icon is for a deprecated item.
      void setMainIcon​(javax.swing.Icon icon)
      Sets the main icon.
      • Methods inherited from class java.lang.Object

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

      • width

        private int width
        The width of this icon.
      • mainIcon

        private javax.swing.Icon mainIcon
        The "main" icon (the icon that is decorated).
      • decorations

        private java.util.List<javax.swing.Icon> decorations
        The "decoration" icons.
      • deprecated

        private boolean deprecated
        Whether this icon is for a "deprecated" item.
      • DEFAULT_WIDTH

        private static final int DEFAULT_WIDTH
        The width of a decoratable icon (16 + 8 + 8, - 8 for overlap).
        See Also:
        Constant Field Values
    • Constructor Detail

      • DecoratableIcon

        public DecoratableIcon​(javax.swing.Icon mainIcon)
        Constructor.
        Parameters:
        mainIcon - The "main" icon. This cannot be null.
      • DecoratableIcon

        public DecoratableIcon​(int width,
                               javax.swing.Icon mainIcon)
        Constructor.
        Parameters:
        width - The width for this icon.
        mainIcon - The "main" icon. This cannot be null.
    • Method Detail

      • addDecorationIcon

        public void addDecorationIcon​(javax.swing.Icon decoration)
        Adds a decoration icon.
        Parameters:
        decoration - A new decoration icon. This cannot be null.
        See Also:
        setMainIcon(Icon)
      • getIconHeight

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

        public int getIconWidth()
        Specified by:
        getIconWidth in interface javax.swing.Icon
      • paintIcon

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

        public void setDeprecated​(boolean deprecated)
        Sets whether this icon is for a deprecated item.
        Parameters:
        deprecated - Whether this icon is for a deprecated item.
      • setMainIcon

        public void setMainIcon​(javax.swing.Icon icon)
        Sets the main icon.
        Parameters:
        icon - The "main" icon. This cannot be null.
        See Also:
        addDecorationIcon(Icon)