]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
move fo/PropertyManager.getCTMandRelDims() to area/CTM.getCTMandRelDims(), adding...
authorWilliam Victor Mote <vmote@apache.org>
Sat, 23 Aug 2003 19:26:30 +0000 (19:26 +0000)
committerWilliam Victor Mote <vmote@apache.org>
Sat, 23 Aug 2003 19:26:30 +0000 (19:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196829 13f79535-47bb-0310-9956-ffa450edef68

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
src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java

index 78d16ecb89ba3d9904d38dda2241e7ac7b46340d..07e142b66215bb3b00944e5e905c5d73a22281fb 100644 (file)
@@ -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
  * (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 <jtauber@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 @@ import org.apache.fop.fo.properties.WritingMode;
  * 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 class CTM implements Serializable {
     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));
+    }
+
+}
index 4f1d73e0306ce259b349e055a7d3d296b2267d0a..11d11c82e4542d423b831a737b6a00716aa671de 100644 (file)
@@ -52,11 +52,8 @@ package org.apache.fop.fo;
 
 // 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.InlineProps;
 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;
@@ -512,77 +508,11 @@ public class PropertyManager {
         return textInfo;
     }
 
-    /**
-     * 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;
     }
-}
 
+}
index 10079df209a54b8f59f4ac4f710a351e0d630d08..28d60211d0d19cc82118126d29bcd8780f8fb730 100644 (file)
@@ -195,7 +195,7 @@ public abstract class Region extends FObj {
      */
     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));
     }
 
     /**
index 2d73df7279a791396ba8b28a23e2699daf6a0482..44eb03717a78d5bd0adcbe53e7e8b157364e0073 100644 (file)
@@ -149,7 +149,7 @@ public class SimplePageMaster extends FObj {
         // 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
 
index fec324cd88e31d5f4d911b87cbbbd7d16523a5b2..295bff9096aacd524f5835d6756259dab285fd28 100644 (file)
@@ -100,7 +100,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
                                 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 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         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;