Search in sources :

Example 6 with SwingUniversalImage

use of org.pentaho.di.core.SwingUniversalImage in project pentaho-kettle by pentaho.

the class SwingGC method drawImage.

@Override
public void drawImage(EImage image, int x, int y, float magnification, double angle) {
    SwingUniversalImage img = getNativeImage(image);
    drawImage(img, x, y, angle, small_icon_size);
}
Also used : SwingUniversalImage(org.pentaho.di.core.SwingUniversalImage)

Example 7 with SwingUniversalImage

use of org.pentaho.di.core.SwingUniversalImage in project pentaho-kettle by pentaho.

the class SwingGUIResource method getUniversalImageIcon.

private SwingUniversalImage getUniversalImageIcon(PluginInterface plugin) throws KettleException {
    try {
        PluginRegistry registry = PluginRegistry.getInstance();
        String filename = plugin.getImageFile();
        ClassLoader classLoader = registry.getClassLoader(plugin);
        SwingUniversalImage image = null;
        if (SvgSupport.isSvgEnabled() && SvgSupport.isSvgName(filename)) {
            // Try to use the plugin class loader to get access to the icon
            // 
            InputStream inputStream = classLoader.getResourceAsStream(filename);
            if (inputStream == null) {
                inputStream = classLoader.getResourceAsStream("/" + filename);
            }
            // 
            if (inputStream == null) {
                inputStream = registry.getClass().getResourceAsStream(filename);
            }
            if (inputStream == null) {
                inputStream = registry.getClass().getResourceAsStream("/" + filename);
            }
            // 
            if (inputStream == null) {
                try {
                    inputStream = new FileInputStream(filename);
                } catch (FileNotFoundException e) {
                // Ignore, throws error below
                }
            }
            if (inputStream != null) {
                try {
                    SvgImage svg = SvgSupport.loadSvgImage(inputStream);
                    image = new SwingUniversalImageSvg(svg);
                } finally {
                    IOUtils.closeQuietly(inputStream);
                }
            }
        }
        if (image == null) {
            filename = SvgSupport.toPngName(filename);
            // Try to use the plugin class loader to get access to the icon
            // 
            InputStream inputStream = classLoader.getResourceAsStream(filename);
            if (inputStream == null) {
                inputStream = classLoader.getResourceAsStream("/" + filename);
            }
            // 
            if (inputStream == null) {
                inputStream = registry.getClass().getResourceAsStream(filename);
            }
            if (inputStream == null) {
                inputStream = registry.getClass().getResourceAsStream("/" + filename);
            }
            // 
            if (inputStream == null) {
                try {
                    inputStream = new FileInputStream(filename);
                } catch (FileNotFoundException e) {
                // Ignore, throws error below
                }
            }
            if (inputStream != null) {
                try {
                    BufferedImage bitmap = ImageIO.read(inputStream);
                    WaitingImageObserver wia = new WaitingImageObserver(bitmap);
                    wia.waitImageLoaded();
                    image = new SwingUniversalImageBitmap(bitmap);
                } finally {
                    IOUtils.closeQuietly(inputStream);
                }
            }
        }
        if (image == null) {
            throw new KettleException("Unable to find file: " + plugin.getImageFile() + " for plugin: " + plugin);
        }
        return image;
    } catch (Throwable e) {
        throw new KettleException("Unable to load image from file : '" + plugin.getImageFile() + "' for plugin: " + plugin, e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) SvgImage(org.pentaho.di.core.svg.SvgImage) SwingUniversalImage(org.pentaho.di.core.SwingUniversalImage) FileInputStream(java.io.FileInputStream) BufferedImage(java.awt.image.BufferedImage) WaitingImageObserver(org.pentaho.reporting.libraries.base.util.WaitingImageObserver) SwingUniversalImageSvg(org.pentaho.di.core.SwingUniversalImageSvg) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) SwingUniversalImageBitmap(org.pentaho.di.core.SwingUniversalImageBitmap)

Example 8 with SwingUniversalImage

use of org.pentaho.di.core.SwingUniversalImage in project pentaho-kettle by pentaho.

the class SwingDirectGC method drawStepIcon.

public void drawStepIcon(int x, int y, StepMeta stepMeta, float magnification) {
    String steptype = stepMeta.getStepID();
    SwingUniversalImage im = stepImages.get(steptype);
    if (im != null) {
        // Draw the icon!
        drawImage(im, x + xOffset, y + xOffset, iconsize);
    }
}
Also used : SwingUniversalImage(org.pentaho.di.core.SwingUniversalImage)

Example 9 with SwingUniversalImage

use of org.pentaho.di.core.SwingUniversalImage in project pentaho-kettle by pentaho.

the class SwingGC method drawImage.

public void drawImage(EImage image, int x, int y, int width, int height, float magnification) {
    SwingUniversalImage img = getNativeImage(image);
    drawImage(img, x, y, width, height);
}
Also used : SwingUniversalImage(org.pentaho.di.core.SwingUniversalImage)

Example 10 with SwingUniversalImage

use of org.pentaho.di.core.SwingUniversalImage in project pentaho-kettle by pentaho.

the class SwingGUIResource method loadEntryImages.

private Map<String, SwingUniversalImage> loadEntryImages() {
    Map<String, SwingUniversalImage> map = new HashMap<>();
    for (PluginInterface plugin : PluginRegistry.getInstance().getPlugins(JobEntryPluginType.class)) {
        try {
            if (JobMeta.STRING_SPECIAL.equals(plugin.getIds()[0])) {
                continue;
            }
            SwingUniversalImage image = getUniversalImageIcon(plugin);
            if (image == null) {
                throw new KettleException("Unable to find image file: " + plugin.getImageFile() + " for plugin: " + plugin);
            }
            map.put(plugin.getIds()[0], image);
        } catch (Exception e) {
            log.logError("Unable to load job entry icon image for plugin: " + plugin.getName() + " (id=" + plugin.getIds()[0] + ")", e);
        }
    }
    return map;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) HashMap(java.util.HashMap) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) SwingUniversalImage(org.pentaho.di.core.SwingUniversalImage) KettleException(org.pentaho.di.core.exception.KettleException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

SwingUniversalImage (org.pentaho.di.core.SwingUniversalImage)14 FileNotFoundException (java.io.FileNotFoundException)4 KettleException (org.pentaho.di.core.exception.KettleException)4 BufferedImage (java.awt.image.BufferedImage)3 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 SwingUniversalImageBitmap (org.pentaho.di.core.SwingUniversalImageBitmap)3 SwingUniversalImageSvg (org.pentaho.di.core.SwingUniversalImageSvg)3 SvgImage (org.pentaho.di.core.svg.SvgImage)3 WaitingImageObserver (org.pentaho.reporting.libraries.base.util.WaitingImageObserver)3 HashMap (java.util.HashMap)1 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1