xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr KnuthPenalty.java
Date Wed, 22 Jun 2005 14:56:23 GMT
jeremias    2005/06/22 07:56:23

  Modified:    src/java/org/apache/fop/layoutmgr KnuthPenalty.java
  Log:
  Support late setting of break class.
  Slightly improved toString().
  Javadocs.
  
  Revision  Changes    Path
  1.7       +43 -5     xml-fop/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java
  
  Index: KnuthPenalty.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/KnuthPenalty.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- KnuthPenalty.java	24 May 2005 09:36:52 -0000	1.6
  +++ KnuthPenalty.java	22 Jun 2005 14:56:23 -0000	1.7
  @@ -18,6 +18,8 @@
   
   package org.apache.fop.layoutmgr;
   
  +import org.apache.fop.fo.Constants;
  +
   /**
    * An instance of this class represents information about a feasible
    * breaking point; it does not represent any piece of content.
  @@ -38,6 +40,7 @@
    */
   public class KnuthPenalty extends KnuthElement {
   
  +    /** Used for flagged penalties. See Knuth algorithm. */
       public static final int FLAGGED_PENALTY = 50;
   
       private int penalty;
  @@ -59,6 +62,16 @@
           bFlagged = f;
       }
   
  +    /**
  +     * Create a new KnuthPenalty.
  +     *
  +     * @param w the width of this penalty
  +     * @param p the penalty value of this penalty
  +     * @param f is this penalty flagged?
  +     * @param iBreakClass the break class of this penalty (one of the break-* constants)
  +     * @param pos the Position stored in this penalty
  +     * @param bAux is this penalty auxiliary?
  +     */
       public KnuthPenalty(int w, int p, boolean f,
               int iBreakClass, Position pos, boolean bAux) {
           super(w, pos, bAux);
  @@ -67,6 +80,7 @@
           breakClass = iBreakClass;
       }
   
  +    /** @see org.apache.fop.layoutmgr.KnuthElement#isPenalty() */
       public boolean isPenalty() {
           return true;
       }
  @@ -86,21 +100,29 @@
           this.penalty = p;
       }
       
  -    /**
  -     * Return true is this penalty is a flagged one.
  -     */
  +    /** @return true is this penalty is a flagged one. */
       public boolean isFlagged() {
           return bFlagged;
       }
   
  +    /** @see org.apache.fop.layoutmgr.KnuthElement#isForcedBreak() */
       public boolean isForcedBreak() {
           return penalty == -KnuthElement.INFINITE;
       }
       
  +    /** @return the break class of this penalty (one of the break-* constants) */
       public int getBreakClass() {
           return breakClass;
       }
       
  +    /**
  +     * Sets the break class for this penalty.
  +     * @param cl the break class (one of the break-* constants)
  +     */
  +    public void setBreakClass(int cl) {
  +        this.breakClass = cl;
  +    }
  +    
       /** @see java.lang.Object#toString() */
       public String toString() {
           StringBuffer sb = new StringBuffer(64);
  @@ -123,7 +145,23 @@
           sb.append(" w=");
           sb.append(getW());
           if (isForcedBreak()) {
  -            sb.append(" (forced break)");
  +            sb.append(" (forced break");
  +            switch (getBreakClass()) {
  +            case Constants.EN_PAGE:
  +                sb.append(", page");
  +                break;
  +            case Constants.EN_COLUMN:
  +                sb.append(", column");
  +                break;
  +            case Constants.EN_EVEN_PAGE:
  +                sb.append(", even page");
  +                break;
  +            case Constants.EN_ODD_PAGE:
  +                sb.append(", odd page");
  +                break;
  +            default:
  +            }
  +            sb.append(")");
           }
           return sb.toString();
       }
  
  
  

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


Mime
View raw message