Revision: 1119
Author: heuermh
Date: Tue Mar 15 21:55:34 2011
Log: Issue 195 ; mock painting methods were missing logic in PSwing.paint(PPaintContext)
http://code.google.com/p/piccolo2d/source/detail?r=1119

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

=======================================
--- /piccolo2d.java/trunk/extras/src/test/java/org/piccolo2d/extras/pswing/PSwingTest.java Tue Mar 15 15:23:53 2011 +++ /piccolo2d.java/trunk/extras/src/test/java/org/piccolo2d/extras/pswing/PSwingTest.java Tue Mar 15 21:55:34 2011
@@ -93,10 +93,11 @@
                final MockPaintingPSwing pSwing = new MockPaintingPSwing(panel);
                panel.setBackground(Color.RED);
                panel.setPreferredSize(new Dimension(100, 100));
-
-               final BufferedImage img = pSwing.paintComponent();
-
-               assertEquals(Color.RED.getRGB(), img.getRGB(50, 50));
+ 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() {
@@ -212,7 +213,11 @@
                canvas.doLayout();
                // While paint, it uses the graphics element to determine the 
font's
                // display size and hence determine minimum size of JLabel.
-               swing.paint();
+               BufferedImage image = new BufferedImage(100, 100,
+                               BufferedImage.TYPE_INT_RGB);
+               Graphics2D graphics = image.createGraphics();
+               PPaintContext paintContext = new PPaintContext(graphics);
+               swing.paint(paintContext);

                assertFalse(10 == swing.getWidth());
        }
@@ -228,7 +233,11 @@
                canvas.doLayout();
                // While paint, it uses the graphics element to determine the 
font's
                // display size and hence determine minimum size of JLabel.
-               swing.paint();
+               BufferedImage image = new BufferedImage(100, 100,
+                               BufferedImage.TYPE_INT_RGB);
+               Graphics2D graphics = image.createGraphics();
+               PPaintContext paintContext = new PPaintContext(graphics);
+               swing.paint(paintContext);
                assertFalse(10 == swing.getWidth());
        }

@@ -280,30 +289,6 @@
                public MockPaintingPSwing(JComponent component) {
                        super(component);
                }
-
-               public void paintOnto(BufferedImage image) {
-                       PPaintContext paintContext = new PPaintContext(image
-                                       .createGraphics());
-                       paint(paintContext);
-               }
-
-               public BufferedImage paint() {
-                       BufferedImage image = new BufferedImage((int) 
getWidth(),
-                                       (int) getHeight(), 
BufferedImage.TYPE_INT_RGB);
-                       paintOnto(image);
-                       return image;
-               }
-
-               public BufferedImage paintComponent() {
-                       BufferedImage image = new BufferedImage((int) 
getWidth(),
-                                       (int) getHeight(), 
BufferedImage.TYPE_INT_RGB);
-                       paintComponentOnto(image);
-                       return image;
-               }
-
-               public void paintComponentOnto(BufferedImage image) {
-                       paint(image.createGraphics());
-               }

                public void paint(Graphics2D paintContext) {
                        super.paint(paintContext);

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

Reply via email to