Java Code Examples for org.eclipse.jface.resource.ImageDescriptor#getImageData()

The following examples show how to use org.eclipse.jface.resource.ImageDescriptor#getImageData() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
protected void drawOverlays(ImageDescriptor[] overlays, int[] locations) {
	Point size = getSize();
	for (int i = 0; i < overlays.length; i++) {
		ImageDescriptor overlay = overlays[i];
		ImageData overlayData = overlay.getImageData();
		switch (locations[i]) {
			case TOP_LEFT:
				drawImage(overlayData, 0, 0);			
				break;
			case TOP_RIGHT:
				drawImage(overlayData, size.x - overlayData.width, 0);			
				break;
			case BOTTOM_LEFT:
				drawImage(overlayData, 0, size.y - overlayData.height);			
				break;
			case BOTTOM_RIGHT:
				drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height);			
				break;
		}
	}
}
 
Example 2
@Override
protected IStatus run(IProgressMonitor monitor) {
  ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageUrl);
  imageData = descriptor.getImageData();
  if (imageData != null) {
    LabelImageLoader.storeInCache(imageUrl.toString(), imageData);
    display.syncExec(new SetImageRunnable());
  }
  return Status.OK_STATUS;
}
 
Example 3
private ImageData getImageData(ImageDescriptor descriptor) {
	ImageData data = descriptor.getImageData(); // see bug 51965:
												// getImageData can return
												// null
	if (data == null) {
		data = DEFAULT_IMAGE_DATA;
		//		JavaScriptPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
	}
	return data;
}
 
Example 4
public static URL getImageURL(ImageDescriptor descriptor) {
	if (fTempDir == null)
		return null;

	URL url = fURLMap.get(descriptor);
	if (url != null)
		return url;

	File imageFile = getNewFile();
	ImageData imageData = descriptor.getImageData();
	if (imageData == null) {
		return null;
	}

	ImageLoader loader = new ImageLoader();
	loader.data = new ImageData[] { imageData };
	loader.save(imageFile.getAbsolutePath(), SWT.IMAGE_PNG);

	try {
		url = imageFile.toURI().toURL();
		fURLMap.put(descriptor, url);
		return url;
	} catch (MalformedURLException e) {
		TypeScriptUIPlugin.log("Failed to create image directory ", e); //$NON-NLS-1$
	}
	return null;
}
 
Example 5
private ImageData getImageData( ImageDescriptor descriptor )
{
	ImageData data = descriptor.getImageData( ); // null
	if ( data == null )
	{
		data = DEFAULT_IMAGE_DATA;
	}
	return data;
}
 
Example 6
/**
 * Constructs a new CenteredCompositeImageDescriptor
 * 
 * @param baseImage
 * @param overlayImage
 */
CenteredCompositeImageDescriptor(ImageDescriptor baseImage, ImageDescriptor overlayImage)
{
	this.baseImageData = baseImage.getImageData();
	this.overlayImageData = overlayImage.getImageData();
	this.size = new Point(baseImageData.width, baseImageData.height);
}
 
Example 7
private ImageData getImageData( ImageDescriptor descriptor )
{
	ImageData data = descriptor.getImageData( ); // null
	if ( data == null )
	{
		data = DEFAULT_IMAGE_DATA;
	}
	return data;
}
 
Example 8
private ImageData getImageData(ImageDescriptor descriptor) {
	ImageData data= descriptor.getImageData(); // see bug 51965: getImageData can return null
	if (data == null) {
		data= DEFAULT_IMAGE_DATA;
		JavaPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
	}
	return data;
}
 
Example 9
public URL getImageURL(ImageDescriptor descriptor) {
	if (fTempDir == null)
		return null;

	URL url= fURLMap.get(descriptor);
	if (url != null)
		return url;

	File imageFile= getNewFile();
	ImageData imageData= descriptor.getImageData();
	if (imageData == null) {
		return null;
	}

	ImageLoader loader= new ImageLoader();
	loader.data= new ImageData[] { imageData };
	loader.save(imageFile.getAbsolutePath(), SWT.IMAGE_PNG);

	try {
		url= imageFile.toURI().toURL();
		fURLMap.put(descriptor, url);
		return url;
	} catch (MalformedURLException e) {
		JavaPlugin.log(e);
	}
	return null;
}
 
Example 10
private ImageData getImageData(ImageDescriptor descriptor) {
	ImageData data= descriptor.getImageData(); // see bug 51965: getImageData can return null
	if (data == null) {
		data= DEFAULT_IMAGE_DATA;
		JavaPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
	}
	return data;
}
 
Example 11
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 12
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 13
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 14
Source Project: saros   File: ImageManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an image from the file at the given plug-in relative path.
 *
 * @param path
 * @return image; the returned image <b>MUST be disposed after usage</b> to free up memory
 */
public static Image getImage(final String path) {
  ImageDescriptor descriptor = getImageDescriptor(path);

  if (descriptor == null) {
    log.warn(
        "could not create image for path '"
            + path
            + "', either the file does not exists or the format is not supported");
    descriptor = ImageDescriptor.getMissingImageDescriptor();
  }

  return new Image(Display.getDefault(), descriptor.getImageData());
}
 
Example 15
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 16
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 17
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 18
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 19
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}
 
Example 20
/**
 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
 * @param path
 *            the path
 * @return the icon descriptor
 */
public static ImageDescriptor getIconDescriptor(String path) {
	ImageDescriptor image = getImageDescriptor(path);
	ImageData data = image.getImageData();
	data = data.scaledTo(16, 16);
	image = ImageDescriptor.createFromImageData(data);
	return image;
}