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 ad...@apache.org on 2011/02/05 02:25:37 UTC

svn commit: r1067371 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline: FootnoteLayoutManager.java InlineLayoutManager.java InlineStackingLayoutManager.java LineLayoutManager.java

Author: adelmelle
Date: Sat Feb  5 01:25:37 2011
New Revision: 1067371

URL: http://svn.apache.org/viewvc?rev=1067371&view=rev
Log:
Decommission InlineStackingLM.StackingIter (+ minor fixups)

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java?rev=1067371&r1=1067370&r2=1067371&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java Sat Feb  5 01:25:37 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);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java?rev=1067371&r1=1067370&r2=1067371&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java Sat Feb  5 01:25:37 2011
@@ -77,8 +77,6 @@ public class InlineLayoutManager extends
     private boolean areaCreated = false;
     private LayoutManager lastChildLM = null; // Set when return last breakposs;
 
-    private Position auxiliaryPosition;
-
     private Font font;
 
     /** The alignment adjust property */
@@ -113,6 +111,7 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     public void initialize() {
         InlineLevel fobj = (InlineLevel) this.fobj;
 
@@ -150,6 +149,7 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) {
         int borderAndPadding = 0;
         if (borderProps != null) {
@@ -167,6 +167,7 @@ public class InlineLayoutManager extends
 
 
     /** {@inheritDoc} */
+    @Override
     protected boolean hasLeadingFence(boolean isNotFirst) {
         return borderProps != null
             && (borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this) > 0
@@ -175,6 +176,7 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     protected boolean hasTrailingFence(boolean isNotLast) {
         return borderProps != null
             && (borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this) > 0
@@ -183,10 +185,12 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     protected SpaceProperty getSpaceStart() {
         return inlineProps != null ? inlineProps.spaceStart : null;
     }
     /** {@inheritDoc} */
+    @Override
     protected SpaceProperty getSpaceEnd() {
         return inlineProps != null ? inlineProps.spaceEnd : null;
     }
@@ -212,6 +216,7 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     protected void setTraits(boolean isNotFirst, boolean isNotLast) {
         if (borderProps != null) {
             // Add border and padding to current area and set flags (FIRST, LAST ...)
@@ -239,15 +244,16 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getNextKnuthElements                            // CSOK: MethodLength
         (LayoutContext context, int alignment) {
         LayoutManager curLM;
 
         // the list returned by child LM
-        List returnedList;
+        List<KnuthSequence> returnedList;
 
         // the list which will be returned to the parent LM
-        List returnList = new LinkedList();
+        List<KnuthSequence> returnList = new LinkedList<KnuthSequence>();
         KnuthSequence lastSequence = null;
 
         if (fobj instanceof Title) {
@@ -328,16 +334,16 @@ public class InlineLayoutManager extends
                     sequence.wrapPositions(this);
                 }
                 int insertionStartIndex = 0;
-                if (lastSequence != null && lastSequence.appendSequenceOrClose
-                        ((KnuthSequence) returnedList.get(0))) {
+                if (lastSequence != null
+                        && lastSequence.appendSequenceOrClose(returnedList.get(0))) {
                     insertionStartIndex = 1;
                 }
                 // add border and padding to the first complete sequence of this LM
                 if (!borderAdded && !returnedList.isEmpty()) {
-                    addKnuthElementsForBorderPaddingStart((KnuthSequence) returnedList.get(0));
+                    addKnuthElementsForBorderPaddingStart(returnedList.get(0));
                     borderAdded = true;
                 }
-                for (Iterator iter = returnedList.listIterator(insertionStartIndex);
+                for (Iterator<KnuthSequence> iter = returnedList.listIterator(insertionStartIndex);
                         iter.hasNext();) {
                     returnList.add(iter.next());
                 }
@@ -368,7 +374,7 @@ public class InlineLayoutManager extends
                 context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
                 childLC.clearKeepsPending();
             }
-            lastSequence = (KnuthSequence) ListUtil.getLast(returnList);
+            lastSequence = ListUtil.getLast(returnList);
             lastChildLM = curLM;
         }
 
@@ -408,6 +414,7 @@ public class InlineLayoutManager extends
      * by this LayoutManager.
      * @param context layout context.
      */
+    @Override
     public void addAreas(PositionIterator parentIter,
                          LayoutContext context) {
 
@@ -433,21 +440,18 @@ public class InlineLayoutManager extends
         // set in the layout context, it must be also set in the
         // layout context given to lastLM, but must be cleared in the
         // layout context given to the other LMs.
-        List positionList = new LinkedList();
-        NonLeafPosition pos;
+        List<Position> positionList = new LinkedList<Position>();
+        Position pos;
         LayoutManager lastLM = null; // last child LM in this iterator
         Position lastPos = null;
         while (parentIter.hasNext()) {
-            pos = (NonLeafPosition) parentIter.next();
+            pos = parentIter.next();
             if (pos != null && pos.getPosition() != null) {
                 positionList.add(pos.getPosition());
                 lastLM = pos.getPosition().getLM();
                 lastPos = pos;
             }
         }
-        /*if (pos != null) {
-            lastLM = pos.getPosition().getLM();
-        }*/
 
         addMarkersToPage(
                 true,
@@ -469,8 +473,8 @@ public class InlineLayoutManager extends
         }
         setCurrentArea(parent);
 
-        StackingIter childPosIter
-            = new StackingIter(positionList.listIterator());
+        PositionIterator childPosIter
+            = new PositionIterator(positionList.listIterator());
 
         LayoutManager prevLM = null;
         LayoutManager childLM;
@@ -522,6 +526,7 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     public void addChildArea(Area childArea) {
         Area parent = getCurrentArea();
         if (getContext().resolveLeadingSpace()) {
@@ -532,6 +537,7 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getChangedKnuthElements(List oldList, int alignment, int depth) {
         List returnedList = new LinkedList();
         addKnuthElementsForBorderPaddingStart(returnedList);
@@ -546,7 +552,7 @@ public class InlineLayoutManager extends
      */
     protected void addKnuthElementsForBorderPaddingStart(List returnList) {
         //Border and Padding (start)
-        /**
+        /*
          * If the returnlist is a BlockKnuthSequence, the border and padding should be added
          * to the first paragraph inside it, but it is too late to do that now.
          * At least, avoid adding it to the bpd sequence.
@@ -571,7 +577,7 @@ public class InlineLayoutManager extends
      */
     protected void addKnuthElementsForBorderPaddingEnd(List returnList) {
         //Border and Padding (after)
-        /**
+        /*
          * If the returnlist is a BlockKnuthSequence, the border and padding should be added
          * to the last paragraph inside it, but it is too late to do that now.
          * At least, avoid adding it to the bpd sequence.
@@ -590,13 +596,8 @@ public class InlineLayoutManager extends
         }
     }
 
-    /** @return a cached auxiliary Position instance used for things like spaces. */
+    /** @return an auxiliary {@link Position} instance used for things like spaces. */
     protected Position getAuxiliaryPosition() {
-        //if (this.auxiliaryPosition == null) {
-            //this.auxiliaryPosition = new NonLeafPosition(this, new LeafPosition(this, -1));
-            this.auxiliaryPosition = new NonLeafPosition(this, null);
-        //}
-        return this.auxiliaryPosition;
+        return new NonLeafPosition(this, null);
     }
-
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java?rev=1067371&r1=1067370&r2=1067371&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java Sat Feb  5 01:25:37 2011
@@ -19,7 +19,6 @@
 
 package org.apache.fop.layoutmgr.inline;
 
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
@@ -31,10 +30,8 @@ import org.apache.fop.fo.properties.Spac
 import org.apache.fop.layoutmgr.AbstractLayoutManager;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.NonLeafPosition;
 import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.traits.MinOptMax;
 
 /**
@@ -45,33 +42,6 @@ import org.apache.fop.traits.MinOptMax;
 public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
                                          implements InlineLevelLayoutManager {
 
-
-    /**
-     * A stacking iterator.
-     */
-    protected static class StackingIter extends PositionIterator {
-
-        StackingIter(Iterator parentIter) {
-            super(parentIter);
-        }
-
-        /**
-         * @param nextObj the next object
-         * @return layout manager of next object
-         */
-        protected LayoutManager getLM(Object nextObj) {
-            return ((Position) nextObj).getLM();
-        }
-
-        /**
-         * @param nextObj the next object
-         * @return position of next object
-         */
-        protected Position getPos(Object nextObj) {
-            return ((Position) nextObj);
-        }
-    }
-
     /**
      * Size of border and padding in BPD (ie, before and after).
      */
@@ -296,6 +266,7 @@ public abstract class InlineStackingLayo
             } else {
                 currLM = (InlineLevelLayoutManager) pos.getLM(depth);
             }
+
             // initialize prevLM
             if (prevLM == null) {
                 prevLM = currLM;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=1067371&r1=1067370&r2=1067371&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Sat Feb  5 01:25:37 2011
@@ -1562,7 +1562,7 @@ public class LineLayoutManager extends I
         lc.setAlignmentContext(alignmentContext);
         setChildContext(lc);
 
-        PositionIterator childPosIter = new StackingIter(positionList.listIterator());
+        PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
         LayoutContext blocklc = new LayoutContext(0);
         blocklc.setLeadingSpace(new SpaceSpecifier(true));
         blocklc.setTrailingSpace(new SpaceSpecifier(false));



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