]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
check if there's enougth space left on the page to draw the image
authoreschaeffer <eschaeffer@unknown>
Wed, 31 May 2000 15:23:03 +0000 (15:23 +0000)
committereschaeffer <eschaeffer@unknown>
Wed, 31 May 2000 15:23:03 +0000 (15:23 +0000)
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
src/org/apache/fop/fo/flow/InlineGraphic.java

index fe6f2efbd2434a203711a73849c5853d844c59cd..348833804287add1e15e7f6108bdb74fe42e9169 100644 (file)
@@ -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,
index b6542f17009739022b157f0d74463bb027742367..5baee4cbff2abc7d0fbe35b31668c9e771ce51ee 100644 (file)
@@ -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,