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 2007/11/08 21:00:27 UTC

svn commit: r593282 - in /xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr: FlowLayoutManager.java inline/LineLayoutManager.java list/ListItemLayoutManager.java

Author: spepping
Date: Thu Nov  8 12:00:26 2007
New Revision: 593282

URL: http://svn.apache.org/viewvc?rev=593282&view=rev
Log:
Removed no longer used code

Modified:
    xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
    xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
    xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=593282&r1=593281&r2=593282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Thu Nov  8 12:00:26 2007
@@ -86,15 +86,9 @@
                 log.debug("span change from " + currentSpan + " to " + span);
                 context.signalSpanChange(span);
                 currentSpan = span;
-                /* postpone space resolution
-                SpaceResolver.resolveElementList(returnList);
-                */
                 return returnList;
             }
             
-            // Set up a LayoutContext
-            //MinOptMax bpd = context.getStackLimit();
-
             LayoutContext childLC = new LayoutContext(0);
             childLC.setStackLimit(context.getStackLimit());
             childLC.setRefIPD(context.getRefIPD());
@@ -117,9 +111,6 @@
                 && ElementListUtils.endsWithForcedBreak(returnedList)) {
                 // a descendant of this flow has break-before
                 returnList.addAll(returnedList);
-                /* postpone space resolution
-                SpaceResolver.resolveElementList(returnList);
-                */
                 return returnList;
             } else {
                 if (returnList.size() > 0) {
@@ -142,9 +133,6 @@
                     returnList.addAll(returnedList);
                     if (ElementListUtils.endsWithForcedBreak(returnList)) {
                         // a descendant of this flow has break-after
-                        /* postpone space resolution
-                        SpaceResolver.resolveElementList(returnList);
-                        */
                         return returnList;
                     }
                 }
@@ -156,9 +144,6 @@
             }
         }
 
-        /* postpone space resolution
-        SpaceResolver.resolveElementList(returnList);
-        */
         setFinished(true);
 
         if (returnList.size() > 0) {

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=593282&r1=593281&r2=593282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Thu Nov  8 12:00:26 2007
@@ -203,146 +203,6 @@
         }
     }
     
-/*    private class LineBreakingAlgorithm extends BreakingAlgorithm {
-        private LineLayoutManager thisLLM;
-        private int pageAlignment;
-        private int activePossibility;
-        private int addedPositions;
-        private int textIndent;
-        private int fillerMinWidth;
-        private int lineHeight;
-        private int lead;
-        private int follow;
-        private int maxDiff;
-        private static final double MAX_DEMERITS = 10e6;
-
-        public LineBreakingAlgorithm (int pageAlign,
-                                      int textAlign, int textAlignLast,
-                                      int indent, int fillerWidth,
-                                      int lh, int ld, int fl, boolean first,
-                                      int maxFlagCount, LineLayoutManager llm) {
-            super(textAlign, textAlignLast, first, false, maxFlagCount);
-            pageAlignment = pageAlign;
-            textIndent = indent;
-            fillerMinWidth = fillerWidth;
-            lineHeight = lh;
-            lead = ld;
-            follow = fl;
-            thisLLM = llm;
-            activePossibility = -1;
-            maxDiff = fobj.getWidows() >= fobj.getOrphans() 
-                    ? fobj.getWidows()
-                    : fobj.getOrphans();
-        }
-
-        public void updateData1(int lineCount, double demerits) {
-            lineLayouts.addPossibility(lineCount, demerits);
-            if (super.log.isTraceEnabled()) {
-                super.log.trace(
-                        "Layout possibility in " + lineCount + " lines; break at position:");
-            }
-        }
-
-        public void updateData2(KnuthNode bestActiveNode,
-                                KnuthSequence par,
-                                int total) {
-            // compute indent and adjustment ratio, according to
-            // the value of text-align and text-align-last
-            int indent = 0;
-            int difference = bestActiveNode.difference;
-            int textAlign = (bestActiveNode.line < total) ? alignment : alignmentLast;
-            indent += (textAlign == Constants.EN_CENTER)
-                      ? difference / 2 : (textAlign == Constants.EN_END) ? difference : 0;
-            indent += (bestActiveNode.line == 1 && bFirst && isFirstInBlock) ? textIndent : 0;
-            double ratio = (textAlign == Constants.EN_JUSTIFY
-                || difference < 0 && -difference <= bestActiveNode.availableShrink)
-                        ? bestActiveNode.adjustRatio : 0;
-
-            // add nodes at the beginning of the list, as they are found
-            // backwards, from the last one to the first one
-
-            // the first time this method is called, initialize activePossibility
-            if (activePossibility == -1) {
-                activePossibility = 0;
-                addedPositions = 0;
-            }
-
-            if (addedPositions == lineLayouts.getLineCount(activePossibility)) {
-                activePossibility++;
-                addedPositions = 0;
-            }
-
-            if (difference + bestActiveNode.availableShrink < 0) {
-                if (super.log.isWarnEnabled()) {
-                    super.log.warn(FONode.decorateWithContextInfo(
-                            "Line " + (addedPositions + 1) 
-                            + " of a paragraph overflows the available area.", getFObj()));
-                }
-            }
-            
-            //log.debug("LLM> (" + (lineLayouts.getLineNumber(activePossibility) - addedPositions) 
-            //    + ") difference = " + difference + " ratio = " + ratio);
-            MinOptMax lineFiller = ((KnuthParagraph)par).getLineFiller();
-            lineLayouts.addBreakPosition(makeLineBreakPosition(par,
-                   (bestActiveNode.line > 1 ? bestActiveNode.previous.position + 1 : 0),
-                   bestActiveNode.position,
-                   bestActiveNode.availableShrink - (addedPositions > 0 
-                       ? 0 : lineFiller.opt - lineFiller.min), 
-                   bestActiveNode.availableStretch, 
-                   difference, ratio, indent), activePossibility);
-            addedPositions++;
-        }
-
-         reset activePossibility, as if breakpoints have not yet been computed
-         
-        public void resetAlgorithm() {
-            activePossibility = -1;
-        }
-
-        protected int filterActiveNodes() {
-            KnuthNode bestActiveNode = null;
-
-            if (pageAlignment == EN_JUSTIFY) {
-                // leave all active nodes and find the optimum line number
-                //log.debug("LBA.filterActiveNodes> " + activeNodeCount + " layouts");
-                for (int i = startLine; i < endLine; i++) {
-                    for (KnuthNode node = getNode(i); node != null; node = node.next) {
-                        //log.debug("                       + lines = " + node.line + " demerits = " + node.totalDemerits);
-                        bestActiveNode = compareNodes(bestActiveNode, node);
-                    }
-                }
-
-                // scan the node set once again and remove some nodes
-                //log.debug("LBA.filterActiveList> layout selection");
-                for (int i = startLine; i < endLine; i++) {
-                    for (KnuthNode node = getNode(i); node != null; node = node.next) {
-                        //if (Math.abs(node.line - bestActiveNode.line) > maxDiff) {
-                        //if (false) {
-                        if (node.line != bestActiveNode.line
-                            && node.totalDemerits > MAX_DEMERITS) {
-                            //log.debug("                     XXX lines = " + node.line + " demerits = " + node.totalDemerits);
-                            removeNode(i, node);
-                        } else {
-                            //log.debug("                      ok lines = " + node.line + " demerits = " + node.totalDemerits);
-                        }
-                    }
-                }
-            } else {
-                // leave only the active node with fewest total demerits
-                for (int i = startLine; i < endLine; i++) {
-                    for (KnuthNode node = getNode(i); node != null; node = node.next) {
-                        bestActiveNode = compareNodes(bestActiveNode, node);
-                        if (node != bestActiveNode) {
-                            removeNode(i, node);
-                        }
-                    }
-                }
-            }
-            return bestActiveNode.line;
-        }
-    }
-*/
-      
     public LineBreakPosition makeLineBreakPosition(KnuthParagraph par,
                                                     int firstElementIndex,
                                                     int lastElementIndex,
@@ -489,37 +349,6 @@
             return null;
         }
 
-        //PHASE 2: Create line breaks
-            
-        /*
-        LineBreakPosition lbp = null;
-        if (breakpoints == null) {
-            // find the optimal line breaking points for each paragraph
-            breakpoints = new ArrayList();
-            ListIterator paragraphsIterator
-                = knuthParagraphs.listIterator(knuthParagraphs.size());
-            Paragraph currPar = null;
-            while (paragraphsIterator.hasPrevious()) {
-                currPar = (Paragraph) paragraphsIterator.previous();
-                findBreakingPoints(currPar, context.getStackLimit().opt);
-            }
-        }*/
-
-        //PHASE 3: Return lines
-
-        /*
-        // get a break point from the list
-        lbp = (LineBreakPosition) breakpoints.get(iReturnedLBP ++);
-        if (iReturnedLBP == breakpoints.size()) {
-            setFinished(true);
-        }
-
-        BreakPoss curLineBP = new BreakPoss(lbp);
-        curLineBP.setFlag(BreakPoss.ISLAST, isFinished());
-        curLineBP.setStackingSize(new MinOptMax(lbp.lineHeight));
-        return curLineBP;
-        */
-
         setFinished(true);
         return postProcessSequences();
     }
@@ -701,134 +530,6 @@
     }
     
     /**
-     * Find a set of breaking points.
-     * This method is called only once by getNextBreakPoss, and it 
-     * subsequently calls the other findBreakingPoints() method with 
-     * different parameters, until a set of breaking points is found.
-     *
-     * @param par       the list of elements that must be parted
-     *                  into lines
-     * @param lineWidth the desired length ot the lines
-     */
-    /*
-    private void findBreakingPoints(Paragraph par, int lineWidth) {
-        // maximum adjustment ratio permitted
-        float maxAdjustment = 1;
-
-        // first try
-        if (!findBreakingPoints(par, lineWidth, maxAdjustment, false)) {
-            // the first try failed, now try something different
-            log.debug("No set of breaking points found with maxAdjustment = " + maxAdjustment);
-            if (hyphenationProperties.hyphenate == Constants.EN_TRUE) {
-                // consider every hyphenation point as a legal break
-                findHyphenationPoints(par);
-            } else {
-                // try with a higher threshold
-                maxAdjustment = 5;
-            }
-
-            if (!findBreakingPoints(par, lineWidth, maxAdjustment, false)) {
-                // the second try failed too, try with a huge threshold;
-                // if this fails too, use a different algorithm
-                log.debug("No set of breaking points found with maxAdjustment = " + maxAdjustment
-                          + (hyphenationProperties.hyphenate == Constants.EN_TRUE ? " and hyphenation" : ""));
-                maxAdjustment = 20;
-                if (!findBreakingPoints(par, lineWidth, maxAdjustment, true)) {
-                    log.debug("No set of breaking points found, using first-fit algorithm");
-                }
-            }
-        }
-    }
-    
-    private boolean findBreakingPoints(Paragraph par, int lineWidth,
-            double threshold, boolean force) {
-        KnuthParagraph knuthPara = new KnuthParagraph(par);
-        int lines = knuthPara.findBreakPoints(lineWidth, threshold, force);
-        if (lines == 0) {
-            return false;
-        }
-        
-        for (int i = lines-1; i >= 0; i--) {
-            int line = i+1;
-            if (log.isTraceEnabled()) {
-                log.trace("Making line from " + knuthPara.getStart(i) + " to " + 
-                           knuthPara.getEnd(i));
-            }
-            // compute indent and adjustment ratio, according to
-            // the value of text-align and text-align-last
-
-            int difference = knuthPara.getDifference(i);
-            if (line == lines) {
-                difference += par.lineFillerWidth;
-            }    
-            int textAlign = (line < lines)
-                ? textAlignment : textAlignmentLast;
-            int indent = (textAlign == EN_CENTER)
-                ? difference / 2
-                : (textAlign == EN_END) ? difference : 0;
-            indent += (line == 1 && knuthParagraphs.indexOf(par) == 0)
-                ? textIndent.getValue(this) : 0;
-            double ratio = (textAlign == EN_JUSTIFY)
-                ? knuthPara.getAdjustRatio(i) : 0;
-
-            int start = knuthPara.getStart(i);
-            int end = knuthPara.getEnd(i);
-            makeLineBreakPosition(par, start, end, 0, ratio, indent);
-        }
-        return true;        
-    }
-
-    private void makeLineBreakPosition(Paragraph par,
-                                       int firstElementIndex, int lastElementIndex,
-                                       int insertIndex, double ratio, int indent) {
-        // line height calculation
-
-        int halfLeading = (lineHeight - lead - follow) / 2;
-        // height above the main baseline
-        int lineLead = lead + halfLeading;
-        // maximum size of top and bottom alignment
-        int lineFollow = follow + halfLeading;
-
-        ListIterator inlineIterator
-            = par.listIterator(firstElementIndex);
-        for (int j = firstElementIndex;
-             j <= lastElementIndex;
-             j++) {
-            KnuthElement element = (KnuthElement) inlineIterator.next();
-            if (element.isBox()) {
-                KnuthInlineBox box = (KnuthInlineBox)element;
-                if (box.getLead() > lineLead) {
-                    lineLead = box.getLead();
-                }
-                if (box.getTotal() > lineFollow) {
-                    lineFollow = box.getTotal();
-                }
-                if (box.getMiddle() > lineLead + middleShift) {
-                    lineLead += box.getMiddle()
-                                - lineLead - middleShift;
-                }
-                if (box.getMiddle() > middlefollow - middleShift) {
-                    middlefollow += box.getMiddle()
-                                    - middlefollow + middleShift;
-                }
-            }
-        }
-
-        if (lineFollow - lineLead > middlefollow) {
-                    middlefollow = lineFollow - lineLead;
-        }
-
-        breakpoints.add(insertIndex,
-                        new LineBreakPosition(this,
-                                              knuthParagraphs.indexOf(par),
-                                              lastElementIndex ,
-                                              ratio, 0, indent,
-                                              lineLead + middlefollow,
-                                              lineLead));
-    }*/
-
-    
-    /**
      * Phase 2 of Knuth algorithm: find optimal break points.
      * @param bpdAlignment alignment in BP direction of the paragraph
      * @param context the layout context
@@ -907,15 +608,6 @@
                 returnList.add(new KnuthBlockBox
                                (lbp.lineHeight + lbp.spaceBefore + lbp.spaceAfter,
                                 footnoteList, lbp, false));
-                /* // add stretch and shrink to the returnlist
-                    if (!seq.isInlineSequence()
-                            && lbp.availableStretch != 0 || lbp.availableShrink != 0) {
-                        returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE,
-                                false, new Position(this), false));
-                        returnList.add(new KnuthGlue(0, lbp.availableStretch, lbp.availableShrink,
-                                new Position(this), false));
-                    }
-                 */
             }
         }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=593282&r1=593281&r2=593282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java Thu Nov  8 12:00:26 2007
@@ -224,11 +224,6 @@
         label.initialize();
         labelList = label.getNextKnuthElements(childLC, alignment);
         
-        //Space resolution as if the contents were placed in a new reference area
-        //(see 6.8.3, XSL 1.0, section on Constraints, last paragraph)
-        // SpaceResolver.resolveElementList(labelList);
-        // ElementListObserver.observe(labelList, "list-item-label", label.getPartFO().getId());
-        
         if (childLC.isKeepWithPreviousPending()) {
             context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
         }
@@ -240,22 +235,11 @@
         body.initialize();
         bodyList = body.getNextKnuthElements(childLC, alignment);
 
-        //Space resolution as if the contents were placed in a new reference area
-        //(see 6.8.3, XSL 1.0, section on Constraints, last paragraph)
-        // SpaceResolver.resolveElementList(bodyList);
-        // ElementListObserver.observe(bodyList, "list-item-body", body.getPartFO().getId());
-        
         if (childLC.isKeepWithPreviousPending()) {
             context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
         }
         this.keepWithNextPendingOnBody = childLC.isKeepWithNextPending();
 
-        // create a combined list
-        // LinkedList returnedList = getCombinedKnuthElementsForListItem(labelList, bodyList, context);
-
-        // "wrap" the Position inside each element
-        // wrapPositionElements(returnedList, returnList, true);
-        
         Position returnPosition = new LeafPosition(this, 0);
         ListElement elt = new ListItemListElement(this, returnPosition, context);
         returnList.add(elt);
@@ -278,19 +262,6 @@
 
     public LinkedList doLineBreaking(LayoutContext context) {
         LinkedList returnList = new LinkedList();
-        // TODO
-
-        // for label
-        //Space resolution as if the contents were placed in a new reference area
-        //(see 6.8.3, XSL 1.0, section on Constraints, last paragraph)
-        // SpaceResolver.resolveElementList(labelList);
-        // ElementListObserver.observe(labelList, "list-item-label", label.getPartFO().getId());
-        
-        // for body
-        //Space resolution as if the contents were placed in a new reference area
-        //(see 6.8.3, XSL 1.0, section on Constraints, last paragraph)
-        // SpaceResolver.resolveElementList(bodyList);
-        // ElementListObserver.observe(bodyList, "list-item-body", body.getPartFO().getId());
 
         // create a combined list
         LinkedList returnedList = getCombinedKnuthElementsForListItem(context);
@@ -469,6 +440,8 @@
                 --i;
             }
         }
+
+        //Space resolution as if the contents were placed in a new reference area
         SpaceResolver.resolveElementList(seq, startIndex);
     }
 



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