public final class ImageUtilities extends Object
Modifier and Type | Method and Description |
---|---|
static Image |
addToolTipToImage(Image image,
String text)
Add text to tool tip for given image (creates new or returns cached, original remains unmodified)
Text can contain HTML tags e.g.
|
static Image |
assignToolTipToImage(Image image,
String text)
Assign tool tip text to given image (creates new or returns cached, original remains unmodified)
Text can contain HTML tags e.g.
|
static Icon |
createDisabledIcon(Icon icon)
Creates disabled (color saturation lowered) icon.
|
static Image |
createDisabledImage(Image image)
Creates disabled (color saturation lowered) image.
|
static String |
getImageToolTip(Image image)
Get tool tip text for given image
|
static Image |
icon2Image(Icon icon)
Converts given icon to a
Image . |
static Icon |
image2Icon(Image image)
Converts given image to an icon.
|
static Image |
loadImage(String resourceID)
Loads an image from the specified resource ID.
|
static Image |
loadImage(String resource,
boolean localized)
Loads an image based on resource path.
|
static ImageIcon |
loadImageIcon(String resource,
boolean localized)
Loads an icon based on resource path.
|
static Image |
mergeImages(Image image1,
Image image2,
int x,
int y)
This method merges two images into the new one.
|
public static final Image loadImage(String resourceID)
resourceID
- resource path of the icon (no initial slash)public static final Image loadImage(String resource, boolean localized)
loadImage(String)
but may do a localized search.
For example, requesting org/netbeans/modules/foo/resources/foo.gif
might actually find org/netbeans/modules/foo/resources/foo_ja.gif
or org/netbeans/modules/foo/resources/foo_mybranding.gif.
Caching of loaded images can be used internally to improve performance.
Since version 8.12 the returned image object responds to call
image.getProperty("url", null)
by returning the internal
URL
of the found and loaded resource
.
If the current look and feel is 'dark' (UIManager.getBoolean("nb.dark.theme")
)
then the method first attempts to load image <original file name>_dark.<original extension>.
If such file doesn't exist the default one is loaded instead.
resource
- resource path of the image (no initial slash)localized
- true for localized searchpublic static final ImageIcon loadImageIcon(String resource, boolean localized)
loadImage(String, boolean)
, returns ImageIcon instead of Image.
If the current look and feel is 'dark' (UIManager.getBoolean("nb.dark.theme")
)
then the method first attempts to load image <original file name>_dark.<original extension>.
If such file doesn't exist the default one is loaded instead.
resource
- resource path of the icon (no initial slash)localized
- localized resource should be usedpublic static final Image mergeImages(Image image1, Image image2, int x, int y)
image1
- underlying imageimage2
- second imagex
- x position of top-left cornery
- y position of top-left cornerpublic static final Icon image2Icon(Image image)
image
- to be convertedpublic static final Image icon2Image(Icon icon)
Image
.icon
- Icon
to be converted.public static final Image assignToolTipToImage(Image image, String text)
image
- image to which tool tip should be settext
- tool tip textpublic static final String getImageToolTip(Image image)
image
- image which is asked for tool tip textpublic static final Image addToolTipToImage(Image image, String text)
text
- text to add to tool tippublic static Icon createDisabledIcon(Icon icon)
icon
- original icon used for conversionBuilt on August 30 2023. | Copyright © 2017-2023 Apache Software Foundation. All Rights Reserved.