int leftDiff = 0;
int topDiff = 0;
int widthDiff = 0;
int heightDiff = 0;
JRLineBox box = image.getLineBox();
if (box != null)
{
leftDiff = box.getLeftPadding().intValue();
topDiff = box.getTopPadding().intValue();
widthDiff =
getInsideBorderOffset(box.getLeftPen().getLineWidth().floatValue())
+ getInsideBorderOffset(box.getRightPen().getLineWidth().floatValue());
heightDiff =
getInsideBorderOffset(box.getTopPen().getLineWidth().floatValue())
+ getInsideBorderOffset(box.getBottomPen().getLineWidth().floatValue());
}
writer.write(" style=\"position:absolute;left:");
writer.write(toSizeUnit(leftDiff));
writer.write(";top:");
writer.write(toSizeUnit(topDiff));
writer.write(";width:");
writer.write(toSizeUnit(availableImageWidth - widthDiff));
writer.write(";height:");
writer.write(toSizeUnit(availableImageHeight - heightDiff));
writer.write("\"");
break;
}
case CLIP :
{
double normalWidth = availableImageWidth;
double normalHeight = availableImageHeight;
if (!image.isLazy())
{
// Image load might fail.
JRRenderable tmpRenderer =
JRImageRenderer.getOnErrorRendererForDimension(renderer, image.getOnErrorTypeValue());
Dimension2D dimension = tmpRenderer == null ? null : tmpRenderer.getDimension();
// If renderer was replaced, ignore image dimension.
if (tmpRenderer == renderer && dimension != null)
{
normalWidth = dimension.getWidth();
normalHeight = dimension.getHeight();
}
}
int leftDiff = 0;
int topDiff = 0;
int widthDiff = 0;
int heightDiff = 0;
JRLineBox box = image.getLineBox();
if (box != null)
{
leftDiff = box.getLeftPadding().intValue();
topDiff = box.getTopPadding().intValue();
widthDiff =
getInsideBorderOffset(box.getLeftPen().getLineWidth().floatValue())
+ getInsideBorderOffset(box.getRightPen().getLineWidth().floatValue());
heightDiff =
getInsideBorderOffset(box.getTopPen().getLineWidth().floatValue())
+ getInsideBorderOffset(box.getBottomPen().getLineWidth().floatValue());
}
writer.write(" style=\"position:absolute;left:");
writer.write(toSizeUnit((int)(leftDiff + xAlignFactor * (availableImageWidth - widthDiff - normalWidth))));
writer.write(";top:");
writer.write(toSizeUnit((int)(topDiff + yAlignFactor * (availableImageHeight - heightDiff - normalHeight))));
writer.write(";width:");
writer.write(toSizeUnit((int)normalWidth));
writer.write(";height:");
writer.write(toSizeUnit((int)normalHeight));
writer.write(";clip:rect(");
writer.write(toSizeUnit((int)(yAlignFactor * (normalHeight - availableImageHeight + heightDiff))));
writer.write(",");
writer.write(toSizeUnit((int)(xAlignFactor * normalWidth + (1 - xAlignFactor) * (availableImageWidth - widthDiff))));
writer.write(",");
writer.write(toSizeUnit((int)(yAlignFactor * normalHeight + (1 - yAlignFactor) * (availableImageHeight - heightDiff))));
writer.write(",");
writer.write(toSizeUnit((int)(xAlignFactor * (normalWidth - availableImageWidth + widthDiff))));
writer.write(")\"");
break;
}
case RETAIN_SHAPE :
default :
{
double normalWidth = availableImageWidth;
double normalHeight = availableImageHeight;
if (!image.isLazy())
{
// Image load might fail.
JRRenderable tmpRenderer =
JRImageRenderer.getOnErrorRendererForDimension(renderer, image.getOnErrorTypeValue());
Dimension2D dimension = tmpRenderer == null ? null : tmpRenderer.getDimension();
// If renderer was replaced, ignore image dimension.
if (tmpRenderer == renderer && dimension != null)
{
normalWidth = dimension.getWidth();
normalHeight = dimension.getHeight();
}
}
int leftDiff = 0;
int topDiff = 0;
int widthDiff = 0;
int heightDiff = 0;
JRLineBox box = image.getLineBox();
if (box != null)
{
leftDiff = box.getLeftPadding().intValue();
topDiff = box.getTopPadding().intValue();
widthDiff =
getInsideBorderOffset(box.getLeftPen().getLineWidth().floatValue())
+ getInsideBorderOffset(box.getRightPen().getLineWidth().floatValue());
heightDiff =
getInsideBorderOffset(box.getTopPen().getLineWidth().floatValue())
+ getInsideBorderOffset(box.getBottomPen().getLineWidth().floatValue());
}
if (availableImageHeight > 0)
{
double ratio = normalWidth / normalHeight;