xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r391332 - in /xmlgraphics/fop/trunk: ./ lib/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/image/ src/java/org/apache/fop/pdf/ src/java/org/apache/fop/render/ src/java/org/apache/fop/render/bitmap/ src/java/org/apache/fop/render/ps/ s...
Date Tue, 04 Apr 2006 15:15:28 GMT
Author: jeremias
Date: Tue Apr  4 08:15:23 2006
New Revision: 391332

URL: http://svn.apache.org/viewcvs?rev=391332&view=rev
Log:
Adding dependency on XML Graphics Commons.
Switching to code in XML Graphics Commons for:
- PSGraphics2D
- Service discovery
- Codecs
Removed local classes that have been ported to Commons.
xmlgraphics-commons-snapshot.jar is a Trunk snapshot built with JDK 1.4.2 from today. It should work under JDK 1.3.1.

Added:
    xmlgraphics/fop/trunk/lib/xmlgraphics-commons-snapshot.jar   (with props)
    xmlgraphics/fop/trunk/lib/xmlgraphics-commons.LICENSE.txt   (with props)
    xmlgraphics/fop/trunk/lib/xmlgraphics-commons.NOTICE.txt   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/XmlGraphicsCommonsImage.java
      - copied, changed from r381073, xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java   (with props)
Removed:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSDocumentGraphics2D.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/DSCConstants.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGenerator.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2D.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSProcSets.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSResource.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSState.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ASCII85Constants.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ASCII85InputStream.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ASCII85OutputStream.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ASCIIHexOutputStream.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/Finalizable.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/FlateEncodeOutputStream.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/RunLengthEncodeOutputStream.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/Service.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/SubInputStream.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/util/ASCII85InputStreamTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/util/ASCII85OutputStreamTestCase.java
Modified:
    xmlgraphics/fop/trunk/build.xml
    xmlgraphics/fop/trunk/lib/README.txt
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/PNGImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCII85Filter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCIIHexFilter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/FlateFilter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerRegistry.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/EPSTranscoder.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageUtils.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTranscoder.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/UtilityCodeTestSuite.java

Modified: xmlgraphics/fop/trunk/build.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/build.xml?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/build.xml (original)
+++ xmlgraphics/fop/trunk/build.xml Tue Apr  4 08:15:23 2006
@@ -75,6 +75,7 @@
   <fileset dir="${basedir}" id="dist.bin.lib">
     <patternset id="dist.lib">
       <include name="lib/avalon-framework*"/>
+      <include name="lib/xmlgraphics-commons*"/>
       <include name="lib/batik*"/>
       <include name="lib/commons-io*"/>
       <include name="lib/commons-logging*"/>
@@ -581,7 +582,7 @@
     <include name="commons-io*.jar"/>
     <include name="avalon-framework*.jar"/>
     <include name="commons-logging*.jar"/>
-    <include name="xmlgraphics*.jar"/>
+    <include name="xmlgraphics-commons*.jar"/>
   </fileset>
   
   <target name="uptodate-transcoder-pkg" depends="compile-java">
@@ -626,6 +627,11 @@
         <include name="org/apache/commons/io/output/ProxyOutputStream.class"/>
         <include name="org/apache/commons/io/output/ByteArrayOutputStream.class"/>
         <include name="org/apache/commons/io/output/CountingOutputStream.class"/>
+        <!-- TODO Remove the following lines once Batik switches over to using XML Graphics Commons -->
+        <include name="org/apache/xmlgraphics/java2d/**"/>
+        <include name="org/apache/xmlgraphics/ps/**"/>
+        <include name="org/apache/xmlgraphics/fonts/**"/>
+        <include name="org/apache/xmlgraphics/util/io/**"/>
       </patternset>
       <fileset refid="transcoder-lib-files"/>
     </unjar>

Modified: xmlgraphics/fop/trunk/lib/README.txt
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/lib/README.txt?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/lib/README.txt (original)
+++ xmlgraphics/fop/trunk/lib/README.txt Tue Apr  4 08:15:23 2006
@@ -35,6 +35,14 @@
     
     Apache License v2.0
 
+- Apache XML Graphics Commons
+
+    xmlgraphics-commons-*.jar
+    http://xmlgraphics.apache.org/
+    (Common Library for Apache Batik and Apache FOP)
+    
+    Apache License v2.0
+
 - Apache Batik
 
     batik-*.jar

Added: xmlgraphics/fop/trunk/lib/xmlgraphics-commons-snapshot.jar
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/lib/xmlgraphics-commons-snapshot.jar?rev=391332&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/lib/xmlgraphics-commons-snapshot.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/lib/xmlgraphics-commons.LICENSE.txt
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/lib/xmlgraphics-commons.LICENSE.txt?rev=391332&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/lib/xmlgraphics-commons.LICENSE.txt (added)
+++ xmlgraphics/fop/trunk/lib/xmlgraphics-commons.LICENSE.txt Tue Apr  4 08:15:23 2006
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Propchange: xmlgraphics/fop/trunk/lib/xmlgraphics-commons.LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/lib/xmlgraphics-commons.NOTICE.txt
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/lib/xmlgraphics-commons.NOTICE.txt?rev=391332&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/lib/xmlgraphics-commons.NOTICE.txt (added)
+++ xmlgraphics/fop/trunk/lib/xmlgraphics-commons.NOTICE.txt Tue Apr  4 08:15:23 2006
@@ -0,0 +1,2 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/lib/xmlgraphics-commons.NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java Tue Apr  4 08:15:23 2006
@@ -19,17 +19,19 @@
 package org.apache.fop.fo;
 
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
+import org.w3c.dom.DOMImplementation;
+import org.xml.sax.Locator;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.util.Service;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FopFactory;
 import org.apache.fop.fo.ElementMapping.Maker;
-import org.apache.fop.util.Service;
-import org.w3c.dom.DOMImplementation;
-import org.xml.sax.Locator;
 
 /**
  * This class keeps track of all configured ElementMapping implementations which are responsible
@@ -69,9 +71,9 @@
         Iterator providers = Service.providers(ElementMapping.class);
         if (providers != null) {
             while (providers.hasNext()) {
-                String str = (String)providers.next();
+                ElementMapping mapping = (ElementMapping)providers.next();
                 try {
-                    addElementMapping(str);
+                    addElementMapping(mapping);
                 } catch (IllegalArgumentException e) {
                     log.warn("Error while adding element mapping", e);
                 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/PNGImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/PNGImage.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/PNGImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/PNGImage.java Tue Apr  4 08:15:23 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2005 The Apache Software Foundation 
+ * Copyright 2004-2006 The Apache Software Foundation 
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,17 +18,13 @@
 
 package org.apache.fop.image;
 
-import java.awt.color.ColorSpace;
-import java.awt.color.ICC_Profile;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
-import org.apache.batik.ext.awt.image.codec.PNGRed;
-import org.apache.batik.ext.awt.image.codec.PNGDecodeParam;
-import org.apache.batik.ext.awt.image.codec.SeekableStream;
-import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.xmlgraphics.image.codec.png.PNGRed;
+import org.apache.xmlgraphics.image.codec.png.PNGDecodeParam;
+import org.apache.xmlgraphics.image.codec.util.SeekableStream;
+import org.apache.xmlgraphics.image.rendered.CachableRed;
 import org.apache.commons.io.IOUtils;
-import org.apache.fop.util.CMYKColorSpace;
 
 /**
  * FopImage object using PNG
@@ -36,7 +32,7 @@
  * @see AbstractFopImage
  * @see FopImage
  */
-public class PNGImage extends BatikImage {
+public class PNGImage extends XmlGraphicsCommonsImage {
 
     /**
      * Constructs a new PNGImage instance.
@@ -48,7 +44,8 @@
     }
 
     /**
-     * @see org.apache.fop.image.BatikImage#decodeImage(org.apache.batik.ext.awt.image.codec.SeekableStream)
+     * @see org.apache.fop.image.XmlGraphicsCommonsImage#decodeImage(
+     *          org.apache.xmlgraphics.image.codec.util.SeekableStream)
      */
     protected CachableRed decodeImage(SeekableStream stream) throws IOException {
         PNGDecodeParam param = new PNGDecodeParam();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java Tue Apr  4 08:15:23 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2005 The Apache Software Foundation 
+ * Copyright 2004-2006 The Apache Software Foundation 
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,17 +21,17 @@
 import java.awt.color.ColorSpace;
 import java.io.IOException;
 
-import org.apache.batik.ext.awt.image.codec.SeekableStream;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFDirectory;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFField;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageDecoder;
-import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.xmlgraphics.image.codec.util.SeekableStream;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFDirectory;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFField;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFImageDecoder;
+import org.apache.xmlgraphics.image.rendered.CachableRed;
 import org.apache.commons.io.IOUtils;
 
 /**
  * TIFF implementation using the Batik codecs.
  */
-public class TIFFImage extends BatikImage {
+public class TIFFImage extends XmlGraphicsCommonsImage {
 
     private int compression = 0;
     private int stripCount = 0;
@@ -62,10 +62,13 @@
         return stripCount;
     }
 
-    /** @see org.apache.fop.image.BatikImage */
+    /**
+     * @see org.apache.fop.image.XmlGraphicsCommonsImage#decodeImage(
+     *          org.apache.xmlgraphics.image.codec.util.SeekableStream)
+     */
     protected CachableRed decodeImage(SeekableStream stream) throws IOException {
-        org.apache.batik.ext.awt.image.codec.tiff.TIFFImage img
-            = new org.apache.batik.ext.awt.image.codec.tiff.TIFFImage
+        org.apache.xmlgraphics.image.codec.tiff.TIFFImage img
+            = new org.apache.xmlgraphics.image.codec.tiff.TIFFImage
                 (stream, null, 0);
         TIFFDirectory dir = (TIFFDirectory)img.getProperty("tiff_directory");
         TIFFField fld = dir.getField(TIFFImageDecoder.TIFF_RESOLUTION_UNIT);

Copied: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/XmlGraphicsCommonsImage.java (from r381073, xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java)
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/XmlGraphicsCommonsImage.java?p2=xmlgraphics/fop/trunk/src/java/org/apache/fop/image/XmlGraphicsCommonsImage.java&p1=xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java&r1=381073&r2=391332&rev=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/XmlGraphicsCommonsImage.java Tue Apr  4 08:15:23 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2005 The Apache Software Foundation 
+ * Copyright 2004-2006 The Apache Software Foundation 
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,24 +22,25 @@
 import java.awt.Transparency;
 import java.awt.image.ColorModel;
 import java.awt.image.IndexColorModel;
+import java.awt.image.RenderedImage;
 import java.awt.image.WritableRaster;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
 
-import org.apache.batik.ext.awt.image.codec.SeekableStream;
-import org.apache.batik.ext.awt.image.codec.MemoryCacheSeekableStream;
-import org.apache.batik.ext.awt.image.codec.FileCacheSeekableStream;
-import org.apache.batik.ext.awt.image.rendered.Any2sRGBRed;
-import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.xmlgraphics.image.GraphicsUtil;
+import org.apache.xmlgraphics.image.codec.util.SeekableStream;
+import org.apache.xmlgraphics.image.codec.util.MemoryCacheSeekableStream;
+import org.apache.xmlgraphics.image.codec.util.FileCacheSeekableStream;
+import org.apache.xmlgraphics.image.rendered.CachableRed;
+
 import org.apache.commons.io.IOUtils;
 
 /**
- * FopImage object using TIFF
- * @author Eric SCHAEFFER
+ * Abstract FopImage implementation which uses the internal codecs from XML Graphics Commons.
  * @see AbstractFopImage
  * @see FopImage
  */
-public abstract class BatikImage extends AbstractFopImage {
+public abstract class XmlGraphicsCommonsImage extends AbstractFopImage {
 
     private byte[] softMask = null;
 
@@ -57,7 +58,7 @@
      * Constructs a new BatikImage instance.
      * @param imgReader basic metadata for the image
      */
-    public BatikImage(FopImage.ImageInfo imgReader) {
+    public XmlGraphicsCommonsImage(FopImage.ImageInfo imgReader) {
         super(imgReader);
     }
 
@@ -105,7 +106,7 @@
                         }
                     }
                 } else {
-                    cr = new Any2sRGBRed(cr);
+                    cr = GraphicsUtil.convertTosRGB(cr);
                 }
 
                 // Get our current ColorModel
@@ -187,32 +188,7 @@
 
                 this.bitmaps = new byte[this.width * this.height * 3];
 
-                WritableRaster wr = (WritableRaster)cr.getData();
-                BufferedImage bi = new BufferedImage
-                    (cm, wr.createWritableTranslatedChild(0, 0), 
-                     cm.isAlphaPremultiplied(), null);
-                int [] tmpMap = new int[this.width];
-                int idx = 0;
-                int sfIdx = 0;
-                for (int y = 0; y < this.height; y++) {
-                    tmpMap = bi.getRGB(0, y, this.width, 1, tmpMap, 0, this.width);
-                    if (softMask != null) {
-                        for (int x = 0; x < this.width; x++) {
-                            int pix = tmpMap[x];
-                            this.softMask[sfIdx++] = (byte)(pix >>> 24);
-                            this.bitmaps[idx++]    = (byte)((pix >>> 16) & 0xFF);
-                            this.bitmaps[idx++]    = (byte)((pix >>> 8)  & 0xFF);
-                            this.bitmaps[idx++]    = (byte)((pix)        & 0xFF);
-                        }
-                    } else {
-                        for (int x = 0; x < this.width; x++) {
-                            int pix = tmpMap[x];
-                            this.bitmaps[idx++] = (byte)((pix >> 16) & 0xFF);
-                            this.bitmaps[idx++] = (byte)((pix >> 8)  & 0xFF);
-                            this.bitmaps[idx++] = (byte)((pix)       & 0xFF);
-                        }
-                    }
-                }
+                constructBitmaps(cr, this.bitmaps, this.softMask);
             } catch (Exception ex) {
                 log.error("Error while loading image (Batik): " + ex.getMessage(), ex);
             } finally {
@@ -225,4 +201,37 @@
             }
         }
     }
-};
+
+    private static void constructBitmaps(RenderedImage red, byte[] bitmaps, byte[] softMask) {
+        WritableRaster wr = (WritableRaster)red.getData();
+        ColorModel cm = red.getColorModel();
+        BufferedImage bi = new BufferedImage
+            (cm, wr.createWritableTranslatedChild(0, 0), 
+             cm.isAlphaPremultiplied(), null);
+        int width = red.getWidth();
+        int height = red.getHeight();
+        int [] tmpMap = new int[width];
+        int idx = 0;
+        int sfIdx = 0;
+        for (int y = 0; y < height; y++) {
+            tmpMap = bi.getRGB(0, y, width, 1, tmpMap, 0, width);
+            if (softMask != null) {
+                for (int x = 0; x < width; x++) {
+                    int pix = tmpMap[x];
+                    softMask[sfIdx++] = (byte)(pix >>> 24);
+                    bitmaps[idx++]    = (byte)((pix >>> 16) & 0xFF);
+                    bitmaps[idx++]    = (byte)((pix >>> 8)  & 0xFF);
+                    bitmaps[idx++]    = (byte)((pix)        & 0xFF);
+                }
+            } else {
+                for (int x = 0; x < width; x++) {
+                    int pix = tmpMap[x];
+                    bitmaps[idx++] = (byte)((pix >> 16) & 0xFF);
+                    bitmaps[idx++] = (byte)((pix >> 8)  & 0xFF);
+                    bitmaps[idx++] = (byte)((pix)       & 0xFF);
+                }
+            }
+        }
+    }
+    
+}
\ No newline at end of file

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCII85Filter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCII85Filter.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCII85Filter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCII85Filter.java Tue Apr  4 08:15:23 2006
@@ -21,7 +21,7 @@
 import java.io.OutputStream;
 import java.io.IOException;
 
-import org.apache.fop.util.ASCII85OutputStream;
+import org.apache.xmlgraphics.util.io.ASCII85OutputStream;
 
 /**
  * PDF Filter for ASCII85.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCIIHexFilter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCIIHexFilter.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCIIHexFilter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/ASCIIHexFilter.java Tue Apr  4 08:15:23 2006
@@ -21,7 +21,7 @@
 import java.io.OutputStream;
 import java.io.IOException;
 
-import org.apache.fop.util.ASCIIHexOutputStream;
+import org.apache.xmlgraphics.util.io.ASCIIHexOutputStream;
 
 /**
  * ASCII Hex filter for PDF streams.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/FlateFilter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/FlateFilter.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/FlateFilter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/FlateFilter.java Tue Apr  4 08:15:23 2006
@@ -18,10 +18,10 @@
  
 package org.apache.fop.pdf;
 
-import org.apache.fop.util.FlateEncodeOutputStream;
-
 import java.io.OutputStream;
 import java.io.IOException;
+
+import org.apache.xmlgraphics.util.io.FlateEncodeOutputStream;
 
 /**
  * A filter to deflate a stream.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java Tue Apr  4 08:15:23 2006
@@ -24,19 +24,18 @@
 import java.util.List;
 import java.util.Map;
 
-//Avalon
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-//FOP
+import org.apache.xmlgraphics.util.Service;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.fo.FOEventHandler;
-import org.apache.fop.util.Service;
 
 /**
  * Factory for FOEventHandlers and Renderers.
@@ -268,12 +267,13 @@
             = Service.providers(Renderer.class);
         if (providers != null) {
             while (providers.hasNext()) {
-                String str = (String)providers.next();
+                AbstractRendererMaker maker = (AbstractRendererMaker)providers.next();
                 try {
                     if (log.isDebugEnabled()) {
-                        log.debug("Dynamically adding maker for Renderer: " + str);
+                        log.debug("Dynamically adding maker for Renderer: " 
+                                + maker.getClass().getName());
                     }
-                    addRendererMaker(str);
+                    addRendererMaker(maker);
                 } catch (IllegalArgumentException e) {
                     log.error("Error while adding maker for Renderer", e);
                 }
@@ -292,12 +292,13 @@
             = Service.providers(FOEventHandler.class);
         if (providers != null) {
             while (providers.hasNext()) {
-                String str = (String)providers.next();
+                AbstractFOEventHandlerMaker maker = (AbstractFOEventHandlerMaker)providers.next();
                 try {
                     if (log.isDebugEnabled()) {
-                        log.debug("Dynamically adding maker for FOEventHandler: " + str);
+                        log.debug("Dynamically adding maker for FOEventHandler: " 
+                                + maker.getClass().getName());
                     }
-                    addFOEventHandlerMaker(str);
+                    addFOEventHandlerMaker(maker);
                 } catch (IllegalArgumentException e) {
                     log.error("Error while adding maker for FOEventHandler", e);
                 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerRegistry.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerRegistry.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerRegistry.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerRegistry.java Tue Apr  4 08:15:23 2006
@@ -24,7 +24,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fop.util.Service;
+
+import org.apache.xmlgraphics.util.Service;
 
 /**
  * This class holds references to various XML handlers used by FOP. It also
@@ -148,12 +149,12 @@
         Iterator providers = Service.providers(XMLHandler.class);
         if (providers != null) {
             while (providers.hasNext()) {
-                String str = (String)providers.next();
+                XMLHandler handler = (XMLHandler)providers.next();
                 try {
                     if (log.isDebugEnabled()) {
-                        log.debug("Dynamically adding XMLHandler: " + str);
+                        log.debug("Dynamically adding XMLHandler: " + handler.getClass().getName());
                     }
-                    addXMLHandler(str);
+                    addXMLHandler(handler);
                 } catch (IllegalArgumentException e) {
                     log.error("Error while adding XMLHandler", e);
                 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer.java Tue Apr  4 08:15:23 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,9 +26,12 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.batik.ext.awt.image.codec.PNGEncodeParam;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
+import org.apache.xmlgraphics.image.writer.ImageWriter;
+import org.apache.xmlgraphics.image.writer.ImageWriterParams;
+import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
+
 import org.apache.commons.io.IOUtils;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.PageViewport;
@@ -50,9 +53,6 @@
     /** The output directory where images are to be written */
     private File outputDir;
 
-    /** The PNGEncodeParam for the image */
-    private PNGEncodeParam renderParams;
-
     /** The OutputStream for the first Image */
     private OutputStream firstOutputStream;
 
@@ -115,17 +115,13 @@
     
                 // Encode this image
                 log.debug("Encoding page " + (i + 1));
-                renderParams = PNGEncodeParam.getDefaultEncodeParam(image);
-                
-                // Set resolution
-                float pixSzMM = userAgent.getTargetPixelUnitToMillimeter();
-                // num Pixs in 1 Meter
-                int numPix = (int)((1000 / pixSzMM) + 0.5);
-                renderParams.setPhysicalDimension(numPix, numPix, 1); // 1 means 'pix/meter'
+                ImageWriterParams params = new ImageWriterParams();
+                params.setResolution(Math.round(userAgent.getTargetResolution()));
                 
                 // Encode PNG image
-                PNGImageEncoder encoder = new PNGImageEncoder(os, renderParams);
-                encoder.encode(image);
+                ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(getMimeType());
+                log.debug("Writing image using " + writer.getClass().getName());
+                writer.writeImage(image, os, params);
             } finally {
                 //Only close self-created OutputStreams
                 if (os != firstOutputStream) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java Tue Apr  4 08:15:23 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,9 +26,11 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.batik.ext.awt.image.codec.PNGEncodeParam;
-import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
+import org.apache.xmlgraphics.image.codec.png.PNGEncodeParam;
+import org.apache.xmlgraphics.image.codec.png.PNGImageEncoder;
+
 import org.apache.commons.io.IOUtils;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.render.java2d.Java2DRenderer;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java Tue Apr  4 08:15:23 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,12 +33,12 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.batik.ext.awt.image.GraphicsUtil;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFEncodeParam;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFField;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageDecoder;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageEncoder;
-import org.apache.batik.ext.awt.image.rendered.FormatRed;
+import org.apache.xmlgraphics.image.GraphicsUtil;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFEncodeParam;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFField;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFImageDecoder;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder;
+import org.apache.xmlgraphics.image.rendered.FormatRed;
 import org.apache.commons.logging.Log;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.MimeConstants;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java?rev=391332&r1=391331&r2=391332&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 Tue Apr  4 08:15:23 2006
@@ -24,7 +24,6 @@
 import java.io.IOException;
 
 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;
@@ -32,7 +31,11 @@
 
 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.ps.AbstractPSDocumentGraphics2D;
+import org.apache.xmlgraphics.java2d.ps.TextHandler;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.svg.SVGLength;
@@ -62,7 +65,6 @@
  * millimeter conversion factor.
  *
  * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
- * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
  * @version $Id$
  */
 public abstract class AbstractPSTranscoder extends AbstractFOPTranscoder {
@@ -92,15 +94,11 @@
         throws TranscoderException {
 
         graphics = createDocumentGraphics2D();
-        
-        try {
-            if (this.cfg != null) {
-                ContainerUtil.configure(graphics, this.cfg);
-            }
-            ContainerUtil.initialize(graphics);
-        } catch (Exception e) {
-            throw new TranscoderException(
-                "Error while setting up PDFDocumentGraphics2D", e);
+        if (!isTextStroked()) {
+            FontInfo fontInfo = new FontInfo();   
+            //TODO Do custom font configuration here somewhere/somehow 
+            FontSetup.setup(fontInfo, null, null);   
+            graphics.setCustomTextHandler(new NativeTextHandler(graphics, fontInfo));
         }
 
         super.transcode(document, uri, output);
@@ -117,18 +115,17 @@
                 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);
-            graphics.setSVGDimension(width, height);
+            graphics.setViewportDimension(width, height);
 
             if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) {
                 graphics.setBackgroundColor
                     ((Color)hints.get(ImageTranscoder.KEY_BACKGROUND_COLOR));
         }
             graphics.setGraphicContext
-                (new org.apache.batik.ext.awt.g2d.GraphicContext());
+                (new org.apache.xmlgraphics.java2d.GraphicContext());
             graphics.setTransform(curTxf);
 
             this.root.paint(graphics);
@@ -138,17 +135,29 @@
             throw new TranscoderException(ex);
         }
     }
-
-    protected BridgeContext createBridgeContext() {
-        /*boolean stroke = true;
+    
+    /** @return true if text should be stroked rather than painted using text operators */
+    protected boolean isTextStroked() {
+        boolean stroke = false;
         if (hints.containsKey(KEY_STROKE_TEXT)) {
             stroke = ((Boolean)hints.get(KEY_STROKE_TEXT)).booleanValue();
-        }*/
+        }
+        return stroke;
+    }
+
+    /** @see org.apache.batik.transcoder.SVGAbstractTranscoder#createBridgeContext() */
+    protected BridgeContext createBridgeContext() {
 
         BridgeContext ctx = new BridgeContext(userAgent);
-        PSTextPainter textPainter = new PSTextPainter(graphics.getFontInfo());
-        ctx.setTextPainter(textPainter);
-        ctx.putBridge(new PSTextElementBridge(textPainter));
+        if (!isTextStroked()) {
+            TextHandler handler = graphics.getCustomTextHandler();
+            if (handler instanceof NativeTextHandler) {
+                NativeTextHandler nativeTextHandler = (NativeTextHandler)handler; 
+                PSTextPainter textPainter = new PSTextPainter(nativeTextHandler);
+                ctx.setTextPainter(textPainter);
+                ctx.putBridge(new PSTextElementBridge(textPainter));
+            }
+        }
 
         //ctx.putBridge(new PSImageElementBridge());
         return ctx;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/EPSTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/EPSTranscoder.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/EPSTranscoder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/EPSTranscoder.java Tue Apr  4 08:15:23 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,9 @@
  
 package org.apache.fop.render.ps;
 
+import org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D;
+import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D;
+
 /**
  * This class enables to transcode an input to a EPS document.
  *
@@ -43,7 +46,6 @@
  * millimeter conversion factor.
  *
  * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
- * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
  * @version $Id$
  */
 public class EPSTranscoder extends AbstractPSTranscoder {
@@ -55,6 +57,7 @@
         super();
     }
 
+    /** @see AbstractPSTranscoder#createDocumentGraphics2D() */
     protected AbstractPSDocumentGraphics2D createDocumentGraphics2D() {
         return new EPSDocumentGraphics2D(false);
     }

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java?rev=391332&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java Tue Apr  4 08:15:23 2006
@@ -0,0 +1,190 @@
+/*
+ * Copyright 1999-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.ps;
+
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.io.IOException;
+
+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.TextHandler;
+import org.apache.xmlgraphics.ps.PSGenerator;
+
+/**
+ * Specialized TextHandler implementation that the PSGraphics2D class delegates to to paint text
+ * using PostScript text operations.
+ */
+public class NativeTextHandler implements TextHandler {
+
+    private PSGraphics2D g2d;
+    
+    /** FontInfo containing all available fonts */
+    protected FontInfo fontInfo;
+
+    /** Currently valid Font */
+    protected Font font;
+    
+    /** Overriding FontState */
+    protected Font overrideFont = null;
+    
+    /** the current (internal) font name */
+    protected String currentFontName;
+
+    /** the current font size in millipoints */
+    protected int currentFontSize;
+
+    /**
+     * Main constructor.
+     * @param g2d the PSGraphics2D instance this instances is used by
+     * @param fontInfo the FontInfo object with all available fonts
+     */
+    public NativeTextHandler(PSGraphics2D g2d, FontInfo fontInfo) {
+        this.g2d = g2d;
+        if (fontInfo != null) {
+            this.fontInfo = fontInfo;
+        } else {
+            setupFontInfo();
+        }
+    }
+    
+    private void setupFontInfo() {
+        //Sets up a FontInfo with default fonts
+        fontInfo = new FontInfo();
+        FontSetup.setup(fontInfo, null, null);
+    }
+    
+    /**
+     * Return the font information associated with this object
+     * @return the FontInfo object
+     */
+    public FontInfo getFontInfo() {
+        return fontInfo;
+    }
+
+    private PSGenerator getPSGenerator() {
+        return this.g2d.getPSGenerator();
+    }
+    
+    /** @see org.apache.xmlgraphics.java2d.ps.TextHandler#writeSetup() */
+    public void writeSetup() throws IOException {
+        if (fontInfo != null) {
+            PSFontUtils.writeFontDict(getPSGenerator(), fontInfo);
+        }
+    }
+
+    /** @see org.apache.xmlgraphics.java2d.ps.TextHandler#writePageSetup() */
+    public void writePageSetup() throws IOException {
+        if (fontInfo != null) {         
+            getPSGenerator().writeln("FOPFonts begin");
+        }
+    }
+
+    /**
+     * Draw a string to the PostScript document. The text is painted using 
+     * text operations.
+     * @see org.apache.xmlgraphics.java2d.ps.TextHandler#drawString(java.lang.String, float, float)
+     */
+    public void drawString(String s, float x, float y) throws IOException {
+        g2d.preparePainting();
+        if (this.overrideFont == null) {
+            java.awt.Font awtFont = g2d.getFont();
+            this.font = createFont(awtFont);
+        } else {
+            this.font = this.overrideFont;
+            this.overrideFont = null;
+        }
+        
+        //Color and Font state
+        g2d.establishColor(g2d.getColor());
+        establishCurrentFont();
+
+        PSGenerator gen = getPSGenerator();
+        gen.saveGraphicsState();
+
+        //Clip
+        Shape imclip = g2d.getClip();
+        g2d.writeClip(imclip);
+
+        //Prepare correct transformation
+        AffineTransform trans = g2d.getTransform();
+        gen.concatMatrix(trans);
+        gen.writeln(gen.formatDouble(x) + " "
+                  + gen.formatDouble(y) + " moveto ");
+        gen.writeln("1 -1 scale");
+  
+        StringBuffer sb = new StringBuffer("(");
+        escapeText(s, sb);
+        sb.append(") t ");
+
+        gen.writeln(sb.toString());
+        
+        gen.restoreGraphicsState();        
+    }
+
+    private void escapeText(final String text, StringBuffer target) {
+        final int l = text.length();
+        for (int i = 0; i < l; i++) {
+            final char ch = text.charAt(i);
+            final char mch = this.font.mapChar(ch);
+            PSGenerator.escapeChar(mch, target);
+        }
+    }
+
+    private Font createFont(java.awt.Font f) {
+        String fontFamily = f.getFamily();
+        if (fontFamily.equals("sanserif")) {
+            fontFamily = "sans-serif";
+        }
+        int fontSize = 1000 * f.getSize();
+        String style = f.isItalic() ? "italic" : "normal";
+        int weight = f.isBold() ? Font.BOLD : Font.NORMAL;
+                
+        FontTriplet triplet = fontInfo.findAdjustWeight(fontFamily, style, weight);
+        if (triplet == null) {
+            triplet = fontInfo.findAdjustWeight("sans-serif", style, weight);
+        }
+        return fontInfo.getFontInstance(triplet, fontSize);
+    }
+
+    private void establishCurrentFont() throws IOException {
+        if ((currentFontName != this.font.getFontName()) 
+                || (currentFontSize != this.font.getFontSize())) {
+            PSGenerator gen = getPSGenerator();
+            gen.writeln(this.font.getFontName() + " " 
+                    + gen.formatDouble(font.getFontSize() / 1000f) + " F");
+            currentFontName = this.font.getFontName();
+            currentFontSize = this.font.getFontSize();
+        }
+    }
+
+    /**
+     * Sets the overriding font.
+     * @param override Overriding Font to set
+     */
+    public void setOverrideFont(Font override) {
+        this.overrideFont = override;
+    }
+    
+
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java Tue Apr  4 08:15:23 2006
@@ -18,7 +18,6 @@
 
 package org.apache.fop.render.ps;
 
-import java.io.BufferedReader;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
@@ -29,22 +28,20 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
-import org.apache.commons.io.EndianUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.fop.fonts.CustomFont;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontType;
-import org.apache.fop.fonts.Glyphs;
 import org.apache.fop.fonts.LazyFont;
 import org.apache.fop.fonts.Typeface;
-import org.apache.fop.util.ASCIIHexOutputStream;
-import org.apache.fop.util.SubInputStream;
+import org.apache.xmlgraphics.ps.DSCConstants;
+import org.apache.xmlgraphics.ps.PSGenerator;
+import org.apache.xmlgraphics.ps.PSResource;
 
 /**
  * Utility code for font handling in PostScript.
  */
-public class PSFontUtils {
+public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
 
     /**
      * Generates the PostScript code for the font dictionary.
@@ -133,56 +130,6 @@
         return fontResources;
     }
 
-    /**
-     * This method reads a Type 1 font from a stream and embeds it into a PostScript stream.
-     * Note: Only the IBM PC Format as described in section 3.3 of the Adobe Technical Note #5040
-     * is supported.
-     * @param gen The PostScript generator
-     * @param in the InputStream from which to read the Type 1 font
-     * @throws IOException in case an I/O problem occurs
-     */
-    private static void embedType1Font(PSGenerator gen, InputStream in) throws IOException {
-        boolean finished = false;
-        while (!finished) {
-            int segIndicator = in.read();
-            if (segIndicator < 0) {
-                throw new IOException("Unexpected end-of-file while reading segment indicator");
-            } else if (segIndicator != 128) {
-                throw new IOException("Expected ASCII 128, found: " + segIndicator);
-            }
-            int segType = in.read();
-            if (segType < 0) {
-                throw new IOException("Unexpected end-of-file while reading segment type");
-            }
-            int dataSegLen = 0;
-            switch (segType) {
-                case 1: //ASCII
-                    dataSegLen = EndianUtils.readSwappedInteger(in);
-
-                    BufferedReader reader = new BufferedReader(
-                            new java.io.InputStreamReader(
-                                    new SubInputStream(in, dataSegLen), "US-ASCII"));
-                    String line;
-                    while ((line = reader.readLine()) != null) {
-                        gen.writeln(line);
-                        }
-                    break;
-                case 2: //binary
-                    dataSegLen = EndianUtils.readSwappedInteger(in);
-
-                    SubInputStream sin = new SubInputStream(in, dataSegLen);
-                    ASCIIHexOutputStream hexOut = new ASCIIHexOutputStream(gen.getOutputStream());
-                    IOUtils.copy(sin, hexOut);
-                    gen.newLine();
-                    break;
-                case 3: //EOF
-                    finished = true;
-                    break;
-                default: throw new IOException("Unsupported segment type: " + segType);
-            }
-        }
-    }
-
     private static InputStream getInputStreamOnFont(PSGenerator gen, CustomFont font) 
                 throws IOException {
         if (font.isEmbeddable()) {
@@ -220,28 +167,4 @@
         }
     }
 
-    private static void defineWinAnsiEncoding(PSGenerator gen) throws IOException {
-        gen.writeln("/WinAnsiEncoding [");
-        for (int i = 0; i < Glyphs.WINANSI_ENCODING.length; i++) {
-            if (i > 0) {
-                if ((i % 5) == 0) {
-                    gen.newLine();
-                } else {
-                    gen.write(" ");
-                }
-            }
-            final char ch = Glyphs.WINANSI_ENCODING[i];
-            final String glyphname = Glyphs.charToGlyphName(ch);
-            if ("".equals(glyphname)) {
-                gen.write("/" + Glyphs.NOTDEF);
-            } else {
-                gen.write("/");
-                gen.write(glyphname);
-            }
-        }
-        gen.newLine();
-        gen.writeln("] def");
-    }
-
-    
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java Tue Apr  4 08:15:23 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,8 @@
 import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.Graphics2DImagePainter;
 import org.apache.fop.render.RendererContext;
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.ps.PSGenerator;
 
 /**
  * Graphics2DAdapter implementation for PostScript.
@@ -75,7 +77,7 @@
 
         final boolean textAsShapes = false;
         PSGraphics2D graphics = new PSGraphics2D(textAsShapes, gen);
-        graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext());
+        graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
         AffineTransform transform = new AffineTransform();
         // scale to viewbox
         transform.translate(fx, fy);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageUtils.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageUtils.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageUtils.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageUtils.java Tue Apr  4 08:15:23 2006
@@ -19,29 +19,20 @@
 package org.apache.fop.render.ps;
 
 import java.awt.Dimension;
-import java.awt.color.ColorSpace;
 import java.awt.geom.Rectangle2D;
-import java.awt.image.ColorModel;
-import java.awt.image.DataBuffer;
-import java.awt.image.Raster;
-import java.awt.image.RenderedImage;
 import java.io.IOException;
-import java.io.OutputStream;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.image.EPSImage;
 import org.apache.fop.image.FopImage;
 import org.apache.fop.image.JpegImage;
-import org.apache.fop.util.ASCII85OutputStream;
-import org.apache.fop.util.Finalizable;
-import org.apache.fop.util.FlateEncodeOutputStream;
-import org.apache.fop.util.RunLengthEncodeOutputStream;
+import org.apache.xmlgraphics.ps.PSGenerator;
 
 /**
  * Utility code for rendering images in PostScript. 
  */
-public class PSImageUtils {
+public class PSImageUtils extends org.apache.xmlgraphics.ps.PSImageUtils {
 
     /** logging instance */
     protected static Log log = LogFactory.getLog(PSImageUtils.class);
@@ -85,187 +76,6 @@
                 img.getColorSpace(), gen);
     }
 
-    private static void writeImage(byte[] img,
-            Dimension imgDim, String imgName,
-            Rectangle2D targetRect, 
-            boolean isJPEG, ColorSpace colorSpace,
-            PSGenerator gen) throws IOException {
-        boolean iscolor = colorSpace.getType() != ColorSpace.CS_GRAY;
-
-        gen.saveGraphicsState();
-        gen.writeln(gen.formatDouble(targetRect.getX()) + " " 
-                + gen.formatDouble(targetRect.getY()) + " translate");
-        gen.writeln(gen.formatDouble(targetRect.getWidth()) + " " 
-                + gen.formatDouble(targetRect.getHeight()) + " scale");
-
-        gen.commentln("%FOPBeginBitmap: " + imgName);
-        if (colorSpace.getType() == ColorSpace.TYPE_CMYK) {
-            gen.writeln("/DeviceCMYK setcolorspace");
-        } else if (colorSpace.getType() == ColorSpace.CS_GRAY) {
-            gen.writeln("/DeviceGray setcolorspace");
-        } else {
-            gen.writeln("/DeviceRGB setcolorspace");
-        }
-
-        gen.writeln("{{");
-        // Template: (RawData is used for the EOF signal only)
-        // gen.write("/RawData currentfile <first filter> filter def");
-        // gen.write("/Data RawData <second filter> <third filter> [...] def");
-        if (isJPEG) {
-            gen.writeln("/RawData currentfile /ASCII85Decode filter def");
-            gen.writeln("/Data RawData << >> /DCTDecode filter def");
-        } else {
-            if (gen.getPSLevel() >= 3) {
-                gen.writeln("/RawData currentfile /ASCII85Decode filter def");
-                gen.writeln("/Data RawData /FlateDecode filter def");
-            } else {
-                gen.writeln("/RawData currentfile /ASCII85Decode filter def");
-                gen.writeln("/Data RawData /RunLengthDecode filter def");
-            }
-        }
-        gen.writeln("<<");
-        gen.writeln("  /ImageType 1");
-        gen.writeln("  /Width " + imgDim.width);
-        gen.writeln("  /Height " + imgDim.height);
-        gen.writeln("  /BitsPerComponent 8");
-        if (colorSpace.getType() == ColorSpace.TYPE_CMYK) {
-            if (false /*TODO img.invertImage()*/) {
-                gen.writeln("  /Decode [1 0 1 0 1 0 1 0]");
-            } else {
-                gen.writeln("  /Decode [0 1 0 1 0 1 0 1]");
-            }
-        } else if (iscolor) {
-            gen.writeln("  /Decode [0 1 0 1 0 1]");
-        } else {
-            gen.writeln("  /Decode [0 1]");
-        }
-        // Setup scanning for left-to-right and top-to-bottom
-        gen.writeln("  /ImageMatrix [" + imgDim.width + " 0 0 "
-              + imgDim.height + " 0 0]");
-
-        gen.writeln("  /DataSource Data");
-        gen.writeln(">>");
-        gen.writeln("image");
-        /* the following two lines could be enabled if something still goes wrong
-         * gen.write("Data closefile");
-         * gen.write("RawData flushfile");
-         */
-        gen.writeln("} stopped {handleerror} if");
-        gen.writeln("  RawData flushfile");
-        gen.writeln("} exec");
-
-        OutputStream out = gen.getOutputStream();
-        out = new ASCII85OutputStream(out);
-        if (isJPEG) {
-            //nop
-        } else {
-            if (gen.getPSLevel() >= 3) {
-                out = new FlateEncodeOutputStream(out);
-            } else {
-                out = new RunLengthEncodeOutputStream(out);
-            }
-        }
-        out.write(img);
-        if (out instanceof Finalizable) {
-            ((Finalizable)out).finalizeStream();
-        } else {
-            out.flush();
-        }
-
-        gen.writeln("");
-        gen.commentln("%FOPEndBitmap");
-        gen.restoreGraphicsState();
-    }
-
-    /**
-     * Renders a bitmap image to PostScript.
-     * @param img image to render
-     * @param x x position
-     * @param y y position
-     * @param w width
-     * @param h height
-     * @param gen PS generator
-     * @throws IOException In case of an I/O problem while rendering the image
-     */
-    public static void renderBitmapImage(RenderedImage img, 
-                float x, float y, float w, float h, PSGenerator gen)
-                    throws IOException {
-        byte[] imgmap = getBitmapBytes(img);
-
-        String imgName = img.getClass().getName();
-        Dimension imgDim = new Dimension(img.getWidth(), img.getHeight());
-        Rectangle2D targetRect = new Rectangle2D.Double(x, y, w, h);
-        boolean isJPEG = false;
-        writeImage(imgmap, imgDim, imgName, targetRect, isJPEG, 
-                img.getColorModel().getColorSpace(), gen);
-    }
-
-    private static byte[] getBitmapBytes(RenderedImage img) {
-        int[] tmpMap = getRGB(img, 0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());
-        // Should take care of the ColorSpace and bitsPerPixel
-        byte[] bitmaps = new byte[img.getWidth() * img.getHeight() * 3];
-        for (int y = 0, my = img.getHeight(); y < my; y++) {
-            for (int x = 0, mx = img.getWidth(); x < mx; x++) {
-                int p = tmpMap[y * mx + x];
-                int r = (p >> 16) & 0xFF;
-                int g = (p >> 8) & 0xFF;
-                int b = (p) & 0xFF;
-                bitmaps[3 * (y * mx + x)] = (byte)(r & 0xFF);
-                bitmaps[3 * (y * mx + x) + 1] = (byte)(g & 0xFF);
-                bitmaps[3 * (y * mx + x) + 2] = (byte)(b & 0xFF);
-            }
-        }
-        return bitmaps;
-    }
-    
-    public static int[] getRGB(RenderedImage img,
-                int startX, int startY, int w, int h,
-                int[] rgbArray, int offset, int scansize) {
-        Raster raster = img.getData();
-        int yoff  = offset;
-        int off;
-        Object data;
-        int nbands = raster.getNumBands();
-        int dataType = raster.getDataBuffer().getDataType();
-        switch (dataType) {
-        case DataBuffer.TYPE_BYTE:
-            data = new byte[nbands];
-            break;
-        case DataBuffer.TYPE_USHORT:
-            data = new short[nbands];
-            break;
-        case DataBuffer.TYPE_INT:
-            data = new int[nbands];
-            break;
-        case DataBuffer.TYPE_FLOAT:
-            data = new float[nbands];
-            break;
-        case DataBuffer.TYPE_DOUBLE:
-            data = new double[nbands];
-            break;
-        default:
-            throw new IllegalArgumentException("Unknown data buffer type: "+
-                                               dataType);
-        }
-        
-        if (rgbArray == null) {
-            rgbArray = new int[offset+h*scansize];
-        }
-        
-        ColorModel colorModel = img.getColorModel();
-        for (int y = startY; y < startY+h; y++, yoff+=scansize) {
-            off = yoff;
-            for (int x = startX; x < startX+w; x++) {
-                rgbArray[off++] = colorModel.getRGB(raster.getDataElements(x,
-                                    y,
-                                    data));
-            }
-        }
-        
-        return rgbArray;
-
-    }
-    
     public static void renderEPS(EPSImage img, 
             float x, float y, float w, float h,
             PSGenerator gen) {
@@ -289,53 +99,6 @@
             log.error("PSRenderer.renderImageArea(): Error rendering bitmap ("
                                    + e.getMessage() + ")", e);
         }
-    }
-
-    /**
-     * Places an EPS file in the PostScript stream.
-     * @param rawEPS byte array containing the raw EPS data
-     * @param name name for the EPS document
-     * @param x x-coordinate of viewport in millipoints
-     * @param y y-coordinate of viewport in millipoints
-     * @param w width of viewport in millipoints
-     * @param h height of viewport in millipoints
-     * @param bboxx x-coordinate of EPS bounding box in points
-     * @param bboxy y-coordinate of EPS bounding box in points
-     * @param bboxw width of EPS bounding box in points
-     * @param bboxh height of EPS bounding box in points
-     * @param gen the PS generator
-     * @throws IOException in case an I/O error happens during output
-     */
-    public static void renderEPS(byte[] rawEPS, String name,
-                    float x, float y, float w, float h,
-                    float bboxx, float bboxy, float bboxw, float bboxh,
-                    PSGenerator gen) throws IOException {
-        gen.notifyResourceUsage(PSProcSets.EPS_PROCSET, false);
-        gen.writeln("%FOPBeginEPS: " + name);
-        gen.writeln("BeginEPSF");
-
-        gen.writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " translate");
-        gen.writeln("0 " + gen.formatDouble(h) + " translate");
-        gen.writeln("1 -1 scale");
-        float sx = w / bboxw;
-        float sy = h / bboxh;
-        if (sx != 1 || sy != 1) {
-            gen.writeln(gen.formatDouble(sx) + " " + gen.formatDouble(sy) + " scale");
-        }
-        if (bboxx != 0 || bboxy != 0) {
-            gen.writeln(gen.formatDouble(-bboxx) + " " + gen.formatDouble(-bboxy) + " translate");
-        }
-        gen.writeln(gen.formatDouble(bboxy) + " " + gen.formatDouble(bboxy) 
-                + " " + gen.formatDouble(bboxw) + " " + gen.formatDouble(bboxh) + " re clip");
-        gen.writeln("newpath");
-        
-        PSResource res = new PSResource(PSResource.TYPE_FILE, name);
-        gen.notifyResourceUsage(res, false);
-        gen.writeDSCComment(DSCConstants.BEGIN_DOCUMENT, res.getName());
-        gen.writeByteArr(rawEPS);
-        gen.writeDSCComment(DSCConstants.END_DOCUMENT);
-        gen.writeln("EndEPSF");
-        gen.writeln("%FOPEndEPS");
     }
 
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java Tue Apr  4 08:15:23 2006
@@ -70,6 +70,12 @@
 import org.apache.fop.render.ps.extensions.PSSetupCode;
 import org.apache.fop.util.CharUtilities;
 
+import org.apache.xmlgraphics.ps.DSCConstants;
+import org.apache.xmlgraphics.ps.PSGenerator;
+import org.apache.xmlgraphics.ps.PSProcSets;
+import org.apache.xmlgraphics.ps.PSResource;
+import org.apache.xmlgraphics.ps.PSState;
+
 import org.w3c.dom.Document;
 
 /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSSVGHandler.java?rev=391332&r1=391331&r2=391332&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 Tue Apr  4 08:15:23 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,6 +41,8 @@
 import org.apache.fop.render.XMLHandler;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.svg.SVGUserAgent;
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.ps.PSGenerator;
 
 // Commons-Logging
 import org.apache.commons.logging.Log;
@@ -251,10 +253,16 @@
                 context.getUserAgent().getSourcePixelUnitToMillimeter(),
                 new AffineTransform());
 
+        PSGraphics2D graphics = new PSGraphics2D(strokeText, gen);
+        graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
+
         GVTBuilder builder = new GVTBuilder();
+        NativeTextHandler nativeTextHandler = null;
         BridgeContext ctx = new BridgeContext(ua);
         if (!strokeText) {
-            PSTextPainter textPainter = new PSTextPainter(psInfo.getFontInfo());
+            nativeTextHandler = new NativeTextHandler(graphics, psInfo.getFontInfo());
+            graphics.setCustomTextHandler(nativeTextHandler);
+            PSTextPainter textPainter = new PSTextPainter(nativeTextHandler);
             ctx.setTextPainter(textPainter);            
             PSTextElementBridge tBridge = new PSTextElementBridge(textPainter);
             ctx.putBridge(tBridge);
@@ -306,9 +314,6 @@
                 gen.concatMatrix(vals);
             }*/
 
-            final boolean textAsShapes = false;
-            PSGraphics2D graphics = new PSGraphics2D(textAsShapes, gen);
-            graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext());
             AffineTransform transform = new AffineTransform();
             // scale to viewbox
             transform.translate(xOffset, yOffset);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java Tue Apr  4 08:15:23 2006
@@ -31,9 +31,15 @@
 import java.awt.Paint;
 import java.awt.Stroke;
 import java.awt.Color;
+import java.io.IOException;
 import java.util.List;
 import java.util.Iterator;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+
 import org.apache.batik.dom.svg.SVGOMTextElement;
 import org.apache.batik.gvt.text.Mark;
 import org.apache.batik.gvt.TextPainter;
@@ -42,8 +48,6 @@
 import org.apache.batik.gvt.text.TextPaintInfo;
 import org.apache.batik.gvt.font.GVTFontFamily;
 import org.apache.batik.gvt.renderer.StrokingTextPainter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
@@ -68,7 +72,8 @@
     /** the logger for this class */
     protected Log log = LogFactory.getLog(PSTextPainter.class);
     
-    private FontInfo fontInfo;
+    private NativeTextHandler nativeTextHandler;
+    //private FontInfo fontInfo;
 
     /**
      * Use the stroking text painter to get the bounds and shape.
@@ -79,10 +84,10 @@
 
     /**
      * Create a new PS text painter with the given font information.
-     * @param fontInfo the FontInfo object
+     * @param nativeTextHandler the NativeTextHandler instance used for text painting
      */
-    public PSTextPainter(FontInfo fontInfo) {
-        this.fontInfo = fontInfo;
+    public PSTextPainter(NativeTextHandler nativeTextHandler) {
+        this.nativeTextHandler = nativeTextHandler;
     }
 
     /**
@@ -188,7 +193,9 @@
         
         Object rcDel = aci.getAttribute(
                 GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER);
-        if (!(rcDel instanceof SVGOMTextElement)) {
+        //Batik 1.6 returns null here which makes it impossible to determine whether this can
+        //be painted or not, i.e. fall back to stroking. :-(
+        if (/*rcDel != null &&*/ !(rcDel instanceof SVGOMTextElement)) {
             log.trace("-> spans found");
             hasunsupported = true; //Filter spans
         }
@@ -307,15 +314,17 @@
         }
         
         //Finally draw text
-        if (g2d instanceof PSGraphics2D) {
-            ((PSGraphics2D) g2d).setOverrideFont(font);
-        }
+        nativeTextHandler.setOverrideFont(font);
         try {
-            g2d.drawString(txt, (float)(loc.getX() + tx), (float)(loc.getY()));
-        } finally {
-            if (g2d instanceof PSGraphics2D) {
-                ((PSGraphics2D) g2d).setOverrideFont(null);
+            try {
+                nativeTextHandler.drawString(txt, (float)(loc.getX() + tx), (float)(loc.getY()));
+            } catch (IOException ioe) {
+                if (g2d instanceof PSGraphics2D) {
+                    ((PSGraphics2D)g2d).handleIOException(ioe);
+                }
             }
+        } finally {
+            nativeTextHandler.setOverrideFont(null);
         }
         loc.setLocation(loc.getX() + (double)advance, loc.getY());
         return loc;
@@ -370,6 +379,7 @@
         int weight = getWeight(aci);
 
         boolean found = false;
+        FontInfo fontInfo = nativeTextHandler.getFontInfo();
         String fontFamily = null;
         List gvtFonts = (List) aci.getAttribute(
                       GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTranscoder.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTranscoder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTranscoder.java Tue Apr  4 08:15:23 2006
@@ -18,6 +18,8 @@
 
 package org.apache.fop.render.ps;
 
+import org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D;
+import org.apache.xmlgraphics.java2d.ps.PSDocumentGraphics2D;
 
 /**
  * This class enables to transcode an input to a PostScript document.
@@ -44,7 +46,6 @@
  * millimeter conversion factor.
  *
  * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
- * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
  * @version $Id$
  */
 public class PSTranscoder extends AbstractPSTranscoder {
@@ -56,6 +57,7 @@
         super();
     }
 
+    /** @see AbstractPSTranscoder#createDocumentGraphics2D() */
     protected AbstractPSDocumentGraphics2D createDocumentGraphics2D() {
         return new PSDocumentGraphics2D(false);
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java Tue Apr  4 08:15:23 2006
@@ -24,7 +24,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import org.apache.fop.util.Service;
+import org.apache.xmlgraphics.util.Service;
 
 /**
  * This class holds references to various XML handlers used by FOP. It also
@@ -101,12 +101,13 @@
         Iterator providers = Service.providers(ContentHandlerFactory.class);
         if (providers != null) {
             while (providers.hasNext()) {
-                String str = (String)providers.next();
+                ContentHandlerFactory factory = (ContentHandlerFactory)providers.next();
                 try {
                     if (log.isDebugEnabled()) {
-                        log.debug("Dynamically adding ContentHandlerFactory: " + str);
+                        log.debug("Dynamically adding ContentHandlerFactory: " 
+                                + factory.getClass().getName());
                     }
-                    addContentHandlerFactory(str);
+                    addContentHandlerFactory(factory);
                 } catch (IllegalArgumentException e) {
                     log.error("Error while adding ContentHandlerFactory", e);
                 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/UtilityCodeTestSuite.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/UtilityCodeTestSuite.java?rev=391332&r1=391331&r2=391332&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/UtilityCodeTestSuite.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/UtilityCodeTestSuite.java Tue Apr  4 08:15:23 2006
@@ -20,8 +20,6 @@
 
 import org.apache.fop.traits.BorderPropsTestCase;
 import org.apache.fop.traits.TraitColorTestCase;
-import org.apache.fop.util.ASCII85InputStreamTestCase;
-import org.apache.fop.util.ASCII85OutputStreamTestCase;
 import org.apache.fop.util.PDFNumberTestCase;
 
 import junit.framework.Test;
@@ -40,8 +38,6 @@
         TestSuite suite = new TestSuite(
             "Test suite for FOP's utility classes");
         //$JUnit-BEGIN$
-        suite.addTest(new TestSuite(ASCII85OutputStreamTestCase.class));
-        suite.addTest(new TestSuite(ASCII85InputStreamTestCase.class));
         suite.addTest(new TestSuite(PDFNumberTestCase.class));
         suite.addTest(new TestSuite(TraitColorTestCase.class));
         suite.addTest(new TestSuite(BorderPropsTestCase.class));



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


Mime
View raw message