Package resources
Class MultiIconBuilder
- java.lang.Object
-
- resources.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. Thebuild()
method returns anImageIcon
, 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-leftMultiIconBuilder
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 heightMultiIconBuilder
addLowerRightIcon(javax.swing.Icon icon)
Adds the given icon as an overlay to the base icon, to the lower-rightMultiIconBuilder
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 heightMultiIconBuilder
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.
-
-
-
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 overlayw
- width of the overlaid iconh
- height of the overlaid iconquandrant
- 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 iconw
- the desired widthh
- 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 iconw
- the desired widthh
- 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 twofont
- 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 textcolor
- The color to use when rendering the textquandrant
- TheQUADRANT
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()
-
-