Bug [ 1704548 ] Non printing images from database
This commit is contained in:
parent
1924725a64
commit
bf8c24c879
|
@ -18,6 +18,7 @@ package org.compiere.print.layout;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.geom.*;
|
import java.awt.geom.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
@ -84,6 +85,38 @@ public class ImageElement extends PrintElement
|
||||||
return new ImageElement(image.getImage());
|
return new ImageElement(image.getImage());
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Image from database column
|
||||||
|
* @param data the printdataelement, containing the reference
|
||||||
|
* @param imageURLString image url - containing just the AD_Image_ID reference
|
||||||
|
* @return image element
|
||||||
|
*/
|
||||||
|
public static ImageElement get(PrintDataElement data, String imageURLString)
|
||||||
|
{
|
||||||
|
Object key = imageURLString;
|
||||||
|
ImageElement image = (ImageElement)s_cache.get(key);
|
||||||
|
if (image == null)
|
||||||
|
{
|
||||||
|
BigDecimal imkeybd = (BigDecimal) data.getValue();
|
||||||
|
MImage im = null;
|
||||||
|
if (imkeybd != null && imkeybd.intValue() > 0) {
|
||||||
|
im = new MImage(Env.getCtx(), imkeybd.intValue(), null);
|
||||||
|
} else {
|
||||||
|
im = null;
|
||||||
|
}
|
||||||
|
if (im != null) {
|
||||||
|
image = new ImageElement(im.getImage());
|
||||||
|
s_cache.put(key, image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (image == null) {
|
||||||
|
Image imnull = null;
|
||||||
|
return new ImageElement(imnull);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return new ImageElement(image.getImage());
|
||||||
|
} // get
|
||||||
|
|
||||||
/** 60 minute Cache */
|
/** 60 minute Cache */
|
||||||
private static CCache<Object,ImageElement> s_cache
|
private static CCache<Object,ImageElement> s_cache
|
||||||
= new CCache<Object,ImageElement>("ImageElement", 10, 60);
|
= new CCache<Object,ImageElement>("ImageElement", 10, 60);
|
||||||
|
|
|
@ -966,6 +966,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
||||||
element = ImageElement.get (item.get_ID());
|
element = ImageElement.get (item.get_ID());
|
||||||
else
|
else
|
||||||
element = ImageElement.get (item.getImageURL());
|
element = ImageElement.get (item.getImageURL());
|
||||||
|
if (element != null)
|
||||||
element.layout(maxWidth, item.getMaxHeight(), false, alignment);
|
element.layout(maxWidth, item.getMaxHeight(), false, alignment);
|
||||||
}
|
}
|
||||||
else if (item.isTypeField()) //** Field
|
else if (item.isTypeField()) //** Field
|
||||||
|
@ -1321,7 +1322,12 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
||||||
else // should create an empty area
|
else // should create an empty area
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ImageElement element = ImageElement.get (url);
|
ImageElement element = null;
|
||||||
|
if (data.getDisplayType() == DisplayType.Image) {
|
||||||
|
element = ImageElement.get (data, url);
|
||||||
|
} else {
|
||||||
|
element = ImageElement.get (url);
|
||||||
|
}
|
||||||
return element;
|
return element;
|
||||||
} // createImageElement
|
} // createImageElement
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue