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 vh...@apache.org on 2009/12/22 18:20:53 UTC

svn commit: r893238 [1/4] - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/area/ src/java/org/apache/fop/fo/properties/ src/java/org/apache/fop/layoutmgr/ src/java/org/apache/fop/layoutmgr/inline/ src/java/org/apache/fop/layoutmgr/list/ src/java/or...

Author: vhennebert
Date: Tue Dec 22 17:20:51 2009
New Revision: 893238

URL: http://svn.apache.org/viewvc?rev=893238&view=rev
Log:
Bugzilla #48071: made the MinOptMax class immutable. Also, lots of clean ups and minor refactorings.
Patch submitted by Alexander Kiel.

Added:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Adjustment.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/MinOptMaxTest.java   (with props)
Removed:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Area.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBox.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthGlue.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceElement.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/MinOptMax.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/SpaceVal.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Area.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Area.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Area.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/Area.java Tue Dec 22 17:20:51 2009
@@ -119,7 +119,7 @@
     public static final int CLASS_MAX = CLASS_SIDE_FLOAT + 1;
 
     private int areaClass = CLASS_NORMAL;
-    
+
     /** the area's inline-progression-dimension */
     protected int ipd;
 
@@ -174,18 +174,18 @@
      * @see <a href="http://www.w3.org/TR/xsl/#inline-progression-dimension">ipd</a>
      */
     public int getIPD() {
-        return this.ipd;
+        return ipd;
     }
 
     /**
      * Set the block progression dimension of the content rectangle
      * for this area.
      *
-     * @param b the new block progression dimension
+     * @param bpd the new block progression dimension
      * @see <a href="http://www.w3.org/TR/xsl/#block-progression-dimension">bpd</a>
      */
-    public void setBPD(int b) {
-        bpd = b;
+    public void setBPD(int bpd) {
+        this.bpd = bpd;
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java Tue Dec 22 17:20:51 2009
@@ -25,6 +25,7 @@
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.traits.MinOptMax;
 
 /**
  * Superclass for properties that contain LengthRange values
@@ -40,6 +41,22 @@
     private boolean consistent = false;
 
     /**
+     * Converts this <code>LengthRangeProperty</code> to a <code>MinOptMax</code>.
+     *
+     * @param context Percentage evaluation context
+     * @return the requested MinOptMax instance
+     */
+    public MinOptMax toMinOptMax(PercentBaseContext context) {
+        int min = getMinimum(context).isAuto() ? 0
+                : getMinimum(context).getLength().getValue(context);
+        int opt = getOptimum(context).isAuto() ? min
+                : getOptimum(context).getLength().getValue(context);
+        int max = getMaximum(context).isAuto() ? Integer.MAX_VALUE
+                : getMaximum(context).getLength().getValue(context);
+        return MinOptMax.getInstance(min, opt, max);
+    }
+
+    /**
      * Inner class for a Maker for LengthProperty objects
      */
     public static class Maker extends CompoundPropertyMaker {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java Tue Dec 22 17:20:51 2009
@@ -201,7 +201,7 @@
     protected int alignment;
     private int alignmentLast;
 
-    protected MinOptMax footnoteSeparatorLength = new MinOptMax(0);
+    protected MinOptMax footnoteSeparatorLength = MinOptMax.ZERO;
 
     protected abstract int getCurrentDisplayAlign();
     protected abstract boolean hasMoreContent();
@@ -307,7 +307,7 @@
      */
     public void doLayout(int flowBPD, boolean autoHeight) {
         LayoutContext childLC = createLayoutContext();
-        childLC.setStackLimitBP(new MinOptMax(flowBPD));
+        childLC.setStackLimitBP(MinOptMax.getInstance(flowBPD));
 
         if (getCurrentDisplayAlign() == Constants.EN_X_FILL) {
             //EN_X_FILL is non-standard (by LF)
@@ -613,7 +613,7 @@
                     int averageLineLength = optimizeLineLength(effectiveList,
                             startElementIndex, endElementIndex);
                     if (averageLineLength != 0) {
-                        childLC.setStackLimitBP(new MinOptMax(averageLineLength));
+                        childLC.setStackLimitBP(MinOptMax.getInstance(averageLineLength));
                     }
                 }
                 /* *** *** non-standard extension *** *** */
@@ -762,7 +762,8 @@
      * @param endElementIndex   index of the element ending the range
      * @return the average line length, 0 if there's no content
      */
-    private int optimizeLineLength(KnuthSequence effectiveList, int startElementIndex, int endElementIndex) {
+    private int optimizeLineLength(KnuthSequence effectiveList, int startElementIndex,
+            int endElementIndex) {
         ListIterator effectiveListIterator;
         // optimize line length
         int boxCount = 0;
@@ -783,9 +784,9 @@
                     accumulatedLineLength += ((KnuthBlockBox) tempEl)
                             .getBPD();
                 }
-                if (blockBox.getIPDRange().min > greatestMinimumLength) {
+                if (blockBox.getIPDRange().getMin() > greatestMinimumLength) {
                     greatestMinimumLength = blockBox
-                            .getIPDRange().min;
+                            .getIPDRange().getMin();
                 }
             }
         }
@@ -808,7 +809,8 @@
      * @param availableBPD the available BPD
      * @return the effective list
      */
-    private BlockSequence justifyBoxes(BlockSequence blockList, PageBreakingAlgorithm alg, int availableBPD) {
+    private BlockSequence justifyBoxes(BlockSequence blockList, PageBreakingAlgorithm alg,
+            int availableBPD) {
         int iOptPageNumber;
         alg.setConstantLineWidth(availableBPD);
         iOptPageNumber = alg.findBreakingPoints(blockList, /*availableBPD,*/
@@ -857,8 +859,8 @@
 
             // scan the sub-sequence representing a page,
             // collecting information about potential adjustments
-            MinOptMax lineNumberMaxAdjustment = new MinOptMax(0);
-            MinOptMax spaceMaxAdjustment = new MinOptMax(0);
+            MinOptMax lineNumberMaxAdjustment = MinOptMax.ZERO;
+            MinOptMax spaceMaxAdjustment = MinOptMax.ZERO;
             double spaceAdjustmentRatio = 0.0;
             LinkedList blockSpacesList = new LinkedList();
             LinkedList unconfirmedList = new LinkedList();
@@ -872,30 +874,23 @@
                     // glue elements are used to represent adjustable
                     // lines
                     // and adjustable spaces between blocks
-                    switch (((KnuthGlue) thisElement)
-                            .getAdjustmentClass()) {
-                    case BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT:
-                    // fall through
-                    case BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT:
+                    Adjustment adjustment = ((KnuthGlue) thisElement).getAdjustmentClass();
+                    if (adjustment.equals(Adjustment.SPACE_BEFORE_ADJUSTMENT)
+                            || adjustment.equals(Adjustment.SPACE_AFTER_ADJUSTMENT)) {
                         // potential space adjustment
                         // glue items before the first box or after the
                         // last one
                         // must be ignored
                         unconfirmedList.add(thisElement);
-                        break;
-                    case BlockLevelLayoutManager.LINE_NUMBER_ADJUSTMENT:
+                    } else if (adjustment.equals(Adjustment.LINE_NUMBER_ADJUSTMENT)) {
                         // potential line number adjustment
-                        lineNumberMaxAdjustment.max += ((KnuthGlue) thisElement)
-                                .getStretch();
-                        lineNumberMaxAdjustment.min -= ((KnuthGlue) thisElement)
-                                .getShrink();
+                        lineNumberMaxAdjustment
+                                = lineNumberMaxAdjustment.plusMax(thisElement.getStretch());
+                        lineNumberMaxAdjustment
+                                = lineNumberMaxAdjustment.minusMin(thisElement.getShrink());
                         adjustableLinesList.add(thisElement);
-                        break;
-                    case BlockLevelLayoutManager.LINE_HEIGHT_ADJUSTMENT:
+                    } else if (adjustment.equals(Adjustment.LINE_HEIGHT_ADJUSTMENT)) {
                         // potential line height adjustment
-                        break;
-                    default:
-                    // nothing
                     }
                 } else if (thisElement.isBox()) {
                     if (!bBoxSeen) {
@@ -909,10 +904,8 @@
                             // blockSpaceList
                             KnuthGlue blockSpace = (KnuthGlue) unconfirmedList
                                     .removeFirst();
-                            spaceMaxAdjustment.max += ((KnuthGlue) blockSpace)
-                                    .getStretch();
-                            spaceMaxAdjustment.min -= ((KnuthGlue) blockSpace)
-                                    .getShrink();
+                            spaceMaxAdjustment = spaceMaxAdjustment.plusMax(blockSpace.getStretch());
+                            spaceMaxAdjustment = spaceMaxAdjustment.minusMin(blockSpace.getShrink());
                             blockSpacesList.add(blockSpace);
                         }
                     }
@@ -931,16 +924,19 @@
             }
 
             if (thisBreak.bpdAdjust != 0
-                    && (thisBreak.difference > 0 && thisBreak.difference <= spaceMaxAdjustment.max)
-                    || (thisBreak.difference < 0 && thisBreak.difference >= spaceMaxAdjustment.min)) {
+                    && (thisBreak.difference > 0 && thisBreak.difference <= spaceMaxAdjustment
+                            .getMax())
+                    || (thisBreak.difference < 0 && thisBreak.difference >= spaceMaxAdjustment
+                            .getMin())) {
                 // modify only the spaces between blocks
-                spaceAdjustmentRatio = ((double) thisBreak.difference / (thisBreak.difference > 0 ? spaceMaxAdjustment.max
-                        : spaceMaxAdjustment.min));
+                spaceAdjustmentRatio = ((double) thisBreak.difference / (thisBreak.difference > 0
+                        ? spaceMaxAdjustment.getMax()
+                        : spaceMaxAdjustment.getMin()));
                 adjustedDiff += adjustBlockSpaces(
                         blockSpacesList,
                         thisBreak.difference,
-                        (thisBreak.difference > 0 ? spaceMaxAdjustment.max
-                                : -spaceMaxAdjustment.min));
+                        (thisBreak.difference > 0 ? spaceMaxAdjustment.getMax()
+                                : -spaceMaxAdjustment.getMin()));
                 log.debug("single space: "
                         + (adjustedDiff == thisBreak.difference
                                 || thisBreak.bpdAdjust == 0 ? "ok"
@@ -949,13 +945,13 @@
                 adjustedDiff += adjustLineNumbers(
                         adjustableLinesList,
                         thisBreak.difference,
-                        (thisBreak.difference > 0 ? lineNumberMaxAdjustment.max
-                                : -lineNumberMaxAdjustment.min));
+                        (thisBreak.difference > 0 ? lineNumberMaxAdjustment.getMax()
+                                : -lineNumberMaxAdjustment.getMin()));
                 adjustedDiff += adjustBlockSpaces(
                         blockSpacesList,
                         thisBreak.difference - adjustedDiff,
-                        ((thisBreak.difference - adjustedDiff) > 0 ? spaceMaxAdjustment.max
-                                : -spaceMaxAdjustment.min));
+                        ((thisBreak.difference - adjustedDiff) > 0 ? spaceMaxAdjustment.getMax()
+                                : -spaceMaxAdjustment.getMin()));
                 log.debug("lines and space: "
                         + (adjustedDiff == thisBreak.difference
                                 || thisBreak.bpdAdjust == 0 ? "ok"

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -48,7 +48,7 @@
     private static Log log = LogFactory.getLog(AbstractLayoutManager.class);
 
     /** Parent LayoutManager for this LayoutManager */
-    protected LayoutManager parentLM;
+    protected LayoutManager parentLayoutManager;
     /** List of child LayoutManagers */
     protected List childLMs;
     /** Iterator for child LayoutManagers */
@@ -91,12 +91,12 @@
 
     /** {@inheritDoc} */
     public void setParent(LayoutManager lm) {
-        this.parentLM = lm;
+        this.parentLayoutManager = lm;
     }
 
     /** {@inheritDoc} */
     public LayoutManager getParent() {
-        return this.parentLM;
+        return this.parentLayoutManager;
     }
 
     /** {@inheritDoc} */
@@ -230,7 +230,7 @@
 
     /** {@inheritDoc} */
     public PageSequenceLayoutManager getPSLM() {
-        return parentLM.getPSLM();
+        return parentLayoutManager.getPSLM();
     }
 
     /**
@@ -442,7 +442,7 @@
              * LM is a descendant of the FlowLM. For static-content
              * the FO may still be needed on following pages.
              */
-            LayoutManager lm = this.parentLM;
+            LayoutManager lm = this.parentLayoutManager;
             while (!(lm instanceof FlowLayoutManager
                         || lm instanceof PageSequenceLayoutManager)) {
                 lm = lm.getParent();

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Adjustment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Adjustment.java?rev=893238&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Adjustment.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Adjustment.java Tue Dec 22 17:20:51 2009
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr;
+
+/**
+ * @see KnuthGlue
+ * @see "http://www.leverkruid.eu/GKPLinebreaking/elements.html"
+ */
+public final class Adjustment {
+
+    /**
+     * Adjustment class: no adjustment.
+     */
+    public static final Adjustment NO_ADJUSTMENT = new Adjustment("none");
+
+    /**
+     * Adjustment class: adjustment for space-before.
+     */
+    public static final Adjustment SPACE_BEFORE_ADJUSTMENT = new Adjustment("space-before");
+
+    /**
+     * Adjustment class: adjustment for space-after.
+     */
+    public static final Adjustment SPACE_AFTER_ADJUSTMENT = new Adjustment("space-after");
+
+    /**
+     * Adjustment class: adjustment for number of lines.
+     */
+    public static final Adjustment LINE_NUMBER_ADJUSTMENT = new Adjustment("line-number");
+
+    /**
+     * Adjustment class: adjustment for line height.
+     */
+    public static final Adjustment LINE_HEIGHT_ADJUSTMENT = new Adjustment("line-height");
+
+    private final String name;
+
+    private Adjustment(String name) {
+        this.name = name;
+    }
+
+    /** {@inheritDoc} */
+    public boolean equals(Object obj) {
+        return this == obj;
+    }
+
+    /** {@inheritDoc} */
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return name;
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Adjustment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/Adjustment.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -107,8 +107,7 @@
         startIndent = getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(this);
         endIndent = getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(this);
 
-        boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
-        if (rotated) {
+        if (blockProgressionDirectionChanges()) {
             height = getBlockContainerFO().getInlineProgressionDimension()
                             .getOptimum(this).getLength();
             width = getBlockContainerFO().getBlockProgressionDimension()
@@ -156,10 +155,6 @@
         return (overflow == EN_HIDDEN || overflow == EN_ERROR_IF_OVERFLOW);
     }
 
-    private int getSpaceBefore() {
-        return foBlockSpaceBefore.opt;
-    }
-
     private int getBPIndents() {
         int indents = 0;
         /* TODO This is wrong isn't it?
@@ -200,7 +195,7 @@
 
         autoHeight = false;
         //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
-        int maxbpd = context.getStackLimitBP().opt;
+        int maxbpd = context.getStackLimitBP().getOpt();
         int allocBPD;
         if (height.getEnum() == EN_AUTO
                 || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) {
@@ -246,7 +241,7 @@
                     getBlockContainerFO().getLocator());
         }
 
-        MinOptMax stackLimit = new MinOptMax(relDims.bpd);
+        MinOptMax stackLimit = MinOptMax.getInstance(relDims.bpd);
 
         List returnedList;
         List contentList = new LinkedList();
@@ -279,7 +274,7 @@
                 LayoutContext childLC = new LayoutContext(0);
                 childLC.copyPendingMarksFrom(context);
                 // curLM is a ?
-                childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit));
+                childLC.setStackLimitBP(context.getStackLimitBP().minus(stackLimit));
                 childLC.setRefIPD(relDims.ipd);
                 childLC.setWritingMode(getBlockContainerFO().getWritingMode());
                 if (curLM == this.childLMs.get(0)) {
@@ -349,41 +344,8 @@
             wrapPositionElements(contentList, returnList);
 
         } else {
-            MinOptMax range = new MinOptMax(relDims.ipd);
-            BlockContainerBreaker breaker = new BlockContainerBreaker(this, range);
-            breaker.doLayout(relDims.bpd, autoHeight);
-            boolean contentOverflows = breaker.isOverflow();
-            if (autoHeight) {
-                //Update content BPD now that it is known
-                int newHeight = breaker.deferredAlg.totalWidth;
-                boolean switchedProgressionDirection
-                    = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
-                if (switchedProgressionDirection) {
-                    setContentAreaIPD(newHeight);
-                } else {
-                    vpContentBPD = newHeight;
-                }
-                updateRelDims(contentRectOffsetX, contentRectOffsetY, false);
-            }
-
-            Position bcPosition = new BlockContainerPosition(this, breaker);
-            returnList.add(new KnuthBox(vpContentBPD, notifyPos(bcPosition), false));
-            //TODO Handle min/opt/max for block-progression-dimension
-            /* These two elements will be used to add stretchability to the above box
-            returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE,
-                                   false, returnPosition, false));
-            returnList.add(new KnuthGlue(0, 1 * constantLineHeight, 0,
-                                   LINE_NUMBER_ADJUSTMENT, returnPosition, false));
-            */
-
-            if (contentOverflows) {
-                BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
-                        getBlockContainerFO().getUserAgent().getEventBroadcaster());
-                boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
-                eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
-                        breaker.getOverflowAmount(), needClip(), canRecover,
-                        getBlockContainerFO().getLocator());
-            }
+            returnList.add(refactoredBecauseOfDuplicateCode(contentRectOffsetX,
+                    contentRectOffsetY));
         }
         addKnuthElementsForBorderPaddingAfter(returnList, true);
         addKnuthElementsForSpaceAfter(returnList, alignment);
@@ -398,6 +360,49 @@
         return returnList;
     }
 
+    private KnuthBox refactoredBecauseOfDuplicateCode(double contentRectOffsetX,
+                                                      double contentRectOffsetY) {
+
+        MinOptMax range = MinOptMax.getInstance(relDims.ipd);
+        BlockContainerBreaker breaker = new BlockContainerBreaker(this, range);
+        breaker.doLayout(relDims.bpd, autoHeight);
+        boolean contentOverflows = breaker.isOverflow();
+        if (autoHeight) {
+            //Update content BPD now that it is known
+            int newHeight = breaker.deferredAlg.totalWidth;
+            if (blockProgressionDirectionChanges()) {
+                setContentAreaIPD(newHeight);
+            } else {
+                vpContentBPD = newHeight;
+            }
+            updateRelDims(contentRectOffsetX, contentRectOffsetY, false);
+        }
+
+        Position bcPosition = new BlockContainerPosition(this, breaker);
+        KnuthBox knuthBox = new KnuthBox(vpContentBPD, notifyPos(bcPosition), false);
+        //TODO Handle min/opt/max for block-progression-dimension
+        /* These two elements will be used to add stretchability to the above box
+    returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE,
+                           false, returnPosition, false));
+    returnList.add(new KnuthGlue(0, 1 * constantLineHeight, 0,
+                           LINE_NUMBER_ADJUSTMENT, returnPosition, false));
+    */
+
+        if (contentOverflows) {
+            BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
+                    getBlockContainerFO().getUserAgent().getEventBroadcaster());
+            boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
+            eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
+                    breaker.getOverflowAmount(), needClip(), canRecover,
+                    getBlockContainerFO().getLocator());
+        }
+        return knuthBox;
+    }
+
+    private boolean blockProgressionDirectionChanges() {
+        return getBlockContainerFO().getReferenceOrientation() % 180 != 0;
+    }
+
     /** {@inheritDoc} */
     public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
             Position restartPosition, LayoutManager restartAtLM) {
@@ -408,7 +413,7 @@
 
         autoHeight = false;
         //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
-        int maxbpd = context.getStackLimitBP().opt;
+        int maxbpd = context.getStackLimitBP().getOpt();
         int allocBPD;
         if (height.getEnum() == EN_AUTO
                 || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) {
@@ -454,7 +459,7 @@
                     getBlockContainerFO().getLocator());
         }
 
-        MinOptMax stackLimit = new MinOptMax(relDims.bpd);
+        MinOptMax stackLimit = MinOptMax.getInstance(relDims.bpd);
 
         List returnedList;
         List contentList = new LinkedList();
@@ -492,7 +497,7 @@
                 setCurrentChildLM(curLM);
 
                 childLC.copyPendingMarksFrom(context);
-                childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit));
+                childLC.setStackLimitBP(context.getStackLimitBP().minus(stackLimit));
                 childLC.setRefIPD(relDims.ipd);
                 childLC.setWritingMode(getBlockContainerFO().getWritingMode());
                 if (curLM == this.childLMs.get(0)) {
@@ -507,7 +512,7 @@
                 setCurrentChildLM(curLM);
 
                 childLC.copyPendingMarksFrom(context);
-                childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit));
+                childLC.setStackLimitBP(context.getStackLimitBP().minus(stackLimit));
                 childLC.setRefIPD(relDims.ipd);
                 childLC.setWritingMode(getBlockContainerFO().getWritingMode());
                 if (curLM == this.childLMs.get(0)) {
@@ -578,7 +583,7 @@
                 childLC = new LayoutContext(0);
                 childLC.copyPendingMarksFrom(context);
                 // curLM is a ?
-                childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit));
+                childLC.setStackLimitBP(context.getStackLimitBP().minus(stackLimit));
                 childLC.setRefIPD(relDims.ipd);
                 childLC.setWritingMode(getBlockContainerFO().getWritingMode());
                 if (curLM == this.childLMs.get(0)) {
@@ -649,41 +654,8 @@
             wrapPositionElements(contentList, returnList);
 
         } else {
-            MinOptMax range = new MinOptMax(relDims.ipd);
-            BlockContainerBreaker breaker = new BlockContainerBreaker(this, range);
-            breaker.doLayout(relDims.bpd, autoHeight);
-            boolean contentOverflows = breaker.isOverflow();
-            if (autoHeight) {
-                //Update content BPD now that it is known
-                int newHeight = breaker.deferredAlg.totalWidth;
-                boolean switchedProgressionDirection
-                    = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
-                if (switchedProgressionDirection) {
-                    setContentAreaIPD(newHeight);
-                } else {
-                    vpContentBPD = newHeight;
-                }
-                updateRelDims(contentRectOffsetX, contentRectOffsetY, false);
-            }
-
-            Position bcPosition = new BlockContainerPosition(this, breaker);
-            returnList.add(new KnuthBox(vpContentBPD, notifyPos(bcPosition), false));
-            //TODO Handle min/opt/max for block-progression-dimension
-            /* These two elements will be used to add stretchability to the above box
-            returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE,
-                                   false, returnPosition, false));
-            returnList.add(new KnuthGlue(0, 1 * constantLineHeight, 0,
-                                   LINE_NUMBER_ADJUSTMENT, returnPosition, false));
-            */
-
-            if (contentOverflows) {
-                BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
-                        getBlockContainerFO().getUserAgent().getEventBroadcaster());
-                boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
-                eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
-                        breaker.getOverflowAmount(), needClip(), canRecover,
-                        getBlockContainerFO().getLocator());
-            }
+            returnList.add(refactoredBecauseOfDuplicateCode(contentRectOffsetX,
+                    contentRectOffsetY));
         }
         addKnuthElementsForBorderPaddingAfter(returnList, true);
         addKnuthElementsForSpaceAfter(returnList, alignment);
@@ -706,8 +678,7 @@
     private List getNextKnuthElementsAbsolute(LayoutContext context, int alignment) {
         autoHeight = false;
 
-        boolean switchedProgressionDirection
-            = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
+        boolean bpDirectionChanges = blockProgressionDirectionChanges();
         Point offset = getAbsOffset();
         int allocBPD, allocIPD;
         if (height.getEnum() == EN_AUTO
@@ -720,7 +691,7 @@
                 if (isFixed()) {
                     availHeight = (int)getCurrentPV().getViewArea().getHeight();
                 } else {
-                    availHeight = context.getStackLimitBP().opt;
+                    availHeight = context.getStackLimitBP().getOpt();
                 }
                 allocBPD = availHeight;
                 allocBPD -= offset.y;
@@ -753,8 +724,8 @@
                     }
                 }
             } else {
-                allocBPD = context.getStackLimitBP().opt;
-                if (!switchedProgressionDirection) {
+                allocBPD = context.getStackLimitBP().getOpt();
+                if (!bpDirectionChanges) {
                     autoHeight = true;
                 }
             }
@@ -798,7 +769,7 @@
                     */
                     allocIPD = 0;
                 }
-                if (switchedProgressionDirection) {
+                if (bpDirectionChanges) {
                     autoHeight = true;
                 }
             }
@@ -812,14 +783,14 @@
 
         updateRelDims(0, 0, autoHeight);
 
-        MinOptMax range = new MinOptMax(relDims.ipd);
+        MinOptMax range = MinOptMax.getInstance(relDims.ipd);
         BlockContainerBreaker breaker = new BlockContainerBreaker(this, range);
         breaker.doLayout((autoHeight ? 0 : relDims.bpd), autoHeight);
         boolean contentOverflows = breaker.isOverflow();
         if (autoHeight) {
             //Update content BPD now that it is known
             int newHeight = breaker.deferredAlg.totalWidth;
-            if (switchedProgressionDirection) {
+            if (bpDirectionChanges) {
                 setContentAreaIPD(newHeight);
             } else {
                 vpContentBPD = newHeight;
@@ -928,7 +899,7 @@
 
         protected LayoutContext createLayoutContext() {
             LayoutContext lc = super.createLayoutContext();
-            lc.setRefIPD(ipd.opt);
+            lc.setRefIPD(ipd.getOpt());
             lc.setWritingMode(getBlockContainerFO().getWritingMode());
             return lc;
         }
@@ -1026,7 +997,7 @@
         // if this will create the first block area in a page
         // and display-align is bottom or center, add space before
         if (layoutContext.getSpaceBefore() > 0) {
-            addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
+            addBlockSpacing(0.0, MinOptMax.getInstance(layoutContext.getSpaceBefore()));
         }
 
         LayoutManager childLM;
@@ -1150,20 +1121,20 @@
                     foBlockSpaceAfter = new SpaceVal(getBlockContainerFO()
                                 .getCommonMarginBlock().spaceAfter, this).getSpace();
                     adjustedSpaceBefore = (neededUnits(splitLength
-                            + foBlockSpaceBefore.min
-                            + foBlockSpaceAfter.min)
+                            + foBlockSpaceBefore.getMin()
+                            + foBlockSpaceAfter.getMin())
                             * bpUnit - splitLength) / 2;
                     adjustedSpaceAfter = neededUnits(splitLength
-                            + foBlockSpaceBefore.min
-                            + foBlockSpaceAfter.min)
+                            + foBlockSpaceBefore.getMin()
+                            + foBlockSpaceAfter.getMin())
                             * bpUnit - splitLength - adjustedSpaceBefore;
                 } else if (bSpaceBefore) {
                     adjustedSpaceBefore = neededUnits(splitLength
-                            + foBlockSpaceBefore.min)
+                            + foBlockSpaceBefore.getMin())
                             * bpUnit - splitLength;
                 } else {
                     adjustedSpaceAfter = neededUnits(splitLength
-                            + foBlockSpaceAfter.min)
+                            + foBlockSpaceAfter.getMin())
                             * bpUnit - splitLength;
                 }
                 //log.debug("space before = " + adjustedSpaceBefore
@@ -1209,8 +1180,7 @@
      */
     public Area getParentArea(Area childArea) {
         if (referenceArea == null) {
-            boolean switchedProgressionDirection
-                = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
+            boolean switchedProgressionDirection = blockProgressionDirectionChanges();
             boolean allowBPDUpdate = autoHeight && !switchedProgressionDirection;
 
             viewportBlockArea = new BlockViewport(allowBPDUpdate);
@@ -1270,7 +1240,7 @@
 
             // Set up dimensions
             // Must get dimensions from parent area
-            /*Area parentArea =*/ parentLM.getParentArea(referenceArea);
+            /*Area parentArea =*/ parentLayoutManager.getParentArea(referenceArea);
             //int referenceIPD = parentArea.getIPD();
             referenceArea.setIPD(relDims.ipd);
             // Get reference IPD from parentArea

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -241,7 +241,7 @@
         // if this will create the first block area in a page
         // and display-align is after or center, add space before
         if (layoutContext.getSpaceBefore() > 0) {
-            addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
+            addBlockSpacing(0.0, MinOptMax.getInstance(layoutContext.getSpaceBefore()));
         }
 
         LayoutManager childLM;
@@ -356,20 +356,20 @@
                 foSpaceAfter = new SpaceVal(getBlockFO()
                                     .getCommonMarginBlock().spaceAfter, this).getSpace();
                 adjustedSpaceBefore = (neededUnits(splitLength
-                        + foSpaceBefore.min
-                        + foSpaceAfter.min)
+                        + foSpaceBefore.getMin()
+                        + foSpaceAfter.getMin())
                         * bpUnit - splitLength) / 2;
                 adjustedSpaceAfter = neededUnits(splitLength
-                        + foSpaceBefore.min
-                        + foSpaceAfter.min)
+                        + foSpaceBefore.getMin()
+                        + foSpaceAfter.getMin())
                         * bpUnit - splitLength - adjustedSpaceBefore;
                 } else if (spaceBefore) {
                 adjustedSpaceBefore = neededUnits(splitLength
-                        + foSpaceBefore.min)
+                        + foSpaceBefore.getMin())
                         * bpUnit - splitLength;
                 } else {
                 adjustedSpaceAfter = neededUnits(splitLength
-                        + foSpaceAfter.min)
+                        + foSpaceAfter.getMin())
                         * bpUnit - splitLength;
                 }
             //log.debug("spazio prima = " + adjustedSpaceBefore
@@ -426,7 +426,7 @@
 
             // Must get dimensions from parent area
             //Don't optimize this line away. It can have ugly side-effects.
-            /*Area parentArea =*/ parentLM.getParentArea(curBlockArea);
+            /*Area parentArea =*/ parentLayoutManager.getParentArea(curBlockArea);
 
             // set traits
             TraitSetter.setProducerID(curBlockArea, getBlockFO().getId());

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -26,17 +26,6 @@
  */
 public interface BlockLevelLayoutManager extends LayoutManager {
 
-    /** Adjustment class: no adjustment */
-    int NO_ADJUSTMENT = -1;
-    /** Adjustment class: adjustment for space-before */
-    int SPACE_BEFORE_ADJUSTMENT = 0;
-    /** Adjustment class: adjustment for space-after */
-    int SPACE_AFTER_ADJUSTMENT = 1;
-    /** Adjustment class: adjustment for number of lines */
-    int LINE_NUMBER_ADJUSTMENT = 2;
-    /** Adjustment class: adjustment for line height */
-    int LINE_HEIGHT_ADJUSTMENT = 3;
-
     int negotiateBPDAdjustment(int adj, KnuthElement lastElement);
 
     void discardSpace(KnuthGlue spaceGlue);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -128,7 +128,7 @@
         if (sp != 0) {
             Block spacer = new Block();
             spacer.setBPD(sp);
-            parentLM.addChildArea(spacer);
+            parentLayoutManager.addChildArea(spacer);
         }
     }
 
@@ -177,7 +177,7 @@
      */
     protected void flush() {
         if (getCurrentArea() != null) {
-            parentLM.addChildArea(getCurrentArea());
+            parentLayoutManager.addChildArea(getCurrentArea());
         }
     }
 
@@ -654,7 +654,8 @@
 
         if (innerPosition == null && lastElement.isGlue()) {
             // this adjustment applies to space-before or space-after of this block
-            if (((KnuthGlue) lastElement).getAdjustmentClass() == SPACE_BEFORE_ADJUSTMENT) {
+            if (((KnuthGlue) lastElement).getAdjustmentClass()
+                    == Adjustment.SPACE_BEFORE_ADJUSTMENT) {
                 // this adjustment applies to space-before
                 adjustedSpaceBefore += adj;
 /*LF*/          //log.debug("  BLM.negotiateBPDAdjustment> spazio prima: " + adj);
@@ -735,14 +736,14 @@
             // if this block has block-progression-unit > 0, innerPosition can be
             // a MappingPosition
             // spaceGlue represents space before or space after of this block
-            if (spaceGlue.getAdjustmentClass() == SPACE_BEFORE_ADJUSTMENT) {
+            if (spaceGlue.getAdjustmentClass() == Adjustment.SPACE_BEFORE_ADJUSTMENT) {
                 // space-before must be discarded
                 adjustedSpaceBefore = 0;
-                foSpaceBefore = new MinOptMax(0);
+                foSpaceBefore = MinOptMax.ZERO;
             } else {
                 // space-after must be discarded
                 adjustedSpaceAfter = 0;
-                foSpaceAfter = new MinOptMax(0);
+                foSpaceAfter = MinOptMax.ZERO;
                 //TODO Why are both cases handled in the same way?
             }
         } else {
@@ -909,10 +910,10 @@
             }
             if (bpUnit > 0) {
                 returnList.add(new KnuthGlue(0, 0, 0,
-                    SPACE_BEFORE_ADJUSTMENT, new NonLeafPosition(this, null), true));
+                    Adjustment.SPACE_BEFORE_ADJUSTMENT, new NonLeafPosition(this, null), true));
             } else {
                 returnList.add(new KnuthGlue(adjustedSpaceBefore, 0, 0,
-                    SPACE_BEFORE_ADJUSTMENT, new NonLeafPosition(this, null), true));
+                    Adjustment.SPACE_BEFORE_ADJUSTMENT, new NonLeafPosition(this, null), true));
             }
         }
 
@@ -949,12 +950,12 @@
             }
             if (bpUnit > 0) {
                 returnList.add(new KnuthGlue(0, 0, 0,
-                        SPACE_AFTER_ADJUSTMENT,
+                        Adjustment.SPACE_AFTER_ADJUSTMENT,
                         new NonLeafPosition(this, null),
                         spaceAfterIsConditional));
             } else {
                 returnList.add(new KnuthGlue(adjustedSpaceAfter, 0, 0,
-                        SPACE_AFTER_ADJUSTMENT,
+                        Adjustment.SPACE_AFTER_ADJUSTMENT,
                         new NonLeafPosition(this, null),
                         spaceAfterIsConditional));
             }
@@ -1396,8 +1397,7 @@
             bAddedBoxAfter = true;
         }
 
-        MinOptMax totalLength = new MinOptMax(0);
-        MinOptMax totalUnits = new MinOptMax(0);
+        MinOptMax totalLength = MinOptMax.ZERO;
         LinkedList newList = new LinkedList();
 
         //log.debug(" Prima scansione");
@@ -1406,11 +1406,11 @@
         while (oldListIterator.hasNext()) {
             KnuthElement element = (KnuthElement) oldListIterator.next();
             if (element.isBox()) {
-                totalLength.add(new MinOptMax(element.getWidth()));
+                totalLength = totalLength.plus(element.getWidth());
                 //log.debug("box " + element.getWidth());
             } else if (element.isGlue()) {
-                totalLength.min -= element.getShrink();
-                totalLength.max += element.getStretch();
+                totalLength = totalLength.minusMin(element.getShrink());
+                totalLength = totalLength.plusMax(element.getStretch());
                 //leafValue = ((LeafPosition) element.getPosition()).getLeafPos();
                 //log.debug("glue " + element.getWidth() + " + "
                 //    + ((KnuthGlue) element).getStretch() + " - "
@@ -1421,9 +1421,9 @@
             }
         }
         // compute the total amount of "units"
-        totalUnits = new MinOptMax(neededUnits(totalLength.min),
-                                   neededUnits(totalLength.opt),
-                                   neededUnits(totalLength.max));
+        MinOptMax totalUnits = MinOptMax.getInstance(neededUnits(totalLength.getMin()),
+                                   neededUnits(totalLength.getOpt()),
+                                   neededUnits(totalLength.getMax()));
         //log.debug(" totalLength= " + totalLength);
         //log.debug(" unita'= " + totalUnits);
 
@@ -1432,35 +1432,35 @@
         // in order to compute partial min, opt and max length
         // and create the new elements
         oldListIterator = oldList.listIterator();
-        boolean bPrevIsBox = false;
-        MinOptMax lengthBeforeBreak = new MinOptMax(0);
-        MinOptMax lengthAfterBreak = (MinOptMax) totalLength.clone();
+        boolean prevIsBox;
+        MinOptMax lengthBeforeBreak = MinOptMax.ZERO;
+        MinOptMax lengthAfterBreak = totalLength;
         MinOptMax unitsBeforeBreak;
         MinOptMax unitsAfterBreak;
-        MinOptMax unsuppressibleUnits = new MinOptMax(0);
+        MinOptMax unsuppressibleUnits = MinOptMax.ZERO;
         int firstIndex = 0;
         int lastIndex = -1;
         while (oldListIterator.hasNext()) {
             KnuthElement element = (KnuthElement) oldListIterator.next();
             lastIndex++;
             if (element.isBox()) {
-                lengthBeforeBreak.add(new MinOptMax(element.getWidth()));
-                lengthAfterBreak.subtract(new MinOptMax(element.getWidth()));
-                bPrevIsBox = true;
+                lengthBeforeBreak = lengthBeforeBreak.plus(element.getWidth());
+                lengthAfterBreak = lengthAfterBreak.minus(element.getWidth());
+                prevIsBox = true;
             } else if (element.isGlue()) {
-                lengthBeforeBreak.min -= element.getShrink();
-                lengthAfterBreak.min += element.getShrink();
-                lengthBeforeBreak.max += element.getStretch();
-                lengthAfterBreak.max -= element.getStretch();
-                bPrevIsBox = false;
+                lengthBeforeBreak = lengthBeforeBreak.minusMin(element.getShrink());
+                lengthAfterBreak = lengthAfterBreak.plusMin(element.getShrink());
+                lengthBeforeBreak = lengthBeforeBreak.plusMax(element.getStretch());
+                lengthAfterBreak = lengthAfterBreak.minusMax(element.getStretch());
+                prevIsBox = false;
             } else {
-                lengthBeforeBreak.add(new MinOptMax(element.getWidth()));
-                bPrevIsBox = false;
+                lengthBeforeBreak = lengthBeforeBreak.plus(element.getWidth());
+                prevIsBox = false;
             }
 
             // create the new elements
             if (element.isPenalty() && element.getPenalty() < KnuthElement.INFINITE
-                    || element.isGlue() && bPrevIsBox
+                    || element.isGlue() && prevIsBox
                     || !oldListIterator.hasNext()) {
                 // suppress elements after the breaking point
                 int iStepsForward = 0;
@@ -1469,8 +1469,8 @@
                     iStepsForward++;
                     if (el.isGlue()) {
                         // suppressed glue
-                        lengthAfterBreak.min += el.getShrink();
-                        lengthAfterBreak.max -= el.getStretch();
+                        lengthAfterBreak = lengthAfterBreak.plusMin(el.getShrink());
+                        lengthAfterBreak = lengthAfterBreak.minusMax(el.getStretch());
                     } else if (el.isPenalty()) {
                         // suppressed penalty, do nothing
                     } else {
@@ -1479,36 +1479,37 @@
                     }
                 }
                 // compute the partial amount of "units" before and after the break
-                unitsBeforeBreak = new MinOptMax(neededUnits(lengthBeforeBreak.min),
-                                                 neededUnits(lengthBeforeBreak.opt),
-                                                 neededUnits(lengthBeforeBreak.max));
-                unitsAfterBreak = new MinOptMax(neededUnits(lengthAfterBreak.min),
-                                                neededUnits(lengthAfterBreak.opt),
-                                                neededUnits(lengthAfterBreak.max));
+                unitsBeforeBreak = MinOptMax.getInstance(neededUnits(lengthBeforeBreak.getMin()),
+                                                 neededUnits(lengthBeforeBreak.getOpt()),
+                                                 neededUnits(lengthBeforeBreak.getMax()));
+                unitsAfterBreak = MinOptMax.getInstance(neededUnits(lengthAfterBreak.getMin()),
+                                                neededUnits(lengthAfterBreak.getOpt()),
+                                                neededUnits(lengthAfterBreak.getMax()));
 
                 // rewind the iterator and lengthAfterBreak
                 for (int i = 0; i < iStepsForward; i++) {
                     KnuthElement el = (KnuthElement) oldListIterator.previous();
                     if (el.isGlue()) {
-                        lengthAfterBreak.min -= el.getShrink();
-                        lengthAfterBreak.max += el.getStretch();
+                        lengthAfterBreak = lengthAfterBreak.minusMin(el.getShrink());
+                        lengthAfterBreak = lengthAfterBreak.plusMax(el.getStretch());
                     }
                 }
 
                 // compute changes in length, stretch and shrink
-                int uLengthChange = unitsBeforeBreak.opt + unitsAfterBreak.opt - totalUnits.opt;
-                int uStretchChange = (unitsBeforeBreak.max + unitsAfterBreak.max - totalUnits.max)
-                    - (unitsBeforeBreak.opt + unitsAfterBreak.opt - totalUnits.opt);
-                int uShrinkChange = (unitsBeforeBreak.opt + unitsAfterBreak.opt - totalUnits.opt)
-                    - (unitsBeforeBreak.min + unitsAfterBreak.min - totalUnits.min);
+                int uLengthChange = unitsBeforeBreak.getOpt() + unitsAfterBreak.getOpt()
+                        - totalUnits.getOpt();
+                int uStretchChange = unitsBeforeBreak.getStretch()
+                        + unitsAfterBreak.getStretch() - totalUnits.getStretch();
+                int uShrinkChange = unitsBeforeBreak.getShrink()
+                        + unitsAfterBreak.getShrink() - totalUnits.getShrink();
 
                 // compute the number of normal, stretch and shrink unit
                 // that must be added to the new sequence
-                int uNewNormal = unitsBeforeBreak.opt - unsuppressibleUnits.opt;
-                int uNewStretch = (unitsBeforeBreak.max - unitsBeforeBreak.opt)
-                                  - (unsuppressibleUnits.max - unsuppressibleUnits.opt);
-                int uNewShrink = (unitsBeforeBreak.opt - unitsBeforeBreak.min)
-                                 - (unsuppressibleUnits.opt - unsuppressibleUnits.min);
+                int uNewNormal = unitsBeforeBreak.getOpt() - unsuppressibleUnits.getOpt();
+                int uNewStretch = unitsBeforeBreak.getStretch()
+                        - unsuppressibleUnits.getStretch();
+                int uNewShrink = unitsBeforeBreak.getShrink()
+                        - unsuppressibleUnits.getShrink();
 
                 //log.debug("("
                 //    + unsuppressibleUnits.min + "-" + unsuppressibleUnits.opt + "-"
@@ -1539,10 +1540,8 @@
                                                                  lastIndex - lastIndexCorrection);
 
                 // new box
-                newList.add(new KnuthBox((uNewNormal - uLengthChange) * bpUnit,
-                                         mappingPos,
-                                         false));
-                unsuppressibleUnits.add(new MinOptMax(uNewNormal - uLengthChange));
+                newList.add(new KnuthBox((uNewNormal - uLengthChange) * bpUnit, mappingPos, false));
+                unsuppressibleUnits = unsuppressibleUnits.plus(uNewNormal - uLengthChange);
                 //log.debug("        box " + (uNewNormal - uLengthChange));
 
                 // new infinite penalty, glue and box, if necessary
@@ -1558,17 +1557,15 @@
                     newList.add(new KnuthGlue(0,
                                               iStretchUnits * bpUnit,
                                               iShrinkUnits * bpUnit,
-                                              LINE_NUMBER_ADJUSTMENT,
+                                              Adjustment.LINE_NUMBER_ADJUSTMENT,
                                               mappingPos,
                                               false));
                     //log.debug("        PENALTY");
                     //log.debug("        glue 0 " + iStretchUnits + " " + iShrinkUnits);
-                    unsuppressibleUnits.max += iStretchUnits;
-                    unsuppressibleUnits.min -= iShrinkUnits;
+                    unsuppressibleUnits = unsuppressibleUnits.plusMax(iStretchUnits);
+                    unsuppressibleUnits = unsuppressibleUnits.minusMin(iShrinkUnits);
                     if (!oldListIterator.hasNext()) {
-                        newList.add(new KnuthBox(0,
-                                                 mappingPos,
-                                                 false));
+                        newList.add(new KnuthBox(0, mappingPos, false));
                         //log.debug("        box 0");
                     }
                 }
@@ -1583,7 +1580,7 @@
                     newList.add(new KnuthGlue(0,
                                               uStretchChange * bpUnit,
                                               uShrinkChange * bpUnit,
-                                              LINE_NUMBER_ADJUSTMENT,
+                                              Adjustment.LINE_NUMBER_ADJUSTMENT,
                                               mappingPos,
                                               false));
                     newList.add(new KnuthPenalty(uLengthChange * bpUnit,
@@ -1591,7 +1588,7 @@
                     newList.add(new KnuthGlue(0,
                                               -uStretchChange * bpUnit,
                                               -uShrinkChange * bpUnit,
-                                              LINE_NUMBER_ADJUSTMENT,
+                                              Adjustment.LINE_NUMBER_ADJUSTMENT,
                                               mappingPos,
                                               false));
                     //log.debug("        PENALTY");
@@ -1612,7 +1609,7 @@
             }
 
             if (element.isPenalty()) {
-                lengthBeforeBreak.add(new MinOptMax(-element.getWidth()));
+                lengthBeforeBreak = lengthBeforeBreak.minus(element.getWidth());
             }
 
         }
@@ -1637,13 +1634,13 @@
             KnuthBox wrongBox = (KnuthBox) newList.removeFirst();
             // if this paragraph is at the top of a page, the space before
             // must be ignored; compute the length change
-            int decreasedLength = (neededUnits(totalLength.opt)
-                                   - neededUnits(totalLength.opt - adjustedSpaceBefore))
+            int decreasedLength = (neededUnits(totalLength.getOpt())
+                                   - neededUnits(totalLength.getOpt() - adjustedSpaceBefore))
                                   * bpUnit;
             // insert the correct elements
             newList.addFirst(new KnuthBox(wrongBox.getWidth() - decreasedLength,
                                           wrongBox.getPosition(), false));
-            newList.addFirst(new KnuthGlue(decreasedLength, 0, 0, SPACE_BEFORE_ADJUSTMENT,
+            newList.addFirst(new KnuthGlue(decreasedLength, 0, 0, Adjustment.SPACE_BEFORE_ADJUSTMENT,
                                            wrongBox.getPosition(), false));
             //log.debug("        rimosso box " + neededUnits(wrongBox.getWidth()));
             //log.debug("        aggiunto glue " + neededUnits(decreasedLength) + " 0 0");
@@ -1673,8 +1670,8 @@
 
             // if this paragraph is at the bottom of a page, the space after
             // must be ignored; compute the length change
-            int decreasedLength = (neededUnits(totalLength.opt)
-                                   - neededUnits(totalLength.opt - adjustedSpaceAfter))
+            int decreasedLength = (neededUnits(totalLength.getOpt())
+                                   - neededUnits(totalLength.getOpt() - adjustedSpaceAfter))
                                   * bpUnit;
             // insert the correct box
             newList.addLast(new KnuthBox(wrongBox.getWidth() - decreasedLength,
@@ -1684,7 +1681,7 @@
                 newList.addAll(preserveList);
             }
             // insert the correct glue
-            newList.addLast(new KnuthGlue(decreasedLength, 0, 0, SPACE_AFTER_ADJUSTMENT,
+            newList.addLast(new KnuthGlue(decreasedLength, 0, 0, Adjustment.SPACE_AFTER_ADJUSTMENT,
                                           wrongBox.getPosition(), false));
             //log.debug("        rimosso box " + neededUnits(wrongBox.getWidth()));
             //log.debug("        aggiunto box " + neededUnits(
@@ -1773,8 +1770,7 @@
      */
     protected void wrapPositionElement(ListElement el, List targetList, boolean force) {
         if (force || el.getLayoutManager() != this) {
-            el.setPosition(notifyPos(new NonLeafPosition(this,
-                    el.getPosition())));
+            el.setPosition(notifyPos(new NonLeafPosition(this, el.getPosition())));
         }
         targetList.add(el);
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BorderOrPaddingElement.java Tue Dec 22 17:20:51 2009
@@ -41,7 +41,7 @@
             RelSide side,
             boolean isFirst, boolean isLast, PercentBaseContext context) {
         super(position,
-                new MinOptMax(condLength.getLength().getValue(context)), side,
+                MinOptMax.getInstance(condLength.getLength().getValue(context)), side,
                         condLength.isDiscard(), isFirst, isLast);
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java Tue Dec 22 17:20:51 2009
@@ -43,7 +43,7 @@
      * @return true if the opt constraint is bigger than the list contents
      */
     public static boolean removeLegalBreaks(List elements, MinOptMax constraint) {
-        return removeLegalBreaks(elements, constraint.opt);
+        return removeLegalBreaks(elements, constraint.getOpt());
     }
 
     /**
@@ -132,7 +132,7 @@
                     }
                 } else if (el instanceof UnresolvedListElementWithLength) {
                     UnresolvedListElementWithLength uel = (UnresolvedListElementWithLength)el;
-                    len += uel.getLength().opt;
+                    len += uel.getLength().getOpt();
                 }
             } else {
                 KnuthElement kel = (KnuthElement)el;
@@ -240,4 +240,4 @@
         return prevBreak;
     }
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -83,7 +83,7 @@
     /** {@inheritDoc} */
     public void addChildArea(Area childArea) {
         childArea.setAreaClass(Area.CLASS_FOOTNOTE);
-        parentLM.addChildArea(childArea);
+        parentLayoutManager.addChildArea(childArea);
     }
 
     /** @return the FootnoteBody node */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java Tue Dec 22 17:20:51 2009
@@ -41,30 +41,32 @@
 
     /**
      * Creates a new box.
-     * @param w block progression dimension of this box
-     * @param range min, opt, max inline progression dimension of this box
-     * @param bpdim natural width of the line represented by this box.
-     * @param pos the Position stored in this box
-     * @param bAux is this box auxiliary?
-     */
-    public KnuthBlockBox(int w, MinOptMax range, int bpdim, Position pos, boolean bAux) {
-        super(w, pos, bAux);
-        ipdRange = (MinOptMax) range.clone();
+     *
+     * @param width     block progression dimension of this box
+     * @param range     min, opt, max inline progression dimension of this box
+     * @param bpdim     natural width of the line represented by this box.
+     * @param pos       the Position stored in this box
+     * @param auxiliary is this box auxiliary?
+     */
+    public KnuthBlockBox(int width, MinOptMax range, int bpdim, Position pos, boolean auxiliary) {
+        super(width, pos, auxiliary);
+        ipdRange = range;
         bpd = bpdim;
         footnoteList = new LinkedList();
     }
 
     /**
      * Creates a new box.
-     * @param w block progression dimension of this box
-     * @param list footnotes cited by elements in this box. The list contains the
-     * corresponding FootnoteBodyLayoutManagers
-     * @param pos the Position stored in this box
-     * @param bAux is this box auxiliary?
-     */
-    public KnuthBlockBox(int w, List list, Position pos, boolean bAux) {
-        super(w, pos, bAux);
-        ipdRange = new MinOptMax(0);
+     *
+     * @param width     block progression dimension of this box
+     * @param list      footnotes cited by elements in this box. The list contains the corresponding
+     *                  FootnoteBodyLayoutManagers
+     * @param pos       the Position stored in this box
+     * @param auxiliary is this box auxiliary?
+     */
+    public KnuthBlockBox(int width, List list, Position pos, boolean auxiliary) {
+        super(width, pos, auxiliary);
+        ipdRange = MinOptMax.ZERO;
         bpd = 0;
         footnoteList = new LinkedList(list);
     }
@@ -85,6 +87,7 @@
 
     /**
      * Adds the given list of Knuth elements to this box' list of elements.
+     *
      * @param list elements corresponding to a footnote body
      */
     public void addElementList(List list) {
@@ -96,8 +99,8 @@
 
     /**
      * Returns the list of Knuth sequences registered by this box.
-     * @return a list of KnuthElement sequences corresponding to footnotes cited in this
-     * box
+     *
+     * @return a list of KnuthElement sequences corresponding to footnotes cited in this box
      */
     public List getElementLists() {
         return elementLists;
@@ -107,12 +110,13 @@
      * @return the inline progression dimension of this box.
      */
     public MinOptMax getIPDRange() {
-        return (MinOptMax) ipdRange.clone();
+        return ipdRange;
     }
 
     /**
-     * Returns the natural width (without stretching nor shrinking) of the line
-     * represented by this box.
+     * Returns the natural width (without stretching nor shrinking) of the line represented by this
+     * box.
+     *
      * @return the line width
      */
     public int getBPD() {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBox.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBox.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBox.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBox.java Tue Dec 22 17:20:51 2009
@@ -35,7 +35,7 @@
 public class KnuthBox extends KnuthElement {
 
     /**
-     * Create a new KnuthBox.
+     * Creates a new <code>KnuthBox</code>.
      *
      * @param width    the width of this box
      * @param pos  the Position stored in this box

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthElement.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthElement.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthElement.java Tue Dec 22 17:20:51 2009
@@ -36,8 +36,7 @@
     private boolean auxiliary;
 
     /**
-     * Create a new KnuthElement.
-     * This class being abstract, this can be called only by subclasses.
+     * Creates a new <code>KnuthElement</code>.
      *
      * @param width    the width of this element
      * @param pos  the Position stored in this element

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthGlue.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthGlue.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthGlue.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthGlue.java Tue Dec 22 17:20:51 2009
@@ -19,6 +19,8 @@
 
 package org.apache.fop.layoutmgr;
 
+import org.apache.fop.traits.MinOptMax;
+
 /**
  * An instance of this class represents a piece of content with adjustable
  * width: for example a space between words of justified text.
@@ -47,31 +49,49 @@
  */
 public class KnuthGlue extends KnuthElement {
 
-    private int stretchability;
-    private int shrinkability;
-    private int adjustmentClass = -1;
+    private final int stretch;
+    private final int shrink;
+    private final Adjustment adjustmentClass;
+
+    /**
+     * Creates a new <code>KnuthGlue</code>.
+     *
+     * @param minOptMax a <code>MinOptMax</code> where the {@link MinOptMax#getOpt() opt-value} is
+     *                  mapped to the width, the {@link MinOptMax#getStretch()
+     *                  stretchability} is mapped to the stretchability and the the {@link
+     *                  MinOptMax#getShrink() shrinkability} is mapped to the shrinkability
+     * @param pos       the Position stored in this glue
+     * @param auxiliary is this glue auxiliary?
+     */
+    public KnuthGlue(MinOptMax minOptMax, Position pos, boolean auxiliary) {
+        super(minOptMax.getOpt(), pos, auxiliary);
+        this.stretch = minOptMax.getStretch();
+        this.shrink = minOptMax.getShrink();
+        this.adjustmentClass = Adjustment.NO_ADJUSTMENT;
+    }
 
     /**
-     * Create a new KnuthGlue.
+     * Creates a new <code>KnuthGlue</code>.
      *
-     * @param width the width of this glue
-     * @param stretchability the stretchability of this glue
-     * @param shrinkability the shrinkability of this glue
-     * @param pos the Position stored in this glue
+     * @param width     the width of this glue
+     * @param stretch   the stretchability of this glue
+     * @param shrink    the shrinkability of this glue
+     * @param pos       the Position stored in this glue
      * @param auxiliary is this glue auxiliary?
      */
-    public KnuthGlue(int width, int stretchability, int shrinkability, Position pos,
+    public KnuthGlue(int width, int stretch, int shrink, Position pos,
                      boolean auxiliary) {
         super(width, pos, auxiliary);
-        this.stretchability = stretchability;
-        this.shrinkability = shrinkability;
+        this.stretch = stretch;
+        this.shrink = shrink;
+        this.adjustmentClass = Adjustment.NO_ADJUSTMENT;
     }
 
-    public KnuthGlue(int width, int stretchability, int shrinkability, int adjustmentClass,
+    public KnuthGlue(int width, int stretch, int shrink, Adjustment adjustmentClass,
                      Position pos, boolean auxiliary) {
         super(width, pos, auxiliary);
-        this.stretchability = stretchability;
-        this.shrinkability = shrinkability;
+        this.stretch = stretch;
+        this.shrink = shrink;
         this.adjustmentClass = adjustmentClass;
     }
 
@@ -82,16 +102,16 @@
 
     /** @return the stretchability of this glue. */
     public int getStretch() {
-        return stretchability;
+        return stretch;
     }
 
     /** @return the shrinkability of this glue. */
     public int getShrink() {
-        return shrinkability;
+        return shrink;
     }
 
     /** @return the adjustment class (or role) of this glue. */
-    public int getAdjustmentClass() {
+    public Adjustment getAdjustmentClass() {
         return adjustmentClass;
     }
 
@@ -105,7 +125,7 @@
         buffer.append(" w=").append(getWidth());
         buffer.append(" stretch=").append(getStretch());
         buffer.append(" shrink=").append(getShrink());
-        if (getAdjustmentClass() >= 0) {
+        if (!getAdjustmentClass().equals(Adjustment.NO_ADJUSTMENT)) {
             buffer.append(" adj-class=").append(getAdjustmentClass());
         }
         return buffer.toString();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java Tue Dec 22 17:20:51 2009
@@ -173,7 +173,7 @@
     public LayoutContext(int flags) {
         this.flags = flags;
         this.refIPD = 0;
-        stackLimitBP = new MinOptMax(0);
+        stackLimitBP = MinOptMax.ZERO;
         leadingSpace = null;
         trailingSpace = null;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LeafPosition.java Tue Dec 22 17:20:51 2009
@@ -23,8 +23,8 @@
 
     private int leafPos;
 
-    public LeafPosition(LayoutManager lm, int pos) {
-        super(lm);
+    public LeafPosition(LayoutManager layoutManager, int pos) {
+        super(layoutManager);
         leafPos = pos;
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java Tue Dec 22 17:20:51 2009
@@ -19,7 +19,6 @@
 
 package org.apache.fop.layoutmgr;
 
-import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 
@@ -204,7 +203,7 @@
                         pslm, footnoteSeparator, separatorArea);
             footnoteSeparatorLM.doLayout();
 
-            footnoteSeparatorLength = new MinOptMax(separatorArea.getBPD());
+            footnoteSeparatorLength = MinOptMax.getInstance(separatorArea.getBPD());
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java Tue Dec 22 17:20:51 2009
@@ -116,7 +116,7 @@
         this.pageProvider = pageProvider;
         this.layoutListener = layoutListener;
         best = new BestPageRecords();
-        this.footnoteSeparatorLength = (MinOptMax) footnoteSeparatorLength.clone();
+        this.footnoteSeparatorLength = footnoteSeparatorLength;
         this.autoHeight = autoHeight;
         this.favorSinglePart = favorSinglePart;
     }
@@ -483,7 +483,7 @@
             if (allFootnotes > 0) {
                 // this page contains some footnote citations
                 // add the footnote separator width
-                actualWidth += footnoteSeparatorLength.opt;
+                actualWidth += footnoteSeparatorLength.getOpt();
                 if (actualWidth + allFootnotes <= getLineWidth(activeNode.line)) {
                     // there is enough space to insert all footnotes:
                     // add the whole allFootnotes length
@@ -757,7 +757,7 @@
             int maxAdjustment = totalStretch - activeNode.totalStretch;
             // add the footnote separator stretch if some footnote content will be added
             if (((KnuthPageNode) activeNode).totalFootnotes < totalFootnotesLength) {
-                maxAdjustment += footnoteSeparatorLength.max - footnoteSeparatorLength.opt;
+                maxAdjustment += footnoteSeparatorLength.getStretch();
             }
             if (maxAdjustment > 0) {
                 return (double) difference / maxAdjustment;
@@ -768,7 +768,7 @@
             int maxAdjustment = totalShrink - activeNode.totalShrink;
             // add the footnote separator shrink if some footnote content will be added
             if (((KnuthPageNode) activeNode).totalFootnotes < totalFootnotesLength) {
-                maxAdjustment += footnoteSeparatorLength.opt - footnoteSeparatorLength.min;
+                maxAdjustment += footnoteSeparatorLength.getShrink();
             }
             if (maxAdjustment > 0) {
                 return (double) difference / maxAdjustment;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceElement.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceElement.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceElement.java Tue Dec 22 17:20:51 2009
@@ -40,13 +40,10 @@
      * @param isLast true if this is a space-after of the last area generated.
      * @param context the property evaluation context
      */
-    public SpaceElement(Position position, SpaceProperty space, RelSide side,
-            boolean isFirst, boolean isLast,
-            PercentBaseContext context) {
-        super(position,
-                MinOptMaxUtil.toMinOptMax(
-                        space.getSpace().getLengthRange(),
-                context), side, space.isDiscard(), isFirst, isLast);
+    public SpaceElement(Position position, SpaceProperty space, RelSide side, boolean isFirst,
+                        boolean isLast, PercentBaseContext context) {
+        super(position, space.getSpace().getLengthRange().toMinOptMax(context), side,
+                space.isDiscard(), isFirst, isLast);
         int en = space.getSpace().getPrecedence().getEnum();
         if (en == Constants.EN_FORCE) {
             this.precedence = Integer.MAX_VALUE;



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