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/09/22 15:12:39 UTC

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

bckfnn      2004/09/22 06:12:38

  Modified:    src/java/org/apache/fop/render AbstractRenderer.java
               src/java/org/apache/fop/render/awt AWTRenderer.java
               src/java/org/apache/fop/render/pdf PDFRenderer.java
               src/java/org/apache/fop/render/ps PSRenderer.java
               src/java/org/apache/fop/render/svg SVGRenderer.java
  Log:
  Gets rid of currentBlockIPPosition. Use currentIPPosition instead and
  restore it after each block-level area.
  
  Revision  Changes    Path
  1.35      +13 -19    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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- AbstractRenderer.java	22 Sep 2004 08:27:21 -0000	1.34
  +++ AbstractRenderer.java	22 Sep 2004 13:12:38 -0000	1.35
  @@ -98,11 +98,6 @@
       protected int currentIPPosition = 0;
   
       /**
  -     * current inline progression position in block
  -     */
  -    protected int currentBlockIPPosition = 0;
  -
  -    /**
        * the block progression position of the containing block used for
        * absolutely positioned blocks
        */
  @@ -264,7 +259,6 @@
               // set origin for the region to 0,0.
               currentBPPosition = 0;
               currentIPPosition = 0;
  -            currentBlockIPPosition = currentIPPosition;
   
               RegionReference region = port.getRegion();
               handleRegionTraits(port);
  @@ -469,6 +463,8 @@
        * @param blocks  The block areas
        */
       protected void renderBlocks(Block parent, List blocks) {
  +        int saveIP = currentIPPosition;
  +        
           // the position of the containing block is used for
           // absolutely positioned areas
           int contBP = currentBPPosition;
  @@ -479,6 +475,7 @@
           for (int count = 0; count < blocks.size(); count++) {
               Object obj = blocks.get(count);
               if (obj instanceof Block) {
  +                currentIPPosition = saveIP;
                   containingBPPosition = contBP;
                   containingIPPosition = contIP;
                   renderBlock((Block) obj);
  @@ -488,11 +485,11 @@
                   // a line area is rendered from the top left position
                   // of the line, each inline object is offset from there
                   LineArea line = (LineArea) obj;
  -                currentBlockIPPosition =
  -                        currentIPPosition + line.getStartIndent();
  +                currentIPPosition = saveIP + line.getStartIndent();
                   renderLineArea(line);
                   currentBPPosition += line.getAllocBPD();
               }
  +            currentIPPosition = saveIP;
           }
       }
   
  @@ -534,9 +531,9 @@
                   renderBlocks(block, children);
   
                   // stacked and relative blocks effect stacking
  +                currentIPPosition = saveIP;
                   currentBPPosition = saveBP + block.getAllocBPD();
               }
  -            currentIPPosition = saveIP;
           }
       }
   
  @@ -576,7 +573,7 @@
   
       /** @see org.apache.fop.render.Renderer */
       protected void renderCharacter(Character ch) {
  -        currentBlockIPPosition += ch.getAllocIPD();
  +        currentIPPosition += ch.getAllocIPD();
       }
   
       /** @see org.apache.fop.render.Renderer */
  @@ -585,27 +582,27 @@
           // 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.getAllocIPD();
  +        currentIPPosition += space.getAllocIPD();
       }
   
       /** @see org.apache.fop.render.Renderer */
       protected void renderLeader(Leader area) {
  -        currentBlockIPPosition += area.getAllocIPD();
  +        currentIPPosition += area.getAllocIPD();
       }
   
       /** @see org.apache.fop.render.Renderer */
       protected void renderText(TextArea text) {
  -        currentBlockIPPosition += text.getAllocIPD();
  +        currentIPPosition += text.getAllocIPD();
       }
   
       /** @see org.apache.fop.render.Renderer */
       protected void renderInlineParent(InlineParent ip) {
  -        int saveIP = currentBlockIPPosition;
  +        int saveIP = currentIPPosition;
           Iterator iter = ip.getChildAreas().iterator();
           while (iter.hasNext()) {
               renderInlineArea((InlineArea) iter.next()); 
           }
  -        currentBlockIPPosition = saveIP + ip.getAllocIPD();
  +        currentIPPosition = saveIP + ip.getAllocIPD();
       }
   
       /** @see org.apache.fop.render.Renderer */
  @@ -621,7 +618,7 @@
           } else if (content instanceof ForeignObject) {
               renderForeignObject((ForeignObject) content, contpos);
           }
  -        currentBlockIPPosition += viewport.getAllocIPD();
  +        currentIPPosition += viewport.getAllocIPD();
           currentBPPosition = saveBP;
       }
   
  @@ -640,14 +637,11 @@
       /** @see org.apache.fop.render.Renderer */
       public void renderContainer(Container cont) {
           int saveIP = currentIPPosition;
  -        currentIPPosition = currentBlockIPPosition;
  -        int saveBlockIP = currentBlockIPPosition;
           int saveBP = currentBPPosition;
   
           List blocks = cont.getBlocks();
           renderBlocks(null, blocks);
           currentIPPosition = saveIP;
  -        currentBlockIPPosition = saveBlockIP;
           currentBPPosition = saveBP;
       }
   
  
  
  
  1.32      +2 -2      xml-fop/src/java/org/apache/fop/render/awt/AWTRenderer.java
  
  Index: AWTRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/awt/AWTRenderer.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- AWTRenderer.java	22 Sep 2004 08:29:45 -0000	1.31
  +++ AWTRenderer.java	22 Sep 2004 13:12:38 -0000	1.32
  @@ -448,7 +448,7 @@
           graphics.setFont(new java.awt.Font("monospaced", java.awt.Font.PLAIN,
               10));
           
  -        int rx = currentBlockIPPosition;
  +        int rx = currentIPPosition;
           int bl = currentBPPosition + text.getOffset();
   
           int newx = (int) (rx + 500) / 1000;
  @@ -459,7 +459,7 @@
           graphics.drawString(s, 220, 200);
   
           // TODO: render text decorations
  -        currentBlockIPPosition += text.getAllocIPD();
  +        currentIPPosition += text.getAllocIPD();
       }
   
       /** @see org.apache.fop.render.AbstractRenderer */
  
  
  
  1.50      +8 -8      xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java
  
  Index: PDFRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- PDFRenderer.java	22 Sep 2004 08:30:21 -0000	1.49
  +++ PDFRenderer.java	22 Sep 2004 13:12:38 -0000	1.50
  @@ -889,7 +889,7 @@
        * @param ip the inline parent area
        */
       public void renderInlineParent(InlineParent ip) {
  -        float start = (currentBlockIPPosition + ipMarginOffset) / 1000f;
  +        float start = (currentIPPosition + ipMarginOffset) / 1000f;
           float top = (ip.getOffset() + currentBPPosition + bpMarginOffset) / 1000f;
           float width = ip.getIPD() / 1000f;
           float height = ip.getBPD() / 1000f;
  @@ -956,7 +956,7 @@
           // word.getOffset() = only height of text itself
           // currentBlockIPPosition: 0 for beginning of line; nonzero
           //  where previous line area failed to take up entire allocated space
  -        int rx = currentBlockIPPosition + ipMarginOffset;
  +        int rx = currentIPPosition + ipMarginOffset;
           int bl = currentBPPosition + bpMarginOffset + ch.getOffset();
   
   /*        System.out.println("Text = " + ch.getTextArea() +
  @@ -1027,7 +1027,7 @@
           // word.getOffset() = only height of text itself
           // currentBlockIPPosition: 0 for beginning of line; nonzero
           //  where previous line area failed to take up entire allocated space
  -        int rx = currentBlockIPPosition + ipMarginOffset;
  +        int rx = currentIPPosition + ipMarginOffset;
           int bl = currentBPPosition + bpMarginOffset + text.getOffset();
   
   /*        System.out.println("Text = " + text.getTextArea() +
  @@ -1283,7 +1283,7 @@
           saveGraphicsState();
           currentStream.add(((float) w) + " 0 0 "
                             + ((float) -h) + " "
  -                          + (((float) currentBlockIPPosition + ipMarginOffset) / 1000f + x) + " "
  +                          + (((float) currentIPPosition + ipMarginOffset) / 1000f + x) + " "
                             + (((float)(currentBPPosition + bpMarginOffset + 1000 * h)) / 1000f
                             + y) + " cm\n" + "/Im" + xobj + " Do\n");
           restoreGraphicsState();
  @@ -1318,7 +1318,7 @@
           context.setProperty(PDFXMLHandler.PDF_CONTEXT, currentContext);
           context.setProperty(PDFXMLHandler.PDF_STREAM, currentStream);
           context.setProperty(PDFXMLHandler.PDF_XPOS,
  -                            new Integer(currentBlockIPPosition + (int) pos.getX()));
  +                            new Integer(currentIPPosition + (int) pos.getX()));
           context.setProperty(PDFXMLHandler.PDF_YPOS,
                               new Integer(currentBPPosition + (int) pos.getY()));
           context.setProperty(PDFXMLHandler.PDF_FONT_INFO, fontInfo);
  @@ -1341,7 +1341,7 @@
       public void renderViewport(Viewport viewport) {
           closeText();
   
  -        float x = currentBlockIPPosition / 1000f;
  +        float x = currentIPPosition / 1000f;
           float y = (currentBPPosition + viewport.getOffset()) / 1000f;
           float width = viewport.getIPD() / 1000f;
           float height = viewport.getBPD() / 1000f;
  @@ -1389,9 +1389,9 @@
                   alt = true;
               break;
           }
  -        float startx = ((float) currentBlockIPPosition) / 1000f;
  +        float startx = ((float) currentIPPosition) / 1000f;
           float starty = ((currentBPPosition + area.getOffset()) / 1000f);
  -        float endx = (currentBlockIPPosition + area.getIPD()) / 1000f;
  +        float endx = (currentIPPosition + area.getIPD()) / 1000f;
           if (!alt) {
               currentStream.add(area.getRuleThickness() / 1000f + " w\n");
               drawLine(startx, starty, endx, starty);
  
  
  
  1.32      +2 -2      xml-fop/src/java/org/apache/fop/render/ps/PSRenderer.java
  
  Index: PSRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/ps/PSRenderer.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- PSRenderer.java	22 Sep 2004 08:29:44 -0000	1.31
  +++ PSRenderer.java	22 Sep 2004 13:12:38 -0000	1.32
  @@ -452,7 +452,7 @@
           Typeface f = (Typeface) fontInfo.getFonts().get(fontname);
   
           //Determine position
  -        int rx = currentBlockIPPosition;
  +        int rx = currentIPPosition;
           int bl = currentBPPosition + area.getOffset();
   
           useFont(fontname, fontsize);
  @@ -830,7 +830,7 @@
           context.setProperty(PSXMLHandler.PS_HEIGHT,
                               new Integer((int) pos.getHeight()));
           context.setProperty(PSXMLHandler.PS_XPOS,
  -                            new Integer(currentBlockIPPosition + (int) pos.getX()));
  +                            new Integer(currentIPPosition + (int) pos.getX()));
           context.setProperty(PSXMLHandler.PS_YPOS,
                               new Integer(currentBPPosition + (int) pos.getY()));
           //context.setProperty("strokeSVGText", options.get("strokeSVGText"));
  
  
  
  1.19      +5 -6      xml-fop/src/java/org/apache/fop/render/svg/SVGRenderer.java
  
  Index: SVGRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/svg/SVGRenderer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- SVGRenderer.java	22 Sep 2004 08:29:45 -0000	1.18
  +++ SVGRenderer.java	22 Sep 2004 13:12:38 -0000	1.19
  @@ -337,8 +337,7 @@
               Element view = svgDocument.createElementNS(SVG_NAMESPACE, "svg");
               Node newsvg = svgDocument.importNode(svg, true);
               //view.setAttributeNS(null, "viewBox", "0 0 ");
  -            view.setAttributeNS(null, "x",
  -                                "" + currentBlockIPPosition / 1000f);
  +            view.setAttributeNS(null, "x", "" + currentIPPosition / 1000f);
               view.setAttributeNS(null, "y", "" + currentBPPosition / 1000f);
   
               // this fixes a problem where the xmlns is repeated sometimes
  @@ -377,10 +376,10 @@
                   break;
           }
           Element line = SVGUtilities.createLine(svgDocument,
  -                        currentBlockIPPosition / 1000,
  +                        currentIPPosition / 1000,
                           (currentBPPosition + area.getOffset()
                               - area.getRuleThickness() / 2) / 1000,
  -                        (currentBlockIPPosition + area.getIPD()) / 1000,
  +                        (currentIPPosition + area.getIPD()) / 1000,
                           (currentBPPosition + area.getOffset()
                               - area.getRuleThickness() / 2) / 1000);
           line.setAttributeNS(null, "style", style);
  @@ -394,7 +393,7 @@
        */
       public void renderText(TextArea text) {
           Element textElement = SVGUtilities.createText(svgDocument,
  -                                               currentBlockIPPosition / 1000,
  +                                               currentIPPosition / 1000,
                                                  (currentBPPosition + text.getOffset()) / 1000,
                                                  text.getTextArea());
           currentPageG.appendChild(textElement);
  @@ -407,7 +406,7 @@
        */
       public void renderCharacter(org.apache.fop.area.inline.Character ch) {
           Element text = SVGUtilities.createText(svgDocument,
  -                                               currentBlockIPPosition / 1000,
  +                                               currentIPPosition / 1000,
                                                  (currentBPPosition + ch.getOffset()) / 1000,
                                                  "" + ch.getChar());
           currentPageG.appendChild(text);
  
  
  

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