Revision: 816
Author: [email protected]
Date: Fri Oct 23 19:23:06 2009
Log: issue#142 fixed IMO
http://code.google.com/p/piccolo2d/source/detail?r=816
Modified:
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/nodes/P3DRect.java
/piccolo2d.java/trunk/extras/src/test/java/edu/umd/cs/piccolox/nodes/P3DRectTest.java
=======================================
---
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/nodes/P3DRect.java
Thu Oct 22 20:02:42 2009
+++
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/nodes/P3DRect.java
Fri Oct 23 19:23:06 2009
@@ -55,8 +55,8 @@
private Color topLeftInnerColor;
private Color bottomRightInnerColor;
private Color bottomRightOuterColor;
- private final GeneralPath path;
- private final transient Stroke stroke;
+ private transient GeneralPath path = null;
+ private transient Stroke stroke = null;
private boolean raised;
/**
@@ -64,8 +64,6 @@
*/
public P3DRect() {
raised = true;
- stroke = new BasicStroke(0);
- path = new GeneralPath();
}
/**
@@ -118,6 +116,14 @@
* @param paintContext context in which the paiting should occur
*/
protected void paint(final PPaintContext paintContext) {
+ // lazy init:
+ if (stroke == null) {
+ stroke = new BasicStroke(0);
+ }
+ if (path == null) {
+ path = new GeneralPath();
+ }
+
final Graphics2D g2 = paintContext.getGraphics();
final double x = getX();
@@ -208,6 +214,8 @@
}
/**
+ * TODO can we remove this?
+ *
* @deprecated since it has been moved to P3DRectExample.
*
* @param args Command line arguments
=======================================
---
/piccolo2d.java/trunk/extras/src/test/java/edu/umd/cs/piccolox/nodes/P3DRectTest.java
Fri Oct 23 19:13:09 2009
+++
/piccolo2d.java/trunk/extras/src/test/java/edu/umd/cs/piccolox/nodes/P3DRectTest.java
Fri Oct 23 19:23:06 2009
@@ -39,7 +39,6 @@
public void testClone() {
P3DRect rect = new P3DRect(10, 10, 10, 10);
rect.setPaint(Color.BLUE);
- // FIXME breaks on jdk < 1.6 as GeneralPath field isn't transient
nor serializable
P3DRect cloned = (P3DRect) rect.clone();
assertNotNull(cloned);
assertEquals(Color.BLUE, cloned.getPaint());
--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---