ImageHelperpublic class ImageHelper extends Object
Methods Summary |
---|
public static org.eclipse.swt.graphics.Image | createPlaceHolderArt(org.eclipse.swt.widgets.Display display, int width, int height, org.eclipse.swt.graphics.Color color)Create place-holder art with the specified color.
Image img = new Image(display, width, height);
GC gc = new GC(img);
gc.setForeground(color);
gc.drawLine(0, 0, width, height);
gc.drawLine(0, height - 1, width, -1);
gc.dispose();
return img;
| public static org.eclipse.swt.graphics.Image | loadImage(IImageLoader loader, org.eclipse.swt.widgets.Display display, java.lang.String fileName, int width, int height, org.eclipse.swt.graphics.Color phColor)Loads an image from a resource. This method used a class to locate the
resources, and then load the filename from /images inside the resources.
Extra parameters allows for creation of a replacement image of the
loading failed.
Image img = null;
if (loader != null) {
img = loader.loadImage(fileName, display);
}
if (img == null) {
Log.w("ddms", "Couldn't load " + fileName);
// if we had the extra parameter to create replacement image then we
// create and return it.
if (width != -1 && height != -1) {
return createPlaceHolderArt(display, width, height,
phColor != null ? phColor : display
.getSystemColor(SWT.COLOR_BLUE));
}
// otherwise, just return null
return null;
}
return img;
|
|