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 je...@apache.org on 2004/10/10 14:20:47 UTC

cvs commit: xml-fop/src/java/org/apache/fop/render/ps AbstractPSTranscoder.java AbstractPSDocumentGraphics2D.java

jeremias    2004/10/10 05:20:47

  Modified:    src/java/org/apache/fop/render/ps AbstractPSTranscoder.java
                        AbstractPSDocumentGraphics2D.java
  Log:
  Implement the cheaper mechanism to ensure correct rendering at differing resolutions. This is probably only an intermediate solution and does not implement what Thomas DeWeese suggested.
  
  Revision  Changes    Path
  1.6       +31 -19    xml-fop/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
  
  Index: AbstractPSTranscoder.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractPSTranscoder.java	24 Apr 2004 06:08:13 -0000	1.5
  +++ AbstractPSTranscoder.java	10 Oct 2004 12:20:47 -0000	1.6
  @@ -26,6 +26,7 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.batik.bridge.BridgeContext;
  +import org.apache.batik.bridge.UnitProcessor;
   import org.apache.batik.transcoder.TranscoderException;
   import org.apache.batik.transcoder.TranscoderOutput;
   
  @@ -34,6 +35,7 @@
   import org.apache.fop.svg.AbstractFOPTranscoder;
   
   import org.w3c.dom.Document;
  +import org.w3c.dom.svg.SVGLength;
   
   /**
    * This class enables to transcode an input to a PostScript document.
  @@ -77,21 +79,6 @@
   
       protected abstract AbstractPSDocumentGraphics2D createDocumentGraphics2D();
   
  -    protected BridgeContext createBridgeContext() {
  -        /*boolean stroke = true;
  -        if (hints.containsKey(KEY_STROKE_TEXT)) {
  -            stroke = ((Boolean)hints.get(KEY_STROKE_TEXT)).booleanValue();
  -        }*/
  -
  -        BridgeContext ctx = new BridgeContext(userAgent);
  -        PSTextPainter textPainter = new PSTextPainter(graphics.getFontInfo());
  -        ctx.setTextPainter(textPainter);
  -        ctx.putBridge(new PSTextElementBridge(textPainter));
  -
  -        //ctx.putBridge(new PSImageElementBridge());
  -        return ctx;
  -    }
  -
       /**
        * Transcodes the specified Document as an image in the specified output.
        *
  @@ -118,9 +105,19 @@
   
           super.transcode(document, uri, output);
   
  +        getLogger().trace("document size: " + width + " x " + height);
  +        
           // prepare the image to be painted
  -        int w = (int)(width + 0.5);
  -        int h = (int)(height + 0.5);
  +        UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, 
  +                    document.getDocumentElement());
  +        float widthInPt = UnitProcessor.userSpaceToSVG(width, SVGLength.SVG_LENGTHTYPE_PT, 
  +                    UnitProcessor.HORIZONTAL_LENGTH, uctx);
  +        int w = (int)(widthInPt + 0.5);
  +        float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT, 
  +                UnitProcessor.HORIZONTAL_LENGTH, uctx);
  +        int h = (int)(heightInPt + 0.5);
  +        getLogger().trace("document size: " + w + "pt x " + h + "pt");
  +        
   
           try {
               graphics.setupDocument(output.getOutputStream(), w, h);
  @@ -140,6 +137,21 @@
           } catch (IOException ex) {
               throw new TranscoderException(ex);
           }
  +    }
  +
  +    protected BridgeContext createBridgeContext() {
  +        /*boolean stroke = true;
  +        if (hints.containsKey(KEY_STROKE_TEXT)) {
  +            stroke = ((Boolean)hints.get(KEY_STROKE_TEXT)).booleanValue();
  +        }*/
  +
  +        BridgeContext ctx = new BridgeContext(userAgent);
  +        PSTextPainter textPainter = new PSTextPainter(graphics.getFontInfo());
  +        ctx.setTextPainter(textPainter);
  +        ctx.putBridge(new PSTextElementBridge(textPainter));
  +
  +        //ctx.putBridge(new PSImageElementBridge());
  +        return ctx;
       }
   
   
  
  
  
  1.7       +18 -4     xml-fop/src/java/org/apache/fop/render/ps/AbstractPSDocumentGraphics2D.java
  
  Index: AbstractPSDocumentGraphics2D.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/ps/AbstractPSDocumentGraphics2D.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractPSDocumentGraphics2D.java	24 Apr 2004 06:08:13 -0000	1.6
  +++ AbstractPSDocumentGraphics2D.java	10 Oct 2004 12:20:47 -0000	1.7
  @@ -45,6 +45,9 @@
       
       protected int width;
       protected int height;
  +    
  +    protected float viewportWidth;
  +    protected float viewportHeight;
   
       protected int pagecount;
       protected boolean pagePending;
  @@ -126,9 +129,12 @@
        * @throws IOException in case of an I/O problem
        */
       public void setSVGDimension(float w, float h) throws IOException {
  +        this.viewportWidth = w;
  +        this.viewportHeight = h;
  +        /*
           if (w != this.width || h != this.height) {
               gen.concatMatrix(width / w, 0, 0, height / h, 0, 0);
  -        }
  +        }*/
       }
   
       /**
  @@ -213,7 +219,15 @@
             
           writePageHeader();
           gen.writeln("0.001 0.001 scale");
  -        gen.concatMatrix(1, 0, 0, -1, 0, this.height * 1000);
  +        if ((this.viewportWidth != this.width 
  +                || this.viewportHeight != this.height)
  +                && (this.viewportWidth > 0) && (this.viewportHeight > 0)){
  +            gen.concatMatrix(this.width / this.viewportWidth, 0, 
  +                       0, -1 * (this.height / this.viewportHeight), 
  +                       0, this.height * 1000);
  +        } else {
  +            gen.concatMatrix(1, 0, 0, -1, 0, this.height * 1000);
  +        }
           gen.writeDSCComment(DSCConstants.END_PAGE_SETUP);
           this.pagePending = true;
       }
  
  
  

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