Package resources
Class MultiIconBuilder
java.lang.Object
resources.MultiIconBuilder
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
-
Method Summary
Modifier and TypeMethodDescriptionaddCenteredIcon
(Icon icon) Adds the specified icon as an overlay to the base icon at the given offsets and scaled to the specified width and height.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.addLowerLeftIcon
(Icon icon) Adds the given icon as an overlay to the base icon, to the lower-leftaddLowerLeftIcon
(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 heightaddLowerRightIcon
(Icon icon) Adds the given icon as an overlay to the base icon, to the lower-rightaddLowerRightIcon
(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 heightAdd text overlaid on the base icon, aligned to the specified quadrant.build()
setDescription
(String description) Sets a description for the icon being built.
-
Constructor Details
-
MultiIconBuilder
-
-
Method Details
-
addIcon
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)
-
addIcon
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 overlayw
- width of the overlaid iconh
- height of the overlaid iconx
- the horizontal offset of the overlay with respect to the base icony
- the vertical offset of the overlay with respect to the base icon- Returns:
- this builder (for chaining)
-
addLowerRightIcon
Adds the given icon as an overlay to the base icon, to the lower-right- Parameters:
icon
- the icon- Returns:
- this builder
-
addLowerRightIcon
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
Adds the given icon as an overlay to the base icon, to the lower-left- Parameters:
icon
- the icon- Returns:
- this builder
-
addLowerLeftIcon
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
-
addCenteredIcon
-
addText
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
Sets a description for the icon being built. This is useful for debugging.- Parameters:
description
- the description- Returns:
- this builder
-
build
-