public static final class ImageIcon.Builder extends Object implements AutoCloseable
Constructor and Description |
---|
Builder(ImageIcon.Builder other) |
Modifier and Type | Method and Description |
---|---|
ImageIcon.Builder |
addImage(Image image,
double displayScale)
Adds an
Image to the icon builder. |
ImageIcon.Builder |
addImage(Image image,
double anchorX,
double anchorY,
double displayScale)
Adds an
Image to the icon builder. |
IIcon |
build()
Returns the
IIcon based on the provided images. |
void |
close() |
protected void |
finalize() |
public Builder(@NotNull ImageIcon.Builder other)
public void close()
close
in interface AutoCloseable
@NotNull public IIcon build() throws IllegalStateException
IIcon
based on the provided images.IIcon
based on the provided images.IllegalStateException
- If no images have been set.@NotNull public ImageIcon.Builder addImage(@NotNull Image image, double displayScale) throws NullPointerException, IllegalArgumentException
Image
to the icon builder.
The anchor point is place at the center of the image.
When an image is already provided for a given display scale the last call overrides the previous image.
image
- The image. Cannot be null
.displayScale
- The display scale factor for the image. Must be > 0.NullPointerException
- when the image is a null
value.IllegalArgumentException
- when the display scale is <= 0.@NotNull public ImageIcon.Builder addImage(@NotNull Image image, double anchorX, double anchorY, double displayScale) throws NullPointerException, IllegalArgumentException
Image
to the icon builder.
When an image is already provided for a given display scale the last call overrides the previous image.
image
- The image. Cannot be null
.anchorX
- The x coordinate of the anchor point in pixels. This must be a value in the [0, getWidth()] range.anchorY
- The y coordinate of the anchor point in pixels. This must be a value in the [0, getHeight()] range.displayScale
- The display scale factor for the image. Must be > 0.NullPointerException
- when the image is a null
value.IllegalArgumentException
- when the display scale is <= 0 or an invalid value is provided for the anchor point.IIconPainter