use of org.pentaho.di.core.SwtUniversalImage in project pentaho-kettle by pentaho.
the class GUIResource method loadStepImages.
/**
* Load all step images from files.
*/
private void loadStepImages() {
// imagesSteps.clear();
// imagesStepsSmall.clear();
//
// STEP IMAGES TO LOAD
//
PluginRegistry registry = PluginRegistry.getInstance();
List<PluginInterface> steps = registry.getPlugins(StepPluginType.class);
for (PluginInterface step : steps) {
if (imagesSteps.get(step.getIds()[0]) != null) {
continue;
}
SwtUniversalImage image = null;
Image small_image = null;
String filename = step.getImageFile();
try {
ClassLoader classLoader = registry.getClassLoader(step);
image = SwtSvgImageUtil.getUniversalImage(display, classLoader, filename);
} catch (Throwable t) {
log.logError("Error occurred loading image [" + filename + "] for plugin " + step, t);
} finally {
if (image == null) {
log.logError("Unable to load image file [" + filename + "] for plugin " + step);
image = SwtSvgImageUtil.getMissingImage(display);
}
}
// Calculate the smaller version of the image @ 16x16...
// Perhaps we should make this configurable?
//
small_image = image.getAsBitmapForSize(display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE);
imagesSteps.put(step.getIds()[0], image);
imagesStepsSmall.put(step.getIds()[0], small_image);
}
}
use of org.pentaho.di.core.SwtUniversalImage in project pentaho-kettle by pentaho.
the class GUIResource method getImage.
/**
* Loads an image from a location once. The second time, the image comes from a cache. Because of this, it's important
* to never dispose of the image you get from here. (easy!) The images are automatically disposed when the application
* ends.
*
* @param location the location of the image resource to load
* @param classLoader the ClassLoader to use to locate resources
* @param width The height to resize the image to
* @param height The width to resize the image to
* @return the loaded image
*/
public Image getImage(String location, ClassLoader classLoader, int width, int height) {
Image image = imageMap.get(location);
if (image == null) {
SwtUniversalImage svg = SwtSvgImageUtil.getUniversalImage(display, classLoader, location);
image = new Image(display, svg.getAsBitmapForSize(display, width, height), SWT.IMAGE_COPY);
svg.dispose();
imageMap.put(location, image);
}
return image;
}
use of org.pentaho.di.core.SwtUniversalImage in project pentaho-kettle by pentaho.
the class SWTDirectGC method drawJobEntryIcon.
public void drawJobEntryIcon(int x, int y, JobEntryCopy jobEntryCopy, float magnification) {
if (jobEntryCopy == null) {
// Don't draw anything
return;
}
SwtUniversalImage swtImage = null;
int w = Math.round(iconsize * magnification);
int h = Math.round(iconsize * magnification);
if (jobEntryCopy.isSpecial()) {
if (jobEntryCopy.isStart()) {
swtImage = GUIResource.getInstance().getSwtImageStart();
}
if (jobEntryCopy.isDummy()) {
swtImage = GUIResource.getInstance().getSwtImageDummy();
}
} else {
String configId = jobEntryCopy.getEntry().getPluginId();
if (configId != null) {
swtImage = GUIResource.getInstance().getImagesJobentries().get(configId);
}
}
if (swtImage == null) {
return;
}
Image image = swtImage.getAsBitmapForSize(gc.getDevice(), w, h);
org.eclipse.swt.graphics.Rectangle bounds = image.getBounds();
gc.drawImage(image, 0, 0, bounds.width, bounds.height, x, y, iconsize, iconsize);
}
use of org.pentaho.di.core.SwtUniversalImage in project pentaho-kettle by pentaho.
the class SWTGC method drawJobEntryIcon.
public void drawJobEntryIcon(int x, int y, JobEntryCopy jobEntryCopy, float magnification) {
if (jobEntryCopy == null) {
// Don't draw anything
return;
}
SwtUniversalImage swtImage = null;
int w = Math.round(iconsize * magnification);
int h = Math.round(iconsize * magnification);
if (jobEntryCopy.isSpecial()) {
if (jobEntryCopy.isStart()) {
swtImage = GUIResource.getInstance().getSwtImageStart();
}
if (jobEntryCopy.isDummy()) {
swtImage = GUIResource.getInstance().getSwtImageDummy();
}
} else {
String configId = jobEntryCopy.getEntry().getPluginId();
if (configId != null) {
swtImage = GUIResource.getInstance().getImagesJobentries().get(configId);
}
}
if (jobEntryCopy.isMissing()) {
swtImage = GUIResource.getInstance().getSwtImageMissing();
}
if (swtImage == null) {
return;
}
Image image = swtImage.getAsBitmapForSize(gc.getDevice(), w, h);
org.eclipse.swt.graphics.Rectangle bounds = image.getBounds();
gc.drawImage(image, 0, 0, bounds.width, bounds.height, x, y, iconsize, iconsize);
}
use of org.pentaho.di.core.SwtUniversalImage in project pentaho-kettle by pentaho.
the class GUIResource method loadAsResource.
// load image from svg
private Image loadAsResource(Display display, String location, int size) {
SwtUniversalImage img = SwtSvgImageUtil.getImageAsResource(display, location);
Image image;
if (size > 0) {
image = new Image(display, img.getAsBitmapForSize(display, size, size), SWT.IMAGE_COPY);
} else {
image = new Image(display, img.getAsBitmap(display), SWT.IMAGE_COPY);
}
img.dispose();
return image;
}
Aggregations