BF [ 1673548 ] Image is not scaled in a report table cell
This commit is contained in:
parent
69336cd9a0
commit
2c92c25022
|
@ -234,6 +234,7 @@ public class ImageElement extends PrintElement
|
||||||
return true; // don't bother scaling and prevent div by 0
|
return true; // don't bother scaling and prevent div by 0
|
||||||
|
|
||||||
// 0 = unlimited so scale to fit restricted dimension
|
// 0 = unlimited so scale to fit restricted dimension
|
||||||
|
/* teo_sarca, [ 1673548 ] Image is not scaled in a report table cell
|
||||||
if (p_maxWidth * p_maxHeight != 0) // scale to maintain aspect ratio
|
if (p_maxWidth * p_maxHeight != 0) // scale to maintain aspect ratio
|
||||||
{
|
{
|
||||||
if (p_width/p_height > p_maxWidth/p_maxHeight)
|
if (p_width/p_height > p_maxWidth/p_maxHeight)
|
||||||
|
@ -242,6 +243,13 @@ public class ImageElement extends PrintElement
|
||||||
else
|
else
|
||||||
m_scaleFactor = p_maxHeight/p_height;
|
m_scaleFactor = p_maxHeight/p_height;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
m_scaleFactor = 1;
|
||||||
|
if (p_maxWidth != 0 && p_width > p_maxWidth)
|
||||||
|
m_scaleFactor = p_maxWidth / p_width;
|
||||||
|
if (p_maxHeight != 0 && p_height > p_maxHeight && p_maxHeight/p_height < m_scaleFactor)
|
||||||
|
m_scaleFactor = p_maxHeight / p_height;
|
||||||
|
|
||||||
p_width = (float) m_scaleFactor * p_width;
|
p_width = (float) m_scaleFactor * p_width;
|
||||||
p_height = (float) m_scaleFactor * p_height;
|
p_height = (float) m_scaleFactor * p_height;
|
||||||
}
|
}
|
||||||
|
@ -257,6 +265,18 @@ public class ImageElement extends PrintElement
|
||||||
return m_image;
|
return m_image;
|
||||||
} // getImage
|
} // getImage
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get image scale factor.
|
||||||
|
*
|
||||||
|
* @author teo_sarca - [ 1673548 ] Image is not scaled in a report table cell
|
||||||
|
* @return scale factor
|
||||||
|
*/
|
||||||
|
public double getScaleFactor() {
|
||||||
|
if (!p_sizeCalculated)
|
||||||
|
p_sizeCalculated = calculateSize();
|
||||||
|
return m_scaleFactor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paint Image
|
* Paint Image
|
||||||
* @param g2D Graphics
|
* @param g2D Graphics
|
||||||
|
|
|
@ -1558,6 +1558,9 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
||||||
data[row][col] = ImageElement.get (item.get_ID());
|
data[row][col] = ImageElement.get (item.get_ID());
|
||||||
else
|
else
|
||||||
data[row][col] = ImageElement.get (item.getImageURL());
|
data[row][col] = ImageElement.get (item.getImageURL());
|
||||||
|
// Image layout - teo_sarca, [ 1673548 ]
|
||||||
|
if (data[row][col] != null)
|
||||||
|
((ImageElement)data[row][col]).layout(item.getMaxWidth(), item.getMaxHeight(), false, item.getFieldAlignmentType());
|
||||||
}
|
}
|
||||||
else if (item.isBarcode())
|
else if (item.isBarcode())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1355,7 +1355,19 @@ public class TableElement extends PrintElement
|
||||||
{
|
{
|
||||||
Image imageToDraw = ((ImageElement)printItems[index]).getImage();
|
Image imageToDraw = ((ImageElement)printItems[index]).getImage();
|
||||||
if (imageToDraw.getHeight((ImageElement)printItems[index]) != -1)
|
if (imageToDraw.getHeight((ImageElement)printItems[index]) != -1)
|
||||||
g2D.drawImage(imageToDraw, curX, (int)penY, this);
|
{
|
||||||
|
// Draw image using the scale factor - teo_sarca, [ 1673548 ] Image is not scaled in a report table cell
|
||||||
|
double scale = ((ImageElement)printItems[index]).getScaleFactor();
|
||||||
|
if (scale != 1.0) {
|
||||||
|
AffineTransform transform = new AffineTransform();
|
||||||
|
transform.translate(curX, penY);
|
||||||
|
transform.scale(scale, scale);
|
||||||
|
g2D.drawImage(imageToDraw, transform, this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
g2D.drawImage(imageToDraw, curX, (int)penY, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (printItems[index] instanceof BarcodeElement)
|
else if (printItems[index] instanceof BarcodeElement)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue