aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Lease <klease@apache.org>2001-03-04 21:38:41 +0000
committerKaren Lease <klease@apache.org>2001-03-04 21:38:41 +0000
commitbd571c5c746ea6d60acb01a2805347f21473b186 (patch)
tree1304115fa30d8404e0f129660ae50f84d6136d5e
parentc4c93d19cb14ed39fe185265fa8000b123e2b3e8 (diff)
downloadxmlgraphics-fop-bd571c5c746ea6d60acb01a2805347f21473b186.tar.gz
xmlgraphics-fop-bd571c5c746ea6d60acb01a2805347f21473b186.zip
New property/trait groups
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194127 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/org/apache/fop/layout/Area.java108
-rw-r--r--src/org/apache/fop/layout/AreaContainer.java4
-rw-r--r--src/org/apache/fop/layout/BodyAreaContainer.java9
-rw-r--r--src/org/apache/fop/layout/BorderAndPadding.java108
-rw-r--r--src/org/apache/fop/layout/HyphenationProps.java69
5 files changed, 234 insertions, 64 deletions
diff --git a/src/org/apache/fop/layout/Area.java b/src/org/apache/fop/layout/Area.java
index 4c35587de..7e378257c 100644
--- a/src/org/apache/fop/layout/Area.java
+++ b/src/org/apache/fop/layout/Area.java
@@ -62,6 +62,7 @@ abstract public class Area extends Box {
/* nominal font size and nominal font family incorporated in
fontState */
protected FontState fontState;
+ protected BorderAndPadding bp=null;
protected Vector children = new Vector();
@@ -86,39 +87,26 @@ abstract public class Area extends Box {
protected ColorType backgroundColor;
private IDReferences idReferences;
- protected int paddingTop;
- protected int paddingLeft;
- protected int paddingBottom;
- protected int paddingRight;
/* author : Seshadri G
** the fo which created it */
public org.apache.fop.fo.FObj foCreator;
- public int borderWidthTop;
- public int borderWidthLeft;
- public int borderWidthRight;
- public int borderWidthBottom;
- public int borderStyleTop;
- public int borderStyleLeft;
- public int borderStyleRight;
- public int borderStyleBottom;
- public ColorType borderColorTop;
- public ColorType borderColorLeft;
- public ColorType borderColorRight;
- public ColorType borderColorBottom;
-
public Area (FontState fontState) {
- this.fontState = fontState;
+ setFontState(fontState);
}
public Area (FontState fontState, int allocationWidth, int maxHeight) {
- this.fontState = fontState;
+ setFontState(fontState);
this.allocationWidth = allocationWidth;
this.contentRectangleWidth = allocationWidth;
this.maxHeight = maxHeight;
}
+ private void setFontState(FontState fontState) {
+ // fontState.setFontInfo(this.page.getFontInfo());
+ this.fontState = fontState;
+ }
public void addChild(Box child) {
this.children.addElement(child);
child.parent = this;
@@ -143,8 +131,11 @@ abstract public class Area extends Box {
}
public int getAllocationWidth() {
- return this.allocationWidth - paddingLeft - paddingRight -
- borderWidthLeft - borderWidthRight;
+ /* ATTENTION: this may change your output!! (Karen Lease, 4mar2001)
+ return this.allocationWidth - getPaddingLeft() - getPaddingRight()
+ - getBorderLeftWidth() - getBorderRightWidth();
+ */
+ return this.allocationWidth ;
}
public void setAllocationWidth(int w) {
@@ -157,8 +148,11 @@ abstract public class Area extends Box {
}
public int getContentWidth() {
- return contentRectangleWidth - paddingLeft - paddingRight -
- borderWidthLeft - borderWidthRight;
+ /* ATTENTION: this may change your output!! (Karen Lease, 4mar2001)
+ return contentRectangleWidth - getPaddingLeft() - getPaddingRight()
+ - getBorderLeftWidth() - getBorderRightWidth();
+ */
+ return contentRectangleWidth ;
}
public FontState getFontState() {
@@ -170,13 +164,13 @@ abstract public class Area extends Box {
}
public int getHeight() {
- return this.currentHeight + paddingTop + paddingBottom +
- borderWidthTop + borderWidthBottom;
+ return this.currentHeight + getPaddingTop() + getPaddingBottom() +
+ getBorderTopWidth() + getBorderBottomWidth();
}
public int getMaxHeight() {
- return this.maxHeight - paddingTop - paddingBottom -
- borderWidthTop - borderWidthBottom;
+ return this.maxHeight - getPaddingTop() - getPaddingBottom() -
+ getBorderTopWidth() - getBorderBottomWidth();
}
public Page getPage() {
@@ -187,20 +181,39 @@ abstract public class Area extends Box {
return this.backgroundColor;
}
+ // Must handle conditionality here, depending on isLast/isFirst
public int getPaddingTop() {
- return this.paddingTop;
+ return (bp==null? 0 : bp.getPaddingTop(false));
}
public int getPaddingLeft() {
- return this.paddingLeft;
+ return(bp==null? 0 : bp.getPaddingLeft(false));
}
public int getPaddingBottom() {
- return this.paddingBottom;
+ return (bp==null? 0 : bp.getPaddingBottom(false));
}
public int getPaddingRight() {
- return this.paddingRight;
+ return (bp==null? 0 : bp.getPaddingRight(false));
+ }
+
+ // Handle border-width, including conditionality
+ // For now, just pass false everywhere!
+ public int getBorderTopWidth() {
+ return (bp==null? 0 : bp.getBorderTopWidth(false));
+ }
+
+ public int getBorderRightWidth() {
+ return (bp==null? 0 : bp.getBorderRightWidth(false));
+ }
+
+ public int getBorderLeftWidth() {
+ return (bp==null? 0 : bp.getBorderLeftWidth(false));
+ }
+
+ public int getBorderBottomWidth() {
+ return (bp==null? 0 : bp.getBorderBottomWidth(false));
}
public int getTableCellXOffset() {
@@ -252,33 +265,8 @@ abstract public class Area extends Box {
this.backgroundColor = bgColor;
}
- public void setPadding(int top, int left, int bottom, int right) {
- this.paddingTop = top;
- this.paddingLeft = left;
- this.paddingBottom = bottom;
- this.paddingRight = right;
- }
-
- public void setBorderWidth(int top, int left, int bottom, int right) {
- this.borderWidthTop = top;
- this.borderWidthLeft = left;
- this.borderWidthBottom = bottom;
- this.borderWidthRight = right;
- }
-
- public void setBorderStyle(int top, int left, int bottom, int right) {
- this.borderStyleTop = top;
- this.borderStyleLeft = left;
- this.borderStyleBottom = bottom;
- this.borderStyleRight = right;
- }
-
- public void setBorderColor(ColorType top, ColorType left,
- ColorType bottom, ColorType right) {
- this.borderColorTop = top;
- this.borderColorLeft = left;
- this.borderColorBottom = bottom;
- this.borderColorRight = right;
+ public void setBorderAndPadding(BorderAndPadding bp) {
+ this.bp = bp;
}
public int spaceLeft() {
@@ -333,4 +321,8 @@ abstract public class Area extends Box {
}
return (AreaContainer)area;
}
+
+ public BorderAndPadding getBorderAndPadding() {
+ return bp;
+ }
}
diff --git a/src/org/apache/fop/layout/AreaContainer.java b/src/org/apache/fop/layout/AreaContainer.java
index e97129bd2..79822f7d2 100644
--- a/src/org/apache/fop/layout/AreaContainer.java
+++ b/src/org/apache/fop/layout/AreaContainer.java
@@ -82,7 +82,7 @@ public class AreaContainer extends Area {
}
public int getXPosition() {
- return xPosition + this.paddingLeft + this.borderWidthLeft;
+ return xPosition + getPaddingLeft() + getBorderLeftWidth();
}
public void setXPosition(int value) {
@@ -90,7 +90,7 @@ public class AreaContainer extends Area {
}
public int getYPosition() {
- return yPosition + this.paddingTop + this.borderWidthTop;
+ return yPosition + getPaddingTop() + getBorderTopWidth();
}
public int getCurrentYPosition() {
diff --git a/src/org/apache/fop/layout/BodyAreaContainer.java b/src/org/apache/fop/layout/BodyAreaContainer.java
index 9b07db38c..d2aee8d3e 100644
--- a/src/org/apache/fop/layout/BodyAreaContainer.java
+++ b/src/org/apache/fop/layout/BodyAreaContainer.java
@@ -122,8 +122,9 @@ public class BodyAreaContainer extends Area {
this.addChild(footnoteReferenceArea);
// all padding and border-width must be 0
- setPadding(0, 0, 0, 0);
- setBorderWidth(0, 0, 0, 0);
+ //setBorderAndPadding(new BorderAndPadding());
+ // setPadding(0, 0, 0, 0);
+ // setBorderWidth(0, 0, 0, 0);
}
public void render(Renderer renderer) {
@@ -135,7 +136,7 @@ public class BodyAreaContainer extends Area {
}
public int getXPosition() {
- return xPosition + this.paddingLeft + this.borderWidthLeft;
+ return xPosition + getPaddingLeft() + getBorderLeftWidth();
}
public void setXPosition(int value)
@@ -144,7 +145,7 @@ public class BodyAreaContainer extends Area {
}
public int getYPosition() {
- return yPosition + this.paddingTop + this.borderWidthTop;
+ return yPosition + getPaddingTop() + getBorderTopWidth();
}
public void setYPosition(int value)
diff --git a/src/org/apache/fop/layout/BorderAndPadding.java b/src/org/apache/fop/layout/BorderAndPadding.java
new file mode 100644
index 000000000..db30592ee
--- /dev/null
+++ b/src/org/apache/fop/layout/BorderAndPadding.java
@@ -0,0 +1,108 @@
+/*-- $Id$ -- */
+/*
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+package org.apache.fop.layout;
+
+
+import org.apache.fop.datatypes.ColorType;
+import org.apache.fop.datatypes.CondLength;
+
+public class BorderAndPadding {
+
+ public static final int TOP=0;
+ public static final int RIGHT=1;
+ public static final int BOTTOM=2;
+ public static final int LEFT=3;
+
+ public static class BorderInfo {
+ private int mStyle; // Enum for border style
+ private CondLength mWidth;
+ private ColorType mColor; // Border color
+
+ BorderInfo(int style, CondLength width, ColorType color) {
+ mStyle = style;
+ mWidth = width;
+ mColor = color;
+ }
+ }
+
+ private BorderInfo[] borderInfo = new BorderInfo[4];
+ private CondLength[] padding = new CondLength[4];
+
+ public BorderAndPadding() {
+ }
+
+ public void setBorder(int side, int style, CondLength width, ColorType color ) {
+ borderInfo[side] = new BorderInfo(style, width, color);
+ }
+
+ public void setPadding(int side, CondLength width ) {
+ padding[side] = width;
+ }
+
+ public int getBorderLeftWidth(boolean bDiscard) {
+ return getBorderWidth(LEFT, bDiscard);
+ }
+
+ public int getBorderRightWidth(boolean bDiscard) {
+ return getBorderWidth(RIGHT, bDiscard);
+ }
+
+ public int getBorderTopWidth(boolean bDiscard) {
+ return getBorderWidth(TOP, bDiscard);
+ }
+
+ public int getBorderBottomWidth(boolean bDiscard) {
+ return getBorderWidth(BOTTOM, bDiscard);
+ }
+
+ public int getPaddingLeft(boolean bDiscard) {
+ return getPadding(LEFT, bDiscard);
+ }
+
+ public int getPaddingRight(boolean bDiscard) {
+ return getPadding(RIGHT, bDiscard);
+ }
+
+ public int getPaddingBottom(boolean bDiscard) {
+ return getPadding(BOTTOM, bDiscard);
+ }
+
+ public int getPaddingTop(boolean bDiscard) {
+ return getPadding(TOP, bDiscard);
+ }
+
+
+ private int getBorderWidth(int side, boolean bDiscard) {
+ if ((borderInfo[side] == null) ||
+ (bDiscard && borderInfo[side].mWidth.isDiscard())) {
+ return 0;
+ }
+ else return borderInfo[side].mWidth.mvalue();
+ }
+
+ public ColorType getBorderColor(int side) {
+ if (borderInfo[side] != null) {
+ return borderInfo[side].mColor;
+ }
+ else return null;
+ }
+
+ public int getBorderStyle(int side) {
+ if (borderInfo[side] != null) {
+ return borderInfo[side].mStyle;
+ }
+ else return 0;
+ }
+
+ private int getPadding(int side, boolean bDiscard) {
+ if ((padding[side] == null) ||
+ (bDiscard && padding[side].isDiscard())) {
+ return 0;
+ }
+ else return padding[side].mvalue();
+ }
+}
diff --git a/src/org/apache/fop/layout/HyphenationProps.java b/src/org/apache/fop/layout/HyphenationProps.java
new file mode 100644
index 000000000..dc01f698e
--- /dev/null
+++ b/src/org/apache/fop/layout/HyphenationProps.java
@@ -0,0 +1,69 @@
+/*-- $Id$ --
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+ include the following acknowledgment: "This product includes software
+ developed by the Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowledgment may appear in the software itself, if
+ and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ endorse or promote products derived from this software without prior
+ written permission. For written permission, please contact
+ apache@apache.org.
+
+ 5. Products derived from this software may not be called "Apache", nor may
+ "Apache" appear in their name, without prior written permission of the
+ Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many individuals
+ on behalf of the Apache Software Foundation and was originally created by
+ James Tauber <jtauber@jtauber.com>. For more information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+
+package org.apache.fop.layout;
+
+
+/**
+ * Store all hyphenation related properties on an FO.
+ * Public "structure" allows direct member access.
+ */
+public class HyphenationProps {
+ public int hyphenate; // Enum true or false: store as boolean!
+ public char hyphenationChar;
+ public int hyphenationPushCharacterCount;
+ public int hyphenationRemainCharacterCount;
+ public String language; // Language code or enum "NONE"
+ public String country; // Country code or enum "NONE"
+
+ public HyphenationProps() {
+ }
+}