From 44883bb9871c47ad9ed1c0cf83bee441f32894de Mon Sep 17 00:00:00 2001 From: Karen Lease Date: Fri, 10 Nov 2000 22:06:21 +0000 Subject: [PATCH] New methods used in calculating percent-based property values git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193768 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/FObj.java | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/org/apache/fop/fo/FObj.java b/src/org/apache/fop/fo/FObj.java index bc4f789f6..221c25e27 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -142,7 +142,31 @@ public class FObj extends FONode { return(properties.get(name)); } - + /** + * Return the width of the containing area for this FO's areas. + * This is used by percent-based properties to get the dimension of + * the containing block. + * If an FO has a property with a percentage value, that value + * is usually calculated on the basis of the corresponding dimenions + * of the block which contains areas generated by the FO. + * Implementation note: if this block has an FObj parent, this method + * returns the value of getContentWidth() on that FObj. Normally subclasses + * will override getContentWidth and not getContainingWidth(). + */ + public int getContainingWidth() { + FObj parent = getParent(); + if (parent != null) + return parent.getContentWidth(); + else return 0; // no parent, top level box + } + + /** + * Return the "content width" of the areas generated by this FO. + * NOTE: subclasses of FObj should implement this! + */ + protected int getContentWidth() { + return 0; + } /** * removes property id -- 2.39.5