]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
create fo/FOTreeControl interface, and make control/Document implement it, to further...
authorWilliam Victor Mote <vmote@apache.org>
Tue, 19 Aug 2003 05:19:21 +0000 (05:19 +0000)
committerWilliam Victor Mote <vmote@apache.org>
Tue, 19 Aug 2003 05:19:21 +0000 (05:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196811 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/apps/Driver.java
src/java/org/apache/fop/control/Document.java
src/java/org/apache/fop/fo/FONode.java
src/java/org/apache/fop/fo/FOTreeBuilder.java
src/java/org/apache/fop/fo/FOTreeControl.java [new file with mode: 0644]
src/java/org/apache/fop/fo/FObjMixed.java
src/java/org/apache/fop/fo/PropertyManager.java
src/java/org/apache/fop/fo/pagination/Root.java
src/java/org/apache/fop/layoutmgr/AddLMVisitor.java

index dcd012206740e780eb1e8bb4fbd6417b1cf0c7bb..6345b7fbe3cec886964bf58e8717896e49bedead 100644 (file)
@@ -601,7 +601,7 @@ public class Driver implements LogEnabled, FOTreeListener {
         if (foInputHandler instanceof FOTreeHandler) {
             currentDocument.setLayoutStrategy(new LayoutManagerLS());
         }
-        treeBuilder.document = currentDocument;
+        treeBuilder.foTreeControl = currentDocument;
         try {
             if (foInputHandler instanceof FOTreeHandler) {
                 FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler;
index a72de0b45e735443c11abb845cc38addbfd22c67..8096541a8252e9ea37534d0bab4746979a666416 100644 (file)
@@ -55,6 +55,7 @@ import java.util.Map;
 
 // FOP
 import org.apache.fop.apps.Driver;
+import org.apache.fop.fo.FOTreeControl;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontMetrics;
 import org.apache.fop.layout.LayoutStrategy;
@@ -63,7 +64,7 @@ import org.apache.fop.layout.LayoutStrategy;
  * Class storing information for the FOP Document being processed, and managing
  * the processing of it.
  */
-public class Document {
+public class Document implements FOTreeControl {
 
     /** The parent Driver object */
     private Driver driver;
index 0b20e67526fe9542024d21409b5e914e420ff9aa..732be0af9d7b28f42dc5258b167a398e58aa5c30 100644 (file)
@@ -61,7 +61,7 @@ import org.apache.avalon.framework.logger.Logger;
 
 // FOP
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
 import org.apache.fop.util.CharUtilities;
 
 /**
@@ -216,8 +216,8 @@ public abstract class FONode {
      * which returns the parent Document.
      * @return the Document object that is the parent of this node.
      */
-    public Document getDocument() {
-        return parent.getDocument();
+    public FOTreeControl getFOTreeControl() {
+        return parent.getFOTreeControl();
     }
 
     /**
index 1af4d795fd83c038ad0afe25ea3c431c7d918cc9..7f07bfc4ae2d8459169e228ad5ea52a69d376bc4 100644 (file)
@@ -54,7 +54,7 @@ package org.apache.fop.fo;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
 import org.apache.fop.fo.pagination.Root;
 
 // SAX
@@ -122,7 +122,7 @@ public class FOTreeBuilder extends DefaultHandler {
 
     private FOUserAgent userAgent;
 
-    public Document document;
+    public FOTreeControl foTreeControl;
 
     /**
      * Default constructor
@@ -295,7 +295,7 @@ public class FOTreeBuilder extends DefaultHandler {
                                                         + fobj.getName()));
             }
             rootFObj = (Root)fobj;
-            rootFObj.setDocument(document);
+            rootFObj.setFOTreeControl(foTreeControl);
         } else {
             currentFObj.addChild(fobj);
         }
diff --git a/src/java/org/apache/fop/fo/FOTreeControl.java b/src/java/org/apache/fop/fo/FOTreeControl.java
new file mode 100644 (file)
index 0000000..81871df
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * $Id$
+ * ============================================================================
+ *                    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
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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.fo;
+
+import org.apache.fop.fonts.FontMetrics;
+
+/**
+ * An interface for classes that are conceptually the parent class of the
+ * fo.pagination.Root object. The purpose of the interface is to maintain
+ * encapsulation of the FO Tree classes, but to acknowledge that a higher-level
+ * object is needed to control the building of the FO Tree, to provide it
+ * with information about the environment, and to keep track of meta-type
+ * information.
+ */
+
+public interface FOTreeControl {
+
+    public String fontLookup(String family, String style,
+                             int weight);
+
+    public FontMetrics getMetricsFor(String fontName);
+
+}
index d0320b6cc935186b25c192fc075f60519e2d5f76..f7a4921a3e372ff3f5975f2b750097e9d1c82900 100644 (file)
@@ -50,7 +50,7 @@
  */
 package org.apache.fop.fo;
 
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
 import org.apache.fop.layoutmgr.InlineStackingLayoutManager;
 import org.apache.fop.layoutmgr.LMiter;
 
@@ -64,7 +64,7 @@ public class FObjMixed extends FObj {
     /** TextInfo for this object */
     protected TextInfo textInfo = null;
     /** FontInfo for this object */
-    protected Document fontInfo = null;
+    protected FOTreeControl fontInfo = null;
 
     /**
      * @param parent FONode that is the parent of this object
@@ -90,8 +90,8 @@ public class FObjMixed extends FObj {
         if (textInfo == null) {
             // Really only need one of these, but need to get fontInfo
             // stored in propMgr for later use.
-            propMgr.setFontInfo(getDocument());
-            textInfo = propMgr.getTextLayoutProps(getDocument());
+            propMgr.setFontInfo(getFOTreeControl());
+            textInfo = propMgr.getTextLayoutProps(getFOTreeControl());
         }
 
         FOText ft = new FOText(data, start, length, textInfo, this);
index 42cc308768e6ddfda583951ba0b15a375fb507b6..ac0099a58e9a69a01c29149fc42e597bdc2f0e2c 100644 (file)
@@ -58,7 +58,7 @@ import java.awt.geom.Rectangle2D;
 import org.apache.fop.area.CTM;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.fonts.Font;
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
 import org.apache.fop.fo.properties.CommonBorderAndPadding;
 import org.apache.fop.fo.properties.CommonMarginBlock;
 import org.apache.fop.fo.properties.CommonMarginInline;
@@ -83,7 +83,7 @@ import org.apache.fop.fo.properties.CommonHyphenation;
 public class PropertyManager {
 
     private PropertyList properties;
-    private Document doc = null;
+    private FOTreeControl foTreeControl = null;
     private Font fontState = null;
     private CommonBorderAndPadding borderAndPadding = null;
     private CommonHyphenation hyphProps = null;
@@ -122,8 +122,8 @@ public class PropertyManager {
      * available.
      * @param doc Document containing font information
      */
-    public void setFontInfo(Document doc) {
-        this.doc = doc;
+    public void setFontInfo(FOTreeControl foTreeControl) {
+        this.foTreeControl = foTreeControl;
     }
 
 
@@ -133,12 +133,12 @@ public class PropertyManager {
      * @param doc Document containing the font information
      * @return a FontState object
      */
-    public Font getFontState(Document doc) {
+    public Font getFontState(FOTreeControl foTreeControl) {
         if (fontState == null) {
-            if (doc == null) {
-                doc = this.doc;
-            } else if (this.doc == null) {
-                this.doc = doc;
+            if (foTreeControl == null) {
+                foTreeControl = this.foTreeControl;
+            } else if (this.foTreeControl == null) {
+                this.foTreeControl = foTreeControl;
             }
             /**@todo this is ugly. need to improve. */
 
@@ -167,9 +167,9 @@ public class PropertyManager {
             // various kinds of keywords too
             int fontSize = properties.get("font-size").getLength().getValue();
             //int fontVariant = properties.get("font-variant").getEnum();
-            String fname = doc.fontLookup(fontFamily, fontStyle,
+            String fname = foTreeControl.fontLookup(fontFamily, fontStyle,
                                                fontWeight);
-            FontMetrics metrics = doc.getMetricsFor(fname);
+            FontMetrics metrics = foTreeControl.getMetricsFor(fname);
             fontState = new Font(fname, metrics, fontSize);
         }
         return fontState;
@@ -479,10 +479,10 @@ public class PropertyManager {
      * @param doc Document containing list of available fonts
      * @return a TextInfo object
      */
-    public TextInfo getTextLayoutProps(Document doc) {
+    public TextInfo getTextLayoutProps(FOTreeControl foTreeControl) {
         if (textInfo == null) {
             textInfo = new TextInfo();
-            textInfo.fs = getFontState(doc);
+            textInfo.fs = getFontState(foTreeControl);
             textInfo.color = properties.get("color").getColorType();
 
             textInfo.verticalAlign =
index 75654ad764a6fe2962ccfa48c009074eba9d197a..139cbd414f01071d57952412cccec463f679073c 100644 (file)
@@ -54,7 +54,7 @@ package org.apache.fop.fo.pagination;
 import java.util.List;
 
 // FOP
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.FOTreeVisitor;
@@ -71,7 +71,7 @@ public class Root extends FObj {
      */
     private int runningPageNumberCounter = 0;
 
-    private Document document = null;
+    private FOTreeControl foTreeControl = null;
 
     /**
      * @see org.apache.fop.fo.FONode#FONode(FONode)
@@ -144,22 +144,23 @@ public class Root extends FObj {
     }
 
     /**
-     * Sets the Document that this Root is attached to
-     * @param document the Document that this Root is attached to
+     * Sets the FOTreeControl that this Root is attached to
+     * @param foTreeControl the FOTreeControl implementation to which this Root
+     * is attached
      */
-    public void setDocument(Document document) {
-        this.document = document;
+    public void setFOTreeControl(FOTreeControl foTreeControl) {
+        this.foTreeControl = foTreeControl;
     }
 
     /**
      * This method overrides the FONode version. The FONode version calls the
      * method by the same name for the parent object. Since Root is at the top
-     * of the tree, it returns the actual Document object. Thus, any FONode can
-     * use this chain to find which Document it is being built for.
-     * @return the Document that this Root is attached to
+     * of the tree, it returns the actual foTreeControl object. Thus, any FONode
+     * can use this chain to find which foTreeControl it is being built for.
+     * @return the FOTreeControl implementation that this Root is attached to
      */
-    public Document getDocument() {
-        return document;
+    public FOTreeControl getFOTreeControl() {
+        return foTreeControl;
     }
 
     public void acceptVisitor(FOTreeVisitor fotv) {
index 8afca744f96751c6e1d920521fcc8112ce27e28e..7b0a9b7185eccfe3aa525d7a007847c03f39073f 100644 (file)
@@ -251,7 +251,7 @@ public class AddLMVisitor extends FOTreeVisitor {
          BlockLayoutManager blm = new BlockLayoutManager();
          blm.setUserAgent(node.getUserAgent());
          blm.setFObj(node);
-         TextInfo ti = node.getPropertyManager().getTextLayoutProps(node.getDocument());
+         TextInfo ti = node.getPropertyManager().getTextLayoutProps(node.getFOTreeControl());
          blm.setBlockTextInfo(ti);
          currentLMList.add(blm);
      }