Search in sources :

Example 6 with SwtUniversalImage

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);
    }
}
Also used : PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) Image(org.eclipse.swt.graphics.Image) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage)

Example 7 with SwtUniversalImage

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;
}
Also used : Image(org.eclipse.swt.graphics.Image) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage)

Example 8 with SwtUniversalImage

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);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) BufferedImage(java.awt.image.BufferedImage) Image(org.eclipse.swt.graphics.Image) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage) Point(org.pentaho.di.core.gui.Point) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage)

Example 9 with SwtUniversalImage

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);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) Image(org.eclipse.swt.graphics.Image) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage) BufferedImage(java.awt.image.BufferedImage) Point(org.pentaho.di.core.gui.Point) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage)

Example 10 with SwtUniversalImage

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;
}
Also used : Image(org.eclipse.swt.graphics.Image) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage)

Aggregations

SwtUniversalImage (org.pentaho.di.core.SwtUniversalImage)14 Image (org.eclipse.swt.graphics.Image)11 Display (org.eclipse.swt.widgets.Display)3 BufferedImage (java.awt.image.BufferedImage)2 InputStream (java.io.InputStream)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 SwtUniversalImageSvg (org.pentaho.di.core.SwtUniversalImageSvg)2 Point (org.pentaho.di.core.gui.Point)2 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)2 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)2 SvgImage (org.pentaho.di.core.svg.SvgImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Color (org.eclipse.swt.graphics.Color)1 GC (org.eclipse.swt.graphics.GC)1 ImageLoader (org.eclipse.swt.graphics.ImageLoader)1 Point (org.eclipse.swt.graphics.Point)1 SwtUniversalImageBitmap (org.pentaho.di.core.SwtUniversalImageBitmap)1