jeremias    2005/02/10 07:54:03

  Modified:    src/java/org/apache/fop/layoutmgr LineLayoutManager.java
  Log:
  Rearranged the process a bit to better show the different phases. Helped me 
to better understand what's going on there.
  
  Revision  Changes    Path
  1.40      +24 -16    
xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- LineLayoutManager.java    2 Feb 2005 15:05:51 -0000       1.39
  +++ LineLayoutManager.java    10 Feb 2005 15:54:03 -0000      1.40
  @@ -394,15 +394,15 @@
           }
           prevBP = null;
   
  -        // here starts Knuth's algorithm
  -        KnuthElement thisElement = null;
  -        LinkedList returnedList = null;
  -        LineBreakPosition lbp = null;
  -
  +        //PHASE 1: Create Knuth elements
  +        
           if (knuthParagraphs == null) {
               // it's the first time this method is called
               knuthParagraphs = new ArrayList();
  -            breakpoints = new ArrayList();
  +
  +            // here starts Knuth's algorithm
  +            KnuthElement thisElement = null;
  +            LinkedList returnedList = null;
   
               // convert all the text in a sequence of paragraphs made
               // of KnuthBox, KnuthGlue and KnuthPenalty objects
  @@ -490,14 +490,23 @@
                   }
               }
               knuthPar.endParagraph();
  +        } else {
  +            // this method has been called before
  +            // all line breaks are already calculated
  +        }
   
  -            // emergency patch
  -            if (knuthParagraphs.size() == 0) {
  -                setFinished(true);
  -                return null;
  -            }
  +        // return finished when there's no content
  +        if (knuthParagraphs.size() == 0) {
  +            setFinished(true);
  +            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;
  @@ -505,11 +514,10 @@
                   currPar = (Paragraph) paragraphsIterator.previous();
                   findBreakingPoints(currPar, context.getStackLimit().opt);
               }
  -        } else {
  -            // this method has been called before
  -            // all line breaks are already calculated
           }
   
  +        //PHASE 3: Return lines
  +
           // get a break point from the list
           lbp = (LineBreakPosition) breakpoints.get(iReturnedLBP ++);
           if (iReturnedLBP == breakpoints.size()) {
  @@ -1364,9 +1372,9 @@
               }
               while ((LineBreakPosition) breakpoints.get(iReturnedLBP)
                      != (LineBreakPosition) resetPos) {
  -                iReturnedLBP --;
  +                iReturnedLBP--;
               }
  -            iReturnedLBP ++;
  +            iReturnedLBP++;
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to