]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Use content ipd/bpd instead of allocation width/height.
authorFinn Bock <bckfnn@apache.org>
Wed, 22 Sep 2004 08:30:21 +0000 (08:30 +0000)
committerFinn Bock <bckfnn@apache.org>
Wed, 22 Sep 2004 08:30:21 +0000 (08:30 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197959 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/AbstractRenderer.java
src/java/org/apache/fop/render/awt/AWTRenderer.java
src/java/org/apache/fop/render/pdf/PDFRenderer.java
src/java/org/apache/fop/render/ps/PSRenderer.java
src/java/org/apache/fop/render/svg/SVGRenderer.java
src/java/org/apache/fop/render/xml/XMLRenderer.java

index b7fe955bab31fbf5375f98e792b91aac761688db..48d46b6b7cddb62ea3c702c1a62e9f84fd52390a 100644 (file)
@@ -457,7 +457,7 @@ public abstract class AbstractRenderer
             renderBlocks(bv, children);
 
             currentIPPosition = saveIP;
-            currentBPPosition = saveBP + bv.getHeight();
+            currentBPPosition = saveBP + bv.getAllocBPD();
         }
     }
 
@@ -491,7 +491,7 @@ public abstract class AbstractRenderer
                 currentBlockIPPosition =
                         currentIPPosition + line.getStartIndent();
                 renderLineArea(line);
-                currentBPPosition += line.getHeight();
+                currentBPPosition += line.getAllocBPD();
             }
         }
     }
@@ -506,7 +506,7 @@ public abstract class AbstractRenderer
         if (children == null) {
             handleBlockTraits(block);
             // simply move position
-            currentBPPosition += block.getHeight();
+            currentBPPosition += block.getAllocBPD();
         } else if (block instanceof BlockViewport) {
             renderBlockViewport((BlockViewport) block, children);
         } else {
@@ -534,7 +534,7 @@ public abstract class AbstractRenderer
                 renderBlocks(block, children);
 
                 // stacked and relative blocks effect stacking
-                currentBPPosition = saveBP + block.getHeight();
+                currentBPPosition = saveBP + block.getAllocBPD();
             }
             currentIPPosition = saveIP;
         }
@@ -576,7 +576,7 @@ public abstract class AbstractRenderer
 
     /** @see org.apache.fop.render.Renderer */
     protected void renderCharacter(Character ch) {
-        currentBlockIPPosition += ch.getWidth();
+        currentBlockIPPosition += ch.getAllocIPD();
     }
 
     /** @see org.apache.fop.render.Renderer */
@@ -585,17 +585,17 @@ public abstract class AbstractRenderer
         // for the current block by the width or height of the space
         // it may also have styling (only on this object) that needs
         // handling
-        currentBlockIPPosition += space.getWidth();
+        currentBlockIPPosition += space.getAllocIPD();
     }
 
     /** @see org.apache.fop.render.Renderer */
     protected void renderLeader(Leader area) {
-        currentBlockIPPosition += area.getWidth();
+        currentBlockIPPosition += area.getAllocIPD();
     }
 
     /** @see org.apache.fop.render.Renderer */
     protected void renderText(TextArea text) {
-        currentBlockIPPosition += text.getWidth();
+        currentBlockIPPosition += text.getAllocIPD();
     }
 
     /** @see org.apache.fop.render.Renderer */
@@ -605,7 +605,7 @@ public abstract class AbstractRenderer
         while (iter.hasNext()) {
             renderInlineArea((InlineArea) iter.next()); 
         }
-        currentBlockIPPosition = saveIP + ip.getWidth();
+        currentBlockIPPosition = saveIP + ip.getAllocIPD();
     }
 
     /** @see org.apache.fop.render.Renderer */
@@ -621,7 +621,7 @@ public abstract class AbstractRenderer
         } else if (content instanceof ForeignObject) {
             renderForeignObject((ForeignObject) content, contpos);
         }
-        currentBlockIPPosition += viewport.getWidth();
+        currentBlockIPPosition += viewport.getAllocIPD();
         currentBPPosition = saveBP;
     }
 
index 7af9216ce1a23c8a836d356bbf892b9079e4de25..23fce2b3e2f63cc7ffda165a852e1939cb2752ae 100644 (file)
@@ -459,7 +459,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable
         graphics.drawString(s, 220, 200);
 
         // TODO: render text decorations
-        currentBlockIPPosition += text.getWidth();
+        currentBlockIPPosition += text.getAllocIPD();
     }
 
     /** @see org.apache.fop.render.AbstractRenderer */
index 38ebf4fd63ff1012fbdcd2a65c1fd1b39bbd5535..73407c0883f4f6cb5bf0b88ed74a4b6e936dda6f 100644 (file)
@@ -541,20 +541,49 @@ public class PDFRenderer extends PrintRenderer {
 
         float startx = (currentIPPosition + ipMarginOffset) / 1000f;
         float starty = (currentBPPosition + bpMarginOffset) / 1000f;
-        float width = block.getWidth() / 1000f;
+        float width = block.getIPD() / 1000f;
+        float height = block.getBPD() / 1000f;
 
         Integer spaceStart = (Integer) block.getTrait(Trait.SPACE_START);
         if (spaceStart != null) {
             startx += spaceStart.floatValue() / 1000;
-            width -= spaceStart.floatValue() / 1000;
         }
-        Integer spaceEnd = (Integer) block.getTrait(Trait.SPACE_END);
-        if (spaceEnd != null) {
-            width -= spaceEnd.floatValue() / 1000;
+        BorderProps borderStart = (BorderProps) block.getTrait(Trait.BORDER_START);
+        if (borderStart != null) {
+            width += borderStart.width / 1000f;
+        }
+        Integer paddingStart = (Integer) block.getTrait(Trait.PADDING_START);
+        if (paddingStart != null) {
+            width += paddingStart.intValue() / 1000f;
+        }
+        BorderProps borderEnd = (BorderProps) block.getTrait(Trait.BORDER_END);
+        if (borderEnd != null) {
+            width += borderEnd.width / 1000f;
+        }
+        Integer paddingEnd = (Integer) block.getTrait(Trait.PADDING_END);
+        if (paddingEnd != null) {
+            width += paddingEnd.intValue() / 1000f;
+        }
+
+        BorderProps borderBefore = (BorderProps) block.getTrait(Trait.BORDER_BEFORE);
+        if (borderBefore != null) {
+            height += borderBefore.width / 1000f;
+        }
+        Integer paddingBefore = (Integer) block.getTrait(Trait.PADDING_BEFORE);
+        if (paddingBefore != null) {
+            height += paddingBefore.intValue() / 1000f;
+        }
+        BorderProps borderAfter = (BorderProps) block.getTrait(Trait.BORDER_AFTER);
+        if (borderAfter != null) {
+            height += borderAfter.width / 1000f;
+        }
+        Integer paddingAfter = (Integer) block.getTrait(Trait.PADDING_AFTER);
+        if (paddingAfter != null) {
+            height += paddingAfter.intValue() / 1000f;
         }
 
         drawBackAndBorders(block, startx, starty,
-            width, block.getHeight() / 1000f);
+            width, height);
     }
 
     /**
@@ -740,8 +769,8 @@ public class PDFRenderer extends PrintRenderer {
 
             float x = (float)(bv.getXOffset() + containingIPPosition) / 1000f;
             float y = (float)(bv.getYOffset() + containingBPPosition) / 1000f;
-            float width = (float)bv.getWidth() / 1000f;
-            float height = (float)bv.getHeight() / 1000f;
+            float width = (float)bv.getIPD() / 1000f;
+            float height = (float)bv.getBPD() / 1000f;
 
             drawBackAndBorders(bv, x, y, width, height);
 
@@ -776,11 +805,11 @@ public class PDFRenderer extends PrintRenderer {
                 double[] vals = ctm.toArray();
                 //boolean aclock = vals[2] == 1.0;
                 if (vals[2] == 1.0) {
-                    ctm = ctm.translate(-saveBP - bv.getHeight(), -saveIP);
+                    ctm = ctm.translate(-saveBP - bv.getBPD(), -saveIP);
                 } else if (vals[0] == -1.0) {
-                    ctm = ctm.translate(-saveIP - bv.getWidth(), -saveBP - bv.getHeight());
+                    ctm = ctm.translate(-saveIP - bv.getIPD(), -saveBP - bv.getBPD());
                 } else {
-                    ctm = ctm.translate(saveBP, saveIP - bv.getWidth());
+                    ctm = ctm.translate(saveBP, saveIP - bv.getIPD());
                 }
             }
 
@@ -792,8 +821,8 @@ public class PDFRenderer extends PrintRenderer {
                 saveGraphicsState();
                 float x = (float)bv.getXOffset() / 1000f;
                 float y = (float)bv.getYOffset() / 1000f;
-                float width = (float)bv.getWidth() / 1000f;
-                float height = (float)bv.getHeight() / 1000f;
+                float width = (float)bv.getIPD() / 1000f;
+                float height = (float)bv.getBPD() / 1000f;
                 clip(x, y, width, height);
             }
 
@@ -821,7 +850,7 @@ public class PDFRenderer extends PrintRenderer {
 
             currentIPPosition = saveIP;
             currentBPPosition = saveBP;
-            currentBPPosition += (int)(bv.getHeight());
+            currentBPPosition += (int)(bv.getAllocBPD());
         }
         currentFontName = saveFontName;
     }
@@ -862,8 +891,8 @@ public class PDFRenderer extends PrintRenderer {
     public void renderInlineParent(InlineParent ip) {
         float start = (currentBlockIPPosition + ipMarginOffset) / 1000f;
         float top = (ip.getOffset() + currentBPPosition + bpMarginOffset) / 1000f;
-        float width = ip.getWidth() / 1000f;
-        float height = ip.getHeight() / 1000f;
+        float width = ip.getIPD() / 1000f;
+        float height = ip.getBPD() / 1000f;
         drawBackAndBorders(ip, start, top, width, height);
 
         // render contents
@@ -956,7 +985,7 @@ public class PDFRenderer extends PrintRenderer {
                            + (ch.getTextWordSpaceAdjust() / 1000f) + " Tw [" + startText);
                 textOpen = true;
         }
-        prevWordWidth = ch.getWidth();
+        prevWordWidth = ch.getIPD();
         prevWordX = rx;
 
         String s = ch.getChar();
@@ -1027,7 +1056,7 @@ public class PDFRenderer extends PrintRenderer {
                        + (text.getTextWordSpaceAdjust() / 1000f) + " Tw [" + startText);
                 textOpen = true;
         }
-        prevWordWidth = text.getWidth();
+        prevWordWidth = text.getIPD();
         prevWordX = rx;
 
         String s = text.getTextArea();
@@ -1314,8 +1343,8 @@ public class PDFRenderer extends PrintRenderer {
 
         float x = currentBlockIPPosition / 1000f;
         float y = (currentBPPosition + viewport.getOffset()) / 1000f;
-        float width = viewport.getWidth() / 1000f;
-        float height = viewport.getHeight() / 1000f;
+        float width = viewport.getIPD() / 1000f;
+        float height = viewport.getBPD() / 1000f;
         drawBackAndBorders(viewport, x, y, width, height);
 
         endTextObject();
@@ -1362,7 +1391,7 @@ public class PDFRenderer extends PrintRenderer {
         }
         float startx = ((float) currentBlockIPPosition) / 1000f;
         float starty = ((currentBPPosition + area.getOffset()) / 1000f);
-        float endx = (currentBlockIPPosition + area.getWidth()) / 1000f;
+        float endx = (currentBlockIPPosition + area.getIPD()) / 1000f;
         if (!alt) {
             currentStream.add(area.getRuleThickness() / 1000f + " w\n");
             drawLine(startx, starty, endx, starty);
index 904a1183c567a9406ad89e088d4cf24f83aaa787..4d5cd074b749a05552f844e38320d0fc8756abab 100644 (file)
@@ -522,8 +522,8 @@ public class PSRenderer extends AbstractRenderer {
                 saveGraphicsState();
                 int x = bv.getXOffset() + containingIPPosition;
                 int y = bv.getYOffset() + containingBPPosition;
-                int width = bv.getWidth();
-                int height = bv.getHeight();
+                int width = bv.getIPD();
+                int height = bv.getBPD();
                 clip(x, y, width, height);
             }
 
@@ -556,11 +556,11 @@ public class PSRenderer extends AbstractRenderer {
                 double[] vals = ctm.toArray();
                 //boolean aclock = vals[2] == 1.0;
                 if (vals[2] == 1.0) {
-                    ctm = ctm.translate(-saveBP - bv.getHeight(), -saveIP);
+                    ctm = ctm.translate(-saveBP - bv.getBPD(), -saveIP);
                 } else if (vals[0] == -1.0) {
-                    ctm = ctm.translate(-saveIP - bv.getWidth(), -saveBP - bv.getHeight());
+                    ctm = ctm.translate(-saveIP - bv.getIPD(), -saveBP - bv.getBPD());
                 } else {
-                    ctm = ctm.translate(saveBP, saveIP - bv.getWidth());
+                    ctm = ctm.translate(saveBP, saveIP - bv.getIPD());
                 }
             }
 
@@ -573,8 +573,8 @@ public class PSRenderer extends AbstractRenderer {
                 saveGraphicsState();
                 int x = bv.getXOffset();
                 int y = bv.getYOffset();
-                int width = bv.getWidth();
-                int height = bv.getHeight();
+                int width = bv.getIPD();
+                int height = bv.getBPD();
                 clip(x, y, width, height);
             }
 
@@ -599,7 +599,7 @@ public class PSRenderer extends AbstractRenderer {
 
             currentIPPosition = saveIP;
             currentBPPosition = saveBP;
-            currentBPPosition += (int)(bv.getHeight());
+            currentBPPosition += (int)(bv.getAllocBPD());
         }
         currentFontName = saveFontName;
     }
@@ -663,7 +663,7 @@ public class PSRenderer extends AbstractRenderer {
         float startx = currentIPPosition;
         float starty = currentBPPosition;
         drawBackAndBorders(block, startx, starty,
-                           block.getWidth(), block.getHeight());
+                           block.getIPD(), block.getBPD());
     }
 
     /**
index 55c34dd1a60008d31696d05eb0a710ec9580901b..b10c6b90201d6f6c057baa95bbd3509763438da0 100644 (file)
@@ -380,7 +380,7 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler {
                         currentBlockIPPosition / 1000,
                         (currentBPPosition + area.getOffset()
                             - area.getRuleThickness() / 2) / 1000,
-                        (currentBlockIPPosition + area.getWidth()) / 1000,
+                        (currentBlockIPPosition + area.getIPD()) / 1000,
                         (currentBPPosition + area.getOffset()
                             - area.getRuleThickness() / 2) / 1000);
         line.setAttributeNS(null, "style", style);
index 5d82123842c25d1d976cdf9f65ca0768b737351a..c38cf47e215d18dc7526c5dff9848b8191d45559 100644 (file)
@@ -331,9 +331,8 @@ public class XMLRenderer extends AbstractRenderer {
      * @see org.apache.fop.render.AbstractRenderer#renderBlock(Block)
      */
     protected void renderBlock(Block block) {
-        String prop = " width=\"" + block.getWidth() +
-                      "\" ipd=\"" + block.getIPD() +
-                      "\" height=\"" + block.getHeight() + "\"";
+        String prop = " ipd=\"" + block.getIPD() +
+                      "\" bpd=\"" + block.getBPD() + "\"";
         Map map = block.getTraits();
         if (map != null) {
             prop = prop + " props=\"" + getPropString(map) + "\"";
@@ -352,7 +351,7 @@ public class XMLRenderer extends AbstractRenderer {
         if (map != null) {
             prop = " props=\"" + getPropString(map) + "\"";
         }
-        writeStartTag("<lineArea height=\"" + line.getHeight() + "\""
+        writeStartTag("<lineArea bpd=\"" + line.getBPD() + "\""
                       + prop + ">");
         super.renderLineArea(line);
         writeEndTag("</lineArea>");
@@ -414,7 +413,7 @@ public class XMLRenderer extends AbstractRenderer {
      * @see org.apache.fop.render.Renderer#renderInlineSpace(Space)
      */
     protected void renderInlineSpace(Space space) {
-        writeElement("<space width=\"" + space.getWidth() + "\"/>");
+        writeElement("<space ipd=\"" + space.getIPD() + "\"/>");
     }
 
     /**
@@ -470,7 +469,7 @@ public class XMLRenderer extends AbstractRenderer {
                 style = "ridge";
                 break;
         }
-        writeElement("<leader width=\"" + area.getWidth()
+        writeElement("<leader ipd=\"" + area.getIPD()
                         + "\" ruleStyle=\"" + style
                         + "\" ruleThickness=\"" + area.getRuleThickness()
                         + "\"/>");