bckfnn      2004/10/19 13:13:23

  Modified:    src/java/org/apache/fop/traits SpaceVal.java
  Log:
  Third phase of performance improvement.
  - Added factory methods to create letter and word SpaceVal.
  
  PR: 31699
  
  Revision  Changes    Path
  1.8       +25 -0     xml-fop/src/java/org/apache/fop/traits/SpaceVal.java
  
  Index: SpaceVal.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/traits/SpaceVal.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SpaceVal.java     27 Feb 2004 17:56:25 -0000      1.7
  +++ SpaceVal.java     19 Oct 2004 20:13:23 -0000      1.8
  @@ -21,6 +21,7 @@
   import org.apache.fop.fo.Constants;
   import org.apache.fop.fo.properties.Property;
   import org.apache.fop.fo.properties.SpaceProperty;
  +import org.apache.fop.fonts.Font;
   
   /**
    * Store a single Space property value in simplified form, with all
  @@ -66,6 +67,30 @@
           this.bConditional = bConditional;
           this.bForcing = bForcing;
           this.iPrecedence = iPrecedence;
  +    }
  +
  +    static public SpaceVal makeWordSpacing(Property wordSpacing, SpaceVal 
letterSpacing, Font fs) {
  +        if (wordSpacing.getEnum() == Constants.NORMAL) {
  +            // give word spaces the possibility to shrink by a third,
  +            // and stretch by a half;
  +            int spaceCharIPD = fs.getCharWidth(' ');
  +            MinOptMax space = new MinOptMax(-spaceCharIPD / 3, 0, spaceCharIPD / 2);
  +            return new SpaceVal(
  +                    MinOptMax.add
  +                     (space, MinOptMax.multiply(letterSpacing.getSpace(), 2)),
  +                     true, true, 0);
  +        } else {
  +            return new SpaceVal(wordSpacing.getSpace());
  +        }        
  +    }
  +
  +    static public SpaceVal makeLetterSpacing(Property letterSpacing) {
  +        if (letterSpacing.getEnum() == Constants.NORMAL) {
  +            // letter spaces are set to zero (or use different values?)
  +            return new SpaceVal(new MinOptMax(0), true, true, 0);
  +        } else {
  +            return new SpaceVal(letterSpacing.getSpace());
  +        }
       }
   
       /**
  
  
  

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

Reply via email to