Revision: 1125
Author:   atdi...@gmail.com
Date:     Mon Mar 28 22:05:04 2011
Log: Issue 173; merged from branch; added @param and @since to PSwing.setUseBufferedPainting; added unit test to cover buffered painting branch in PSwing.
http://code.google.com/p/piccolo2d/source/detail?r=1125

Modified:
/piccolo2d.java/trunk/extras/src/main/java/org/piccolo2d/extras/pswing/PSwing.java /piccolo2d.java/trunk/extras/src/test/java/org/piccolo2d/extras/pswing/PSwingTest.java

=======================================
--- /piccolo2d.java/trunk/extras/src/main/java/org/piccolo2d/extras/pswing/PSwing.java Mon Mar 28 21:23:43 2011 +++ /piccolo2d.java/trunk/extras/src/main/java/org/piccolo2d/extras/pswing/PSwing.java Mon Mar 28 22:05:04 2011
@@ -347,6 +347,8 @@
* a transformed context is slow. Enabling buffered painting gives a significant performance * boost on these platforms; however, at the expense of a lower-quality drawing result at larger
      * scales.
+     * @since 1.3.1
+ * @param useBufferedPainting true if this {@link PSwing} should use buffered painting
      */
     public void setUseBufferedPainting(final boolean useBufferedPainting) {
         this.useBufferedPainting = useBufferedPainting;
=======================================
--- /piccolo2d.java/trunk/extras/src/test/java/org/piccolo2d/extras/pswing/PSwingTest.java Tue Mar 15 21:55:34 2011 +++ /piccolo2d.java/trunk/extras/src/test/java/org/piccolo2d/extras/pswing/PSwingTest.java Mon Mar 28 22:05:04 2011
@@ -28,24 +28,20 @@
  */
 package org.piccolo2d.extras.pswing;

+import junit.framework.TestCase;
+import org.piccolo2d.util.PPaintContext;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.RepaintManager;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics2D;
 import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.RepaintManager;
-
-import org.piccolo2d.extras.pswing.PSwing;
-import org.piccolo2d.extras.pswing.PSwingCanvas;
-import org.piccolo2d.extras.pswing.PSwingRepaintManager;
-import org.piccolo2d.util.PPaintContext;
-
-import junit.framework.TestCase;

 public class PSwingTest extends TestCase {
        public void setUp() {
@@ -98,7 +94,22 @@
                 PPaintContext paintContext = new PPaintContext(graphics);
                 pSwing.paint(paintContext);
                 assertEquals(Color.RED.getRGB(), image.getRGB(50, 50));
-       }
+       }
+
+ public void testPSwingWithBufferedPaintingDelegatesPaintingToItsComponent() throws IOException {
+               final JPanel panel = new JPanel();
+               final MockPaintingPSwing pSwing = new MockPaintingPSwing(panel);
+        pSwing.setUseBufferedPainting(true);
+               panel.setBackground(Color.RED);
+               panel.setPreferredSize(new Dimension(100, 100));
+
+               final BufferedImage image = new BufferedImage(100, 100,
+                               BufferedImage.TYPE_INT_RGB);
+               Graphics2D graphics = image.createGraphics();
+               PPaintContext paintContext = new PPaintContext(graphics);
+               pSwing.paint(paintContext);
+               assertEquals(Color.RED.getRGB(), image.getRGB(50, 50));
+       }

        public void testHidingPNodeHidesComponent() {
                final JPanel panel = new JPanel();

--
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

Reply via email to