revert of 9021 & 9022 as requested by Heng Sin Low

This commit is contained in:
mjudd 2009-04-16 10:11:52 +00:00
parent f7a691dc8e
commit e54c9f9d27
4 changed files with 19 additions and 23 deletions

View File

@ -603,7 +603,7 @@ public class CompiereColor implements Serializable
if (m_image == null) if (m_image == null)
{ {
URL url = getTextureURL(); URL url = getTextureURL();
m_image = CompiereUtils.loadBufferedImage(url.toString(), BufferedImage.TYPE_INT_ARGB_PRE); m_image = CompiereUtils.loadBufferedImage(url, BufferedImage.TYPE_INT_ARGB_PRE);
} }
return m_image; return m_image;
} // getTextureImage } // getTextureImage

View File

@ -247,13 +247,9 @@ public class CompiereUtils
Image image = null; Image image = null;
try try
{ {
// if path is null then return null File file = new File(path);
if(!path.equals(null)) URI url = file.toURI();
{ image = loadImage(url.toString());
File file = new File(path);
URI url = file.toURI();
image = loadImage(url);
}
} }
catch (SecurityException e) catch (SecurityException e)
{ {
@ -269,10 +265,10 @@ public class CompiereUtils
* @return loaded image at path or url * @return loaded image at path or url
* @see java.io.File#toURL() * @see java.io.File#toURL()
*/ */
public static synchronized Image loadImage(URI url) public static synchronized Image loadImage(URL url)
{ {
Image image = null; Image image = null;
image = Toolkit.getDefaultToolkit().getImage(url.toString()); image = Toolkit.getDefaultToolkit().getImage(url);
if (image != null) if (image != null)
{ {
s_tracker.addImage(image, 0); s_tracker.addImage(image, 0);
@ -353,7 +349,7 @@ public class CompiereUtils
try try
{ {
URI url = file.toURI(); URI url = file.toURI();
image = loadBufferedImage(url, imageType); image = loadBufferedImage(url.toString(), imageType);
} }
catch (SecurityException e) catch (SecurityException e)
{ {
@ -373,13 +369,13 @@ public class CompiereUtils
* @return loaded image at path or url * @return loaded image at path or url
* @see java.awt.image.BufferedImage * @see java.awt.image.BufferedImage
*/ */
public static synchronized BufferedImage loadBufferedImage(URI url, int imageType) public static synchronized BufferedImage loadBufferedImage(URL url, int imageType)
{ {
BufferedImage image = null; BufferedImage image = null;
// Special handling for JPEG images to avoid extra processing if possible. // Special handling for JPEG images to avoid extra processing if possible.
if (url == null || !url.toString().toLowerCase().endsWith(".jpg")) if (url == null || !url.toString().toLowerCase().endsWith(".jpg"))
{ {
Image tmpImage = loadImage(url.toString()); Image tmpImage = loadImage(url);
if (tmpImage != null) if (tmpImage != null)
{ {
image = new BufferedImage(tmpImage.getWidth(null), tmpImage.getHeight(null), imageType); image = new BufferedImage(tmpImage.getWidth(null), tmpImage.getHeight(null), imageType);
@ -414,7 +410,7 @@ public class CompiereUtils
* @param url URL where the image file is located. * @param url URL where the image file is located.
* @return loaded image at path or url * @return loaded image at path or url
*/ */
public static synchronized BufferedImage loadBufferedJPEGImage (URI url) public static synchronized BufferedImage loadBufferedJPEGImage (URL url)
{ {
BufferedImage image = null; BufferedImage image = null;
if (url != null) if (url != null)
@ -422,7 +418,7 @@ public class CompiereUtils
InputStream in = null; InputStream in = null;
try try
{ {
in = url.toURL().openStream(); in = url.openStream();
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in); JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);
image = decoder.decodeAsBufferedImage(); image = decoder.decodeAsBufferedImage();
} }

View File

@ -69,13 +69,13 @@ public class VStringBeanInfo extends SimpleBeanInfo
{ {
switch (iconKind) { switch (iconKind) {
case BeanInfo.ICON_COLOR_16x16: case BeanInfo.ICON_COLOR_16x16:
return loadImage(iconColor16x16Filename); return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null;
case BeanInfo.ICON_COLOR_32x32: case BeanInfo.ICON_COLOR_32x32:
return loadImage(iconColor32x32Filename); return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null;
case BeanInfo.ICON_MONO_16x16: case BeanInfo.ICON_MONO_16x16:
return loadImage(iconMono16x16Filename); return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null;
case BeanInfo.ICON_MONO_32x32: case BeanInfo.ICON_MONO_32x32:
return loadImage(iconMono32x32Filename); return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null;
} }
return null; return null;
} }

View File

@ -81,13 +81,13 @@ public class VTextBeanInfo extends SimpleBeanInfo
{ {
switch (iconKind) { switch (iconKind) {
case BeanInfo.ICON_COLOR_16x16: case BeanInfo.ICON_COLOR_16x16:
return loadImage(iconColor16x16Filename); return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null;
case BeanInfo.ICON_COLOR_32x32: case BeanInfo.ICON_COLOR_32x32:
return loadImage(iconColor32x32Filename); return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null;
case BeanInfo.ICON_MONO_16x16: case BeanInfo.ICON_MONO_16x16:
return loadImage(iconMono16x16Filename); return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null;
case BeanInfo.ICON_MONO_32x32: case BeanInfo.ICON_MONO_32x32:
return loadImage(iconMono32x32Filename); return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null;
} }
return null; return null;
} }