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);
}
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);
}
}
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);
}
}
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);
}
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;
}
Aggregations