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 sp...@apache.org on 2011/02/11 12:59:35 UTC

svn commit: r1069764 [4/7] - in /xmlgraphics/fop/branches/Temp_ComplexScripts: ./ lib/ lib/build/ src/codegen/java/org/apache/fop/tools/ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/afp/ src/java/org/apache/fop/afp/apps/ src/java/org/...

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Fri Feb 11 11:59:32 2011
@@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.fop.area.Area;
 import org.apache.fop.area.BlockParent;
 import org.apache.fop.fo.pagination.Flow;
+import org.apache.fop.util.ListUtil;
 
 /**
  * LayoutManager for an fo:flow object.
@@ -61,22 +62,9 @@ public class FlowLayoutManager extends B
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getNextKnuthElements(LayoutContext context, int alignment) {
-
-        List elements = new LinkedList();
-
-        LayoutManager currentChildLM;
-        while ((currentChildLM = getChildLM()) != null) {
-            if (addChildElements(elements, currentChildLM, context, alignment) != null) {
-                return elements;
-            }
-        }
-
-        SpaceResolver.resolveElementList(elements);
-        setFinished(true);
-
-        assert !elements.isEmpty();
-        return elements;
+        return getNextKnuthElements(context, alignment, null, null);
     }
 
     /**
@@ -84,46 +72,58 @@ public class FlowLayoutManager extends B
      * of the node assigned to the LM.
      * @param context   the LayoutContext used to store layout information
      * @param alignment the desired text alignment
-     * @param positionAtIPDChange position at ipd change
-     * @param restartAtLM restart at this layout manager
+     * @param restartPosition   {@link Position} to restart from
+     * @param restartLM {@link LayoutManager} to restart from
      * @return the list of KnuthElements
      * @see LayoutManager#getNextKnuthElements(LayoutContext,int)
      */
-    public List getNextKnuthElements(LayoutContext context, int alignment,
-            Position positionAtIPDChange, LayoutManager restartAtLM) {
+    List getNextKnuthElements(LayoutContext context, int alignment,
+            Position restartPosition, LayoutManager restartLM) {
 
-        List elements = new LinkedList();
+        List<ListElement> elements = new LinkedList<ListElement>();
 
-        LayoutManager currentChildLM = positionAtIPDChange.getLM();
-        if (currentChildLM == null) {
-            throw new IllegalStateException(
-                    "Cannot find layout manager from where to re-start layout after IPD change");
-        }
-        if (restartAtLM != null && restartAtLM.getParent() == this) {
-            currentChildLM = restartAtLM;
-            setCurrentChildLM(currentChildLM);
-            currentChildLM.reset();
-            if (addChildElements(elements, currentChildLM, context, alignment) != null) {
-                return elements;
+        boolean isRestart = (restartPosition != null);
+        // always reset in case of restart (exception: see below)
+        boolean doReset = isRestart;
+        LayoutManager currentChildLM;
+        Stack<LayoutManager> lmStack = new Stack<LayoutManager>();
+        if (isRestart) {
+            currentChildLM = restartPosition.getLM();
+            if (currentChildLM == null) {
+                throw new IllegalStateException("Cannot find layout manager to restart from");
             }
-        } else {
-            Stack lmStack = new Stack();
-            while (currentChildLM.getParent() != this) {
-                lmStack.push(currentChildLM);
-                currentChildLM = currentChildLM.getParent();
+            if (restartLM != null && restartLM.getParent() == this) {
+                currentChildLM = restartLM;
+            } else {
+                while (currentChildLM.getParent() != this) {
+                    lmStack.push(currentChildLM);
+                    currentChildLM = currentChildLM.getParent();
+                }
+                doReset = false;
             }
             setCurrentChildLM(currentChildLM);
-            if (addChildElements(elements, currentChildLM, context, alignment, lmStack,
-                    positionAtIPDChange, restartAtLM) != null) {
-                return elements;
-            }
+        } else {
+            currentChildLM = getChildLM();
         }
 
-        while ((currentChildLM = getChildLM()) != null) {
-            currentChildLM.reset(); // TODO won't work with forced breaks
-            if (addChildElements(elements, currentChildLM, context, alignment) != null) {
-                return elements;
+        while (currentChildLM != null) {
+            if (!isRestart || doReset) {
+                if (doReset) {
+                    currentChildLM.reset(); // TODO won't work with forced breaks
+                }
+                if (addChildElements(elements, currentChildLM, context, alignment,
+                        null, null, null) != null) {
+                    return elements;
+                }
+            } else {
+                if (addChildElements(elements, currentChildLM, context, alignment, lmStack,
+                        restartPosition, restartLM) != null) {
+                    return elements;
+                }
+                // restarted; force reset as of next child
+                doReset = true;
             }
+            currentChildLM = getChildLM();
         }
 
         SpaceResolver.resolveElementList(elements);
@@ -133,31 +133,28 @@ public class FlowLayoutManager extends B
         return elements;
     }
 
-    private List addChildElements(List elements, LayoutManager childLM, LayoutContext context,
-            int alignment) {
-        return addChildElements(elements, childLM, context, alignment, null, null, null);
-    }
-
-    private List addChildElements(List elements, LayoutManager childLM, LayoutContext context,
-            int alignment, Stack lmStack, Position position, LayoutManager restartAtLM) {
-        if (handleSpanChange(childLM, elements, context)) {
+    private List<ListElement> addChildElements(List<ListElement> elements,
+            LayoutManager childLM, LayoutContext context, int alignment,
+            Stack<LayoutManager> lmStack, Position position, LayoutManager restartAtLM) {
+        if (handleSpanChange(childLM, context)) {
             SpaceResolver.resolveElementList(elements);
             return elements;
         }
 
-        LayoutContext childLC = new LayoutContext(0);
-        List childrenElements = getNextChildElements(childLM, context, childLC, alignment, lmStack,
-                position, restartAtLM);
+        LayoutContext childLC = makeChildLayoutContext(context);
+        List<ListElement> childElements
+                = getNextChildElements(childLM, context, childLC, alignment, lmStack,
+                    position, restartAtLM);
         if (elements.isEmpty()) {
             context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
         }
         if (!elements.isEmpty()
-                && !ElementListUtils.startsWithForcedBreak(childrenElements)) {
+                && !ElementListUtils.startsWithForcedBreak(childElements)) {
             addInBetweenBreak(elements, context, childLC);
         }
         context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
 
-        elements.addAll(childrenElements);
+        elements.addAll(childElements);
 
         if (ElementListUtils.endsWithForcedBreak(elements)) {
             // a descendant of this flow has break-before or break-after
@@ -170,7 +167,7 @@ public class FlowLayoutManager extends B
         return null;
     }
 
-    private boolean handleSpanChange(LayoutManager childLM, List elements, LayoutContext context) {
+    private boolean handleSpanChange(LayoutManager childLM, LayoutContext context) {
         int span = EN_NONE;
         int disableColumnBalancing = EN_FALSE;
         if (childLM instanceof BlockLayoutManager) {
@@ -196,32 +193,47 @@ public class FlowLayoutManager extends B
         }
     }
 
-    private List getNextChildElements(LayoutManager childLM, LayoutContext context,
-            LayoutContext childLC, int alignment, Stack lmStack, Position restartPosition,
-            LayoutManager restartLM) {
+    /**
+     * Overridden to take into account the current page-master's
+     * writing-mode
+     * {@inheritDoc}
+     */
+    @Override
+    protected LayoutContext makeChildLayoutContext(LayoutContext context) {
+        LayoutContext childLC = new LayoutContext(0);
         childLC.setStackLimitBP(context.getStackLimitBP());
         childLC.setRefIPD(context.getRefIPD());
         childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode());
+        return childLC;
+    }
 
-        List childrenElements;
+    /**
+     * Overridden to wrap the child positions before returning the list
+     * {@inheritDoc}
+     */
+    @Override
+    protected List<ListElement> getNextChildElements(LayoutManager childLM, LayoutContext context,
+            LayoutContext childLC, int alignment, Stack<LayoutManager> lmStack,
+            Position restartPosition, LayoutManager restartLM) {
+        
+        List<ListElement> childElements;
         if (lmStack == null) {
-            childrenElements = childLM.getNextKnuthElements(childLC, alignment);
+            childElements = childLM.getNextKnuthElements(childLC, alignment);
         } else {
-            childrenElements = childLM.getNextKnuthElements(childLC,
-                    alignment, lmStack, restartPosition, restartLM);
+            childElements = childLM.getNextKnuthElements(childLC, alignment,
+                    lmStack, restartPosition, restartLM);
         }
-        assert !childrenElements.isEmpty();
+        assert !childElements.isEmpty();
 
         // "wrap" the Position inside each element
-        List tempList = childrenElements;
-        childrenElements = new LinkedList();
-        wrapPositionElements(tempList, childrenElements);
-        return childrenElements;
+        List tempList = childElements;
+        childElements = new LinkedList<ListElement>();
+        wrapPositionElements(tempList, childElements);
+        return childElements;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
+    @Override
     public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
         log.debug(" FLM.negotiateBPDAdjustment> " + adj);
 
@@ -239,9 +251,8 @@ public class FlowLayoutManager extends B
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
+    @Override
     public void discardSpace(KnuthGlue spaceGlue) {
         log.debug(" FLM.discardSpace> ");
 
@@ -255,26 +266,30 @@ public class FlowLayoutManager extends B
     }
 
     /** {@inheritDoc} */
+    @Override
     public Keep getKeepTogether() {
         return Keep.KEEP_AUTO;
     }
 
     /** {@inheritDoc} */
+    @Override
     public Keep getKeepWithNext() {
         return Keep.KEEP_AUTO;
     }
 
     /** {@inheritDoc} */
+    @Override
     public Keep getKeepWithPrevious() {
         return Keep.KEEP_AUTO;
     }
 
     /** {@inheritDoc} */
-    public List getChangedKnuthElements(List oldList, /*int flaggedPenalty,*/ int alignment) {
-        ListIterator oldListIterator = oldList.listIterator();
+    @Override
+    public List<KnuthElement> getChangedKnuthElements(List oldList, int alignment) {
+        ListIterator<KnuthElement> oldListIterator = oldList.listIterator();
         KnuthElement returnedElement;
-        List returnedList = new LinkedList();
-        List returnList = new LinkedList();
+        List<KnuthElement> returnedList = new LinkedList<KnuthElement>();
+        List<KnuthElement> returnList = new LinkedList<KnuthElement>();
         KnuthElement prevElement = null;
         KnuthElement currElement = null;
         int fromIndex = 0;
@@ -282,7 +297,7 @@ public class FlowLayoutManager extends B
         // "unwrap" the Positions stored in the elements
         KnuthElement oldElement;
         while (oldListIterator.hasNext()) {
-            oldElement = (KnuthElement)oldListIterator.next();
+            oldElement = oldListIterator.next();
             if (oldElement.getPosition() instanceof NonLeafPosition) {
                 // oldElement was created by a descendant of this FlowLM
                 oldElement.setPosition((oldElement.getPosition()).getPosition());
@@ -296,7 +311,7 @@ public class FlowLayoutManager extends B
 
 
         while (oldListIterator.hasNext()) {
-            currElement = (KnuthElement) oldListIterator.next();
+            currElement = oldListIterator.next();
             if (prevElement != null
                 && prevElement.getLayoutManager() != currElement.getLayoutManager()) {
                 // prevElement is the last element generated by the same LM
@@ -314,8 +329,7 @@ public class FlowLayoutManager extends B
                     // add an infinite penalty to forbid a break between blocks
                     returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
                             new Position(this), false));
-                } else if (!((KnuthElement) returnedList.get(returnedList
-                        .size() - 1)).isGlue()) {
+                } else if (!ListUtil.getLast(returnedList).isGlue()) {
                     // add a null penalty to allow a break between blocks
                     returnedList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
                 }
@@ -331,9 +345,9 @@ public class FlowLayoutManager extends B
 
         // "wrap" the Position stored in each element of returnedList
         // and add elements to returnList
-        ListIterator listIter = returnedList.listIterator();
+        ListIterator<KnuthElement> listIter = returnedList.listIterator();
         while (listIter.hasNext()) {
-            returnedElement = (KnuthElement)listIter.next();
+            returnedElement = listIter.next();
             if (returnedElement.getLayoutManager() != this) {
                 returnedElement.setPosition(
                         new NonLeafPosition(this, returnedElement.getPosition()));
@@ -344,9 +358,8 @@ public class FlowLayoutManager extends B
         return returnList;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
+    @Override
     public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
         AreaAdditionUtil.addAreas(this, parentIter, layoutContext);
         flush();
@@ -359,15 +372,15 @@ public class FlowLayoutManager extends B
      *
      * @param childArea the area to add
      */
+    @Override
     public void addChildArea(Area childArea) {
         getParentArea(childArea);
         addChildToArea(childArea,
                           this.currentAreas[childArea.getAreaClass()]);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
+    @Override
     public Area getParentArea(Area childArea) {
         BlockParent parentArea = null;
         int aclass = childArea.getAreaClass();
@@ -392,6 +405,7 @@ public class FlowLayoutManager extends B
      * Returns the IPD of the content area
      * @return the IPD of the content area
      */
+    @Override
     public int getContentAreaIPD() {
         return getCurrentPV().getCurrentSpan().getColumnWidth();
     }
@@ -400,11 +414,13 @@ public class FlowLayoutManager extends B
      * Returns the BPD of the content area
      * @return the BPD of the content area
      */
+    @Override
     public int getContentAreaBPD() {
         return getCurrentPV().getBodyRegion().getBPD();
     }
 
     /** {@inheritDoc} */
+    @Override
     public boolean isRestartable() {
         return true;
     }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java Fri Feb 11 11:59:32 2011
@@ -38,38 +38,36 @@ public class FootnoteBodyLayoutManager e
     }
 
     /** {@inheritDoc} */
+    @Override
     public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
-        LayoutManager childLM = null;
+        LayoutManager childLM;
         LayoutManager lastLM = null;
         LayoutContext lc = new LayoutContext(0);
 
         // "unwrap" the NonLeafPositions stored in parentIter
         // and put them in a new list;
-        LinkedList positionList = new LinkedList();
+        LinkedList<Position> positionList = new LinkedList<Position>();
         Position pos;
         while (parentIter.hasNext()) {
-            pos = (Position) parentIter.next();
-            //log.trace("pos = " + pos.getClass().getName() + "; " + pos);
-            Position innerPosition = pos;
+            pos = parentIter.next();
+            Position innerPosition;
             if (pos instanceof NonLeafPosition) {
-                innerPosition = ((NonLeafPosition) pos).getPosition();
+                innerPosition = pos.getPosition();
                 if (innerPosition.getLM() == this) {
                     // pos was created by this LM and was inside a penalty
                     // allowing or forbidding a page break
                     // nothing to do
-                    //log.trace(" penalty");
                 } else {
                     // innerPosition was created by another LM
                     positionList.add(innerPosition);
                     lastLM = innerPosition.getLM();
-                    //log.trace(" " + innerPosition.getClass().getName());
                 }
             }
         }
 
         // the Positions in positionList were inside the elements
         // created by the LineLM
-        StackingIter childPosIter = new StackingIter(positionList.listIterator());
+        PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
 
         while ((childLM = childPosIter.getNextChildLM()) != null) {
             // set last area flag
@@ -81,6 +79,7 @@ public class FootnoteBodyLayoutManager e
     }
 
     /** {@inheritDoc} */
+    @Override
     public void addChildArea(Area childArea) {
         childArea.setAreaClass(Area.CLASS_FOOTNOTE);
         parentLayoutManager.addChildArea(childArea);
@@ -92,16 +91,19 @@ public class FootnoteBodyLayoutManager e
     }
 
     /** {@inheritDoc} */
+    @Override
     public Keep getKeepTogether() {
         return getParentKeepTogether();
     }
 
     /** {@inheritDoc} */
+    @Override
     public Keep getKeepWithNext() {
         return Keep.KEEP_AUTO;
     }
 
     /** {@inheritDoc} */
+    @Override
     public Keep getKeepWithPrevious() {
         return Keep.KEEP_AUTO;
     }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java Fri Feb 11 11:59:32 2011
@@ -22,7 +22,8 @@ package org.apache.fop.layoutmgr;
 import java.util.List;
 
 /**
- * A Knuth element position iterator.
+ * A dedicated {@link PositionIterator} that is backed by an iterator
+ * over a list of {@link KnuthElement}s.
  */
 public class KnuthPossPosIter extends PositionIterator {
 
@@ -50,6 +51,7 @@ public class KnuthPossPosIter extends Po
     // Check position < endPos
 
     /** {@inheritDoc} */
+    @Override
     protected boolean checkNext() {
         if (iterCount > 0) {
             return super.checkNext();
@@ -60,7 +62,8 @@ public class KnuthPossPosIter extends Po
     }
 
     /** {@inheritDoc} */
-    public Object next() {
+    @Override
+    public Position next() {
         --iterCount;
         return super.next();
     }
@@ -74,11 +77,13 @@ public class KnuthPossPosIter extends Po
     }
 
     /** {@inheritDoc} */
+    @Override
     protected LayoutManager getLM(Object nextObj) {
         return ((ListElement) nextObj).getLayoutManager();
     }
 
     /** {@inheritDoc} */
+    @Override
     protected Position getPos(Object nextObj) {
         return ((ListElement) nextObj).getPosition();
     }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/LMiter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/LMiter.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/LMiter.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/LMiter.java Fri Feb 11 11:59:32 2011
@@ -24,10 +24,10 @@ import java.util.ListIterator;
 import java.util.NoSuchElementException;
 
 /** An iterator for layout managers. */
-public class LMiter implements ListIterator {
+public class LMiter implements ListIterator<LayoutManager> {
 
     /** list of layout managers */
-    protected List listLMs;
+    protected List<LayoutManager> listLMs;
     /** current position in iteration */
     protected int curPos = 0;
     /** The LayoutManager to which this LMiter is attached **/
@@ -44,7 +44,7 @@ public class LMiter implements ListItera
 
     /** {@inheritDoc} */
     public boolean hasNext() {
-        return (curPos < listLMs.size()) ? true : lp.createNextChildLMs(curPos);
+        return (curPos < listLMs.size()) || lp.createNextChildLMs(curPos);
     }
 
     /** {@inheritDoc} */
@@ -53,7 +53,7 @@ public class LMiter implements ListItera
     }
 
     /** {@inheritDoc} */
-    public Object previous() throws NoSuchElementException {
+    public LayoutManager previous() throws NoSuchElementException {
         if (curPos > 0) {
             return listLMs.get(--curPos);
         } else {
@@ -62,7 +62,7 @@ public class LMiter implements ListItera
     }
 
     /** {@inheritDoc} */
-    public Object next() throws NoSuchElementException {
+    public LayoutManager next() throws NoSuchElementException {
         if (curPos < listLMs.size()) {
             return listLMs.get(curPos++);
         } else {
@@ -82,12 +82,12 @@ public class LMiter implements ListItera
 
 
     /** {@inheritDoc} */
-   public void add(Object o) throws UnsupportedOperationException {
+   public void add(LayoutManager lm) throws UnsupportedOperationException {
         throw new UnsupportedOperationException("LMiter doesn't support add");
     }
 
     /** {@inheritDoc} */
-    public void set(Object o) throws UnsupportedOperationException {
+    public void set(LayoutManager lm) throws UnsupportedOperationException {
         throw new UnsupportedOperationException("LMiter doesn't support set");
     }
 

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java Fri Feb 11 11:59:32 2011
@@ -43,16 +43,16 @@ class PageBreakingAlgorithm extends Brea
     private PageProvider pageProvider;
     private PageBreakingLayoutListener layoutListener;
     /** List of PageBreakPosition elements. */
-    private LinkedList pageBreaks = null;
+    private LinkedList<PageBreakPosition> pageBreaks = null;
 
     /** Footnotes which are cited between the currently considered active node (previous
      * break) and the current considered break. Its type is
      * List&lt;List&lt;KnuthElement&gt;&gt;, it contains the sequences of KnuthElement
      * representing the footnotes bodies.
      */
-    private List footnotesList = null;
+    private List<List<KnuthElement>> footnotesList = null;
     /** Cumulated bpd of unhandled footnotes. */
-    private List lengthList = null;
+    private List<Integer> lengthList = null;
     /** Length of all the footnotes which will be put on the current page. */
     private int totalFootnotesLength = 0;
     /**
@@ -64,13 +64,9 @@ class PageBreakingAlgorithm extends Brea
 
     /** True if footnote citations have been met since the beginning of the page sequence. */
     private boolean footnotesPending = false;
-    /**
-     * True if the elements met after the previous break point contain footnote citations.
-     */
+    /** True if the elements met after the previous break point contain footnote citations. */
     private boolean newFootnotes = false;
-    /**
-     * Index of the first footnote met after the previous break point.
-     */
+    /** Index of the first footnote met after the previous break point. */
     private int firstNewFootnoteIndex = 0;
     /** Index of the last footnote inserted on the current page. */
     private int footnoteListIndex = 0;
@@ -206,6 +202,7 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected void initialize() {
         super.initialize();
         insertedFootnotesLength = 0;
@@ -214,11 +211,12 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /**
-     * {@inheritDoc}
      * Overridden to defer a part to the next page, if it
      * must be kept within one page, but is too large to fit in
      * the last column.
+     * {@inheritDoc}
      */
+    @Override
     protected KnuthNode recoverFromTooLong(KnuthNode lastTooLong) {
 
         if (log.isDebugEnabled()) {
@@ -256,6 +254,7 @@ class PageBreakingAlgorithm extends Brea
      * @param node2 The other knuth node.
      * @return the node with the least demerit.
      */
+    @Override
     protected KnuthNode compareNodes(KnuthNode node1, KnuthNode node2) {
 
         /* if either node is null, return the other one */
@@ -281,6 +280,7 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected KnuthNode createNode(int position,                // CSOK: ParameterNumber
                                    int line, int fitness,
                                    int totalWidth, int totalStretch, int totalShrink,
@@ -294,6 +294,7 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected KnuthNode createNode(int position, int line, int fitness,
                                    int totalWidth, int totalStretch, int totalShrink) {
         return new KnuthPageNode(position, line, fitness,
@@ -307,11 +308,11 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /**
-     * {@inheritDoc}
      * Page-breaking specific handling of the given box. Currently it adds the footnotes
      * cited in the given box to the list of to-be-handled footnotes.
-     * @param box a block-level element possibly containing foonotes citations
+     * {@inheritDoc}
      */
+    @Override
     protected void handleBox(KnuthBox box) {
         super.handleBox(box);
         if (box instanceof KnuthBlockBox
@@ -325,11 +326,12 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /**
-     * {@inheritDoc}
      * Overridden to consider penalties with value {@link KnuthElement#INFINITE}
      * as legal break-points, if the current keep-context allows this
      * (a keep-*.within-page="always" constraint still permits column-breaks)
+     * {@inheritDoc}
      */
+    @Override
     protected void handlePenaltyAt(KnuthPenalty penalty, int position,
                                    int allowedBreaks) {
         super.handlePenaltyAt(penalty, position, allowedBreaks);
@@ -352,12 +354,12 @@ class PageBreakingAlgorithm extends Brea
      * @param elementLists list of KnuthElement sequences corresponding to the footnotes
      * bodies
      */
-    private void handleFootnotes(List elementLists) {
+    private void handleFootnotes(List<List<KnuthElement>> elementLists) {
         // initialization
         if (!footnotesPending) {
             footnotesPending = true;
-            footnotesList = new ArrayList();
-            lengthList = new ArrayList();
+            footnotesList = new ArrayList<List<KnuthElement>>();
+            lengthList = new ArrayList<Integer>();
             totalFootnotesLength = 0;
         }
         if (!newFootnotes) {
@@ -366,9 +368,7 @@ class PageBreakingAlgorithm extends Brea
         }
 
         // compute the total length of the footnotes
-        for (Iterator elementListsIterator = elementLists.iterator();
-                elementListsIterator.hasNext();) {
-            final List noteList = (List) elementListsIterator.next();
+        for (List<KnuthElement> noteList : elementLists) {
 
             //Space resolution (Note: this does not respect possible stacking constraints
             //between footnotes!)
@@ -376,23 +376,23 @@ class PageBreakingAlgorithm extends Brea
 
             int noteLength = 0;
             footnotesList.add(noteList);
-            for (Iterator noteListIterator = noteList.iterator();
-                    noteListIterator.hasNext();) {
-                final KnuthElement element = (KnuthElement) noteListIterator.next();
+            for (KnuthElement element : noteList) {
                 if (element.isBox() || element.isGlue()) {
                     noteLength += element.getWidth();
                 }
             }
             int prevLength = (lengthList == null || lengthList.isEmpty())
                     ? 0
-                    : ((Integer) ListUtil.getLast(lengthList)).intValue();
-            //TODO: replace with Integer.valueOf() once we switch to Java 5
-            lengthList.add(new Integer(prevLength + noteLength));
+                    : ListUtil.getLast(lengthList);
+            if (lengthList != null) {
+                lengthList.add(prevLength + noteLength);
+            }
             totalFootnotesLength += noteLength;
         }
     }
 
     /** {@inheritDoc} */
+    @Override
     protected int restartFrom(KnuthNode restartingNode, int currentIndex) {
         int returnValue = super.restartFrom(restartingNode, currentIndex);
         newFootnotes = false;
@@ -410,14 +410,14 @@ class PageBreakingAlgorithm extends Brea
         return returnValue;
     }
 
-    private void resetFootnotes(List elementLists) {
+    private void resetFootnotes(List<List<KnuthElement>> elementLists) {
         for (int i = 0; i < elementLists.size(); i++) {
-            /*LinkedList removedList = (LinkedList)*/ListUtil.removeLast(footnotesList);
+            ListUtil.removeLast(footnotesList);
             ListUtil.removeLast(lengthList);
 
             // update totalFootnotesLength
             if (!lengthList.isEmpty()) {
-                totalFootnotesLength = ((Integer) ListUtil.getLast(lengthList)).intValue();
+                totalFootnotesLength = ListUtil.getLast(lengthList);
             } else {
                 totalFootnotesLength = 0;
             }
@@ -429,6 +429,7 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected void considerLegalBreak(KnuthElement element, int elementIdx) {
         if (element.isPenalty()) {
             int breakClass = ((KnuthPenalty) element).getBreakClass();
@@ -457,6 +458,7 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected boolean elementCanEndLine(KnuthElement element, int line, int difference) {
         if (!(element.isPenalty()) || pageProvider == null) {
             return true;
@@ -489,11 +491,12 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected int computeDifference(KnuthNode activeNode, KnuthElement element,
                                     int elementIndex) {
         KnuthPageNode pageNode = (KnuthPageNode) activeNode;
         int actualWidth = totalWidth - pageNode.totalWidth;
-        int footnoteSplit = 0;
+        int footnoteSplit;
         boolean canDeferOldFN;
         if (element.isPenalty()) {
             actualWidth += element.getWidth();
@@ -562,6 +565,7 @@ class PageBreakingAlgorithm extends Brea
      * @param node active node for the preceding page break
      * @param contentElementIndex index of the Knuth element considered for the
      * current page break
+     * @return  true if footnotes can be deferred
      */
     private boolean canDeferOldFootnotes(KnuthPageNode node, int contentElementIndex) {
         return (noBreakBetween(node.position, contentElementIndex)
@@ -668,8 +672,8 @@ class PageBreakingAlgorithm extends Brea
             // together with all previous, not yet inserted footnotes;
             // but if this is not possible, try adding as much content as possible
             int splitLength = 0;
-            ListIterator noteListIterator = null;
-            KnuthElement element = null;
+            ListIterator<KnuthElement> noteListIterator;
+            KnuthElement element;
             boolean somethingAdded = false;
 
             // prevListIndex and prevElementIndex points to the last footnote element
@@ -687,16 +691,14 @@ class PageBreakingAlgorithm extends Brea
             if (footnotesList.size() - 1 > listIndex) {
                 // add the previous footnotes: these cannot be broken or deferred
                 if (!canDeferOldFootnotes && newFootnotes && firstNewFootnoteIndex > 0) {
-                    splitLength = ((Integer) lengthList.get(firstNewFootnoteIndex - 1)).intValue()
-                                  - prevLength;
+                    splitLength = lengthList.get(firstNewFootnoteIndex - 1) - prevLength;
                     listIndex = firstNewFootnoteIndex;
                     elementIndex = 0;
                 }
                 // try adding the new footnotes
-                while (((Integer) lengthList.get(listIndex)).intValue() - prevLength
+                while (lengthList.get(listIndex) - prevLength
                        <= availableLength) {
-                    splitLength = ((Integer) lengthList.get(listIndex)).intValue()
-                                  - prevLength;
+                    splitLength = lengthList.get(listIndex) - prevLength;
                     somethingAdded = true;
                     listIndex++;
                     elementIndex = 0;
@@ -727,7 +729,7 @@ class PageBreakingAlgorithm extends Brea
                     // all footnotes, and we have already tried (and failed) to insert
                     // this whole footnote, the while loop will never reach the end
                     // of the note sequence
-                    element = (KnuthElement) noteListIterator.next();
+                    element = noteListIterator.next();
                     if (element.isBox()) {
                         // element is a box
                         splitLength += element.getWidth();
@@ -774,6 +776,7 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected double computeAdjustmentRatio(KnuthNode activeNode, int difference) {
         // compute the adjustment ratio
         if (difference > 0) {
@@ -804,6 +807,7 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected double computeDemerits(KnuthNode activeNode, KnuthElement element,
                                     int fitnessClass, double r) {
         double demerits = 0;
@@ -856,6 +860,8 @@ class PageBreakingAlgorithm extends Brea
         return demerits;
     }
 
+    /** {@inheritDoc} */
+    @Override
     protected void finish() {
         for (int i = startLine; i < endLine; i++) {
             for (KnuthPageNode node = (KnuthPageNode) getNode(i);
@@ -880,7 +886,7 @@ class PageBreakingAlgorithm extends Brea
 
         // create pages containing the remaining footnote bodies
         while (insertedFootnotesLength < totalFootnotesLength) {
-            final int tmpLength = ((Integer) lengthList.get(footnoteListIndex)).intValue();
+            final int tmpLength = lengthList.get(footnoteListIndex);
             // try adding some more content
             if ((tmpLength - insertedFootnotesLength) <= availableBPD) {
                 // add a whole footnote
@@ -925,7 +931,7 @@ class PageBreakingAlgorithm extends Brea
      * @return a list of {@link PageBreakPosition} elements
      *          corresponding to the computed page- and column-breaks
      */
-    public LinkedList getPageBreaks() {
+    public LinkedList<PageBreakPosition> getPageBreaks() {
         return pageBreaks;
     }
 
@@ -937,7 +943,7 @@ class PageBreakingAlgorithm extends Brea
      */
     public void insertPageBreakAsFirst(PageBreakPosition pageBreak) {
         if (pageBreaks == null) {
-            pageBreaks = new LinkedList();
+            pageBreaks = new LinkedList<PageBreakPosition>();
         }
         pageBreaks.addFirst(pageBreak);
     }
@@ -948,19 +954,19 @@ class PageBreakingAlgorithm extends Brea
      * whole content should be painted as one part.
      */
     public void removeAllPageBreaks() {
-        if (pageBreaks == null) {
+        if (pageBreaks == null || pageBreaks.isEmpty()) {
             return;
         }
-        while (pageBreaks.size() > 1) {
-            pageBreaks.removeFirst();
-        }
+        pageBreaks.subList(0, pageBreaks.size() - 1).clear();
     }
 
     /** {@inheritDoc} */
+    @Override
     public void updateData1(int total, double demerits) {
     }
 
     /** {@inheritDoc} */
+    @Override
     public void updateData2(KnuthNode bestActiveNode,
                             KnuthSequence sequence,
                             int total) {
@@ -1029,6 +1035,7 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected int filterActiveNodes() {
         // leave only the active node with fewest total demerits
         KnuthNode bestActiveNode = null;
@@ -1058,8 +1065,8 @@ class PageBreakingAlgorithm extends Brea
      * @param index the index in the list of footnotes
      * @return  the element-list
      */
-    protected final List getFootnoteList(int index) {
-        return (List) footnotesList.get(index);
+    protected final List<KnuthElement> getFootnoteList(int index) {
+        return footnotesList.get(index);
     }
 
     /** @return the associated top-level formatting object. */
@@ -1068,6 +1075,7 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected int getLineWidth(int line) {
         int bpd;
         if (pageProvider != null) {
@@ -1097,11 +1105,13 @@ class PageBreakingAlgorithm extends Brea
     }
 
     /** {@inheritDoc} */
+    @Override
     protected int getIPDdifference() {
         return ipdDifference;
     }
 
     /** {@inheritDoc} */
+    @Override
     protected int handleIpdChange() {
         log.trace("Best node for ipd change:" + bestNodeForIPDChange);
         // TODO finish()
@@ -1123,6 +1133,7 @@ class PageBreakingAlgorithm extends Brea
      * @param line number of the line ending at the node's corresponding breakpoint
      * @param node the active node to add
      */
+    @Override
     protected void addNode(int line, KnuthNode node) {
         if (node.position < par.size() - 1 && line > 0
                 && (ipdDifference = compareIPDs(line - 1)) != 0) {  // CSOK: InnerAssignment
@@ -1153,5 +1164,4 @@ class PageBreakingAlgorithm extends Brea
         }
         return pageProvider.compareIPDs(line);
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PositionIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PositionIterator.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PositionIterator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PositionIterator.java Fri Feb 11 11:59:32 2011
@@ -22,20 +22,29 @@ package org.apache.fop.layoutmgr;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
-/** A position iterator. */
-public abstract class PositionIterator implements Iterator {
+/**
+ * An iterator over {@link Position} instances, that is wrapped around
+ * another 'parent' {@link Iterator}. The parent can be either another
+ * {@code PositionIterator}, or an iterator over {@link KnuthElement}s,
+ * for example.<br/>
+ * The {@link #next()} method always returns a {@link Position}. The
+ * {@link #getPos(Object)} method can be overridden in subclasses
+ * to take care of obtaining the {@link LayoutManager} or {@link Position}
+ * from the object returned by the parent iterator's {@code next()} method.
+ */
+public class PositionIterator implements Iterator<Position> {
 
     private Iterator parentIter;
     private Object nextObj;
     private LayoutManager childLM;
-    private boolean bHasNext;
+    private boolean hasNext;
 
     /**
      * Construct position iterator.
-     * @param pIter an iterator to use as parent
+     * @param parentIter an iterator to use as parent
      */
-    protected PositionIterator(Iterator pIter) {
-        parentIter = pIter;
+    public PositionIterator(Iterator parentIter) {
+        this.parentIter = parentIter;
         lookAhead();
         //checkNext();
     }
@@ -45,7 +54,7 @@ public abstract class PositionIterator i
         // Move to next "segment" of iterator, ie: new childLM
         if (childLM == null && nextObj != null) {
             childLM = getLM(nextObj);
-            bHasNext = true;
+            hasNext = true;
         }
         return childLM;
     }
@@ -54,17 +63,29 @@ public abstract class PositionIterator i
      * @param nextObj next object from which to obtain position
      * @return layout manager
      */
-    protected abstract LayoutManager getLM(Object nextObj);
+    protected LayoutManager getLM(Object nextObj) {
+        return getPos(nextObj).getLM();
+    }
 
     /**
+     * Default implementation assumes that the passed
+     * {@code nextObj} is itself a {@link Position}, and just returns it.
+     * Subclasses for which this is not the case, <em>must</em> provide a
+     * suitable override this method.
      * @param nextObj next object from which to obtain position
-     * @return position of next object
+     * @return position of next object.
      */
-    protected abstract Position getPos(Object nextObj);
+    protected Position getPos(Object nextObj) {
+        if (nextObj instanceof Position) {
+            return (Position)nextObj;
+        }
+        throw new IllegalArgumentException(
+                "Cannot obtain Position from the given object.");
+    }
 
     private void lookAhead() {
         if (parentIter.hasNext()) {
-            bHasNext = true;
+            hasNext = true;
             nextObj = parentIter.next();
         } else {
             endIter();
@@ -78,7 +99,7 @@ public abstract class PositionIterator i
             childLM = lm;
         } else if (childLM != lm && lm != null) {
             // End of this sub-sequence with same child LM
-            bHasNext = false;
+            hasNext = false;
             childLM = null;
             return false;
         }
@@ -87,23 +108,23 @@ public abstract class PositionIterator i
 
     /** end (reset) iterator */
     protected void endIter() {
-        bHasNext = false;
+        hasNext = false;
         nextObj = null;
         childLM = null;
     }
 
     /** {@inheritDoc} */
     public boolean hasNext() {
-        return (bHasNext && checkNext());
+        return (hasNext && checkNext());
     }
 
 
     /** {@inheritDoc} */
-    public Object next() throws NoSuchElementException {
-        if (bHasNext) {
-            Object retObj = getPos(nextObj);
+    public Position next() throws NoSuchElementException {
+        if (hasNext) {
+            Position retPos = getPos(nextObj);
             lookAhead();
-            return retObj;
+            return retPos;
         } else {
             throw new NoSuchElementException("PosIter");
         }
@@ -119,4 +140,3 @@ public abstract class PositionIterator i
         throw new UnsupportedOperationException("PositionIterator doesn't support remove");
     }
 }
-

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/SpaceResolver.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/SpaceResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/SpaceResolver.java Fri Feb 11 11:59:32 2011
@@ -136,7 +136,7 @@ public final class SpaceResolver {
 
     private String toString(Object[] arr1, Object[] arr2) {
         if (arr1.length != arr2.length) {
-            new IllegalArgumentException("The length of both arrays must be equal");
+            throw new IllegalArgumentException("The length of both arrays must be equal");
         }
         StringBuffer sb = new StringBuffer("[");
         for (int i = 0; i < arr1.length; i++) {
@@ -647,7 +647,7 @@ public final class SpaceResolver {
                     }
                 }
                 //last = !iter.hasNext();
-                if (breakPoss == null && unresolvedSecond.size() == 0 && !last) {
+                if (breakPoss == null && unresolvedSecond.isEmpty() && !last) {
                     LOG.trace("Swap first and second parts in no-break condition,"
                             + " second part is empty.");
                     //The first list is reversed, so swap if this shouldn't happen

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/TraitSetter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/TraitSetter.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/TraitSetter.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/TraitSetter.java Fri Feb 11 11:59:32 2011
@@ -52,36 +52,36 @@ public final class TraitSetter {
      *
      * @param area      area to set the traits on
      * @param bpProps   border and padding properties
-     * @param bNotFirst True if the area is not the first area
-     * @param bNotLast  True if the area is not the last area
+     * @param isNotFirst True if the area is not the first area
+     * @param isNotLast  True if the area is not the last area
      * @param context   Property evaluation context
      */
     public static void setBorderPaddingTraits(Area area,
-            CommonBorderPaddingBackground bpProps, boolean bNotFirst, boolean bNotLast,
+            CommonBorderPaddingBackground bpProps, boolean isNotFirst, boolean isNotLast,
             PercentBaseContext context) {
-        int iBP;
-        iBP = bpProps.getPadding(CommonBorderPaddingBackground.START, bNotFirst, context);
-        if (iBP > 0) {
-            area.addTrait(Trait.PADDING_START, new Integer(iBP));
+        int padding;
+        padding = bpProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, context);
+        if (padding > 0) {
+            area.addTrait(Trait.PADDING_START, padding);
         }
-        iBP = bpProps.getPadding(CommonBorderPaddingBackground.END, bNotLast, context);
-        if (iBP > 0) {
-            area.addTrait(Trait.PADDING_END, new Integer(iBP));
+        padding = bpProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, context);
+        if (padding > 0) {
+            area.addTrait(Trait.PADDING_END, padding);
         }
-        iBP = bpProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, context);
-        if (iBP > 0) {
-            area.addTrait(Trait.PADDING_BEFORE, new Integer(iBP));
+        padding = bpProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, context);
+        if (padding > 0) {
+            area.addTrait(Trait.PADDING_BEFORE, padding);
         }
-        iBP = bpProps.getPadding(CommonBorderPaddingBackground.AFTER, false, context);
-        if (iBP > 0) {
-            area.addTrait(Trait.PADDING_AFTER, new Integer(iBP));
+        padding = bpProps.getPadding(CommonBorderPaddingBackground.AFTER, false, context);
+        if (padding > 0) {
+            area.addTrait(Trait.PADDING_AFTER, padding);
         }
 
-        addBorderTrait(area, bpProps, bNotFirst,
+        addBorderTrait(area, bpProps, isNotFirst,
                 CommonBorderPaddingBackground.START,
                 BorderProps.SEPARATE, Trait.BORDER_START);
 
-        addBorderTrait(area, bpProps, bNotLast,
+        addBorderTrait(area, bpProps, isNotLast,
                 CommonBorderPaddingBackground.END,
                 BorderProps.SEPARATE, Trait.BORDER_END);
 
@@ -94,7 +94,7 @@ public final class TraitSetter {
                 BorderProps.SEPARATE, Trait.BORDER_AFTER);
     }
 
-    /**
+    /*
      * Sets border traits on an area.
      *
      * @param area    area to set the traits on
@@ -103,13 +103,13 @@ public final class TraitSetter {
      */
     private static void addBorderTrait(Area area,
                                        CommonBorderPaddingBackground bpProps,
-                                       boolean bDiscard, int iSide, int mode,
+                                       boolean discard, int side, int mode,
                                        Integer trait) {
-        int iBP = bpProps.getBorderWidth(iSide, bDiscard);
-        if (iBP > 0) {
+        int borderWidth = bpProps.getBorderWidth(side, discard);
+        if (borderWidth > 0) {
             area.addTrait(trait,
-                    new BorderProps(bpProps.getBorderStyle(iSide),
-                            iBP, bpProps.getBorderColor(iSide),
+                    new BorderProps(bpProps.getBorderStyle(side),
+                            borderWidth, bpProps.getBorderColor(side),
                             mode));
         }
     }
@@ -119,30 +119,30 @@ public final class TraitSetter {
      * Layout managers that create areas with borders can use this to
      * add the borders to the area.
      * @param area the area to set the traits on.
-     * @param bordProps border properties
+     * @param borderProps border properties
      * @param context Property evaluation context
      * @deprecated Call the other addBorders() method and addPadding separately.
      */
-    public static void addBorders(Area area, CommonBorderPaddingBackground bordProps,
+    public static void addBorders(Area area, CommonBorderPaddingBackground borderProps,
                                   PercentBaseContext context) {
-        BorderProps bps = getBorderProps(bordProps, CommonBorderPaddingBackground.BEFORE);
+        BorderProps bps = getBorderProps(borderProps, CommonBorderPaddingBackground.BEFORE);
         if (bps != null) {
             area.addTrait(Trait.BORDER_BEFORE, bps);
         }
-        bps = getBorderProps(bordProps, CommonBorderPaddingBackground.AFTER);
+        bps = getBorderProps(borderProps, CommonBorderPaddingBackground.AFTER);
         if (bps != null) {
             area.addTrait(Trait.BORDER_AFTER, bps);
         }
-        bps = getBorderProps(bordProps, CommonBorderPaddingBackground.START);
+        bps = getBorderProps(borderProps, CommonBorderPaddingBackground.START);
         if (bps != null) {
             area.addTrait(Trait.BORDER_START, bps);
         }
-        bps = getBorderProps(bordProps, CommonBorderPaddingBackground.END);
+        bps = getBorderProps(borderProps, CommonBorderPaddingBackground.END);
         if (bps != null) {
             area.addTrait(Trait.BORDER_END, bps);
         }
 
-        addPadding(area, bordProps, context);
+        addPadding(area, borderProps, context);
     }
 
     /**
@@ -150,30 +150,31 @@ public final class TraitSetter {
      * Layout managers that create areas with borders can use this to
      * add the borders to the area.
      * @param area the area to set the traits on.
-     * @param bordProps border properties
+     * @param borderProps border properties
      * @param discardBefore true if the before border should be discarded
      * @param discardAfter true if the after border should be discarded
      * @param discardStart true if the start border should be discarded
      * @param discardEnd true if the end border should be discarded
      * @param context Property evaluation context
      */
-    public static void addBorders(Area area, CommonBorderPaddingBackground bordProps,
+    //TODO: remove evaluation context; unused, since border-widths are always absolute lengths
+    public static void addBorders(Area area, CommonBorderPaddingBackground borderProps,
                 boolean discardBefore, boolean discardAfter,
                 boolean discardStart, boolean discardEnd,
                 PercentBaseContext context) {
-        BorderProps bps = getBorderProps(bordProps, CommonBorderPaddingBackground.BEFORE);
+        BorderProps bps = getBorderProps(borderProps, CommonBorderPaddingBackground.BEFORE);
         if (bps != null && !discardBefore) {
             area.addTrait(Trait.BORDER_BEFORE, bps);
         }
-        bps = getBorderProps(bordProps, CommonBorderPaddingBackground.AFTER);
+        bps = getBorderProps(borderProps, CommonBorderPaddingBackground.AFTER);
         if (bps != null && !discardAfter) {
             area.addTrait(Trait.BORDER_AFTER, bps);
         }
-        bps = getBorderProps(bordProps, CommonBorderPaddingBackground.START);
+        bps = getBorderProps(borderProps, CommonBorderPaddingBackground.START);
         if (bps != null && !discardStart) {
             area.addTrait(Trait.BORDER_START, bps);
         }
-        bps = getBorderProps(bordProps, CommonBorderPaddingBackground.END);
+        bps = getBorderProps(borderProps, CommonBorderPaddingBackground.END);
         if (bps != null && !discardEnd) {
             area.addTrait(Trait.BORDER_END, bps);
         }
@@ -237,25 +238,25 @@ public final class TraitSetter {
         int padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE,
                 discardBefore, context);
         if (padding != 0) {
-            area.addTrait(Trait.PADDING_BEFORE, new java.lang.Integer(padding));
+            area.addTrait(Trait.PADDING_BEFORE, padding);
         }
 
         padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER,
                 discardAfter, context);
         if (padding != 0) {
-            area.addTrait(Trait.PADDING_AFTER, new java.lang.Integer(padding));
+            area.addTrait(Trait.PADDING_AFTER, padding);
         }
 
         padding = bordProps.getPadding(CommonBorderPaddingBackground.START,
                 discardStart, context);
         if (padding != 0) {
-            area.addTrait(Trait.PADDING_START, new java.lang.Integer(padding));
+            area.addTrait(Trait.PADDING_START, padding);
         }
 
         padding = bordProps.getPadding(CommonBorderPaddingBackground.END,
                 discardEnd, context);
         if (padding != 0) {
-            area.addTrait(Trait.PADDING_END, new java.lang.Integer(padding));
+            area.addTrait(Trait.PADDING_END, padding);
         }
 
     }
@@ -278,9 +279,8 @@ public final class TraitSetter {
         assert borderInfo != null;
         int width = borderInfo.getRetainedWidth();
         if (width != 0) {
-            BorderProps bps = new BorderProps(borderInfo.getStyle(), width, borderInfo.getColor(),
+            return new BorderProps(borderInfo.getStyle(), width, borderInfo.getColor(),
                     (outer ? BorderProps.COLLAPSE_OUTER : BorderProps.COLLAPSE_INNER));
-            return bps;
         } else {
             return null;
         }
@@ -460,24 +460,24 @@ public final class TraitSetter {
                                   int startIndent, int endIndent,
                                   PercentBaseContext context) {
         if (startIndent != 0) {
-            area.addTrait(Trait.START_INDENT, new Integer(startIndent));
+            area.addTrait(Trait.START_INDENT, startIndent);
         }
 
         int spaceStart = startIndent
                 - bpProps.getBorderStartWidth(false)
                 - bpProps.getPaddingStart(false, context);
         if (spaceStart != 0) {
-            area.addTrait(Trait.SPACE_START, new Integer(spaceStart));
+            area.addTrait(Trait.SPACE_START, spaceStart);
         }
 
         if (endIndent != 0) {
-            area.addTrait(Trait.END_INDENT, new Integer(endIndent));
+            area.addTrait(Trait.END_INDENT, endIndent);
         }
         int spaceEnd = endIndent
                 - bpProps.getBorderEndWidth(false)
                 - bpProps.getPaddingEnd(false, context);
         if (spaceEnd != 0) {
-            area.addTrait(Trait.SPACE_END, new Integer(spaceEnd));
+            area.addTrait(Trait.SPACE_END, spaceEnd);
         }
     }
 
@@ -537,7 +537,7 @@ public final class TraitSetter {
             MinOptMax space, double adjust) {
         int effectiveSpace = getEffectiveSpace(adjust, space);
         if (effectiveSpace != 0) {
-            area.addTrait(spaceTrait, new Integer(effectiveSpace));
+            area.addTrait(spaceTrait, effectiveSpace);
         }
     }
 
@@ -561,7 +561,7 @@ public final class TraitSetter {
      */
     public static void addFontTraits(Area area, Font font) {
         area.addTrait(Trait.FONT, font.getFontTriplet());
-        area.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize()));
+        area.addTrait(Trait.FONT_SIZE, font.getFontSize());
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java Fri Feb 11 11:59:32 2011
@@ -33,21 +33,27 @@ import org.apache.fop.traits.WritingMode
  */
 public class AlignmentContext implements Constants {
 
-    /** The height or BPD of this context */
+    /** The height or BPD of this context. */
     private int areaHeight;
-    /** The computed line-height property value applicable */
+
+    /** The computed line-height property value applicable. */
     private int lineHeight;
-    /** The distance in BPD from the top of the box to the alignmentPoint */
+
+    /** The distance in BPD from the top of the box to the alignmentPoint. */
     private int alignmentPoint;
-    /** The baseline shift value in effect */
+
+    /** The baseline shift value in effect. */
     private int baselineShiftValue;
-    /** The computed alignment baseline identifier */
+
+    /** The computed alignment baseline identifier. */
     private int alignmentBaselineIdentifier;
-    /** The x height */
+
+    /** The x height. */
     private int xHeight;
-    private ScaledBaselineTable scaledBaselineTable = null;
-    private ScaledBaselineTable actualBaselineTable = null;
-    private AlignmentContext parentAlignmentContext = null;
+
+    private ScaledBaselineTable scaledBaselineTable;
+    private ScaledBaselineTable actualBaselineTable;
+    private AlignmentContext parentAlignmentContext;
 
     /**
      * Creates a new instance of AlignmentContext
@@ -59,57 +65,20 @@ public class AlignmentContext implements
      * @param dominantBaseline the dominant-baseline property
      * @param parentAlignmentContext the parent alignment context
      */
-    public AlignmentContext(int height
-                            , Length alignmentAdjust
-                            , int alignmentBaseline
-                            , Length baselineShift
-                            , int dominantBaseline
-                            , AlignmentContext parentAlignmentContext) {
-
-        this.areaHeight = height;
-        this.lineHeight = height;
-        this.xHeight = height;
-        this.parentAlignmentContext = parentAlignmentContext;
-        this.scaledBaselineTable = parentAlignmentContext.getScaledBaselineTable();
-        setAlignmentBaselineIdentifier(alignmentBaseline
-                                       , parentAlignmentContext.getDominantBaselineIdentifier());
-        setBaselineShift(baselineShift);
-        int dominantBaselineIdentifier = parentAlignmentContext.getDominantBaselineIdentifier();
-        boolean newScaledBaselineTableRequired = false;
-        if (baselineShiftValue != 0) {
-            newScaledBaselineTableRequired = true;
-        }
-        switch (dominantBaseline) {
-            case EN_AUTO:
-                newScaledBaselineTableRequired = baselineShiftValue != 0;
-                break;
-            case EN_USE_SCRIPT: // TODO
-                break;
-            case EN_NO_CHANGE:
-                break;
-            case EN_RESET_SIZE:
-                newScaledBaselineTableRequired = true;
-                break;
-            default:
-                newScaledBaselineTableRequired = true;
-                dominantBaselineIdentifier = dominantBaseline;
-                break;
-        }
-        actualBaselineTable = ScaledBaselineTableFactory.makeGraphicsScaledBaselineTable(
-                                                            height,
-                                                            dominantBaselineIdentifier,
-                                                            scaledBaselineTable.getWritingMode());
-        if (newScaledBaselineTableRequired) {
-            scaledBaselineTable = ScaledBaselineTableFactory.makeGraphicsScaledBaselineTable(
-                                                            height,
-                                                            dominantBaselineIdentifier,
-                                                            scaledBaselineTable.getWritingMode());
-        }
-        setAlignmentAdjust(alignmentAdjust);
+    AlignmentContext(int height,
+            Length alignmentAdjust,
+            int alignmentBaseline,
+            Length baselineShift,
+            int dominantBaseline,
+            AlignmentContext parentAlignmentContext) {
+
+        this(height, 0, height, height, alignmentAdjust, alignmentBaseline, baselineShift,
+                dominantBaseline, parentAlignmentContext);
     }
 
     /**
-     * Creates a new instance of AlignmentContext
+     * Creates a new instance.
+     *
      * @param font the font
      * @param lineHeight the computed value of the lineHeight property
      * @param alignmentAdjust the alignment-adjust property
@@ -118,18 +87,45 @@ public class AlignmentContext implements
      * @param dominantBaseline the dominant-baseline property
      * @param parentAlignmentContext the parent alignment context
      */
-    public AlignmentContext(Font font
-                            , int lineHeight
-                            , Length alignmentAdjust
-                            , int alignmentBaseline
-                            , Length baselineShift
-                            , int dominantBaseline
-                            , AlignmentContext parentAlignmentContext) {
-        this.areaHeight = font.getAscender() - font.getDescender();
+    AlignmentContext(Font font,
+            int lineHeight,
+            Length alignmentAdjust,
+            int alignmentBaseline,
+            Length baselineShift,
+            int dominantBaseline,
+            AlignmentContext parentAlignmentContext) {
+        this(font.getAscender(), font.getDescender(), lineHeight, font.getXHeight(),
+                alignmentAdjust, alignmentBaseline, baselineShift, dominantBaseline,
+                parentAlignmentContext);
+    }
+
+    /**
+     * Creates a new instance of AlignmentContext.
+     * @param altitude the altitude of the area
+     * @param depth the depth of the area
+     * @param lineHeight the line height
+     * @param xHeight the xHeight
+     * @param alignmentAdjust the alignment-adjust property
+     * @param alignmentBaseline the alignment-baseline property
+     * @param baselineShift the baseline-shift property
+     * @param dominantBaseline the dominant-baseline property
+     * @param parentAlignmentContext the parent alignment context
+     */
+    private AlignmentContext(int altitude,
+            int depth,
+            int lineHeight,
+            int xHeight,
+            Length alignmentAdjust,
+            int alignmentBaseline,
+            Length baselineShift,
+            int dominantBaseline,
+            AlignmentContext parentAlignmentContext) {
+
+        this.areaHeight = altitude - depth;
         this.lineHeight = lineHeight;
+        this.xHeight = xHeight;
         this.parentAlignmentContext = parentAlignmentContext;
         this.scaledBaselineTable = parentAlignmentContext.getScaledBaselineTable();
-        this.xHeight = font.getXHeight();
         setAlignmentBaselineIdentifier(alignmentBaseline
                                        , parentAlignmentContext.getDominantBaselineIdentifier());
         setBaselineShift(baselineShift);
@@ -154,13 +150,19 @@ public class AlignmentContext implements
                 dominantBaselineIdentifier = dominantBaseline;
                 break;
         }
-        actualBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font,
-                                                            dominantBaselineIdentifier,
-                                                            scaledBaselineTable.getWritingMode());
+        actualBaselineTable = new ScaledBaselineTable(
+                altitude,
+                depth,
+                xHeight,
+                dominantBaselineIdentifier,
+                scaledBaselineTable.getWritingMode());
         if (newScaledBaselineTableRequired) {
-            scaledBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font,
-                                    dominantBaselineIdentifier,
-                                    scaledBaselineTable.getWritingMode());
+            scaledBaselineTable = new ScaledBaselineTable(
+                    altitude,
+                    depth,
+                    xHeight,
+                    dominantBaselineIdentifier,
+                    scaledBaselineTable.getWritingMode());
         }
         setAlignmentAdjust(alignmentAdjust);
     }
@@ -172,13 +174,12 @@ public class AlignmentContext implements
      * @param lineHeight the computed value of the lineHeight property
      * @param writingMode the current writing mode
      */
-    public AlignmentContext(Font font, int lineHeight, WritingMode writingMode) {
+    AlignmentContext(Font font, int lineHeight, WritingMode writingMode) {
         this.areaHeight = font.getAscender() - font.getDescender();
         this.lineHeight = lineHeight;
         this.xHeight = font.getXHeight();
-        this.parentAlignmentContext = null;
-        this.scaledBaselineTable
-            = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, writingMode);
+        this.scaledBaselineTable = new ScaledBaselineTable(font.getAscender(), font.getDescender(),
+                font.getXHeight(), Constants.EN_ALPHABETIC, writingMode);
         this.actualBaselineTable = scaledBaselineTable;
         this.alignmentBaselineIdentifier = getDominantBaselineIdentifier();
         this.alignmentPoint = font.getAscender();
@@ -204,7 +205,8 @@ public class AlignmentContext implements
     }
 
     /**
-     * Returns the current alignment baseline identifier
+     * Returns the current alignment baseline identifier.
+     *
      * @return the alignment baseline identifier
      */
     public int getAlignmentBaselineIdentifier() {
@@ -212,7 +214,7 @@ public class AlignmentContext implements
     }
 
     /**
-     * Sets the current alignment baseline identifer. For
+     * Sets the current alignment baseline identifier. For
      * alignment-baseline values of "auto" and "baseline" this
      * method does the conversion into the appropriate computed
      * value assuming script is "auto" and the fo is not fo:character.
@@ -238,8 +240,7 @@ public class AlignmentContext implements
             case EN_MATHEMATICAL:
                 this.alignmentBaselineIdentifier = alignmentBaseline;
                 break;
-            default:
-                break;
+            default: throw new IllegalArgumentException(String.valueOf(alignmentBaseline));
         }
     }
 
@@ -286,7 +287,7 @@ public class AlignmentContext implements
      * Return the scaled baseline table for this context.
      * @return the scaled baseline table
      */
-    public ScaledBaselineTable getScaledBaselineTable() {
+    private ScaledBaselineTable getScaledBaselineTable() {
         return this.scaledBaselineTable;
     }
 
@@ -294,17 +295,17 @@ public class AlignmentContext implements
      * Return the dominant baseline identifier.
      * @return the dominant baseline identifier
      */
-    public int getDominantBaselineIdentifier() {
-        return scaledBaselineTable.getDominantBaselineIdentifier();
+    private int getDominantBaselineIdentifier() {
+        return actualBaselineTable.getDominantBaselineIdentifier();
     }
 
     /**
      * Return the writing mode.
      * @return the writing mode
      */
-    public WritingMode getWritingMode() {
+/*    public WritingMode getWritingMode() {
         return scaledBaselineTable.getWritingMode();
-    }
+    }*/
 
     /**
      * Calculates the baseline shift value based on the baseline-shift
@@ -313,7 +314,6 @@ public class AlignmentContext implements
      */
     private void setBaselineShift(Length baselineShift) {
         baselineShiftValue = 0;
-        ScaledBaselineTable sbt = null;
         switch (baselineShift.getEnum()) {
             case EN_BASELINE: //Nothing to do
                 break;
@@ -333,9 +333,7 @@ public class AlignmentContext implements
                                                 , LengthBase.CUSTOM_BASE
                                                 , parentAlignmentContext.getLineHeight()));
                 break;
-            default:
-                break;
-
+            default: throw new IllegalArgumentException(String.valueOf(baselineShift.getEnum()));
         }
     }
 
@@ -352,7 +350,7 @@ public class AlignmentContext implements
      * the parent dominant baseline.
      * @return the offset in shift direction
      */
-    public int getBaselineOffset() {
+    private int getBaselineOffset() {
         if (parentAlignmentContext == null) {
             return 0;
         }
@@ -371,9 +369,9 @@ public class AlignmentContext implements
     /**
      * Return the offset between the current dominant baseline and
      * the outermost parent dominant baseline.
-     * @return the offet in shift direction
+     * @return the offset in shift direction
      */
-    public int getTotalBaselineOffset() {
+    private int getTotalBaselineOffset() {
         int offset = 0;
         if (parentAlignmentContext != null) {
             offset = getBaselineOffset() + parentAlignmentContext.getTotalBaselineOffset();
@@ -396,7 +394,7 @@ public class AlignmentContext implements
      * @param alignmentBaselineId the alignment baseline
      * @return the offset
      */
-    public int getTotalAlignmentBaselineOffset(int alignmentBaselineId) {
+    private int getTotalAlignmentBaselineOffset(int alignmentBaselineId) {
         int offset = baselineShiftValue;
         if (parentAlignmentContext != null) {
             offset = parentAlignmentContext.getTotalBaselineOffset()
@@ -409,11 +407,12 @@ public class AlignmentContext implements
 
     /**
      * Return the offset between the dominant baseline and
-     * the given actual baseline
+     * the given actual baseline.
+     *
      * @param baselineIdentifier the baseline
      * @return the offset
      */
-    public int getActualBaselineOffset(int baselineIdentifier) {
+    private int getActualBaselineOffset(int baselineIdentifier) {
         // This is the offset from the dominant baseline to the alignment baseline
         int offset = getTotalAlignmentBaselineOffset() - getTotalBaselineOffset();
         // Add the offset to the actual baseline we want
@@ -444,7 +443,7 @@ public class AlignmentContext implements
      * Return the line height of the context.
      * @return the height
      */
-    public int getLineHeight() {
+    private int getLineHeight() {
         return lineHeight;
     }
 
@@ -470,7 +469,7 @@ public class AlignmentContext implements
      * The x height of the context.
      * @return the x height
      */
-    public int getXHeight() {
+    private int getXHeight() {
         return this.xHeight;
     }
 
@@ -514,9 +513,9 @@ public class AlignmentContext implements
                     && parentAlignmentContext.usesInitialBaselineTable());
     }
 
-    private boolean isHorizontalWritingMode() {
+    /* private boolean isHorizontalWritingMode() {
         return (getWritingMode() == WritingMode.LR_TB || getWritingMode() == WritingMode.RL_TB);
-    }
+    }*/
 
     /** {@inheritDoc} */
     public String toString() {

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java Fri Feb 11 11:59:32 2011
@@ -60,6 +60,7 @@ public class CharacterLayoutManager exte
     }
 
     /** {@inheritDoc} */
+    @Override
     public void initialize() {
         Character fobj = (Character)this.fobj;
         font = FontSelector.selectFontForCharacter(fobj, this);
@@ -95,6 +96,7 @@ public class CharacterLayoutManager exte
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getNextKnuthElements(LayoutContext context, int alignment) {
         MinOptMax ipd;
         curArea = get(context);
@@ -151,23 +153,25 @@ public class CharacterLayoutManager exte
 
         addKnuthElementsForBorderPaddingEnd(seq);
 
-        LinkedList returnList = new LinkedList();
+        LinkedList<KnuthSequence> returnList = new LinkedList<KnuthSequence>();
         returnList.add(seq);
         setFinished(true);
         return returnList;
     }
 
     /** {@inheritDoc} */
+    @Override
     public String getWordChars(Position pos) {
         return ((TextArea) curArea).getText();
     }
 
     /** {@inheritDoc} */
+    @Override
     public void hyphenate(Position pos, HyphContext hc) {
         if (hc.getNextHyphPoint() == 1) {
             // the character ends a syllable
-            areaInfo.bHyphenated = true;
-            isSomethingChanged = true;
+            areaInfo.isHyphenated = true;
+            somethingChanged = true;
         } else {
             // hc.getNextHyphPoint() returned -1 (no more hyphenation points)
             // or a number > 1;
@@ -177,42 +181,44 @@ public class CharacterLayoutManager exte
     }
 
     /** {@inheritDoc} */
+    @Override
     public boolean applyChanges(List oldList) {
         setFinished(false);
-        return isSomethingChanged;
+        return somethingChanged;
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getChangedKnuthElements(List oldList, int alignment) {
         if (isFinished()) {
             return null;
         }
 
-        LinkedList returnList = new LinkedList();
+        LinkedList<KnuthElement> returnList = new LinkedList<KnuthElement>();
 
         addKnuthElementsForBorderPaddingStart(returnList);
 
-        if (letterSpaceIPD.isStiff() || areaInfo.iLScount == 0) {
+        if (letterSpaceIPD.isStiff() || areaInfo.letterSpaces == 0) {
             // constant letter space, or no letter space
             returnList.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt(),
                                         areaInfo.alignmentContext,
                                         notifyPos(new LeafPosition(this, 0)), false));
-            if (areaInfo.bHyphenated) {
+            if (areaInfo.isHyphenated) {
                 returnList.add(new KnuthPenalty(hyphIPD, KnuthPenalty.FLAGGED_PENALTY, true,
                         new LeafPosition(this, -1), false));
             }
         } else {
             // adjustable letter space
             returnList.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt()
-                    - areaInfo.iLScount * letterSpaceIPD.getOpt(), areaInfo.alignmentContext,
+                    - areaInfo.letterSpaces * letterSpaceIPD.getOpt(), areaInfo.alignmentContext,
                     notifyPos(new LeafPosition(this, 0)), false));
             returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
                     new LeafPosition(this, -1), true));
-            returnList.add(new KnuthGlue(letterSpaceIPD.mult(areaInfo.iLScount),
+            returnList.add(new KnuthGlue(letterSpaceIPD.mult(areaInfo.letterSpaces),
                     new LeafPosition(this, -1), true));
             returnList.add (
                     new KnuthInlineBox(0, null, notifyPos(new LeafPosition(this, -1)), true));
-            if (areaInfo.bHyphenated) {
+            if (areaInfo.isHyphenated) {
                 returnList.add(new KnuthPenalty(hyphIPD, KnuthPenalty.FLAGGED_PENALTY, true,
                         new LeafPosition(this, -1), false));
             }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java?rev=1069764&r1=1069763&r2=1069764&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java Fri Feb 11 11:59:32 2011
@@ -34,6 +34,7 @@ import org.apache.fop.layoutmgr.LayoutCo
 import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.ListElement;
 import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.layoutmgr.PositionIterator;
 
 /**
@@ -62,6 +63,7 @@ public class FootnoteLayoutManager exten
     }
 
     /** {@inheritDoc} */
+    @Override
     public void initialize() {
         // create an InlineStackingLM handling the fo:inline child of fo:footnote
         citationLM = new InlineLayoutManager(footnote.getFootnoteCitation());
@@ -71,6 +73,7 @@ public class FootnoteLayoutManager exten
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getNextKnuthElements(LayoutContext context,
                                            int alignment) {
         // for the moment, this LM is set as the citationLM's parent
@@ -119,9 +122,8 @@ public class FootnoteLayoutManager exten
         return returnedList;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
+    @Override
     public List getChangedKnuthElements(List oldList, int alignment, int depth) {
         List returnedList = super.getChangedKnuthElements(oldList, alignment, depth);
         addAnchor(returnedList);
@@ -129,16 +131,15 @@ public class FootnoteLayoutManager exten
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
+    @Override
     public void addAreas(PositionIterator posIter, LayoutContext context) {
         // "Unwrap" the NonLeafPositions stored in posIter and put
         // them in a new list, that will be given to the citationLM
-        LinkedList positionList = new LinkedList();
-        NonLeafPosition pos = null;
+        LinkedList<Position> positionList = new LinkedList<Position>();
+        Position pos;
         while (posIter.hasNext()) {
-            pos = (NonLeafPosition) posIter.next();
+            pos = posIter.next();
             if (pos != null && pos.getPosition() != null) {
                 positionList.add(pos.getPosition());
             }
@@ -150,7 +151,7 @@ public class FootnoteLayoutManager exten
 
         // make the citationLM add its areas
         LayoutContext childContext = new LayoutContext(context);
-        StackingIter childPosIter = new StackingIter(positionList.listIterator());
+        PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
         LayoutManager childLM;
         while ((childLM = childPosIter.getNextChildLM()) != null) {
             childLM.addAreas(childPosIter, childContext);



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org