]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added addMargins() to set the SPACE_* traits.
authorFinn Bock <bckfnn@apache.org>
Thu, 29 Jan 2004 19:36:04 +0000 (19:36 +0000)
committerFinn Bock <bckfnn@apache.org>
Thu, 29 Jan 2004 19:36:04 +0000 (19:36 +0000)
PR: 25802.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197291 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/TraitSetter.java

index 87975058dbf0f6eb7eba7c4fb939a9a02b21c23a..5d0b89fa5c4f9eedd30f8579a90a039f6f350a91 100644 (file)
@@ -55,6 +55,7 @@ import org.apache.fop.traits.BorderProps;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Trait;
 import org.apache.fop.fo.properties.CommonBackground;
+import org.apache.fop.fo.properties.CommonMarginBlock;
 
 /**
  * This is a helper class used for setting common traits on areas.
@@ -204,4 +205,29 @@ public class TraitSetter {
             curBlock.addTrait(Trait.BACKGROUND, back);
         }
     }
+
+    /**
+     * Add space to a block area.
+     * Layout managers that create block areas can use this to add space
+     * outside of the border rectangle to the area.
+     * @param curBlock the current block.
+     * @param marginProps the margin properties.
+     */
+    public static void addMargins(Area curBlock,
+                                  CommonBorderAndPadding bpProps, 
+                                  CommonMarginBlock marginProps) {
+        int spaceStart = marginProps.startIndent - 
+                            bpProps.getBorderStartWidth(false) -
+                            bpProps.getPaddingStart(false);
+        if (spaceStart != 0) {
+            curBlock.addTrait(Trait.SPACE_START, new Integer(spaceStart));
+        }
+
+        int spaceEnd = marginProps.endIndent -
+                           bpProps.getBorderEndWidth(false) -
+                           bpProps.getPaddingEnd(false);
+        if (spaceEnd != 0) {
+            curBlock.addTrait(Trait.SPACE_END, new Integer(spaceEnd));
+        }
+    }
 }