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 vm...@apache.org on 2003/08/23 21:26:30 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr BlockContainerLayoutManager.java

vmote       2003/08/23 12:26:30

  Modified:    src/java/org/apache/fop/area CTM.java
               src/java/org/apache/fop/fo PropertyManager.java
               src/java/org/apache/fop/fo/pagination Region.java
                        SimplePageMaster.java
               src/java/org/apache/fop/layoutmgr
                        BlockContainerLayoutManager.java
  Log:
  move fo/PropertyManager.getCTMandRelDims() to area/CTM.getCTMandRelDims(), adding PropertyManager as a parameter, and making the method static.
  
  Revision  Changes    Path
  1.3       +80 -12    xml-fop/src/java/org/apache/fop/area/CTM.java
  
  Index: CTM.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/CTM.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CTM.java	20 Jun 2003 10:06:17 -0000	1.2
  +++ CTM.java	23 Aug 2003 19:26:30 -0000	1.3
  @@ -3,34 +3,34 @@
    * ============================================================================
    *                    The Apache Software License, Version 1.1
    * ============================================================================
  - * 
  + *
    * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  - * 
  + *
    * Redistribution and use in source and binary forms, with or without modifica-
    * tion, are permitted provided that the following conditions are met:
  - * 
  + *
    * 1. Redistributions of source code must retain the above copyright notice,
    *    this list of conditions and the following disclaimer.
  - * 
  + *
    * 2. Redistributions in binary form must reproduce the above copyright notice,
    *    this list of conditions and the following disclaimer in the documentation
    *    and/or other materials provided with the distribution.
  - * 
  + *
    * 3. The end-user documentation included with the redistribution, if any, must
    *    include the following acknowledgment: "This product includes software
    *    developed by the Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself, if
    *    and wherever such third-party acknowledgments normally appear.
  - * 
  + *
    * 4. The names "FOP" and "Apache Software Foundation" must not be used to
    *    endorse or promote products derived from this software without prior
    *    written permission. For written permission, please contact
    *    apache@apache.org.
  - * 
  + *
    * 5. Products derived from this software may not be called "Apache", nor may
    *    "Apache" appear in their name, without prior written permission of the
    *    Apache Software Foundation.
  - * 
  + *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
    * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  @@ -42,14 +42,16 @@
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    * ============================================================================
  - * 
  + *
    * This software consists of voluntary contributions made by many individuals
    * on behalf of the Apache Software Foundation and was originally created by
    * James Tauber <jt...@jtauber.com>. For more information on the Apache
    * Software Foundation, please see <http://www.apache.org/>.
  - */ 
  + */
   package org.apache.fop.area;
   
  +import org.apache.fop.datatypes.FODimension;
  +import org.apache.fop.fo.PropertyManager;
   import java.awt.geom.Rectangle2D;
   import java.awt.Rectangle;
   import java.io.Serializable;
  @@ -62,7 +64,7 @@
    * system used to render pages.
    */
   public class CTM implements Serializable {
  -    
  +
       private double a, b, c, d, e, f;
   
       private static final CTM CTM_LRTB = new CTM(1, 0, 0, 1, 0, 0);
  @@ -276,5 +278,71 @@
       public double[] toArray() {
           return new double[]{a, b, c, d, e, f};
       }
  -}
   
  +    /**
  +     * Construct a coordinate transformation matrix (CTM).
  +     * @param absVPrect absolute viewpoint rectangle
  +     * @param reldims relative dimensions
  +     * @return CTM the coordinate transformation matrix (CTM)
  +     */
  +    public static CTM getCTMandRelDims(PropertyManager pm, Rectangle2D absVPrect,
  +                                FODimension reldims) {
  +        int width, height;
  +        // We will use the absolute reference-orientation to set up the CTM.
  +        // The value here is relative to its ancestor reference area.
  +        int absRefOrient = pm.getAbsRefOrient(
  +                pm.getProperties().get("reference-orientation").getNumber().intValue());
  +        if (absRefOrient % 180 == 0) {
  +            width = (int) absVPrect.getWidth();
  +            height = (int) absVPrect.getHeight();
  +        } else {
  +            // invert width and height since top left are rotated by 90 (cl or ccl)
  +            height = (int) absVPrect.getWidth();
  +            width = (int) absVPrect.getHeight();
  +        }
  +        /* Set up the CTM for the content of this reference area.
  +         * This will transform region content coordinates in
  +         * writing-mode relative into absolute page-relative
  +         * which will then be translated based on the position of
  +         * the region viewport.
  +         * (Note: scrolling between region vp and ref area when
  +         * doing online content!)
  +         */
  +        CTM ctm = new CTM(absVPrect.getX(), absVPrect.getY());
  +
  +        // First transform for rotation
  +        if (absRefOrient != 0) {
  +            // Rotation implies translation to keep the drawing area in the
  +            // first quadrant. Note: rotation is counter-clockwise
  +            switch (absRefOrient) {
  +                case 90:
  +                    ctm = ctm.translate(0, width); // width = absVPrect.height
  +                    break;
  +                case 180:
  +                    ctm = ctm.translate(width, height);
  +                    break;
  +                case 270:
  +                    ctm = ctm.translate(height, 0); // height = absVPrect.width
  +                    break;
  +            }
  +            ctm = ctm.rotate(absRefOrient);
  +        }
  +        int wm = pm.getProperties().get("writing-mode").getEnum();
  +        /* Since we've already put adjusted width and height values for the
  +         * top and left positions implied by the reference-orientation, we
  +         * can set ipd and bpd appropriately based on the writing mode.
  +         */
  +
  +        if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) {
  +            reldims.ipd = width;
  +            reldims.bpd = height;
  +        } else {
  +            reldims.ipd = height;
  +            reldims.bpd = width;
  +        }
  +        // Set a rectangle to be the writing-mode relative version???
  +        // Now transform for writing mode
  +        return ctm.multiply(CTM.getWMctm(wm, reldims.ipd, reldims.bpd));
  +    }
  +
  +}
  
  
  
  1.10      +2 -72     xml-fop/src/java/org/apache/fop/fo/PropertyManager.java
  
  Index: PropertyManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/PropertyManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PropertyManager.java	22 Aug 2003 06:27:34 -0000	1.9
  +++ PropertyManager.java	23 Aug 2003 19:26:30 -0000	1.10
  @@ -52,11 +52,8 @@
   
   // Java
   import java.text.MessageFormat;
  -import java.awt.geom.Rectangle2D;
   
   // FOP
  -import org.apache.fop.area.CTM;
  -import org.apache.fop.datatypes.FODimension;
   import org.apache.fop.fonts.Font;
   import org.apache.fop.fo.properties.CommonBorderAndPadding;
   import org.apache.fop.fo.properties.CommonMarginBlock;
  @@ -71,7 +68,6 @@
   import org.apache.fop.traits.SpaceVal;
   import org.apache.fop.traits.LayoutProps; // keep, break, span, space?
   import org.apache.fop.fo.properties.Constants;
  -import org.apache.fop.fo.properties.WritingMode;
   import org.apache.fop.fo.properties.Span;
   import org.apache.fop.fonts.FontMetrics;
   import org.apache.fop.fo.properties.CommonHyphenation;
  @@ -513,76 +509,10 @@
       }
   
       /**
  -     * Construct a coordinate transformation matrix (CTM).
  -     * @param absVPrect absolute viewpoint rectangle
  -     * @param reldims relative dimensions
  -     * @return CTM the coordinate transformation matrix (CTM)
  -     */
  -    public CTM getCTMandRelDims(Rectangle2D absVPrect,
  -                                FODimension reldims) {
  -        int width, height;
  -        // We will use the absolute reference-orientation to set up the CTM.
  -        // The value here is relative to its ancestor reference area.
  -        int absRefOrient = getAbsRefOrient(
  -                this.properties.get("reference-orientation").getNumber().intValue());
  -        if (absRefOrient % 180 == 0) {
  -            width = (int) absVPrect.getWidth();
  -            height = (int) absVPrect.getHeight();
  -        } else {
  -            // invert width and height since top left are rotated by 90 (cl or ccl)
  -            height = (int) absVPrect.getWidth();
  -            width = (int) absVPrect.getHeight();
  -        }
  -        /* Set up the CTM for the content of this reference area.
  -         * This will transform region content coordinates in
  -         * writing-mode relative into absolute page-relative
  -         * which will then be translated based on the position of
  -         * the region viewport.
  -         * (Note: scrolling between region vp and ref area when
  -         * doing online content!)
  -         */
  -        CTM ctm = new CTM(absVPrect.getX(), absVPrect.getY());
  -
  -        // First transform for rotation
  -        if (absRefOrient != 0) {
  -            // Rotation implies translation to keep the drawing area in the
  -            // first quadrant. Note: rotation is counter-clockwise
  -            switch (absRefOrient) {
  -                case 90:
  -                    ctm = ctm.translate(0, width); // width = absVPrect.height
  -                    break;
  -                case 180:
  -                    ctm = ctm.translate(width, height);
  -                    break;
  -                case 270:
  -                    ctm = ctm.translate(height, 0); // height = absVPrect.width
  -                    break;
  -            }
  -            ctm = ctm.rotate(absRefOrient);
  -        }
  -        int wm = this.properties.get("writing-mode").getEnum();
  -        /* Since we've already put adjusted width and height values for the
  -         * top and left positions implied by the reference-orientation, we
  -         * can set ipd and bpd appropriately based on the writing mode.
  -         */
  -
  -        if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) {
  -            reldims.ipd = width;
  -            reldims.bpd = height;
  -        } else {
  -            reldims.ipd = height;
  -            reldims.bpd = width;
  -        }
  -        // Set a rectangle to be the writing-mode relative version???
  -        // Now transform for writing mode
  -        return ctm.multiply(CTM.getWMctm(wm, reldims.ipd, reldims.bpd));
  -    }
  -
  -    /**
        * Calculate absolute reference-orientation relative to media orientation.
        */
  -    private int getAbsRefOrient(int myRefOrient) {
  +    public int getAbsRefOrient(int myRefOrient) {
           return myRefOrient;
       }
  -}
   
  +}
  
  
  
  1.5       +1 -1      xml-fop/src/java/org/apache/fop/fo/pagination/Region.java
  
  Index: Region.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Region.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Region.java	22 Aug 2003 06:27:34 -0000	1.4
  +++ Region.java	23 Aug 2003 19:26:30 -0000	1.5
  @@ -195,7 +195,7 @@
        */
       protected void setRegionPosition(RegionReference r, Rectangle2D absRegVPRect) {
           FODimension reldims = new FODimension(0, 0);
  -        r.setCTM(propMgr.getCTMandRelDims(absRegVPRect, reldims));
  +        r.setCTM(CTM.getCTMandRelDims(propMgr, absRegVPRect, reldims));
       }
   
       /**
  
  
  
  1.5       +1 -1      xml-fop/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
  
  Index: SimplePageMaster.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimplePageMaster.java	22 Aug 2003 06:27:34 -0000	1.4
  +++ SimplePageMaster.java	23 Aug 2003 19:26:30 -0000	1.5
  @@ -149,7 +149,7 @@
           // Set up the CTM on the page reference area based on writing-mode
           // and reference-orientation
           FODimension reldims = new FODimension(0, 0);
  -        CTM pageCTM = propMgr.getCTMandRelDims(pageRefRect, reldims);
  +        CTM pageCTM = CTM.getCTMandRelDims(propMgr, pageRefRect, reldims);
   
           // Create a RegionViewport/ reference area pair for each page region
   
  
  
  
  1.4       +2 -2      xml-fop/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
  
  Index: BlockContainerLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BlockContainerLayoutManager.java	12 Aug 2003 18:02:45 -0000	1.3
  +++ BlockContainerLayoutManager.java	23 Aug 2003 19:26:30 -0000	1.4
  @@ -100,7 +100,7 @@
                                   abProps.top, abProps.right - abProps.left,
                                   abProps.bottom - abProps.top);
               relDims = new FODimension(0, 0);
  -            absoluteCTM = pm.getCTMandRelDims(rect, relDims);
  +            absoluteCTM = CTM.getCTMandRelDims(pm, rect, relDims);
           }
       }
   
  @@ -121,7 +121,7 @@
           Rectangle2D rect = new Rectangle2D.Double(0, 0, context.getRefIPD(),
                                                     context.getStackLimit().opt);
           relDims = new FODimension(0, 0);
  -        absoluteCTM = propManager.getCTMandRelDims(rect, relDims);
  +        absoluteCTM = CTM.getCTMandRelDims(propManager, rect, relDims);
           double[] vals = absoluteCTM.toArray();
   
           MinOptMax stackLimit;
  
  
  

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