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 ke...@apache.org on 2001/02/07 04:16:14 UTC

cvs commit: xml-fop/src/org/apache/fop/fo/flow PageNumber.java PageNumberCitation.java

keiron      01/02/06 19:16:14

  Modified:    src/org/apache/fop/layout LineArea.java
               src/org/apache/fop/fo FOText.java
               src/org/apache/fop/fo/flow PageNumber.java
                        PageNumberCitation.java
  Log:
  adds vertical align to text
  
  Revision  Changes    Path
  1.33      +40 -14    xml-fop/src/org/apache/fop/layout/LineArea.java
  
  Index: LineArea.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/LineArea.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- LineArea.java	2001/02/01 23:04:20	1.32
  +++ LineArea.java	2001/02/07 03:16:13	1.33
  @@ -1,4 +1,4 @@
  -/*-- $Id: LineArea.java,v 1.32 2001/02/01 23:04:20 fotis Exp $ --
  +/*-- $Id: LineArea.java,v 1.33 2001/02/07 03:16:13 keiron Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -65,6 +65,7 @@
   import org.apache.fop.fo.properties.CountryMaker;
   import org.apache.fop.fo.properties.LanguageMaker;
   import org.apache.fop.fo.properties.LeaderAlignment;
  +import org.apache.fop.fo.properties.VerticalAlign;
   import org.apache.fop.layout.hyphenation.Hyphenation;
   import org.apache.fop.layout.hyphenation.Hyphenator;
   
  @@ -92,6 +93,7 @@
       private float red, green, blue;
       private int wrapOption;
       private int whiteSpaceCollapse;
  +    int vAlign;
   
       /*hyphenation*/
       protected int hyphenate;
  @@ -109,7 +111,7 @@
       protected int embeddedLinkStart = 0;
   
       /* the width of the current word so far */
  -    protected int wordWidth = 0;
  +//    protected int wordWidth = 0;
   
       /* values that prev (below) may take */
       protected static final int NOTHING = 0;
  @@ -120,10 +122,10 @@
       protected int prev = NOTHING;
   
       /* the position in data[] of the start of the current word */
  -    protected int wordStart;
  +//    protected int wordStart;
   
       /* the length (in characters) of the current word */
  -    protected int wordLength = 0;
  +//    protected int wordLength = 0;
   
       /* width of spaces before current word */
       protected int spaceWidth = 0;
  @@ -191,7 +193,6 @@
           pia.setYOffset(placementOffset);
           pendingAreas.addElement(pia);
           pendingWidth += width;
  -        wordWidth = 0;
           prev = TEXT;
   
           return -1;
  @@ -210,9 +211,9 @@
           if(start == -1) return -1;
           boolean overrun = false;
   
  -        wordStart = start;
  -        wordLength = 0;
  -        wordWidth = 0;
  +        int wordStart = start;
  +        int wordLength = 0;
  +        int wordWidth = 0;
           char[] data = new char[odata.length];
           for (int count = 0; count < odata.length; count++) {
               data[count] = odata[count];
  @@ -316,6 +317,7 @@
                           prevOlState = textState.getOverlined();
                           ia.setLineThrough(textState.getLineThrough());
                           prevLTState = textState.getLineThrough();
  +                        ia.setVerticalAlign(vAlign);
   
                           addChild(ia);
                           if (ls != null) {
  @@ -457,6 +459,7 @@
               prevOlState = textState.getOverlined();
               pia.setLineThrough(textState.getLineThrough());
               prevLTState = textState.getLineThrough();
  +            pia.setVerticalAlign(vAlign);
   
               if (ls != null) {
                   Rectangle lr = new Rectangle(finalWidth + spaceWidth +
  @@ -674,17 +677,25 @@
               Box b = (Box) e.nextElement();
               if(b instanceof InlineArea) {
                   InlineArea ia = (InlineArea)b;
  +                if(ia instanceof WordArea) {
  +                    ia.setYOffset(placementOffset);
  +                }
                   if(ia.getHeight() > maxHeight) {
                       maxHeight = ia.getHeight();
                   }
                   int vert = ia.getVerticalAlign();
  -/*                if(vert == VerticalAlign.SUPER) {
  -                    int tbe = fontState.getAscender();
  -                    ia.setYOffset(placementOffset - (tbe - h));
  -                }*/
  +                if(vert == VerticalAlign.SUPER) {
  +                    int fh = fontState.getAscender();
  +                    ia.setYOffset((int)(placementOffset - (fh / 3.0)));
  +                } else if(vert == VerticalAlign.SUB) {
  +                    int fh = fontState.getAscender();
  +                    ia.setYOffset((int)(placementOffset + (fh / 3.0)));
  +                }
               } else {
               }
           }
  +        // adjust the height of this line to the
  +        // resulting alignment height.
           this.allocationHeight = maxHeight;
       }
   
  @@ -706,6 +717,10 @@
           this.wrapOption = wrapOption;
       }
   
  +    public void changeVerticalAlign(int vAlign) {
  +        this.vAlign = vAlign;
  +    }
  +
       public int getEndIndent() {
           return endIndent;
       }
  @@ -724,7 +739,7 @@
   
       public boolean isEmpty() {
           return !(pendingAreas.size() > 0 || children.size() > 0);
  -//        return (prev == 0);
  +//        return (prev == NOTHING);
       }
   
       public Vector getPendingAreas() {
  @@ -834,7 +849,7 @@
        *  handles cases of inword punctuation and quotation marks at the beginning
        *  of words, but not in a internationalized way 
        */
  -    private int doHyphenation (char [] characters, int position, int wordStart, int remainingWidth) {
  +    public int doHyphenation (char [] characters, int position, int wordStart, int remainingWidth) {
           //check whether the language property has been set
           if (this.language.equalsIgnoreCase("none")) {
             MessageHandler.errorln("if property 'hyphenate' is used, a language must be specified");
  @@ -942,12 +957,23 @@
           return this.getContentWidth() - this.getCurrentXPosition();
       }
   
  +    public void setLinkSet(LinkSet ls)
  +    {
  +    }
  +
       public void addInlineArea(Area box)
       {
           addPending();
           addChild(box);
           prev = TEXT;
           finalWidth += box.getContentWidth();
  +    }
  +
  +    public void addInlineSpace(InlineSpace is, int spaceWidth)
  +    {
  +        addChild(is);
  +        finalWidth += spaceWidth;
  +//        spaceWidth = 0;
       }
   
       /** adds a single character to the line area tree*/ 
  
  
  
  1.18      +13 -9     xml-fop/src/org/apache/fop/fo/FOText.java
  
  Index: FOText.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FOText.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- FOText.java	2001/02/01 23:51:30	1.17
  +++ FOText.java	2001/02/07 03:16:13	1.18
  @@ -1,4 +1,4 @@
  -/*-- $Id: FOText.java,v 1.17 2001/02/01 23:51:30 keiron Exp $ --
  +/*-- $Id: FOText.java,v 1.18 2001/02/07 03:16:13 keiron Exp $ --
   
    ============================================================================
   									 The Apache Software License, Version 1.1
  @@ -76,6 +76,7 @@
   		float blue;
   		int wrapOption;
   		int whiteSpaceCollapse;
  +		int verticalAlign;
   
   		// Textdecoration
   		protected boolean underlined = false;
  @@ -152,21 +153,23 @@
   						this.green = c.green();
   						this.blue = c.blue();
   
  +						this.verticalAlign = this.parent.properties.get("vertical-align").getEnum();
  +
   						this.wrapOption =
   							this.parent.properties.get("wrap-option").getEnum();
   						this.whiteSpaceCollapse = this.parent.properties.get(
   																				"white-space-collapse").getEnum(); 
   						this.ts = new TextState();
  -						ts.setUnderlined(underlined);            
  -						ts.setOverlined(overlined);            
  -						ts.setLineThrough(lineThrough);            
  +						ts.setUnderlined(underlined);
  +						ts.setOverlined(overlined);
  +						ts.setLineThrough(lineThrough);
   
   						this.marker = this.start;
   				}
   				int orig_start = this.marker;
   				this.marker = addText((BlockArea)area, fs, red, green, blue,
   											wrapOption, this.getLinkSet(), whiteSpaceCollapse, ca,
  -											this.marker, length, ts);
  +											this.marker, length, ts, verticalAlign);
   				if (this.marker == -1) {
   
   
  @@ -193,7 +196,7 @@
   		public static int addText(BlockArea ba, FontState fontState, float red, float green,
   											 float blue, int wrapOption, LinkSet ls,
   											 int whiteSpaceCollapse, char data[], int start, int end,
  -											 TextState textState) {
  +											 TextState textState, int vAlign) {
   			if (fontState.getFontVariant() == FontVariant.SMALL_CAPS) {
   				FontState smallCapsFontState;
   				try {
  @@ -234,7 +237,7 @@
   						fontStateToUse = fontState;
   					}
   					int index = addRealText(ba, fontStateToUse, red, green, blue, wrapOption, ls,
  -						whiteSpaceCollapse, data, caseStart, i, textState);
  +						whiteSpaceCollapse, data, caseStart, i, textState, vAlign);
   					if (index != -1) {
   						return index;
   					}
  @@ -245,13 +248,13 @@
   
   			// font-variant normal
   			return addRealText(ba, fontState, red, green, blue, wrapOption, ls,
  -				whiteSpaceCollapse, data, start, end, textState);
  +				whiteSpaceCollapse, data, start, end, textState, vAlign);
   		}
   
   		protected static int addRealText(BlockArea ba, FontState fontState, float red, float green,
   											 float blue, int wrapOption, LinkSet ls,
   											 int whiteSpaceCollapse, char data[], int start, int end,
  -											 TextState textState) {
  +											 TextState textState, int vAlign) {
   				int ts, te;
   				char[] ca;
   
  @@ -268,6 +271,7 @@
   				la.changeColor(red, green, blue);
   				la.changeWrapOption(wrapOption);
   				la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
  +				la.changeVerticalAlign(vAlign);
   //				la.changeHyphenation(language, country, hyphenate,
   //																 hyphenationChar, hyphenationPushCharacterCount,
   //																 hyphenationRemainCharacterCount);
  
  
  
  1.15      +2 -2      xml-fop/src/org/apache/fop/fo/flow/PageNumber.java
  
  Index: PageNumber.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/PageNumber.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PageNumber.java	2001/02/01 23:51:35	1.14
  +++ PageNumber.java	2001/02/07 03:16:13	1.15
  @@ -1,4 +1,4 @@
  -/*-- $Id: PageNumber.java,v 1.14 2001/02/01 23:51:35 keiron Exp $ --
  +/*-- $Id: PageNumber.java,v 1.15 2001/02/07 03:16:13 keiron Exp $ --
   
    ============================================================================
   									 The Apache Software License, Version 1.1
  @@ -129,7 +129,7 @@
   				String p = Integer.toString(area.getPage().getNumber());
   				this.marker = FOText.addText((BlockArea) area, fs, red, green, blue,
   											wrapOption, null, whiteSpaceCollapse, p.toCharArray(),
  -											0, p.length(), ts);
  +											0, p.length(), ts, VerticalAlign.BASELINE);
   				return new Status(Status.OK);
   		}
   }
  
  
  
  1.14      +2 -2      xml-fop/src/org/apache/fop/fo/flow/PageNumberCitation.java
  
  Index: PageNumberCitation.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/PageNumberCitation.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- PageNumberCitation.java	2001/02/01 23:51:35	1.13
  +++ PageNumberCitation.java	2001/02/07 03:16:13	1.14
  @@ -1,4 +1,4 @@
  -/*-- $Id: PageNumberCitation.java,v 1.13 2001/02/01 23:51:35 keiron Exp $ --
  +/*-- $Id: PageNumberCitation.java,v 1.14 2001/02/07 03:16:13 keiron Exp $ --
   
    ============================================================================
   									 The Apache Software License, Version 1.1
  @@ -206,7 +206,7 @@
   						this.marker = FOText.addText((BlockArea) area, fs, red, green, blue,
   													wrapOption, null, whiteSpaceCollapse,
   													pageNumber.toCharArray(), 0, pageNumber.length(),
  -													ts);
  +													ts, VerticalAlign.BASELINE);
   				} else { // add pageNumberCitation to area to be resolved during rendering
               BlockArea blockArea = (BlockArea)area;
               LineArea la = blockArea.getCurrentLineArea();