use of org.pentaho.di.core.SwingUniversalImageBitmap in project pentaho-kettle by pentaho.
the class SwingDirectGC method getImageIcon.
private SwingUniversalImage getImageIcon(String fileName) throws KettleException {
SwingUniversalImage image = null;
InputStream inputStream = null;
if (fileName == null) {
throw new KettleException("Image icon file name can not be null");
}
if (SvgSupport.isSvgEnabled() && SvgSupport.isSvgName(fileName)) {
try {
inputStream = new FileInputStream(fileName);
} catch (FileNotFoundException ex) {
// no need to fail
}
if (inputStream == null) {
try {
inputStream = new FileInputStream("/" + fileName);
} catch (FileNotFoundException ex) {
// no need to fail
}
}
if (inputStream == null) {
inputStream = getClass().getResourceAsStream(fileName);
}
if (inputStream == null) {
inputStream = getClass().getResourceAsStream("/" + fileName);
}
if (inputStream != null) {
try {
SvgImage svg = SvgSupport.loadSvgImage(inputStream);
image = new SwingUniversalImageSvg(svg);
} catch (Exception ex) {
throw new KettleException("Unable to load image from classpath : '" + fileName + "'", ex);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
}
if (image == null) {
fileName = SvgSupport.toPngName(fileName);
try {
inputStream = new FileInputStream(fileName);
} catch (FileNotFoundException ex) {
// no need to fail
}
if (inputStream == null) {
try {
inputStream = new FileInputStream("/" + fileName);
} catch (FileNotFoundException ex) {
// no need to fail
}
}
if (inputStream == null) {
inputStream = getClass().getResourceAsStream(fileName);
}
if (inputStream == null) {
inputStream = getClass().getResourceAsStream("/" + fileName);
}
if (inputStream != null) {
try {
BufferedImage bitmap = ImageIO.read(inputStream);
WaitingImageObserver wia = new WaitingImageObserver(bitmap);
wia.waitImageLoaded();
image = new SwingUniversalImageBitmap(bitmap);
} catch (Exception ex) {
throw new KettleException("Unable to load image from classpath : '" + fileName + "'", ex);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
}
if (image == null) {
throw new KettleException("Unable to load image from classpath : '" + fileName + "'");
}
return image;
}
use of org.pentaho.di.core.SwingUniversalImageBitmap in project pentaho-kettle by pentaho.
the class SwingGC method getImageIcon.
private SwingUniversalImage getImageIcon(String fileName) throws KettleException {
SwingUniversalImage image = null;
InputStream inputStream = null;
if (fileName == null) {
throw new KettleException("Image icon file name can not be null");
}
if (SvgSupport.isSvgEnabled() && SvgSupport.isSvgName(fileName)) {
try {
inputStream = new FileInputStream(fileName);
} catch (FileNotFoundException ex) {
// no need to fail
}
if (inputStream == null) {
try {
inputStream = new FileInputStream("/" + fileName);
} catch (FileNotFoundException ex) {
// no need to fail
}
}
if (inputStream == null) {
inputStream = getClass().getResourceAsStream(fileName);
}
if (inputStream == null) {
inputStream = getClass().getResourceAsStream("/" + fileName);
}
if (inputStream != null) {
try {
SvgImage svg = SvgSupport.loadSvgImage(inputStream);
image = new SwingUniversalImageSvg(svg);
} catch (Exception ex) {
throw new KettleException("Unable to load image from classpath : '" + fileName + "'", ex);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
}
if (image == null) {
fileName = SvgSupport.toPngName(fileName);
try {
inputStream = new FileInputStream(fileName);
} catch (FileNotFoundException ex) {
// no need to fail
}
if (inputStream == null) {
try {
inputStream = new FileInputStream("/" + fileName);
} catch (FileNotFoundException ex) {
// no need to fail
}
}
if (inputStream == null) {
inputStream = getClass().getResourceAsStream(fileName);
}
if (inputStream == null) {
inputStream = getClass().getResourceAsStream("/" + fileName);
}
if (inputStream != null) {
try {
BufferedImage bitmap = ImageIO.read(inputStream);
WaitingImageObserver wia = new WaitingImageObserver(bitmap);
wia.waitImageLoaded();
image = new SwingUniversalImageBitmap(bitmap);
} catch (Exception ex) {
throw new KettleException("Unable to load image from classpath : '" + fileName + "'", ex);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
}
if (image == null) {
throw new KettleException("Unable to load image from classpath : '" + fileName + "'");
}
return image;
}
use of org.pentaho.di.core.SwingUniversalImageBitmap 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);
}
}
Aggregations