Package resources

Class MultiIconBuilder

java.lang.Object
resources.MultiIconBuilder

public class MultiIconBuilder extends 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 Details

    • MultiIconBuilder

      public MultiIconBuilder(Icon baseIcon)
  • Method Details

    • addIcon

      public MultiIconBuilder addIcon(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)
    • addIcon

      public MultiIconBuilder addIcon(Icon icon, int w, int h, int x, int y)
      Adds the specified icon as an overlay to the base icon at the given offsets and scaled to the specified width and height.
      Parameters:
      icon - the icon to overlay
      w - width of the overlaid icon
      h - height of the overlaid icon
      x - the horizontal offset of the overlay with respect to the base icon
      y - the vertical offset of the overlay with respect to the base icon
      Returns:
      this builder (for chaining)
    • addLowerRightIcon

      public MultiIconBuilder addLowerRightIcon(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(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(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(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
    • addCenteredIcon

      public MultiIconBuilder addCenteredIcon(Icon icon)
    • addText

      public MultiIconBuilder addText(String text, Font font, 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(String description)
      Sets a description for the icon being built. This is useful for debugging.
      Parameters:
      description - the description
      Returns:
      this builder
    • build

      public ImageIcon build()