Revision: 1086
Author: heuermh
Date: Tue Dec 21 11:47:21 2010
Log: Issue 195 ; mock painting methods were missing logic in
PSwing.paint(PPaintContext)
http://code.google.com/p/piccolo2d/source/detail?r=1086
Modified:
/piccolo2d.java/branches/release-1.3/extras/src/test/java/edu/umd/cs/piccolox/pswing/PSwingTest.java
=======================================
---
/piccolo2d.java/branches/release-1.3/extras/src/test/java/edu/umd/cs/piccolox/pswing/PSwingTest.java
Tue Feb 2 11:20:47 2010
+++
/piccolo2d.java/branches/release-1.3/extras/src/test/java/edu/umd/cs/piccolox/pswing/PSwingTest.java
Tue Dec 21 11:47:21 2010
@@ -90,10 +90,13 @@
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() {
final JPanel panel = new JPanel();
@@ -208,7 +211,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());
}
@@ -224,7 +231,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());
}
@@ -276,30 +287,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