You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2002/05/17 10:56:03 UTC
cvs commit: xml-fop/src/org/apache/fop/layoutmgr LineBPLayoutManager.java LineLayoutManager.java
keiron 02/05/17 01:56:03
Modified: src/org/apache/fop/area LineArea.java
src/org/apache/fop/layoutmgr LineBPLayoutManager.java
LineLayoutManager.java
Log:
moved vert align to line area
Revision Changes Path
1.5 +107 -1 xml-fop/src/org/apache/fop/area/LineArea.java
Index: LineArea.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/LineArea.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LineArea.java 26 Apr 2002 09:40:55 -0000 1.4
+++ LineArea.java 17 May 2002 08:56:03 -0000 1.5
@@ -1,5 +1,5 @@
/*
- * $Id: LineArea.java,v 1.4 2002/04/26 09:40:55 keiron Exp $
+ * $Id: LineArea.java,v 1.5 2002/05/17 08:56:03 keiron Exp $
* 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.
@@ -8,9 +8,12 @@
package org.apache.fop.area;
import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.layoutmgr.LayoutInfo;
+import org.apache.fop.fo.properties.VerticalAlign;
import java.util.ArrayList;
import java.util.List;
+import java.util.Iterator;
// a line area can contain information in ranges of child inline
// areas that have properties such as
@@ -63,6 +66,109 @@
public List getTraitList() {
return props;
+ }
+
+ public void verticalAlign(int lh, int lead, int follow) {
+ int maxHeight = lh;
+ List inlineAreas = getInlineAreas();
+
+ // get smallest possible offset to before edge
+ // this depends on the height of no and middle alignments
+ int before = lead;
+ int after = follow;
+ int halfLeading = (lineHeight - lead - follow) / 2;
+ before += halfLeading;
+ for (Iterator iter = inlineAreas.iterator(); iter.hasNext();) {
+ InlineArea inline = (InlineArea) iter.next();
+ LayoutInfo info = inline.info;
+ int al;
+ int ld = inline.getHeight();
+ if (info != null) {
+ al = info.alignment;
+ ld = info.lead;
+ } else {
+ al = VerticalAlign.BASELINE;
+ }
+ if (al == VerticalAlign.BASELINE) {
+ if (ld > before) {
+ before = ld;
+ }
+ if (inline.getHeight() > before) {
+ before = inline.getHeight();
+ }
+ } else if (al == VerticalAlign.MIDDLE) {
+ if (inline.getHeight() / 2 + lead / 2 > before) {
+ before = inline.getHeight() / 2 + lead / 2;
+ }
+ if (inline.getHeight() / 2 - lead / 2 > after) {
+ after = inline.getHeight() / 2 - lead / 2;
+ }
+ } else if (al == VerticalAlign.TOP) {
+ } else if (al == VerticalAlign.BOTTOM) {
+ }
+ }
+ // then align all before, no and middle alignment
+ for (Iterator iter = inlineAreas.iterator(); iter.hasNext();) {
+ InlineArea inline = (InlineArea) iter.next();
+ LayoutInfo info = inline.info;
+ int al;
+ int ld = inline.getHeight();
+ boolean bloffset = false;
+ if (info != null) {
+ al = info.alignment;
+ ld = info.lead;
+ bloffset = info.blOffset;
+ } else {
+ al = VerticalAlign.BASELINE;
+ }
+ if (al == VerticalAlign.BASELINE) {
+ // the offset position for text is the baseline
+ if (bloffset) {
+ inline.setOffset(before);
+ } else {
+ inline.setOffset(before - ld);
+ }
+ if (inline.getHeight() - ld > after) {
+ after = inline.getHeight() - ld;
+ }
+ } else if (al == VerticalAlign.MIDDLE) {
+ inline.setOffset(before - inline.getHeight() / 2 -
+ lead / 2);
+ } else if (al == VerticalAlign.TOP) {
+ inline.setOffset(0);
+ if (inline.getHeight() - before > after) {
+ after = inline.getHeight() - before;
+ }
+ } else if (al == VerticalAlign.BOTTOM) {
+ if (inline.getHeight() - before > after) {
+ after = inline.getHeight() - before;
+ }
+ }
+ }
+
+ // after alignment depends on maximum height of before
+ // and middle alignments
+ for (Iterator iter = inlineAreas.iterator(); iter.hasNext();) {
+ InlineArea inline = (InlineArea) iter.next();
+ LayoutInfo info = inline.info;
+ int al;
+ if (info != null) {
+ al = info.alignment;
+ } else {
+ al = VerticalAlign.BASELINE;
+ }
+ if (al == VerticalAlign.BASELINE) {
+ } else if (al == VerticalAlign.MIDDLE) {
+ } else if (al == VerticalAlign.TOP) {
+ } else if (al == VerticalAlign.BOTTOM) {
+ inline.setOffset(before + after - inline.getHeight());
+ }
+ }
+ if (before + after > maxHeight) {
+ setHeight(before + after);
+ } else {
+ setHeight(maxHeight);
+ }
}
}
1.4 +11 -2 xml-fop/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java
Index: LineBPLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LineBPLayoutManager.java 13 May 2002 06:12:42 -0000 1.3
+++ LineBPLayoutManager.java 17 May 2002 08:56:03 -0000 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: LineBPLayoutManager.java,v 1.3 2002/05/13 06:12:42 klease Exp $
+ * $Id: LineBPLayoutManager.java,v 1.4 2002/05/17 08:56:03 keiron Exp $
* 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.
@@ -63,10 +63,16 @@
private int m_iTextIndent = 0;
private int m_iIndents = 0;
+ private int lineHeight;
+ private int lead;
+ private int follow;
public LineBPLayoutManager(FObj fobj, List lms, int lh, int l, int f) {
//super(fobj, lms.listIterator(), lh, l, f);
super(fobj, lms.listIterator());
+ lineHeight = lh;
+ lead = l;
+ follow = f;
init(); // Normally done when started by parent!
}
@@ -245,6 +251,9 @@
// No more content to layout!
setFinished(true);
}
+
+if(bp == null) return null;
+
// Choose the best break
if (!bp.isForcedBreak() && vecPossEnd.size()>0) {
m_prevBP = getBestBP(vecPossEnd);
@@ -383,7 +392,7 @@
while ((childLM = inlinePosIter.getNextChildLM())!= null) {
childLM.addAreas(inlinePosIter);
}
- // verticalAlign(m_lineArea);
+ m_lineArea.verticalAlign(lineHeight, lead, follow);
parentLM.addChild(m_lineArea);
}
m_lineArea = null;
1.9 +2 -106 xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java
Index: LineLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- LineLayoutManager.java 10 May 2002 12:38:15 -0000 1.8
+++ LineLayoutManager.java 17 May 2002 08:56:03 -0000 1.9
@@ -1,5 +1,5 @@
/*
- * $Id: LineLayoutManager.java,v 1.8 2002/05/10 12:38:15 klease Exp $
+ * $Id: LineLayoutManager.java,v 1.9 2002/05/17 08:56:03 keiron Exp $
* 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.
@@ -165,7 +165,7 @@
if (currentLine != null) {
// Adjust spacing as necessary
adjustSpacing();
- verticalAlign(currentLine.area);
+ currentLine.area.verticalAlign(lineHeight, lead, follow);
boolean res = parentLM.addChild(currentLine.area);
@@ -276,110 +276,6 @@
}
}
- }
-
- protected void verticalAlign(LineArea lineArea) {
- int maxHeight = lineHeight;
- List inlineAreas = lineArea.getInlineAreas();
-
- // get smallest possible offset to before edge
- // this depends on the height of no and middle alignments
- int before = lead;
- int after = follow;
- int halfLeading = (lineHeight - lead - follow) / 2;
- before += halfLeading;
- for (Iterator iter = inlineAreas.iterator(); iter.hasNext();) {
- InlineArea inline = (InlineArea) iter.next();
- LayoutInfo info = inline.info;
- int al;
- int ld = inline.getHeight();
- if (info != null) {
- al = info.alignment;
- ld = info.lead;
- } else {
- al = VerticalAlign.BASELINE;
- }
- if (al == VerticalAlign.BASELINE) {
- if (ld > before) {
- before = ld;
- }
- if (inline.getHeight() > before) {
- before = inline.getHeight();
- }
- } else if (al == VerticalAlign.MIDDLE) {
- if (inline.getHeight() / 2 + lead / 2 > before) {
- before = inline.getHeight() / 2 + lead / 2;
- }
- if (inline.getHeight() / 2 - lead / 2 > after) {
- after = inline.getHeight() / 2 - lead / 2;
- }
- } else if (al == VerticalAlign.TOP) {
- } else if (al == VerticalAlign.BOTTOM) {
- }
- }
-
- // then align all before, no and middle alignment
- for (Iterator iter = inlineAreas.iterator(); iter.hasNext();) {
- InlineArea inline = (InlineArea) iter.next();
- LayoutInfo info = inline.info;
- int al;
- int ld = inline.getHeight();
- boolean bloffset = false;
- if (info != null) {
- al = info.alignment;
- ld = info.lead;
- bloffset = info.blOffset;
- } else {
- al = VerticalAlign.BASELINE;
- }
- if (al == VerticalAlign.BASELINE) {
- // the offset position for text is the baseline
- if (bloffset) {
- inline.setOffset(before);
- } else {
- inline.setOffset(before - ld);
- }
- if (inline.getHeight() - ld > after) {
- after = inline.getHeight() - ld;
- }
- } else if (al == VerticalAlign.MIDDLE) {
- inline.setOffset(before - inline.getHeight() / 2 -
- lead / 2);
- } else if (al == VerticalAlign.TOP) {
- inline.setOffset(0);
- if (inline.getHeight() - before > after) {
- after = inline.getHeight() - before;
- }
- } else if (al == VerticalAlign.BOTTOM) {
- if (inline.getHeight() - before > after) {
- after = inline.getHeight() - before;
- }
- }
- }
-
- // after alignment depends on maximum height of before
- // and middle alignments
- for (Iterator iter = inlineAreas.iterator(); iter.hasNext();) {
- InlineArea inline = (InlineArea) iter.next();
- LayoutInfo info = inline.info;
- int al;
- if (info != null) {
- al = info.alignment;
- } else {
- al = VerticalAlign.BASELINE;
- }
- if (al == VerticalAlign.BASELINE) {
- } else if (al == VerticalAlign.MIDDLE) {
- } else if (al == VerticalAlign.TOP) {
- } else if (al == VerticalAlign.BOTTOM) {
- inline.setOffset(before + after - inline.getHeight());
- }
- }
- if (before + after > maxHeight) {
- lineArea.setHeight(before + after);
- } else {
- lineArea.setHeight(maxHeight);
- }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org