Images and image descriptors
In the SWT program model there is a difference
between images (SWT images) and image descriptors:
|
Image |
||
|
|
SWT images are instances of the class org.eclipse.swt.Image. Images hold their data in
memory. They already exist in an appropriate representation for display on
screen. The resources associated with these “heavy-weight” objects (that is,
objects that consume considerable system resources) should not be held in
memory for an unlimited length of time. If an image instance is no longer
needed, the resources it consumes should be released explicitly using the dispose() method. This is particularly
important because SWT images occupy an area of memory that is referenced only
by the operating system, which means that the Java Garbage Collector does not
access it. Operating systems, however, can normally hold only a limited
number of image resources in memory. |
|
|
ImageDescriptor |
||
|
|
ImageDescriptors are defined in the class org.eclipse.jface.resource.ImageDescriptor. These “light-weight” objects are
simply descriptions of images. Unlike image instances, they do not hold their
data in memory. However, they contain all the information you need on how to
obtain images. Every call of the createImage() method to an ImageDescriptor returns the
relevant image instance. |
|
Graphic resources you can use with the UI
belonging to your plug-in are available from the following sources:
·
Graphics
for static use ( provided by the plugin.xml file)
·
Standard
Workbench Registry icons (from the Eclipse UI plug-in)
·
SAP
standard icons
·
Plug-in-specific
graphics
·
Standard
icons from other plug-ins (for example, from the JDT)
The following description deals with accessing the appropriate
resources, along with the support available to you in each case.