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 gm...@apache.org on 2004/02/25 04:32:17 UTC

cvs commit: xml-fop/src/java/org/apache/fop/render/xml XMLRenderer.java

gmazza      2004/02/24 19:32:17

  Modified:    src/java/org/apache/fop/area/inline Character.java
                        InlineArea.java InlineParent.java Leader.java
                        Space.java TextArea.java Viewport.java
               src/java/org/apache/fop/render AbstractRenderer.java
               src/java/org/apache/fop/render/xml XMLRenderer.java
  Removed:     src/java/org/apache/fop/area/inline InlineAreaVisitor.java
  Log:
  Removal of Visitor patterns from AbstractRenderer, moving of business logic from InlineArea to AbstractRenderer.
  
  Revision  Changes    Path
  1.3       +0 -10     xml-fop/src/java/org/apache/fop/area/inline/Character.java
  
  Index: Character.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/inline/Character.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Character.java	10 Sep 2003 18:42:22 -0000	1.2
  +++ Character.java	25 Feb 2004 03:32:16 -0000	1.3
  @@ -67,16 +67,6 @@
       }
   
       /**
  -     * Handle InlineAreaVisitor request by passing this back to it.
  -     *
  -     * @param visitor the InlineAreaVisitor wishing to process this.
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void acceptVisitor(InlineAreaVisitor visitor) {
  -        visitor.serveVisitor(this);
  -    }
  -
  -    /**
        * Get the character for this inline character area.
        *
        * @return the character
  
  
  
  1.3       +0 -13     xml-fop/src/java/org/apache/fop/area/inline/InlineArea.java
  
  Index: InlineArea.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/inline/InlineArea.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InlineArea.java	10 Sep 2003 18:42:22 -0000	1.2
  +++ InlineArea.java	25 Feb 2004 03:32:17 -0000	1.3
  @@ -58,8 +58,6 @@
    * Inline Area
    * This area is for all inline areas that can be placed
    * in a line area.
  - * Extensions of this class should render themselves with the
  - * requested renderer.
    */
   public class InlineArea extends Area {
       // int width;
  @@ -73,17 +71,6 @@
        * offset position from top of parent area
        */
       protected int verticalPosition = 0;
  -
  -    /**
  -     * Handle a visitor (usually a renderer) for this inline area.
  -     * Inline areas that extend this class are expected
  -     * to pass themselves back to the visitor so that the visitor can process
  -     * them, usually by rendering them.
  -     *
  -     * @param visitor the InlineAreaVisitor that will process this
  -     */
  -    public void acceptVisitor(InlineAreaVisitor visitor) {
  -    }
   
       /**
        * Set the width of this inline area.
  
  
  
  1.3       +0 -10     xml-fop/src/java/org/apache/fop/area/inline/InlineParent.java
  
  Index: InlineParent.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/inline/InlineParent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InlineParent.java	10 Sep 2003 18:42:22 -0000	1.2
  +++ InlineParent.java	25 Feb 2004 03:32:17 -0000	1.3
  @@ -77,16 +77,6 @@
       }
   
       /**
  -     * Handle InlineAreaVisitor request by passing this back to it.
  -     *
  -     * @param visitor the InlineAreaVisitor wishing to process this.
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void acceptVisitor(InlineAreaVisitor visitor) {
  -        visitor.serveVisitor(this);
  -    }
  -
  -    /**
        * Override generic Area method.
        *
        * @param childArea the child area to add
  
  
  
  1.4       +0 -10     xml-fop/src/java/org/apache/fop/area/inline/Leader.java
  
  Index: Leader.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/inline/Leader.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Leader.java	17 Jan 2004 19:29:45 -0000	1.3
  +++ Leader.java	25 Feb 2004 03:32:17 -0000	1.4
  @@ -108,15 +108,5 @@
           return ruleThickness;
       }
   
  -    /**
  -     * Handle InlineAreaVisitor request by passing this back to it.
  -     *
  -     * @param visitor the InlineAreaVisitor wishing to process this.
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void acceptVisitor(InlineAreaVisitor visitor) {
  -        visitor.serveVisitor(this);
  -    }
  -
   }
   
  
  
  
  1.3       +0 -10     xml-fop/src/java/org/apache/fop/area/inline/Space.java
  
  Index: Space.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/inline/Space.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Space.java	10 Sep 2003 18:42:22 -0000	1.2
  +++ Space.java	25 Feb 2004 03:32:17 -0000	1.3
  @@ -56,14 +56,4 @@
    */
   public class Space extends InlineArea {
   
  -    /**
  -     * Handle InlineAreaVisitor request by passing this back to it.
  -     *
  -     * @param visitor the InlineAreaVisitor wishing to process this.
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void acceptVisitor(InlineAreaVisitor visitor) {
  -        visitor.serveVisitor(this);
  -    }
  -
   }
  
  
  
  1.2       +1 -11     xml-fop/src/java/org/apache/fop/area/inline/TextArea.java
  
  Index: TextArea.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/inline/TextArea.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TextArea.java	28 Oct 2003 04:22:13 -0000	1.1
  +++ TextArea.java	25 Feb 2004 03:32:17 -0000	1.2
  @@ -68,16 +68,6 @@
       }
   
       /**
  -     * Handle InlineAreaVisitor request by passing this back to it.
  -     *
  -     * @param visitor the InlineAreaVisitor wishing to process this.
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void acceptVisitor(InlineAreaVisitor visitor) {
  -        visitor.serveVisitor(this);
  -    }
  -
  -    /**
        * Set the text string
        *
        * @param t the text string
  
  
  
  1.3       +0 -10     xml-fop/src/java/org/apache/fop/area/inline/Viewport.java
  
  Index: Viewport.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/inline/Viewport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Viewport.java	10 Sep 2003 18:42:22 -0000	1.2
  +++ Viewport.java	25 Feb 2004 03:32:17 -0000	1.3
  @@ -124,16 +124,6 @@
           return content;
       }
   
  -    /**
  -     * Handle InlineAreaVisitor request by passing this back to it.
  -     *
  -     * @param visitor the InlineAreaVisitor wishing to process this.
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void acceptVisitor(InlineAreaVisitor visitor) {
  -        visitor.serveVisitor(this);
  -    }
  -
       private void writeObject(java.io.ObjectOutputStream out)
       throws IOException {
           out.writeBoolean(contentPosition != null);
  
  
  
  1.22      +53 -110   xml-fop/src/java/org/apache/fop/render/AbstractRenderer.java
  
  Index: AbstractRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/AbstractRenderer.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- AbstractRenderer.java	4 Feb 2004 13:06:36 -0000	1.21
  +++ AbstractRenderer.java	25 Feb 2004 03:32:17 -0000	1.22
  @@ -85,7 +85,6 @@
   import org.apache.fop.area.inline.ForeignObject;
   import org.apache.fop.area.inline.Image;
   import org.apache.fop.area.inline.InlineArea;
  -import org.apache.fop.area.inline.InlineAreaVisitor;
   import org.apache.fop.area.inline.InlineParent;
   import org.apache.fop.area.inline.Leader;
   import org.apache.fop.area.inline.Space;
  @@ -109,7 +108,7 @@
    * handle viewports. This keeps track of the current block and inline position.
    */
   public abstract class AbstractRenderer extends AbstractLogEnabled
  -         implements Renderer, Configurable, InlineAreaVisitor, Constants {
  +         implements Renderer, Configurable, Constants {
   
       /**
        * user agent
  @@ -618,10 +617,61 @@
   
           for (int count = 0; count < children.size(); count++) {
               InlineArea inline = (InlineArea) children.get(count);
  -            inline.acceptVisitor(this);
  +            renderInlineArea(inline);
           }
       }
   
  +    protected void renderInlineArea(InlineArea inlineArea) {
  +        if (inlineArea instanceof TextArea) {
  +            renderText((TextArea) inlineArea);
  +        } else if (inlineArea instanceof InlineParent) {
  +            renderInlineParent((InlineParent) inlineArea);
  +        } else if (inlineArea instanceof Space) {
  +            renderInlineSpace((Space) inlineArea);
  +        } else if (inlineArea instanceof Character) {
  +            renderCharacter((Character) inlineArea);
  +        } else if (inlineArea instanceof Viewport) {
  +            renderViewport((Viewport) inlineArea);
  +        } else if (inlineArea instanceof Leader) {
  +            renderLeader((Leader) inlineArea);
  +        }
  +    }
  +
  +
  +    /** @see org.apache.fop.render.Renderer */
  +    public void renderCharacter(Character ch) {
  +        currentBlockIPPosition += ch.getWidth();
  +    }
  +
  +    /** @see org.apache.fop.render.Renderer */
  +    public void renderInlineSpace(Space space) {
  +        // an inline space moves the inline progression position
  +        // for the current block by the width or height of the space
  +        // it may also have styling (only on this object) that needs
  +        // handling
  +        currentBlockIPPosition += space.getWidth();
  +    }
  +
  +    /** @see org.apache.fop.render.Renderer */
  +    public void renderLeader(Leader area) {
  +        currentBlockIPPosition += area.getWidth();
  +    }
  +
  +    /** @see org.apache.fop.render.Renderer */
  +    public void renderText(TextArea text) {
  +        currentBlockIPPosition += text.getWidth();
  +    }
  +
  +    /** @see org.apache.fop.render.Renderer */
  +    public void renderInlineParent(InlineParent ip) {
  +        int saveIP = currentBlockIPPosition;
  +        Iterator iter = ip.getChildAreas().iterator();
  +        while (iter.hasNext()) {
  +            renderInlineArea((InlineArea) iter.next()); 
  +        }
  +        currentBlockIPPosition = saveIP + ip.getWidth();
  +    }
  +
       /** @see org.apache.fop.render.Renderer */
       public void renderViewport(Viewport viewport) {
           Area content = viewport.getContent();
  @@ -677,40 +727,6 @@
           // Some renderers (ex. Text) don't support foreign objects.
       }
   
  -    /** @see org.apache.fop.render.Renderer */
  -    public void renderCharacter(Character ch) {
  -        currentBlockIPPosition += ch.getWidth();
  -    }
  -
  -    /** @see org.apache.fop.render.Renderer */
  -    public void renderInlineSpace(Space space) {
  -        // an inline space moves the inline progression position
  -        // for the current block by the width or height of the space
  -        // it may also have styling (only on this object) that needs
  -        // handling
  -        currentBlockIPPosition += space.getWidth();
  -    }
  -
  -    /** @see org.apache.fop.render.Renderer */
  -    public void renderLeader(Leader area) {
  -        currentBlockIPPosition += area.getWidth();
  -    }
  -
  -    /** @see org.apache.fop.render.Renderer */
  -    public void renderText(TextArea text) {
  -        currentBlockIPPosition += text.getWidth();
  -    }
  -
  -    /** @see org.apache.fop.render.Renderer */
  -    public void renderInlineParent(InlineParent ip) {
  -        int saveIP = currentBlockIPPosition;
  -        Iterator iter = ip.getChildAreas().iterator();
  -        while (iter.hasNext()) {
  -            ((InlineArea) iter.next()).acceptVisitor(this);
  -        }
  -        currentBlockIPPosition = saveIP + ip.getWidth();
  -    }
  -
       /**
        * Set the default xml handler for the given mime type.
        * @param mime MIME type
  @@ -770,78 +786,5 @@
                       + "No handler defined for XML: " + namespace);
           }
       }
  -
  -    /**
  -     * Render the specified Viewport.
  -     * Required by InlineAreaVisitor interface, which is used to determine which
  -     * InlineArea subclass should be rendered.
  -     *
  -     * @param viewport  The Viewport area to be rendered
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void serveVisitor(Viewport viewport) {
  -        renderViewport(viewport);
  -    }
  -
  -    /**
  -     * Render the specified Text.
  -     * Required by InlineAreaVisitor interface, which is used to determine which
  -     * InlineArea subclass should be rendered.
  -     *
  -     * @param area  The Text area to be rendered
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void serveVisitor(TextArea area) {
  -        renderText(area);
  -    }
  -
  -    /**
  -     * Render the specified InlineParent.
  -     * Required by InlineAreaVisitor interface, which is used to determine which
  -     * InlineArea subclass should be rendered.
  -     *
  -     * @param ip  The InlineParent area to be rendered
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void serveVisitor(InlineParent ip) {
  -        renderInlineParent(ip);
  -    }
  -
  -    /**
  -     * Render the specified Character.
  -     * Required by InlineAreaVisitor interface, which is used to determine which
  -     * InlineArea subclass should be rendered.
  -     *
  -     * @param ch  The Character area to be rendered
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void serveVisitor(org.apache.fop.area.inline.Character ch) {
  -        renderCharacter(ch);
  -    }
  -
  -    /**
  -     * Render the specified Space.
  -     * Required by InlineAreaVisitor interface, which is used to determine which
  -     * InlineArea subclass should be rendered.
  -     *
  -     * @param space  The Space area to be rendered
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void serveVisitor(Space space) {
  -        renderInlineSpace(space);
  -    }
  -
  -    /**
  -     * Render the specified Leader.
  -     * Required by InlineAreaVisitor interface, which is used to determine which
  -     * InlineArea subclass should be rendered.
  -     *
  -     * @param area  The Leader area to be rendered
  -     * @see org.apache.fop.area.inline.InlineAreaVisitor
  -     */
  -    public void serveVisitor(Leader area) {
  -        renderLeader(area);
  -    }
  -
   }
   
  
  
  
  1.16      +2 -2      xml-fop/src/java/org/apache/fop/render/xml/XMLRenderer.java
  
  Index: XMLRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/xml/XMLRenderer.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- XMLRenderer.java	24 Jan 2004 16:09:48 -0000	1.15
  +++ XMLRenderer.java	25 Feb 2004 03:32:17 -0000	1.16
  @@ -272,7 +272,7 @@
   
               for (int count = 0; count < children.size(); count++) {
                   InlineArea inline = (InlineArea) children.get(count);
  -                inline.acceptVisitor(this);
  +                renderInlineArea(inline);
               }
   
               writeEndTag("</title>");
  @@ -476,7 +476,7 @@
           }
           writeStartTag("<inlineparent" + prop + ">");
           super.renderInlineParent(ip);
  -    writeEndTag("</inlineparent>");
  +        writeEndTag("</inlineparent>");
       }
   
       /**
  
  
  

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