Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jface.resource
Class ImageDescriptor

    java.lang.Object
      org.eclipse.jface.resource.ImageDescriptor

Direct Known Subclasses:
  CompositeImageDescriptor

public abstract class ImageDescriptor
extends Object

An image descriptor is an object that knows how to create an SWT image. It does not hold onto images or cache them, but rather just creates them on demand. An image descriptor is intended to be a lightweight representation of an image that can be manipulated even when no SWT display exists.

This package defines a concrete image descriptor implementation which reads an image from a file (`FileImageDescriptor`). It also provides abstract framework classes (this one and `CompositeImageDescriptor`) which may be subclassed to define news kinds of image descriptors.

Using this abstract class involves defining a concrete subclass and providing an implementation for the `getImageData` method.

See Also:
  `Image`

Field Summary
`protected static ImageData` | `DEFAULT_IMAGE_DATA` A small red square used to warn that an image cannot be created.

Constructor Summary
`protected` | `ImageDescriptor()` Constructs an image descriptor.

Method Summary
`static ImageDescriptor` | `createFromFile(Class location, String filename)` Creates and returns a new image descriptor from a file.
`static ImageDescriptor` | `createFromURL(URL url)` Creates and returns a new image descriptor from a URL.
`Image` | `createImage()` Creates and returns a new SWT image for this image descriptor.
`Image` | `createImage(boolean returnMissingImageOnError)` Creates and returns a new SWT image for this image descriptor.
`Image` | `createImage(boolean returnMissingImageOnError, Device device)` Creates and returns a new SWT image for this image descriptor.
`Image` | `createImage(Device device)` Creates and returns a new SWT image for this image descriptor.
`abstract ImageData` | `getImageData()` Creates and returns a new SWT `ImageData` object for this image descriptor.
`static ImageDescriptor` | `getMissingImageDescriptor()` Returns the shared image descriptor for a missing image.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_IMAGE_DATA

    protected static final ImageData DEFAULT_IMAGE_DATA

  A small red square used to warn that an image cannot be created.

Constructor Detail

### ImageDescriptor

    protected ImageDescriptor()

  Constructs an image descriptor.

Method Detail

### createFromFile

    public static ImageDescriptor createFromFile(Class location,
                                                 String filename)

  Creates and returns a new image descriptor from a file. Convenience method for `new FileImageDescriptor(location,filename)`.

  Parameters:
    `location` - the class whose resource directory contain the file
    `filename` - the file name
  Returns:
    a new image descriptor

### createFromURL

    public static ImageDescriptor createFromURL(URL url)

  Creates and returns a new image descriptor from a URL.

  Parameters:
    `url` - The URL of the image file.
  Returns:
    a new image descriptor

### createImage

    public Image createImage()

  Creates and returns a new SWT image for this image descriptor. Note that each call returns a new SWT image object. A default image is returned in the event of an error.

  Note: it is still possible for this method to return `null` in extreme cases, for example if SWT runs out of image handles.

  Returns:
    a new image or `null` if the image could not be created

### createImage

    public Image createImage(boolean returnMissingImageOnError)

  Creates and returns a new SWT image for this image descriptor. In the even of an error, a default image is returned if `returnMissingImageOnError` is true, otherwise `null` is returned.

  Note: Even if `returnMissingImageOnError` is true, it is still possible for this method to return `null` in extreme cases, for example if SWT runs out of image handles.

  Parameters:
    `returnMissingImageOnError` - flag that determines if a default image is returned on error
  Returns:
    a new image or `null` if the image could not be created

### createImage

    public Image createImage(Device device)

  Creates and returns a new SWT image for this image descriptor. A default image is returned in the event of an error.

  Note: it is still possible for this method to return `null` in extreme cases, for example if SWT runs out of image handles.

  Parameters:
    `device` - the device on which to create the image
  Returns:
    a new image or `null` if the image could not be created
  Since:
    2.0

### createImage

    public Image createImage(boolean returnMissingImageOnError,
                             Device device)

  Creates and returns a new SWT image for this image descriptor. In the even of an error, a default image is returned if `returnMissingImageOnError` is true, otherwise `null` is returned.

  Note: Even if `returnMissingImageOnError` is true, it is still possible for this method to return `null` in extreme cases, for example if SWT runs out of image handles.

  Parameters:
    `returnMissingImageOnError` - flag that determines if a default image is returned on error
    `device` - the device on which to create the image
  Returns:
    a new image or `null` if the image could not be created
  Since:
    2.0

### getImageData

    public abstract ImageData getImageData()

  Creates and returns a new SWT `ImageData` object for this image descriptor. Note that each call returns a new SWT image data object.

  This framework method is declared public so that it is possible to request an image descriptor's image data without creating an SWT image object.

  Returns `null` if the image data could not be created.

  Returns:
    a new image data or `null`

### getMissingImageDescriptor

    public static ImageDescriptor getMissingImageDescriptor()

  Returns the shared image descriptor for a missing image.

  Returns:
    the missing image descriptor

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.