From c3630921dedb480bbf82f50047afd90fe32a936a Mon Sep 17 00:00:00 2001 From: eschaeffer Date: Wed, 31 May 2000 15:23:03 +0000 Subject: [PATCH] check if there's enougth space left on the page to draw the image git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193394 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/flow/DisplayGraphic.java | 14 ++++++++++---- src/org/apache/fop/fo/flow/InlineGraphic.java | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/org/apache/fop/fo/flow/DisplayGraphic.java b/src/org/apache/fop/fo/flow/DisplayGraphic.java index fe6f2efbd..348833804 100644 --- a/src/org/apache/fop/fo/flow/DisplayGraphic.java +++ b/src/org/apache/fop/fo/flow/DisplayGraphic.java @@ -162,14 +162,20 @@ public class DisplayGraphic extends FObj { double imgWidth = img.getWidth(); double imgHeight = img.getHeight(); if ((width == 0) && (height == 0)) { - width = (int) (imgWidth / 2d * 1000d); - height = (int) (imgHeight / 2d * 1000d); + width = (int) ((imgWidth * 1000d) / 2d); + height = (int) ((imgHeight * 1000d) / 2d); } else if (height == 0) { - height = (int) (imgHeight / imgWidth * ((double) width)); + height = (int) ((imgHeight * ((double) width)) / imgWidth); } else if (width == 0) { - width = (int) (imgWidth / imgHeight * ((double) height)); + width = (int) ((imgWidth * ((double) height)) / imgHeight); } +//System.err.println("DisplayGraphic: imgW=" + imgWidth + " imgH=" + imgHeight + " w=" + width + " h=" + height); } + + if (area.spaceLeft() < (height + spaceBefore)) { + return new Status(Status.AREA_FULL_NONE); + } + this.imageArea = new ImageArea( fs, img, diff --git a/src/org/apache/fop/fo/flow/InlineGraphic.java b/src/org/apache/fop/fo/flow/InlineGraphic.java index b6542f170..5baee4cbf 100644 --- a/src/org/apache/fop/fo/flow/InlineGraphic.java +++ b/src/org/apache/fop/fo/flow/InlineGraphic.java @@ -165,14 +165,20 @@ public class InlineGraphic extends FObj { double imgWidth = img.getWidth(); double imgHeight = img.getHeight(); if ((width == 0) && (height == 0)) { - width = (int) (imgWidth / 2d * 1000d); - height = (int) (imgHeight / 2d * 1000d); + width = (int) ((imgWidth * 1000d) / 2d); + height = (int) ((imgHeight * 1000d) / 2d); } else if (height == 0) { - height = (int) (imgHeight / imgWidth * ((double) width)); + height = (int) ((imgHeight * ((double) width)) / imgWidth); } else if (width == 0) { - width = (int) (imgWidth / imgHeight * ((double) height)); + width = (int) ((imgWidth * ((double) height)) / imgHeight); } +//System.err.println("DisplayGraphic: imgW=" + imgWidth + " imgH=" + imgHeight + " w=" + width + " h=" + height); } + + if (area.spaceLeft() < (height + spaceBefore)) { + return new Status(Status.AREA_FULL_NONE); + } + this.imageArea = new ImageArea( fs, img, -- 2.39.5