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 je...@apache.org on 2005/05/17 09:02:14 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr PageSequenceLayoutManager.java BlockStackingLayoutManager.java AbstractBreaker.java BreakingAlgorithm.java PageBreakingAlgorithm.java

jeremias    2005/05/17 00:02:14

  Modified:    src/java/org/apache/fop/layoutmgr
                        PageSequenceLayoutManager.java
                        BlockStackingLayoutManager.java
                        AbstractBreaker.java BreakingAlgorithm.java
                        PageBreakingAlgorithm.java
  Log:
  Converted System.out calls to logger calls.
  
  Revision  Changes    Path
  1.56      +2 -2      xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
  
  Index: PageSequenceLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- PageSequenceLayoutManager.java	16 May 2005 02:54:19 -0000	1.55
  +++ PageSequenceLayoutManager.java	17 May 2005 07:02:14 -0000	1.56
  @@ -230,7 +230,7 @@
   /*LF*/          childFLM = (FlowLayoutManager)curLM;
   /*LF*/      } else {
   /*LF*/          if (curLM != childFLM) {
  -/*LF*/              System.out.println("PLM> figlio sconosciuto (invalid child LM)");
  +/*LF*/              log.error("PSLM> invalid child LM");
   /*LF*/          }
   /*LF*/      }
   
  
  
  
  1.13      +1 -1      xml-fop/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
  
  Index: BlockStackingLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- BlockStackingLayoutManager.java	13 May 2005 19:16:52 -0000	1.12
  +++ BlockStackingLayoutManager.java	17 May 2005 07:02:14 -0000	1.13
  @@ -407,7 +407,7 @@
               return returnValue;
           } else {
               // this should never happen
  -            System.err.println("BlockLayoutManager.negotiateBPDAdjustment(): unexpected Position");
  +            log.error("BlockLayoutManager.negotiateBPDAdjustment(): unexpected Position");
               return 0;
           }
       }
  
  
  
  1.3       +74 -60    xml-fop/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
  
  Index: AbstractBreaker.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractBreaker.java	13 May 2005 19:16:51 -0000	1.2
  +++ AbstractBreaker.java	17 May 2005 07:02:14 -0000	1.3
  @@ -130,7 +130,7 @@
           BlockSequence blockList;
           blockLists = new java.util.ArrayList();
   
  -        System.out.println("PLM> flow BPD =" + flowBPD);
  +        log.debug("PLM> flow BPD =" + flowBPD);
           
           //*** Phase 1: Get Knuth elements ***
           int nextSequenceStartsOn = Constants.EN_ANY;
  @@ -139,20 +139,22 @@
           }
   
           //*** Phase 2: Alignment and breaking ***
  -        System.out.println("PLM> blockLists.size() = " + blockLists.size());
  +        log.debug("PLM> blockLists.size() = " + blockLists.size());
           for (blockListIndex = 0; blockListIndex < blockLists.size(); blockListIndex++) {
               blockList = (BlockSequence) blockLists.get(blockListIndex);
               
               //debug code start
  -            System.err.println("  blockListIndex = " + blockListIndex);
  -            String pagina = (blockList.startOn == Constants.EN_ANY) ? "any page"
  -                    : (blockList.startOn == Constants.EN_ODD_PAGE) ? "odd page"
  -                            : "even page";
  -            System.err.println("  sequence starts on " + pagina);
  -            logBlocklist(blockList);
  +            if (log.isDebugEnabled()) {
  +                log.debug("  blockListIndex = " + blockListIndex);
  +                String pagina = (blockList.startOn == Constants.EN_ANY) ? "any page"
  +                        : (blockList.startOn == Constants.EN_ODD_PAGE) ? "odd page"
  +                                : "even page";
  +                log.debug("  sequence starts on " + pagina);
  +                logBlocklist(blockList);
  +            }
               //debug code end
   
  -            System.out.println("PLM> start of algorithm (" + this.getClass().getName() 
  +            log.debug("PLM> start of algorithm (" + this.getClass().getName() 
                       + "), flow BPD =" + flowBPD);
               PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(),
                       alignment, alignmentLast);
  @@ -170,7 +172,7 @@
               //iOptPageNumber = alg.firstFit(effectiveList, flowBPD, 1, true);
               iOptPageNumber = alg.findBreakingPoints(effectiveList, flowBPD, 1,
                       true, true);
  -            System.out.println("PLM> iOptPageNumber= " + iOptPageNumber
  +            log.debug("PLM> iOptPageNumber= " + iOptPageNumber
                       + " pageBreaks.size()= " + alg.getPageBreaks().size());
   
               
  @@ -206,7 +208,7 @@
           for (int p = 0; p < partCount; p++) {
               PageBreakPosition pbp = (PageBreakPosition) alg.getPageBreaks().get(p);
               endElementIndex = pbp.getLeafPos();
  -            System.out.println("PLM> part: " + (p + 1)
  +            log.debug("PLM> part: " + (p + 1)
                       + ", break at position " + endElementIndex);
   
               startPart(effectiveList, (p == 0));
  @@ -243,7 +245,7 @@
               }
   
               if (startElementIndex <= endElementIndex) {
  -                System.out.println("     addAreas da " + startElementIndex
  +                log.debug("     addAreas da " + startElementIndex
                           + " a " + endElementIndex);
                   childLC = new LayoutContext(0);
                   // add space before if display-align is center or bottom
  @@ -311,20 +313,20 @@
                           .removeLast();
                   switch (breakPenalty.getBreakClass()) {
                   case Constants.EN_PAGE:
  -                    System.err.println("PLM> break - PAGE");
  +                    log.debug("PLM> break - PAGE");
                       nextSequenceStartsOn = Constants.EN_ANY;
                       break;
                   case Constants.EN_COLUMN:
  -                    System.err.println("PLM> break - COLUMN");
  +                    log.debug("PLM> break - COLUMN");
                       //TODO Fix this when implementing multi-column layout
                       nextSequenceStartsOn = Constants.EN_COLUMN;
                       break;
                   case Constants.EN_ODD_PAGE:
  -                    System.err.println("PLM> break - ODD PAGE");
  +                    log.debug("PLM> break - ODD PAGE");
                       nextSequenceStartsOn = Constants.EN_ODD_PAGE;
                       break;
                   case Constants.EN_EVEN_PAGE:
  -                    System.err.println("PLM> break - EVEN PAGE");
  +                    log.debug("PLM> break - EVEN PAGE");
                       nextSequenceStartsOn = Constants.EN_EVEN_PAGE;
                       break;
                   default:
  @@ -399,7 +401,7 @@
           int iOptPageNumber;
           iOptPageNumber = alg.findBreakingPoints(blockList, availableBPD, 1,
                   true, true);
  -        System.out.println("PLM> iOptPageNumber= " + iOptPageNumber);
  +        log.debug("PLM> iOptPageNumber= " + iOptPageNumber);
   
           // 
           ListIterator sequenceIterator = blockList.listIterator();
  @@ -412,10 +414,12 @@
   
           while (breakIterator.hasNext()) {
               thisBreak = (PageBreakPosition) breakIterator.next();
  -            System.out.println("| first page: break= "
  -                    + thisBreak.getLeafPos() + " difference= "
  -                    + thisBreak.difference + " ratio= "
  -                    + thisBreak.bpdAdjust);
  +            if (log.isDebugEnabled()) {
  +                log.debug("| first page: break= "
  +                        + thisBreak.getLeafPos() + " difference= "
  +                        + thisBreak.difference + " ratio= "
  +                        + thisBreak.bpdAdjust);
  +            }
               accumulatedS = 0;
               adjustedDiff = 0;
   
  @@ -428,7 +432,7 @@
               while (!(firstElement = (KnuthElement) sequenceIterator
                       .next()).isBox()) {
                   // 
  -                System.out.println("PLM> ignoring glue or penalty element "
  +                log.debug("PLM> ignoring glue or penalty element "
                           + "at the beginning of the sequence");
                   if (firstElement.isGlue()) {
                       ((BlockLevelLayoutManager) firstElement
  @@ -502,14 +506,13 @@
                       }
                   }
               }
  -            System.out.println("| line number adj= "
  +            log.debug("| line number adj= "
                       + lineNumberMaxAdjustment);
  -            System.out.println("| space adj      = "
  +            log.debug("| space adj      = "
                       + spaceMaxAdjustment);
   
               if (thisElement.isPenalty() && thisElement.getW() > 0) {
  -                System.out
  -                        .println("  mandatory variation to the number of lines!");
  +                log.debug("  mandatory variation to the number of lines!");
                   ((BlockLevelLayoutManager) thisElement
                           .getLayoutManager()).negotiateBPDAdjustment(
                           thisElement.getW(), thisElement);
  @@ -526,7 +529,7 @@
                           thisBreak.difference,
                           (thisBreak.difference > 0 ? spaceMaxAdjustment.max
                                   : -spaceMaxAdjustment.min));
  -                System.out.println("single space: "
  +                log.debug("single space: "
                           + (adjustedDiff == thisBreak.difference
                                   || thisBreak.bpdAdjust == 0 ? "ok"
                                   : "ERROR"));
  @@ -541,7 +544,7 @@
                           thisBreak.difference - adjustedDiff,
                           ((thisBreak.difference - adjustedDiff) > 0 ? spaceMaxAdjustment.max
                                   : -spaceMaxAdjustment.min));
  -                System.out.println("lines and space: "
  +                log.debug("lines and space: "
                           + (adjustedDiff == thisBreak.difference
                                   || thisBreak.bpdAdjust == 0 ? "ok"
                                   : "ERROR"));
  @@ -571,27 +574,30 @@
        * @param blockList block list to log
        */
       private void logBlocklist(KnuthSequence blockList) {
  +        if (!log.isDebugEnabled()) {
  +            return;
  +        }
           ListIterator tempIter = blockList.listIterator();
   
           KnuthElement temp;
  -        System.out.println(" ");
  +        log.debug(" ");
           while (tempIter.hasNext()) {
               temp = (KnuthElement) tempIter.next();
               if (temp.isBox()) {
  -                System.out.println(tempIter.previousIndex()
  +                log.debug(tempIter.previousIndex()
                           + ") " + temp);
               } else if (temp.isGlue()) {
  -                System.out.println(tempIter.previousIndex()
  +                log.debug(tempIter.previousIndex()
                           + ") " + temp);
               } else {
  -                System.out.println(tempIter.previousIndex()
  +                log.debug(tempIter.previousIndex()
                           + ") " + temp);
               }
               if (temp.getPosition() != null) {
  -                System.out.println("            " + temp.getPosition());
  +                log.debug("            " + temp.getPosition());
               }
           }
  -        System.out.println(" ");
  +        log.debug(" ");
       }
   
       /**
  @@ -599,28 +605,37 @@
        * @param effectiveList block list to log
        */
       private void logEffectiveList(KnuthSequence effectiveList) {
  -        System.out.println("Effective list");
  +        log.debug("Effective list");
           logBlocklist(effectiveList);
       }
   
       private int adjustBlockSpaces(LinkedList spaceList, int difference, int total) {
  -    /*LF*/  System.out.println("AdjustBlockSpaces: difference " + difference + " / " + total + " on " + spaceList.size() + " spaces in block");
  -            ListIterator spaceListIterator = spaceList.listIterator();
  -            int adjustedDiff = 0;
  -            int partial = 0;
  -            while (spaceListIterator.hasNext()) {
  -                KnuthGlue blockSpace = (KnuthGlue)spaceListIterator.next();
  -                partial += (difference > 0 ? blockSpace.getY() : blockSpace.getZ());
  -                System.out.println("available = " + partial +  " / " + total);
  -                System.out.println("competenza  = " + (((int) ((float) partial * difference / total)) - adjustedDiff) + " / " + difference);
  -                int newAdjust = ((BlockLevelLayoutManager) blockSpace.getLayoutManager()).negotiateBPDAdjustment(((int) ((float) partial * difference / total)) - adjustedDiff, blockSpace);
  -                adjustedDiff += newAdjust;
  +        if (log.isDebugEnabled()) {
  +            log.debug("AdjustBlockSpaces: difference " + difference + " / " + total 
  +                    + " on " + spaceList.size() + " spaces in block");
  +        }
  +        ListIterator spaceListIterator = spaceList.listIterator();
  +        int adjustedDiff = 0;
  +        int partial = 0;
  +        while (spaceListIterator.hasNext()) {
  +            KnuthGlue blockSpace = (KnuthGlue)spaceListIterator.next();
  +            partial += (difference > 0 ? blockSpace.getY() : blockSpace.getZ());
  +            if (log.isDebugEnabled()) {
  +                log.debug("available = " + partial +  " / " + total);
  +                log.debug("competenza  = " 
  +                        + (((int)((float) partial * difference / total)) - adjustedDiff) 
  +                        + " / " + difference);
               }
  -            return adjustedDiff;
  +            int newAdjust = ((BlockLevelLayoutManager) blockSpace.getLayoutManager()).negotiateBPDAdjustment(((int) ((float) partial * difference / total)) - adjustedDiff, blockSpace);
  +            adjustedDiff += newAdjust;
           }
  +        return adjustedDiff;
  +    }
   
       private int adjustLineNumbers(LinkedList lineList, int difference, int total) {
  -    /*LF*/  System.out.println("AdjustLineNumbers: difference " + difference + " / " + total + " on " + lineList.size() + " elements");
  +        if (log.isDebugEnabled()) {
  +            log.debug("AdjustLineNumbers: difference " + difference + " / " + total + " on " + lineList.size() + " elements");
  +        }
   
   //            int adjustedDiff = 0;
   //            int partial = 0;
  @@ -645,17 +660,16 @@
   //            }
   //            return adjustedDiff;
   
  -            ListIterator lineListIterator = lineList.listIterator();
  -            int adjustedDiff = 0;
  -            int partial = 0;
  -            while (lineListIterator.hasNext()) {
  -                KnuthGlue line = (KnuthGlue)lineListIterator.next();
  -                partial += (difference > 0 ? line.getY() : line.getZ());
  -                int newAdjust = ((BlockLevelLayoutManager) line.getLayoutManager()).negotiateBPDAdjustment(((int) ((float) partial * difference / total)) - adjustedDiff, line);
  -                adjustedDiff += newAdjust;
  -            }
  -            return adjustedDiff;
  +        ListIterator lineListIterator = lineList.listIterator();
  +        int adjustedDiff = 0;
  +        int partial = 0;
  +        while (lineListIterator.hasNext()) {
  +            KnuthGlue line = (KnuthGlue)lineListIterator.next();
  +            partial += (difference > 0 ? line.getY() : line.getZ());
  +            int newAdjust = ((BlockLevelLayoutManager) line.getLayoutManager()).negotiateBPDAdjustment(((int) ((float) partial * difference / total)) - adjustedDiff, line);
  +            adjustedDiff += newAdjust;
           }
  -
  +        return adjustedDiff;
  +    }
       
   }
  
  
  
  1.3       +1 -3      xml-fop/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
  
  Index: BreakingAlgorithm.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BreakingAlgorithm.java	13 May 2005 19:16:51 -0000	1.2
  +++ BreakingAlgorithm.java	17 May 2005 07:02:14 -0000	1.3
  @@ -18,8 +18,6 @@
   
   package org.apache.fop.layoutmgr;
   
  -import java.util.ArrayList;
  -
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  
  
  
  1.3       +5 -3      xml-fop/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
  
  Index: PageBreakingAlgorithm.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PageBreakingAlgorithm.java	13 May 2005 19:16:52 -0000	1.2
  +++ PageBreakingAlgorithm.java	17 May 2005 07:02:14 -0000	1.3
  @@ -58,8 +58,10 @@
   
           // add nodes at the beginning of the list, as they are found
           // backwards, from the last one to the first one
  -        System.out.println("BBA> difference= " + difference + " ratio= " + ratio 
  -                           + " posizione= " + bestActiveNode.position);
  +        if (log.isDebugEnabled()) {
  +            log.debug("BBA> difference= " + difference + " ratio= " + ratio 
  +                    + " posizione= " + bestActiveNode.position);
  +        }
           insertPageBreakAsFirst(new PageBreakPosition(this.topLevelLM, 
                   bestActiveNode.position, ratio, difference));
       }
  
  
  

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