From 20064c8f1a0f36515fdbd7f29b02dcdcd1a01f0b Mon Sep 17 00:00:00 2001 From: mjudd Date: Thu, 16 Apr 2009 09:15:16 +0000 Subject: [PATCH] BF [ 2768070 ] - Recursive calls to loadImage in CompiereUtils --- base/src/org/compiere/plaf/CompiereUtils.java | 24 +++++++++++-------- .../org/compiere/grid/ed/VStringBeanInfo.java | 8 +++---- .../org/compiere/grid/ed/VTextBeanInfo.java | 8 +++---- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/base/src/org/compiere/plaf/CompiereUtils.java b/base/src/org/compiere/plaf/CompiereUtils.java index f638ec952b..6907c8eca6 100644 --- a/base/src/org/compiere/plaf/CompiereUtils.java +++ b/base/src/org/compiere/plaf/CompiereUtils.java @@ -247,9 +247,13 @@ public class CompiereUtils Image image = null; try { - File file = new File(path); - URI url = file.toURI(); - image = loadImage(url.toString()); + // if path is null then return null + if(!path.equals(null)) + { + File file = new File(path); + URI url = file.toURI(); + image = loadImage(url); + } } catch (SecurityException e) { @@ -265,10 +269,10 @@ public class CompiereUtils * @return loaded image at path or url * @see java.io.File#toURL() */ - public static synchronized Image loadImage(URL url) + public static synchronized Image loadImage(URI url) { Image image = null; - image = Toolkit.getDefaultToolkit().getImage(url); + image = Toolkit.getDefaultToolkit().getImage(url.toString()); if (image != null) { s_tracker.addImage(image, 0); @@ -349,7 +353,7 @@ public class CompiereUtils try { URI url = file.toURI(); - image = loadBufferedImage(url.toString(), imageType); + image = loadBufferedImage(url, imageType); } catch (SecurityException e) { @@ -369,13 +373,13 @@ public class CompiereUtils * @return loaded image at path or url * @see java.awt.image.BufferedImage */ - public static synchronized BufferedImage loadBufferedImage(URL url, int imageType) + public static synchronized BufferedImage loadBufferedImage(URI url, int imageType) { BufferedImage image = null; // Special handling for JPEG images to avoid extra processing if possible. if (url == null || !url.toString().toLowerCase().endsWith(".jpg")) { - Image tmpImage = loadImage(url); + Image tmpImage = loadImage(url.toString()); if (tmpImage != null) { image = new BufferedImage(tmpImage.getWidth(null), tmpImage.getHeight(null), imageType); @@ -410,7 +414,7 @@ public class CompiereUtils * @param url URL where the image file is located. * @return loaded image at path or url */ - public static synchronized BufferedImage loadBufferedJPEGImage (URL url) + public static synchronized BufferedImage loadBufferedJPEGImage (URI url) { BufferedImage image = null; if (url != null) @@ -418,7 +422,7 @@ public class CompiereUtils InputStream in = null; try { - in = url.openStream(); + in = url.toURL().openStream(); JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in); image = decoder.decodeAsBufferedImage(); } diff --git a/client/src/org/compiere/grid/ed/VStringBeanInfo.java b/client/src/org/compiere/grid/ed/VStringBeanInfo.java index b75b9136db..c94fa5606d 100644 --- a/client/src/org/compiere/grid/ed/VStringBeanInfo.java +++ b/client/src/org/compiere/grid/ed/VStringBeanInfo.java @@ -69,13 +69,13 @@ public class VStringBeanInfo extends SimpleBeanInfo { switch (iconKind) { case BeanInfo.ICON_COLOR_16x16: - return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null; + return loadImage(iconColor16x16Filename); case BeanInfo.ICON_COLOR_32x32: - return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null; + return loadImage(iconColor32x32Filename); case BeanInfo.ICON_MONO_16x16: - return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null; + return loadImage(iconMono16x16Filename); case BeanInfo.ICON_MONO_32x32: - return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null; + return loadImage(iconMono32x32Filename); } return null; } diff --git a/client/src/org/compiere/grid/ed/VTextBeanInfo.java b/client/src/org/compiere/grid/ed/VTextBeanInfo.java index 14a4585c11..3ada3af40f 100644 --- a/client/src/org/compiere/grid/ed/VTextBeanInfo.java +++ b/client/src/org/compiere/grid/ed/VTextBeanInfo.java @@ -81,13 +81,13 @@ public class VTextBeanInfo extends SimpleBeanInfo { switch (iconKind) { case BeanInfo.ICON_COLOR_16x16: - return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null; + return loadImage(iconColor16x16Filename); case BeanInfo.ICON_COLOR_32x32: - return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null; + return loadImage(iconColor32x32Filename); case BeanInfo.ICON_MONO_16x16: - return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null; + return loadImage(iconMono16x16Filename); case BeanInfo.ICON_MONO_32x32: - return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null; + return loadImage(iconMono32x32Filename); } return null; }