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 ar...@locus.apache.org on 2000/03/10 03:48:38 UTC

cvs commit: xml-fop/src/org/apache/fop/layout LinkSet.java

arved       00/03/09 18:48:38

  Modified:    src/org/apache/fop/layout LinkSet.java
  Log:
  align() method introduced
  
  Revision  Changes    Path
  1.3       +49 -5     xml-fop/src/org/apache/fop/layout/LinkSet.java
  
  Index: LinkSet.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/LinkSet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LinkSet.java	1999/12/03 08:12:59	1.2
  +++ LinkSet.java	2000/03/10 02:48:38	1.3
  @@ -1,4 +1,4 @@
  -/*-- $Id: LinkSet.java,v 1.2 1999/12/03 08:12:59 jtauber Exp $ -- 
  +/*-- $Id: LinkSet.java,v 1.3 2000/03/10 02:48:38 arved Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -59,6 +59,15 @@
   import java.util.Enumeration;
   import java.awt.Rectangle;
   
  +import org.apache.fop.fo.properties.WrapOption; // for enumerated
  +// values 
  +import org.apache.fop.fo.properties.WhiteSpaceTreatment; // for
  +// enumerated values 
  +import org.apache.fop.fo.properties.TextAlign; // for enumerated
  +// values 
  +import org.apache.fop.fo.properties.TextAlignLast; // for enumerated
  +// values 
  +
   /**
    * a set of rectangles on a page that are linked to a common
    * destination
  @@ -71,16 +80,18 @@
       /** the set of rectangles */
       Vector rects = new Vector();
   
  -    int xoffset = 0;
  +    private int xoffset = 0;
  +    private int yoffset = 0;
  +    
  +    // property required for alignment adjustments
  +    int contentRectangleWidth = 0;
   
  -    int yoffset = 0;
  -	
       public LinkSet(String externalDest) {
   	this.externalDestination = externalDest;
       }
       
       public void addRect(Rectangle r) {
  -	r.y = yoffset;
  +	r.y = this.yoffset;
   	rects.addElement(r);
       }
   	
  @@ -88,6 +99,14 @@
   	this.yoffset = y;
       }
   	
  +    public void setXOffset(int x) {
  +	this.xoffset = x;
  +    }
  +	
  +    public void setContentRectangleWidth(int contentRectangleWidth) {
  +	this.contentRectangleWidth = contentRectangleWidth;
  +    }
  +	
       public void applyAreaContainerOffsets(AreaContainer ac) {
   	Enumeration re = rects.elements();
   	while (re.hasMoreElements()) {
  @@ -122,6 +141,31 @@
   	rects = nv;
       }
   	
  +    public void align(int type, int padding) {
  +        int offset = 0;
  +
  +	switch (type) {
  +	case TextAlign.START: // left
  +	    offset = 0;
  +	    break;
  +	case TextAlign.END: // right
  +	    offset = padding / 2;
  +	    break;
  +	case TextAlign.CENTERED: // center
  +	    offset = padding;
  +	    break;
  +	case TextAlign.JUSTIFIED: // justify
  +            // not yet implemented
  +            break;
  +        }
  +
  +	Enumeration re = rects.elements();
  +	while (re.hasMoreElements()) {
  +	    Rectangle r = (Rectangle)re.nextElement();
  +	    r.x += offset;
  +	}
  +    }
  +
       public String getDest() {
   	return this.externalDestination;
       }