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 bc...@apache.org on 2004/10/19 14:52:09 UTC

cvs commit: xml-fop/src/java/org/apache/fop/fo/extensions/svg SVGElement.java

bckfnn      2004/10/19 05:52:09

  Modified:    examples/plan/src/org/apache/fop/plan PlanElement.java
               src/java/org/apache/fop/fo FONode.java FOTreeBuilder.java
                        FObj.java UnknownXMLObj.java XMLObj.java
               src/java/org/apache/fop/fo/extensions/svg SVGElement.java
  Log:
  Second phase of performance improvement. Pass the propertyList into
  processNode(..) and addCharacters(..).
  
  PR: 31699
  
  Revision  Changes    Path
  1.8       +6 -3      xml-fop/examples/plan/src/org/apache/fop/plan/PlanElement.java
  
  Index: PlanElement.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/examples/plan/src/org/apache/fop/plan/PlanElement.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PlanElement.java	14 Aug 2004 16:26:08 -0000	1.7
  +++ PlanElement.java	19 Oct 2004 12:52:09 -0000	1.8
  @@ -21,6 +21,7 @@
   import java.awt.geom.Point2D;
   
   import org.apache.fop.fo.FONode;
  +import org.apache.fop.fo.PropertyList;
   
   import org.w3c.dom.Document;
   import org.xml.sax.Attributes;
  @@ -48,8 +49,10 @@
        * @see org.apache.fop.fo.FONode#processNode
        */
       public void processNode(String elementName, Locator locator, 
  -                            Attributes attlist) throws SAXParseException {
  -        super.processNode(elementName, locator, attlist);
  +                            Attributes attlist, PropertyList propertyList)
  +        throws SAXParseException
  +    {
  +        super.processNode(elementName, locator, attlist, propertyList);
           createBasicDocument();
       }
   
  
  
  
  1.48      +3 -1      xml-fop/src/java/org/apache/fop/fo/FONode.java
  
  Index: FONode.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- FONode.java	18 Oct 2004 20:15:19 -0000	1.47
  +++ FONode.java	19 Oct 2004 12:52:09 -0000	1.48
  @@ -107,7 +107,8 @@
        * @param attlist Collection of attributes passed to us from the parser.
        * @throws SAXParseException for errors or inconsistencies in the attributes
       */
  -    public void processNode(String elementName, Locator locator, Attributes attlist) throws SAXParseException {
  +    public void processNode(String elementName, Locator locator, 
  +            Attributes attlist, PropertyList parent) throws SAXParseException {
           System.out.println("name = " + elementName);
       }
   
  @@ -143,6 +144,7 @@
        * @param locator location in fo source file. 
        */
       protected void addCharacters(char data[], int start, int length,
  +                                 PropertyList pList,
                                    Locator locator) throws SAXParseException {
           // ignore
       }
  
  
  
  1.55      +16 -3     xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java
  
  Index: FOTreeBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- FOTreeBuilder.java	10 Oct 2004 12:24:02 -0000	1.54
  +++ FOTreeBuilder.java	19 Oct 2004 12:52:09 -0000	1.55
  @@ -80,6 +80,11 @@
       protected FONode currentFObj = null;
   
       /**
  +     * Current propertyList for the node being handled.
  +     */
  +    protected PropertyList currentPropertyList;
  +
  +    /**
        * The class that handles formatting and rendering to a stream
        * (mark-fop@inomial.com)
        */
  @@ -188,7 +193,7 @@
       public void characters(char[] data, int start, int length) 
           throws SAXParseException {
               if (currentFObj != null) {
  -                currentFObj.addCharacters(data, start, start + length, locator);
  +                currentFObj.addCharacters(data, start, start + length, currentPropertyList, locator);
               }
       }
   
  @@ -226,6 +231,7 @@
   
           /* the node found in the FO document */
           FONode foNode;
  +        PropertyList propertyList;
   
           // Check to ensure first node encountered is an fo:root
           if (rootFObj == null) {
  @@ -250,7 +256,9 @@
   
           try {
               foNode = fobjMaker.make(currentFObj);
  -            foNode.processNode(localName, locator, attlist);
  +            propertyList = foNode.createPropertyList(currentPropertyList, foEventHandler);
  +            foNode.processNode(localName, locator, attlist, propertyList);
  +            foNode.startOfNode();
           } catch (IllegalArgumentException e) {
               throw new SAXException(e);
           }
  @@ -263,6 +271,9 @@
           }
   
           currentFObj = foNode;
  +        if (propertyList != null) {
  +            currentPropertyList = propertyList;
  +        }
       }
   
       /**
  @@ -277,6 +288,9 @@
               throw e;
           }
   
  +        if (currentPropertyList.getFObj() == currentFObj) {
  +            currentPropertyList = currentPropertyList.getParentPropertyList();
  +        }
           currentFObj = currentFObj.getParent();
       }
   
  @@ -341,7 +355,6 @@
           rootFObj = null;
           foEventHandler = null;
       }
  -
   }
   
   // code stolen from org.apache.batik.util and modified slightly
  
  
  
  1.80      +7 -112    xml-fop/src/java/org/apache/fop/fo/FObj.java
  
  Index: FObj.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObj.java,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- FObj.java	18 Oct 2004 20:15:19 -0000	1.79
  +++ FObj.java	19 Oct 2004 12:52:09 -0000	1.80
  @@ -97,9 +97,12 @@
        * @see org.apache.fop.fo.FONode#processNode
        */
       public void processNode(String elementName, Locator locator, 
  -                            Attributes attlist) throws SAXParseException {
  +                            Attributes attlist, PropertyList pList) throws SAXParseException {
           setLocator(locator);
  -        addProperties(attlist);
  +        propertyList.addAttributesToList(attlist);
  +        propertyList.setWritingMode();
  +        bind(propertyList);
  +        propMgr = new PropertyManager(propertyList);
       }
   
       /**
  @@ -107,7 +110,8 @@
        */
       protected PropertyList createPropertyList(PropertyList parent, FOEventHandler foEventHandler) throws SAXParseException {
           //return foEventHandler.getPropertyListMaker().make(this, parent);
  -        return null;
  +        propertyList = new StaticPropertyList(this, parent);
  +        return propertyList;
       }
   
       /**
  @@ -140,49 +144,6 @@
       }
   
       /**
  -     * Set properties for this FO based on node attributes
  -     * @param attlist Collection of attributes passed to us from the parser.
  -     */
  -    protected void addProperties(Attributes attlist) throws SAXParseException {
  -        FObj parentFO = findNearestAncestorFObj();
  -        PropertyList parentPL = null;
  -
  -        if (parentFO != null) {
  -            parentPL = parentFO.getPropertiesForNamespace(FO_URI);
  -        }
  -
  -        propertyList = new PropertyList(this, parentPL, FO_URI);
  -        propertyList.addAttributesToList(attlist);
  -        propMgr = new PropertyManager(propertyList);
  -        setWritingMode();
  -        
  -        // if this FO can have a PR_ID, make sure it is unique
  -        if (PropertySets.canHaveId(getNameId())) {
  -            setupID();
  -        }
  -    }
  -
  -    /**
  -     * Setup the id for this formatting object.
  -     * Most formatting objects can have an id that can be referenced.
  -     * This methods checks that the id isn't already used by another
  -     * fo and sets the id attribute of this object.
  -     */
  -    private void setupID() throws SAXParseException {
  -        String str = getPropString(PR_ID);
  -        if (str != null && !str.equals("")) {
  -            Set idrefs = getFOEventHandler().getIDReferences();
  -            if (!idrefs.contains(str)) {
  -                idrefs.add(str);
  -            } else {
  -                throw new SAXParseException("Property id \"" + str + 
  -                    "\" previously used; id values must be unique" +
  -                    " in document.", locator);
  -            }
  -        }
  -    }
  -
  -    /**
        * Returns Out Of Line FO Descendant indicator.
        * @return true if Out of Line FO or Out Of Line descendant, false otherwise
        */
  @@ -280,61 +241,6 @@
           return (FObj) par;
       }
   
  -    /**
  -     * Find nearest ancestor which generates Reference Areas.
  -     *
  -     * @param includeSelf Set to true to consider the current FObj as an
  -     * "ancestor". Set to false to only return a true ancestor.
  -     * @param returnRoot Supposing a condition where no appropriate ancestor
  -     * FObj is found, setting returnRoot to true will return the FObj with no
  -     * parent (presumably the root FO). Otherwise, null will be returned.
  -     * Note that this will override a false setting for includeSelf, and return
  -     * the current node if it is the root FO. Setting returnRoot to true should
  -     * always return a valid FObj.
  -     * @return FObj of the nearest ancestor that generates Reference Areas
  -     * and fits the parameters.
  -     */
  -    private FObj findNearestAncestorGeneratingRAs(boolean includeSelf,
  -                                                  boolean returnRoot) {
  -        FObj p = this;
  -        if (includeSelf && p.generatesReferenceAreas()) {
  -            return p;
  -        }
  -        FObj parent = p.findNearestAncestorFObj();
  -        if (parent == null && returnRoot) {
  -            return p;
  -        }
  -        do {
  -            p = parent;
  -            parent = p.findNearestAncestorFObj();
  -        } while (parent != null && !p.generatesReferenceAreas());
  -        if (p.generatesReferenceAreas()) {
  -            return p;
  -        }
  -        // if we got here, it is because parent is null
  -        if (returnRoot) {
  -            return p;
  -        } else {
  -            return null;
  -        }
  -    }
  -
  -    /**
  -     * For a given namespace, determine whether the properties of this object
  -     * match that namespace.
  -     * @param nameSpaceURI the namespace URI to be tested against
  -     * @return this.propertyList, if the namespaces match; otherwise, null
  -     */
  -    public PropertyList getPropertiesForNamespace(String nameSpaceURI) {
  -        if (this.propertyList == null) {
  -            return null;
  -        }
  -        if (!nameSpaceURI.equals(this.propertyList.getNameSpace())) {
  -            return null;
  -        }
  -        return this.propertyList;
  -    }
  -
       /* This section is the implemenation of the property context. */
   
       /**
  @@ -386,17 +292,6 @@
        */
       public boolean generatesReferenceAreas() {
           return false;
  -    }
  -
  -    /**
  -     * Set writing mode for this FO.
  -     * Use that from the nearest ancestor, including self, which generates
  -     * reference areas, or from root FO if no ancestor found.
  -     */
  -    protected void setWritingMode() {
  -        FObj p = findNearestAncestorGeneratingRAs(true, true);
  -        this.propertyList.setWritingMode(
  -          p.getPropEnum(PR_WRITING_MODE));
       }
   
       /**
  
  
  
  1.12      +2 -2      xml-fop/src/java/org/apache/fop/fo/UnknownXMLObj.java
  
  Index: UnknownXMLObj.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/UnknownXMLObj.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- UnknownXMLObj.java	6 Sep 2004 20:54:59 -0000	1.11
  +++ UnknownXMLObj.java	19 Oct 2004 12:52:09 -0000	1.12
  @@ -82,11 +82,11 @@
        *  @see XMLObj#addCharacters
        */
       protected void addCharacters(char data[], int start, int length,
  -                                 Locator locator) {
  +                                 PropertyList pList, Locator locator) {
           if (doc == null) {
               createBasicDocument();
           }
  -        super.addCharacters(data, start, length, locator);
  +        super.addCharacters(data, start, length, pList, locator);
       }
   }
   
  
  
  
  1.18      +2 -2      xml-fop/src/java/org/apache/fop/fo/XMLObj.java
  
  Index: XMLObj.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/XMLObj.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XMLObj.java	5 Sep 2004 04:00:52 -0000	1.17
  +++ XMLObj.java	19 Oct 2004 12:52:09 -0000	1.18
  @@ -69,7 +69,7 @@
        * @see org.apache.fop.fo.FONode#processNode
        */
       public void processNode(String elementName, Locator locator, 
  -        Attributes attlist) throws SAXParseException {
  +        Attributes attlist, PropertyList propertyList) throws SAXParseException {
               setLocator(locator);
               name = elementName;
               attr = attlist;
  @@ -211,7 +211,7 @@
        * @param locator location in fo source file.
        */
       protected void addCharacters(char data[], int start, int length,
  -                                 Locator locator) {
  +                                 PropertyList pList, Locator locator) {
           String str = new String(data, start, length - start);
           org.w3c.dom.Text text = doc.createTextNode(str);
           element.appendChild(text);
  
  
  
  1.12      +4 -3      xml-fop/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java
  
  Index: SVGElement.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SVGElement.java	4 Aug 2004 22:21:03 -0000	1.11
  +++ SVGElement.java	19 Oct 2004 12:52:09 -0000	1.12
  @@ -20,6 +20,7 @@
   
   // FOP
   import org.apache.fop.fo.FONode;
  +import org.apache.fop.fo.PropertyList;
   
   import org.apache.batik.dom.svg.SVGOMDocument;
   import org.apache.batik.dom.svg.SVGOMElement;
  @@ -61,8 +62,8 @@
        * @see org.apache.fop.fo.FONode#processNode
        */
       public void processNode(String elementName, Locator locator, 
  -                            Attributes attlist) throws SAXParseException {
  -        super.processNode(elementName, locator, attlist);
  +                            Attributes attlist, PropertyList propertyList) throws SAXParseException {
  +        super.processNode(elementName, locator, attlist, propertyList);
           init();
       }
   
  
  
  

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