ilog.views.util
Class IlvImageUtil

java.lang.Object
  extended by ilog.views.util.IlvImageUtil

public class IlvImageUtil
extends Object

This class defines a set of utility methods to load and create images.

Since:
JViews 5.5

Method Summary
static BufferedImage createBufferedImage(Image image, int imageType)
          Creates a BufferedImage of the specified type from the given image.
static Image getImageFromFile(Class loader, String file)
          This is a utility method that creates an image from a file stored in a JAR file.
static Image loadImage(String fileName)
          Loads an image from the specified file.
static BufferedImage loadImage(String fileName, int imageType)
          Loads an image from the specified file as a BufferedImage of the specified type.
static Image loadImage(URL url)
          Loads an image from the specified URL.
static BufferedImage loadImage(URL url, int imageType)
          Loads an image from the specified URL as a BufferedImage of the specified type.
static Image loadImageFromFile(Class loader, String filename)
          Utility method that loads an image from a file stored in a JAR file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImageFromFile

public static Image getImageFromFile(Class loader,
                                     String file)
                              throws IOException
This is a utility method that creates an image from a file stored in a JAR file. To read the image file, the method uses the InputStream returned by the method getResourceAsStream called on the loader object.

Parameters:
loader - The Class object on which the method getResourceAsStream is called.
file - The location of the file that contains the image to be read. The location must be specified according to the location of the loader class. For details, see the documentation of Class.getResourceAsStream.
Returns:
The created image.
Throws:
IOException - An exception occurred while trying to read the bytes defining the image.

loadImageFromFile

public static Image loadImageFromFile(Class loader,
                                      String filename)
                               throws IOException
Utility method that loads an image from a file stored in a JAR file. The method returns once the image is fully loaded.

Parameters:
loader - The Class object on which the method getResourceAsStream is called.
filename - The location of the file that contains the image to be read. The location must be specified according to the location of the loader class.
Returns:
The loaded image, or null if the loading failed.
Throws:
IOException - An exception occurred while trying to read the bytes defining the image.
See Also:
getImageFromFile(java.lang.Class, java.lang.String)

createBufferedImage

public static BufferedImage createBufferedImage(Image image,
                                                int imageType)
Creates a BufferedImage of the specified type from the given image.

Parameters:
image - The original image.
imageType - The type of the image to create. It can be any of the predefined image types defined in the java.awt.image.BufferedImage class.

loadImage

public static Image loadImage(URL url)
Loads an image from the specified URL.

Parameters:
url - The URL of the image.
Returns:
The image, or null if the loading failed.

loadImage

public static Image loadImage(String fileName)
Loads an image from the specified file.

Parameters:
fileName - The image file name.
Returns:
The image, or null if the loading failed.

loadImage

public static BufferedImage loadImage(String fileName,
                                      int imageType)
Loads an image from the specified file as a BufferedImage of the specified type.

Parameters:
fileName - The image file name.
imageType - The type of the image to create. It can be any of the predefined image types defined in the java.awt.image.BufferedImage class.
Returns:
The image, or null if the loading failed.

loadImage

public static BufferedImage loadImage(URL url,
                                      int imageType)
Loads an image from the specified URL as a BufferedImage of the specified type.

Parameters:
url - The URL of the image.
imageType - The type of the image to create. It can be any of the predefined image types defined in the java.awt.image.BufferedImage class.
Returns:
The image, or null if the loading failed.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.