keiron      02/04/02 03:50:58

  Modified:    src/org/apache/fop/area/inline InlineArea.java
               src/org/apache/fop/fo FObjMixed.java TextInfo.java
               src/org/apache/fop/fo/flow Block.java
                        InstreamForeignObject.java
               src/org/apache/fop/layoutmgr BlockLayoutManager.java
                        LineLayoutManager.java TextLayoutManager.java
               src/org/apache/fop/render AbstractRenderer.java
  Added:       src/org/apache/fop/layoutmgr LayoutInfo.java
  Log:
  basic vertical alignment and height for lines
  handles alignment.fo
  
  Revision  Changes    Path
  1.6       +4 -1      xml-fop/src/org/apache/fop/area/inline/InlineArea.java
  
  Index: InlineArea.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/inline/InlineArea.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InlineArea.java   21 Mar 2002 09:34:19 -0000      1.5
  +++ InlineArea.java   2 Apr 2002 11:50:58 -0000       1.6
  @@ -1,5 +1,5 @@
   /*
  - * $Id: InlineArea.java,v 1.5 2002/03/21 09:34:19 keiron Exp $
  + * $Id: InlineArea.java,v 1.6 2002/04/02 11:50:58 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -12,6 +12,8 @@
   import org.apache.fop.area.Trait;
   import org.apache.fop.render.Renderer;
   
  +import org.apache.fop.layoutmgr.LayoutInfo;
  +
   import java.util.List;
   import java.util.ArrayList;
   
  @@ -28,6 +30,7 @@
       // position within the line area, either top or baseline
       int verticalPosition;
       // width, height, vertical alignment
  +    public LayoutInfo info = null;
   
       // store properties in array list, need better solution
       ArrayList props = null;
  
  
  
  1.20      +2 -2      xml-fop/src/org/apache/fop/fo/FObjMixed.java
  
  Index: FObjMixed.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FObjMixed.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- FObjMixed.java    21 Mar 2002 09:37:14 -0000      1.19
  +++ FObjMixed.java    2 Apr 2002 11:50:58 -0000       1.20
  @@ -1,5 +1,5 @@
   /*
  - * $Id: FObjMixed.java,v 1.19 2002/03/21 09:37:14 keiron Exp $
  + * $Id: FObjMixed.java,v 1.20 2002/04/02 11:50:58 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -21,7 +21,7 @@
    */
   public class FObjMixed extends FObj {
       TextInfo textInfo = null;
  -    FontInfo fontInfo=null;
  +    protected FontInfo fontInfo=null;
   
       public FObjMixed(FONode parent) {
           super(parent);
  
  
  
  1.2       +2 -1      xml-fop/src/org/apache/fop/fo/TextInfo.java
  
  Index: TextInfo.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/TextInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TextInfo.java     21 Mar 2002 09:37:14 -0000      1.1
  +++ TextInfo.java     2 Apr 2002 11:50:58 -0000       1.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: TextInfo.java,v 1.1 2002/03/21 09:37:14 keiron Exp $
  + * $Id: TextInfo.java,v 1.2 2002/04/02 11:50:58 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources."
  @@ -28,6 +28,7 @@
           public int wrapOption;
           public int whiteSpaceCollapse;
           public int verticalAlign;
  +        public int lineHeight;
   
           // Textdecoration
           public boolean underlined = false;
  
  
  
  1.51      +5 -3      xml-fop/src/org/apache/fop/fo/flow/Block.java
  
  Index: Block.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Block.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- Block.java        21 Mar 2002 09:37:14 -0000      1.50
  +++ Block.java        2 Apr 2002 11:50:58 -0000       1.51
  @@ -1,5 +1,5 @@
   /*
  - * $Id: Block.java,v 1.50 2002/03/21 09:37:14 keiron Exp $
  + * $Id: Block.java,v 1.51 2002/04/02 11:50:58 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -16,6 +16,7 @@
   import org.apache.fop.layoutmgr.LayoutManager;
   import org.apache.fop.layoutmgr.BlockLayoutManager;
   import org.apache.fop.util.CharUtilities;
  +import org.apache.fop.apps.StreamRenderer;
   
   import org.xml.sax.Attributes;
   
  @@ -370,12 +371,13 @@
   BlockLayoutManager blm = new BlockLayoutManager(this);
   TextInfo ti = new TextInfo();
   
  -/*      try {
  +      try {
       ti.fs = propMgr.getFontState(fontInfo);
         } catch (FOPException fopex) {
       log.error("Error setting FontState for characters: " +
           fopex.getMessage());
  -      }*/
  +      }
  +            ti.lineHeight = this.lineHeight;
   
               ColorType c = getProperty("color").getColorType();
               ti.color = c;
  
  
  
  1.24      +5 -1      xml-fop/src/org/apache/fop/fo/flow/InstreamForeignObject.java
  
  Index: InstreamForeignObject.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/InstreamForeignObject.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- InstreamForeignObject.java        21 Mar 2002 09:37:15 -0000      1.23
  +++ InstreamForeignObject.java        2 Apr 2002 11:50:58 -0000       1.24
  @@ -1,5 +1,5 @@
   /*
  - * $Id: InstreamForeignObject.java,v 1.23 2002/03/21 09:37:15 keiron Exp $
  + * $Id: InstreamForeignObject.java,v 1.24 2002/04/02 11:50:58 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -24,6 +24,7 @@
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.layoutmgr.LayoutManager;
   import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
  +import org.apache.fop.layoutmgr.LayoutInfo;
   
   import org.w3c.dom.Document;
   
  @@ -136,6 +137,9 @@
           areaCurrent.setWidth((int)size.getX() * 1000);
           areaCurrent.setHeight((int)size.getY() * 1000);
           areaCurrent.setOffset(0);
  +        areaCurrent.info = new LayoutInfo();
  +        areaCurrent.info.alignment = properties.get("vertical-align").getEnum();
  +        areaCurrent.info.lead = areaCurrent.getHeight();
   
           return areaCurrent;
       }
  
  
  
  1.5       +9 -3      xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
  
  Index: BlockLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BlockLayoutManager.java   21 Mar 2002 09:37:15 -0000      1.4
  +++ BlockLayoutManager.java   2 Apr 2002 11:50:58 -0000       1.5
  @@ -1,5 +1,5 @@
   /*
  - * $Id: BlockLayoutManager.java,v 1.4 2002/03/21 09:37:15 keiron Exp $
  + * $Id: BlockLayoutManager.java,v 1.5 2002/04/02 11:50:58 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -23,12 +23,18 @@
   
       private Block curBlockArea;
   
  +    int lead = 12000;
  +    int lineHeight = 14000;
  +    int follow = 2000;
  +
       public BlockLayoutManager(FObj fobj) {
           super(fobj);
       }
   
       public void setBlockTextInfo(TextInfo ti) {
  -
  +        lead = ti.fs.getAscender();
  +        follow = ti.fs.getDescender();
  +        lineHeight = ti.lineHeight;
       }
   
       /**
  @@ -54,7 +60,7 @@
               FObj childFO = (FObj) children.next();
               if (childFO.generatesInlineAreas()) {
                   children.previous();
  -                lm = new LineLayoutManager(children);
  +                lm = new LineLayoutManager(children, lineHeight, lead, follow);
               } else {
                   lm = childFO.getLayoutManager();
               }
  
  
  
  1.5       +117 -14   xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LineLayoutManager.java    21 Mar 2002 09:37:15 -0000      1.4
  +++ LineLayoutManager.java    2 Apr 2002 11:50:58 -0000       1.5
  @@ -1,5 +1,5 @@
   /*
  - * $Id: LineLayoutManager.java,v 1.4 2002/03/21 09:37:15 keiron Exp $
  + * $Id: LineLayoutManager.java,v 1.5 2002/04/02 11:50:58 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -13,6 +13,10 @@
   import org.apache.fop.area.LineArea;
   import org.apache.fop.area.MinOptMax;
   import org.apache.fop.area.inline.InlineArea;
  +import org.apache.fop.fo.properties.VerticalAlign;
  +
  +import org.apache.fop.area.inline.Word;
  +import org.apache.fop.area.inline.Character;
   
   import java.util.ListIterator;
   import java.util.List;
  @@ -31,11 +35,18 @@
       private boolean bFirstLine;
       private LayoutManager curLM;
       private MinOptMax remainingIPD;
  -    private int lineHeight = 14000;
  +    // the following values must be set by the block
  +    // these are the dominant basline and lineheight values
  +    private int lineHeight;
  +    private int lead;
  +    private int follow;
   
  -    public LineLayoutManager(ListIterator fobjIter) {
  +    public LineLayoutManager(ListIterator fobjIter, int lh, int l, int f) {
           super(null);
           this.fobjIter = fobjIter;
  +        lineHeight = lh;
  +        lead = l;
  +        follow = f;
       }
   
       /**
  @@ -70,20 +81,112 @@
       public void flush() {
           if (lineArea != null) {
               // Adjust spacing as necessary
  -            // Calculate height, based on content (or does the Area do this?)
  -            int maxHeight = lineHeight;
  -            List inlineAreas = lineArea.getInlineAreas();
  -            for(Iterator iter = inlineAreas.iterator(); iter.hasNext(); ) {
  -                InlineArea inline = (InlineArea)iter.next();
  -                int h = inline.getHeight();
  -                if(h > maxHeight) {
  -                    maxHeight = h;
  -                }
  -            }
  -            lineArea.setHeight(maxHeight);
  +
  +            verticalAlign();
   
               parentLM.addChild(lineArea);
               lineArea = null;
  +        }
  +    }
  +
  +    private void verticalAlign() {
  +        int maxHeight = lineHeight;
  +        List inlineAreas = lineArea.getInlineAreas();
  +
  +        // get smallest possible offset to before edge
  +        // this depends on the height of no and middle alignments
  +        int before = lead;
  +        int after = follow;
  +        for(Iterator iter = inlineAreas.iterator(); iter.hasNext(); ) {
  +            InlineArea inline = (InlineArea)iter.next();
  +            LayoutInfo info = inline.info;
  +            int al;
  +            int ld = inline.getHeight();
  +            if(info != null) {
  +                al = info.alignment;
  +                ld = info.lead;
  +            } else {
  +                al = VerticalAlign.BASELINE;
  +            }
  +            if(al == VerticalAlign.BASELINE) {
  +                if(ld > before) {
  +                    before = ld;
  +                }
  +                if(inline.getHeight() > before) {
  +                    before = inline.getHeight();
  +                }
  +            } else if(al == VerticalAlign.MIDDLE) {
  +                if(inline.getHeight() / 2  + lead / 2 > before) {
  +                    before = inline.getHeight() / 2 + lead / 2;
  +                }
  +                if(inline.getHeight() / 2 - lead / 2 > after) {
  +                    after = inline.getHeight() / 2 - lead / 2;
  +                }
  +            } else if(al == VerticalAlign.TOP) {
  +            } else if(al == VerticalAlign.BOTTOM) {
  +            }
  +        }
  +
  +        // then align all before, no and middle alignment
  +        for(Iterator iter = inlineAreas.iterator(); iter.hasNext(); ) {
  +            InlineArea inline = (InlineArea)iter.next();
  +            LayoutInfo info = inline.info;
  +            int al;
  +            int ld = inline.getHeight();
  +            boolean bloffset = false;
  +            if(info != null) {
  +                al = info.alignment;
  +                ld = info.lead;
  +                bloffset = info.blOffset;
  +            } else {
  +                al = VerticalAlign.BASELINE;
  +            }
  +            if(al == VerticalAlign.BASELINE) {
  +                // the offset position for text is the baseline
  +                if(bloffset) {
  +                    inline.setOffset(before);
  +                } else {
  +                    inline.setOffset(before - ld);
  +                }
  +                if(inline.getHeight() - ld > after) {
  +                    after = inline.getHeight() - ld;
  +                }
  +            } else if(al == VerticalAlign.MIDDLE) {
  +                inline.setOffset(before - inline.getHeight() / 2 - lead / 2);
  +            } else if(al == VerticalAlign.TOP) {
  +                inline.setOffset(0);
  +                if(inline.getHeight() - before > after) {
  +                    after = inline.getHeight() - before;
  +                }
  +            } else if(al == VerticalAlign.BOTTOM) {
  +                if(inline.getHeight() - before > after) {
  +                    after = inline.getHeight() - before;
  +                }
  +            }
  +        }
  +
  +        // after alignment depends on maximum height of before
  +        // and middle alignments
  +        for(Iterator iter = inlineAreas.iterator(); iter.hasNext(); ) {
  +            InlineArea inline = (InlineArea)iter.next();
  +            LayoutInfo info = inline.info;
  +            int al; 
  +            if(info != null) {
  +                al = info.alignment;
  +            } else {
  +                al = VerticalAlign.BASELINE;
  +            }
  +            if(al == VerticalAlign.BASELINE) {
  +            } else if(al == VerticalAlign.MIDDLE) {
  +            } else if(al == VerticalAlign.TOP) {
  +            } else if(al == VerticalAlign.BOTTOM) {
  +                inline.setOffset(before + after - inline.getHeight());
  +            }
  +        }
  +        if(before + after > maxHeight) {
  +            lineArea.setHeight(before + after);
  +        } else {
  +            lineArea.setHeight(maxHeight); 
           }
       }
   
  
  
  
  1.6       +6 -1      xml-fop/src/org/apache/fop/layoutmgr/TextLayoutManager.java
  
  Index: TextLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/TextLayoutManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TextLayoutManager.java    21 Mar 2002 09:37:15 -0000      1.5
  +++ TextLayoutManager.java    2 Apr 2002 11:50:58 -0000       1.6
  @@ -1,5 +1,5 @@
   /*
  - * $Id: TextLayoutManager.java,v 1.5 2002/03/21 09:37:15 keiron Exp $
  + * $Id: TextLayoutManager.java,v 1.6 2002/04/02 11:50:58 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -14,6 +14,7 @@
   import org.apache.fop.area.inline.Word;
   import org.apache.fop.area.inline.Space;
   import org.apache.fop.util.CharUtilities;
  +import org.apache.fop.fo.properties.VerticalAlign;
   
   import org.apache.fop.fo.properties.*;
   
  @@ -226,6 +227,10 @@
           curWordArea.setWidth(width);
           curWordArea.setHeight(textInfo.fs.getAscender() - 
textInfo.fs.getDescender());
           curWordArea.setOffset(textInfo.fs.getAscender());
  +        curWordArea.info = new LayoutInfo();
  +        curWordArea.info.lead = textInfo.fs.getAscender();
  +        curWordArea.info.alignment = VerticalAlign.BASELINE;
  +        curWordArea.info.blOffset = true;
   
           curWordArea.setWord(str);
           Trait prop = new Trait();
  
  
  
  1.1                  xml-fop/src/org/apache/fop/layoutmgr/LayoutInfo.java
  
  Index: LayoutInfo.java
  ===================================================================
  /*
   * $Id: LayoutInfo.java,v 1.1 2002/04/02 11:50:58 keiron Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.layoutmgr;
  
  import org.apache.fop.area.Area;
  import org.apache.fop.area.MinOptMax;
  
  public class LayoutInfo {
      public int alignment;
      public int lead;
      public boolean blOffset = false;    
  
      public LayoutInfo() {
      }
  
  }
  
  
  
  1.13      +4 -1      xml-fop/src/org/apache/fop/render/AbstractRenderer.java
  
  Index: AbstractRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/AbstractRenderer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AbstractRenderer.java     26 Feb 2002 12:43:09 -0000      1.12
  +++ AbstractRenderer.java     2 Apr 2002 11:50:58 -0000       1.13
  @@ -1,5 +1,5 @@
   /*
  - * $Id: AbstractRenderer.java,v 1.12 2002/02/26 12:43:09 keiron Exp $
  + * $Id: AbstractRenderer.java,v 1.13 2002/04/02 11:50:58 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -254,6 +254,8 @@
   
       public void renderViewport(Viewport viewport) {
           Area content = viewport.getContent();
  +        int saveBP = currentBPPosition;
  +        currentBPPosition += viewport.getOffset();
           if (content instanceof Image) {
               renderImage((Image) content);
           } else if (content instanceof Container) {
  @@ -262,6 +264,7 @@
               renderForeignObject((ForeignObject) content);
           }
           currentBlockIPPosition += viewport.getWidth();
  +        currentBPPosition = saveBP;
       }
   
       public void renderImage(Image image) {
  
  
  

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

Reply via email to