You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2008/11/04 08:32:14 UTC

svn commit: r711201 - /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java

Author: jeremias
Date: Mon Nov  3 23:32:14 2008
New Revision: 711201

URL: http://svn.apache.org/viewvc?rev=711201&view=rev
Log:
Added support for drawRenderedImage().

Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java?rev=711201&r1=711200&r2=711201&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java Mon Nov  3 23:32:14 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -64,11 +64,11 @@
 public class PSGraphics2D extends AbstractGraphics2D {
 
     private static final AffineTransform IDENTITY_TRANSFORM = new AffineTransform();
-    
+
     private static final boolean DEBUG = false;
-    
+
     protected PSGraphics2D rootG2D;
-    
+
     /** the PostScript generator being created */
     protected PSGenerator gen;
 
@@ -76,10 +76,10 @@
 
     /** Fallback text handler */
     protected TextHandler fallbackTextHandler = new StrokingTextHandler(this);
-    
+
     /** Custom text handler */
     protected TextHandler customTextHandler;
-    
+
     /**
      * the current colour for use in svg
      */
@@ -161,10 +161,10 @@
     public void setCustomTextHandler(TextHandler handler) {
         this.customTextHandler = handler;
     }
-    
+
     /* TODO Add me back at the right place!!!
     private void setPrivateHints() {
-        setRenderingHint(RenderingHintsKeyExt.KEY_AVOID_TILE_PAINTING, 
+        setRenderingHint(RenderingHintsKeyExt.KEY_AVOID_TILE_PAINTING,
                 RenderingHintsKeyExt.VALUE_AVOID_TILE_PAINTING_ON);
     }*/
 
@@ -258,7 +258,7 @@
             gen.concatMatrix(at);
             Shape imclip = getClip();
             writeClip(imclip);
-            PSImageUtils.renderBitmapImage(buf, 
+            PSImageUtils.renderBitmapImage(buf,
                 x, y, width, height, gen);
             gen.restoreGraphicsState();
         } catch (IOException ioe) {
@@ -383,9 +383,9 @@
                                  + " M");
                 break;
             case PathIterator.SEG_QUADTO:
-                gen.writeln(gen.formatDouble(vals[0]) + " " 
-                          + gen.formatDouble(vals[1]) + " " 
-                          + gen.formatDouble(vals[2]) + " " 
+                gen.writeln(gen.formatDouble(vals[0]) + " "
+                          + gen.formatDouble(vals[1]) + " "
+                          + gen.formatDouble(vals[2]) + " "
                           + gen.formatDouble(vals[3]) + " QUADTO ");
                 break;
             case PathIterator.SEG_CLOSE:
@@ -418,7 +418,7 @@
         preparePainting();
         try {
             gen.saveGraphicsState();
-            
+
             AffineTransform trans = getTransform();
             boolean newTransform = gen.getCurrentState().checkTransform(trans)
                     && !trans.isIdentity();
@@ -561,7 +561,19 @@
      */
     public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
         preparePainting();
-        System.err.println("NYI: drawRenderedImage");
+        try {
+            AffineTransform at = getTransform();
+            gen.saveGraphicsState();
+            gen.concatMatrix(at);
+            gen.concatMatrix(xform);
+            Shape imclip = getClip();
+            writeClip(imclip);
+            PSImageUtils.renderBitmapImage(img,
+                0, 0, img.getWidth(), img.getHeight(), gen);
+            gen.restoreGraphicsState();
+        } catch (IOException ioe) {
+            handleIOException(ioe);
+        }
     }
 
     /**
@@ -663,17 +675,17 @@
         preparePainting();
         try {
             gen.saveGraphicsState();
-            
+
             AffineTransform trans = getTransform();
             boolean newTransform = gen.getCurrentState().checkTransform(trans)
                     && !trans.isIdentity();
-            
+
             if (newTransform) {
                 gen.concatMatrix(trans);
             }
             Shape imclip = getClip();
             writeClip(imclip);
-            
+
             establishColor(getColor());
 
             applyPaint(getPaint(), true);
@@ -696,7 +708,7 @@
      * @param nonzero true if the non-zero winding rule should be used when filling
      * @exception IOException In case of an I/O problem
      */
-    protected void doDrawing(boolean fill, boolean stroke, boolean nonzero) 
+    protected void doDrawing(boolean fill, boolean stroke, boolean nonzero)
                 throws IOException {
         preparePainting();
         if (fill) {



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