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 2008/11/21 17:33:34 UTC

svn commit: r719629 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps: AbstractPSTranscoder.java NativeTextHandler.java PSSVGHandler.java

Author: jeremias
Date: Fri Nov 21 08:33:33 2008
New Revision: 719629

URL: http://svn.apache.org/viewvc?rev=719629&view=rev
Log:
Fix for unit test failure in transcoder tests (NullPointerException):
Have to pass the root PSGraphics2D to NativeTextHandler instead of the PSGenerator as this one hasn't been initialized in PSGraphics2D when the NativeTextHandler is built in AbstractPSTranscoder.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java?rev=719629&r1=719628&r2=719629&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java Fri Nov 21 08:33:33 2008
@@ -25,20 +25,23 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.w3c.dom.Document;
+import org.w3c.dom.svg.SVGLength;
+
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.UnitProcessor;
 import org.apache.batik.transcoder.TranscoderException;
 import org.apache.batik.transcoder.TranscoderOutput;
 import org.apache.batik.transcoder.image.ImageTranscoder;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.fonts.FontSetup;
-import org.apache.fop.svg.AbstractFOPTranscoder;
+
 import org.apache.xmlgraphics.java2d.TextHandler;
 import org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D;
 import org.apache.xmlgraphics.ps.PSGenerator;
-import org.w3c.dom.Document;
-import org.w3c.dom.svg.SVGLength;
+
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontSetup;
+import org.apache.fop.svg.AbstractFOPTranscoder;
 
 /**
  * This class enables to transcode an input to a PostScript document.
@@ -99,7 +102,7 @@
             //TODO Do custom font configuration here somewhere/somehow
             FontSetup.setup(fontInfo);
             PSGenerator generator = graphics.getPSGenerator();
-            graphics.setCustomTextHandler(new NativeTextHandler(generator, fontInfo));
+            graphics.setCustomTextHandler(new NativeTextHandler(graphics, fontInfo));
         }
 
         super.transcode(document, uri, output);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java?rev=719629&r1=719628&r2=719629&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java Fri Nov 21 08:33:33 2008
@@ -24,13 +24,14 @@
 import java.awt.geom.AffineTransform;
 import java.io.IOException;
 
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.java2d.ps.PSTextHandler;
+import org.apache.xmlgraphics.ps.PSGenerator;
+
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.fonts.FontTriplet;
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
-import org.apache.xmlgraphics.java2d.ps.PSTextHandler;
-import org.apache.xmlgraphics.ps.PSGenerator;
 
 /**
  * Specialized TextHandler implementation that the PSGraphics2D class delegates to to paint text
@@ -38,7 +39,7 @@
  */
 public class NativeTextHandler implements PSTextHandler {
 
-    private final PSGenerator gen;
+    private PSGraphics2D rootG2D;
 
     /** FontInfo containing all available fonts */
     protected FontInfo fontInfo;
@@ -60,8 +61,8 @@
      * @param g2d the PSGraphics2D instance this instances is used by
      * @param fontInfo the FontInfo object with all available fonts
      */
-    public NativeTextHandler(PSGenerator gen, FontInfo fontInfo) {
-        this.gen = gen;
+    public NativeTextHandler(PSGraphics2D g2d, FontInfo fontInfo) {
+        this.rootG2D = g2d;
         if (fontInfo != null) {
             this.fontInfo = fontInfo;
         } else {
@@ -84,7 +85,7 @@
     }
 
     private PSGenerator getPSGenerator() {
-        return this.gen;
+        return this.rootG2D.getPSGenerator();
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java?rev=719629&r1=719628&r2=719629&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java Fri Nov 21 08:33:33 2008
@@ -24,12 +24,18 @@
 import java.io.IOException;
 import java.util.Map;
 
+import org.w3c.dom.Document;
+
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.GVTBuilder;
 import org.apache.batik.gvt.GraphicsNode;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.ps.PSGenerator;
+
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.render.AbstractGenericSVGHandler;
 import org.apache.fop.render.Renderer;
@@ -37,9 +43,6 @@
 import org.apache.fop.render.RendererContextConstants;
 import org.apache.fop.svg.SVGEventProducer;
 import org.apache.fop.svg.SVGUserAgent;
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
-import org.apache.xmlgraphics.ps.PSGenerator;
-import org.w3c.dom.Document;
 
 /**
  * PostScript XML handler for SVG. Uses Apache Batik for SVG processing.
@@ -259,9 +262,8 @@
         NativeTextHandler nativeTextHandler = null;
         BridgeContext ctx = new BridgeContext(ua);
         if (!strokeText) {
-            PSGenerator generator = graphics.getPSGenerator();
             FontInfo fontInfo = psInfo.getFontInfo();
-            nativeTextHandler = new NativeTextHandler(generator, fontInfo);
+            nativeTextHandler = new NativeTextHandler(graphics, fontInfo);
             graphics.setCustomTextHandler(nativeTextHandler);
             PSTextPainter textPainter = new PSTextPainter(nativeTextHandler);
             ctx.setTextPainter(textPainter);



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


Re: svn commit: r719629 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps: AbstractPSTranscoder.java NativeTextHandler.java PSSVGHandler.java

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Done. Was simply a matter of merging the latest changes from Trunk. It's
good to see that I'm not the only one looking at that branch. Anyway, so
far I wasn't overly concerned about the Ant build. I guess I have to
start paying attention again.

On 21.11.2008 18:55:54 Adrian Cumiskey wrote:
> Jeremias,
> 
> When compiling a fresh checkout of Temp_AreaTreeNewDesign branch I get the following compilation 
> errors :-
> 
> Description	Resource	Path	Location	Type
> ImageProcessingHints.BITMAP_TYPE_INTENT cannot be resolved	PCLPainter.java 
> Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl	line 292	Java Problem
> ImageProcessingHints.BITMAP_TYPE_INTENT cannot be resolved	PCLPainter.java 
> Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl	line 295	Java Problem
> ImageProcessingHints.BITMAP_TYPE_INTENT_GRAY cannot be resolved	PCLPainter.java 
> Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl	line 296	Java Problem
> ImageProcessingHints.BITMAP_TYPE_INTENT_MONO cannot be resolved	PCLPainter.java 
> Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl	line 293	Java Problem
> 
> When I provide the branch with a freshly built XG commons jar it still fails to compile :-
> 
> Description	Resource	Path	Location	Type
> The type NativeTextHandler must implement the inherited abstract method 
> TextHandler.drawString(Graphics2D, String, float, float)	NativeTextHandler.java 
> Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps	line 38	Java Problem
> 
> So the XG commons jar that lives in the Temp_AreaTreeNewDesign branch is not built from the latest 
> XG commons.  Would be great if you could fix this :).
> 
> Thanks,
> 
> Adrian.
<snip/> 


Jeremias Maerki


Re: svn commit: r719629 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps: AbstractPSTranscoder.java NativeTextHandler.java PSSVGHandler.java

Posted by Adrian Cumiskey <de...@cumiskey.com>.
Jeremias,

When compiling a fresh checkout of Temp_AreaTreeNewDesign branch I get the following compilation 
errors :-

Description	Resource	Path	Location	Type
ImageProcessingHints.BITMAP_TYPE_INTENT cannot be resolved	PCLPainter.java 
Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl	line 292	Java Problem
ImageProcessingHints.BITMAP_TYPE_INTENT cannot be resolved	PCLPainter.java 
Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl	line 295	Java Problem
ImageProcessingHints.BITMAP_TYPE_INTENT_GRAY cannot be resolved	PCLPainter.java 
Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl	line 296	Java Problem
ImageProcessingHints.BITMAP_TYPE_INTENT_MONO cannot be resolved	PCLPainter.java 
Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/pcl	line 293	Java Problem

When I provide the branch with a freshly built XG commons jar it still fails to compile :-

Description	Resource	Path	Location	Type
The type NativeTextHandler must implement the inherited abstract method 
TextHandler.drawString(Graphics2D, String, float, float)	NativeTextHandler.java 
Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/ps	line 38	Java Problem

So the XG commons jar that lives in the Temp_AreaTreeNewDesign branch is not built from the latest 
XG commons.  Would be great if you could fix this :).

Thanks,

Adrian.

jeremias@apache.org wrote:
> Author: jeremias
> Date: Fri Nov 21 08:33:33 2008
> New Revision: 719629
> 
> URL: http://svn.apache.org/viewvc?rev=719629&view=rev
> Log:
> Fix for unit test failure in transcoder tests (NullPointerException):
> Have to pass the root PSGraphics2D to NativeTextHandler instead of the PSGenerator as this one hasn't been initialized in PSGraphics2D when the NativeTextHandler is built in AbstractPSTranscoder.
> 
> Modified:
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java
> 
> Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
> URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java?rev=719629&r1=719628&r2=719629&view=diff
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java (original)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java Fri Nov 21 08:33:33 2008
> @@ -25,20 +25,23 @@
>  import java.io.IOException;
>  import java.io.OutputStream;
>  
> +import org.w3c.dom.Document;
> +import org.w3c.dom.svg.SVGLength;
> +
>  import org.apache.avalon.framework.configuration.Configuration;
>  import org.apache.batik.bridge.BridgeContext;
>  import org.apache.batik.bridge.UnitProcessor;
>  import org.apache.batik.transcoder.TranscoderException;
>  import org.apache.batik.transcoder.TranscoderOutput;
>  import org.apache.batik.transcoder.image.ImageTranscoder;
> -import org.apache.fop.fonts.FontInfo;
> -import org.apache.fop.fonts.FontSetup;
> -import org.apache.fop.svg.AbstractFOPTranscoder;
> +
>  import org.apache.xmlgraphics.java2d.TextHandler;
>  import org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D;
>  import org.apache.xmlgraphics.ps.PSGenerator;
> -import org.w3c.dom.Document;
> -import org.w3c.dom.svg.SVGLength;
> +
> +import org.apache.fop.fonts.FontInfo;
> +import org.apache.fop.fonts.FontSetup;
> +import org.apache.fop.svg.AbstractFOPTranscoder;
>  
>  /**
>   * This class enables to transcode an input to a PostScript document.
> @@ -99,7 +102,7 @@
>              //TODO Do custom font configuration here somewhere/somehow
>              FontSetup.setup(fontInfo);
>              PSGenerator generator = graphics.getPSGenerator();
> -            graphics.setCustomTextHandler(new NativeTextHandler(generator, fontInfo));
> +            graphics.setCustomTextHandler(new NativeTextHandler(graphics, fontInfo));
>          }
>  
>          super.transcode(document, uri, output);
> 
> Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java
> URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java?rev=719629&r1=719628&r2=719629&view=diff
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java (original)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java Fri Nov 21 08:33:33 2008
> @@ -24,13 +24,14 @@
>  import java.awt.geom.AffineTransform;
>  import java.io.IOException;
>  
> +import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
> +import org.apache.xmlgraphics.java2d.ps.PSTextHandler;
> +import org.apache.xmlgraphics.ps.PSGenerator;
> +
>  import org.apache.fop.fonts.Font;
>  import org.apache.fop.fonts.FontInfo;
>  import org.apache.fop.fonts.FontSetup;
>  import org.apache.fop.fonts.FontTriplet;
> -import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
> -import org.apache.xmlgraphics.java2d.ps.PSTextHandler;
> -import org.apache.xmlgraphics.ps.PSGenerator;
>  
>  /**
>   * Specialized TextHandler implementation that the PSGraphics2D class delegates to to paint text
> @@ -38,7 +39,7 @@
>   */
>  public class NativeTextHandler implements PSTextHandler {
>  
> -    private final PSGenerator gen;
> +    private PSGraphics2D rootG2D;
>  
>      /** FontInfo containing all available fonts */
>      protected FontInfo fontInfo;
> @@ -60,8 +61,8 @@
>       * @param g2d the PSGraphics2D instance this instances is used by
>       * @param fontInfo the FontInfo object with all available fonts
>       */
> -    public NativeTextHandler(PSGenerator gen, FontInfo fontInfo) {
> -        this.gen = gen;
> +    public NativeTextHandler(PSGraphics2D g2d, FontInfo fontInfo) {
> +        this.rootG2D = g2d;
>          if (fontInfo != null) {
>              this.fontInfo = fontInfo;
>          } else {
> @@ -84,7 +85,7 @@
>      }
>  
>      private PSGenerator getPSGenerator() {
> -        return this.gen;
> +        return this.rootG2D.getPSGenerator();
>      }
>  
>      /** {@inheritDoc} */
> 
> Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java
> URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java?rev=719629&r1=719628&r2=719629&view=diff
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java (original)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java Fri Nov 21 08:33:33 2008
> @@ -24,12 +24,18 @@
>  import java.io.IOException;
>  import java.util.Map;
>  
> +import org.w3c.dom.Document;
> +
>  import org.apache.avalon.framework.configuration.Configuration;
>  import org.apache.batik.bridge.BridgeContext;
>  import org.apache.batik.bridge.GVTBuilder;
>  import org.apache.batik.gvt.GraphicsNode;
>  import org.apache.commons.logging.Log;
>  import org.apache.commons.logging.LogFactory;
> +
> +import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
> +import org.apache.xmlgraphics.ps.PSGenerator;
> +
>  import org.apache.fop.fonts.FontInfo;
>  import org.apache.fop.render.AbstractGenericSVGHandler;
>  import org.apache.fop.render.Renderer;
> @@ -37,9 +43,6 @@
>  import org.apache.fop.render.RendererContextConstants;
>  import org.apache.fop.svg.SVGEventProducer;
>  import org.apache.fop.svg.SVGUserAgent;
> -import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
> -import org.apache.xmlgraphics.ps.PSGenerator;
> -import org.w3c.dom.Document;
>  
>  /**
>   * PostScript XML handler for SVG. Uses Apache Batik for SVG processing.
> @@ -259,9 +262,8 @@
>          NativeTextHandler nativeTextHandler = null;
>          BridgeContext ctx = new BridgeContext(ua);
>          if (!strokeText) {
> -            PSGenerator generator = graphics.getPSGenerator();
>              FontInfo fontInfo = psInfo.getFontInfo();
> -            nativeTextHandler = new NativeTextHandler(generator, fontInfo);
> +            nativeTextHandler = new NativeTextHandler(graphics, fontInfo);
>              graphics.setCustomTextHandler(nativeTextHandler);
>              PSTextPainter textPainter = new PSTextPainter(nativeTextHandler);
>              ctx.setTextPainter(textPainter);
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org
> 
>