Package resources

Class MultiIconBuilder


  • public class MultiIconBuilder
    extends java.lang.Object
    A builder to allow for easier creation of an icon that is composed of a base icon, with other icons overlaid. The build() method returns an ImageIcon, as this allows Java's buttons to automatically create disabled icons correctly.

    Note: this class is a work-in-progress. Add more methods for locating overlays as needed.

    • Constructor Summary

      Constructors 
      Constructor Description
      MultiIconBuilder​(javax.swing.Icon baseIcon)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MultiIconBuilder addIcon​(javax.swing.Icon icon, int w, int h, QUADRANT quandrant)
      Adds the specified icon as an overlay to the base icon, possibly scaled according to the specified width and height, in the specified quadrant corner.
      MultiIconBuilder addLowerLeftIcon​(javax.swing.Icon icon)
      Adds the given icon as an overlay to the base icon, to the lower-left
      MultiIconBuilder addLowerLeftIcon​(javax.swing.Icon icon, int w, int h)
      Adds the given icon as an overlay to the base icon, to the lower-left, scaled to the given width and height
      MultiIconBuilder addLowerRightIcon​(javax.swing.Icon icon)
      Adds the given icon as an overlay to the base icon, to the lower-right
      MultiIconBuilder addLowerRightIcon​(javax.swing.Icon icon, int w, int h)
      Adds the given icon as an overlay to the base icon, to the lower-right, scaled to the given width and height
      MultiIconBuilder addText​(java.lang.String text, java.awt.Font font, java.awt.Color color, QUADRANT quandrant)
      Add text overlaid on the base icon, aligned to the specified quadrant.
      javax.swing.ImageIcon build()  
      MultiIconBuilder setDescription​(java.lang.String description)
      Sets a description for the icon being built.
      • Methods inherited from class java.lang.Object

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

      • MultiIconBuilder

        public MultiIconBuilder​(javax.swing.Icon baseIcon)
    • Method Detail

      • addIcon

        public MultiIconBuilder addIcon​(javax.swing.Icon icon,
                                        int w,
                                        int h,
                                        QUADRANT quandrant)
        Adds the specified icon as an overlay to the base icon, possibly scaled according to the specified width and height, in the specified quadrant corner.
        Parameters:
        icon - the icon to overlay
        w - width of the overlaid icon
        h - height of the overlaid icon
        quandrant - corner to place the overlay on
        Returns:
        this builder (for chaining)
      • addLowerRightIcon

        public MultiIconBuilder addLowerRightIcon​(javax.swing.Icon icon)
        Adds the given icon as an overlay to the base icon, to the lower-right
        Parameters:
        icon - the icon
        Returns:
        this builder
      • addLowerRightIcon

        public MultiIconBuilder addLowerRightIcon​(javax.swing.Icon icon,
                                                  int w,
                                                  int h)
        Adds the given icon as an overlay to the base icon, to the lower-right, scaled to the given width and height
        Parameters:
        icon - the icon
        w - the desired width
        h - the desired height
        Returns:
        this builder
      • addLowerLeftIcon

        public MultiIconBuilder addLowerLeftIcon​(javax.swing.Icon icon)
        Adds the given icon as an overlay to the base icon, to the lower-left
        Parameters:
        icon - the icon
        Returns:
        this builder
      • addLowerLeftIcon

        public MultiIconBuilder addLowerLeftIcon​(javax.swing.Icon icon,
                                                 int w,
                                                 int h)
        Adds the given icon as an overlay to the base icon, to the lower-left, scaled to the given width and height
        Parameters:
        icon - the icon
        w - the desired width
        h - the desired height
        Returns:
        this builder
      • addText

        public MultiIconBuilder addText​(java.lang.String text,
                                        java.awt.Font font,
                                        java.awt.Color color,
                                        QUADRANT quandrant)
        Add text overlaid on the base icon, aligned to the specified quadrant.
        Parameters:
        text - Text string to write onto the icon. Probably can only fit a letter or two
        font - The font to use to render the text. You know the size of the base icon, so you should be able to figure out the size of the font to use for the text
        color - The color to use when rendering the text
        quandrant - The QUADRANT to align the text to different parts of the icon
        Returns:
        this builder (for chaining)
      • setDescription

        public MultiIconBuilder setDescription​(java.lang.String description)
        Sets a description for the icon being built. This is useful for debugging.
        Parameters:
        description - the description
        Returns:
        this builder
      • build

        public javax.swing.ImageIcon build()