org.openide.util 7.31.1 1

org.openide.util
Class ImageUtilities

java.lang.Object
  extended by org.openide.util.ImageUtilities

public final class ImageUtilities
extends Object

Useful static methods for manipulation with images/icons, results are cached.

Since:
7.15

Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadImage

public static final Image loadImage(String resourceID)
Loads an image from the specified resource ID. The image is loaded using the "system" classloader registered in Lookup.

Parameters:
resourceID - resource path of the icon (no initial slash)
Returns:
icon's Image, or null, if the icon cannot be loaded.

loadImage

public static final Image loadImage(String resource,
                                    boolean localized)
Loads an image based on resource path. Exactly like 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.

Parameters:
resource - resource path of the image (no initial slash)
localized - true for localized search
Returns:
icon's Image or null if the icon cannot be loaded

loadImageIcon

public static final ImageIcon loadImageIcon(String resource,
                                            boolean localized)
Loads an icon based on resource path. Similar to loadImage(String, boolean), returns ImageIcon instead of Image.

Parameters:
resource - resource path of the icon (no initial slash)
localized - localized resource should be used
Returns:
ImageIcon or null, if the icon cannot be loaded.
Since:
7.22

mergeImages

public static final Image mergeImages(Image image1,
                                      Image image2,
                                      int x,
                                      int y)
This method merges two images into the new one. The second image is drawn over the first one with its top-left corner at x, y. Images need not be of the same size. New image will have a size of max(second image size + top-left corner, first image size). Method is used mostly when second image contains transparent pixels (e.g. for badging). Method that attempts to find the merged image in the cache first, then creates the image if it was not found.

Parameters:
image1 - underlying image
image2 - second image
x - x position of top-left corner
y - y position of top-left corner
Returns:
new merged image

image2Icon

public static final Icon image2Icon(Image image)
Converts given image to an icon.

Parameters:
image - to be converted
Returns:
icon corresponding icon

icon2Image

public static final Image icon2Image(Icon icon)
Converts given icon to a Image.

Parameters:
icon - Icon to be converted.

assignToolTipToImage

public static final 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. "<b>my</b> text"

Parameters:
image - image to which tool tip should be set
text - tool tip text
Returns:
Image with attached tool tip

getImageToolTip

public static final String getImageToolTip(Image image)
Get tool tip text for given image

Parameters:
image - image which is asked for tool tip text
Returns:
String containing attached tool tip text

addToolTipToImage

public static final 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. "<b>my</b> text"

Parameters:
text - text to add to tool tip
Returns:
Image with attached tool tip

createDisabledIcon

public static Icon createDisabledIcon(Icon icon)
Creates disabled (color saturation lowered) icon. Icon image conversion is performed lazily.

Parameters:
icon - original icon used for conversion
Returns:
less saturated Icon
Since:
7.28

createDisabledImage

public static Image createDisabledImage(Image image)
Creates disabled (color saturation lowered) image.

Parameters:
image - original image used for conversion
Returns:
less saturated Image
Since:
7.28

org.openide.util 7.31.1 1

Built on July 6 2010.  |  Portions Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved.