GoogleCodeArchive / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

OSX: "Error: custom stroke not implemented" #112

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the StrokeExample on OSX, java 1.5 

What is the expected output? What do you see instead?
expected: clear console.

instead:

Error: custom stroke not implemented
java.lang.Exception: Stack trace
    at java.lang.Thread.dumpStack(Thread.java:1082)
    at apple.awt.OSXSurfaceData.setupStroke(OSXSurfaceData.java:809)
    at apple.awt.OSXSurfaceData.setupGraphicsState(OSXSurfaceData.java:1037)
    at apple.awt.CPeerSurfaceData.setupGraphicsState(CPeerSurfaceData.java:110)
    at apple.awt.OSXSurfaceData.setupGraphicsState(OSXSurfaceData.java:978)
    at apple.awt.OSXSurfaceData.setupGraphicsState(OSXSurfaceData.java:974)
    at apple.awt.OSXSurfaceData.drawfillShape(OSXSurfaceData.java:1283)
    at apple.awt.CRenderer.drawfillShape(CRenderer.java:516)
    at apple.awt.CRenderer.draw(CRenderer.java:555)
    at sun.java2d.pipe.ValidatePipe.draw(ValidatePipe.java:114)
    at sun.java2d.SunGraphics2D.draw(SunGraphics2D.java:2493)
    at edu.umd.cs.piccolo.nodes.PPath.paint(PPath.java:315)
    at edu.umd.cs.piccolo.PNode.fullPaint(PNode.java:2534)
    at edu.umd.cs.piccolo.PNode.fullPaint(PNode.java:2539)
    at edu.umd.cs.piccolo.PCamera.paintCameraView(PCamera.java:295)
    at edu.umd.cs.piccolo.PCamera.paint(PCamera.java:279)
    at edu.umd.cs.piccolo.PNode.fullPaint(PNode.java:2534)
    at edu.umd.cs.piccolo.PCamera.fullPaint(PCamera.java:358)
    at edu.umd.cs.piccolo.PCanvas.paintComponent(PCanvas.java:658)
    at javax.swing.JComponent.paint(JComponent.java:840)
    at javax.swing.JComponent._paintImmediately(JComponent.java:4739)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4521)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:436)
    at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueU
tilities.java:117)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:189)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:478)
    at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:2
34)
    at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:184
)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:170)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

Seems to be a known bug in apple java 1.5:
https://mailman.cs.umd.edu/pipermail/piccolo-chat/2005/002852.html
http://lists.apple.com/archives/Java-dev/2007/Feb/msg00057.html

Still in there:
$ java -version
java version "1.5.0_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02-304)
Java HotSpot(TM) Client VM (build 1.5.0_19-137, mixed mode, sharing)

Original issue reported on code.google.com by mr0...@mro.name on 29 Jul 2009 at 8:49

GoogleCodeExporter commented 9 years ago
proposed fix:

### Eclipse Workspace Patch 1.0
#P phtml
Index: core/src/main/java/edu/umd/cs/piccolo/nodes/PPath.java
===================================================================
--- core/src/main/java/edu/umd/cs/piccolo/nodes/PPath.java  (revision 610)
+++ core/src/main/java/edu/umd/cs/piccolo/nodes/PPath.java  (working copy)
@@ -311,8 +311,13 @@

         if (stroke != null && strokePaint != null) {
             g2.setPaint(strokePaint);
-            g2.setStroke(stroke);
-            g2.draw(path);
+            if (!(stroke instanceof BasicStroke) && "Apple
Inc.".equals(System.getProperty("java.vm.vendor"))) {
+                g2.fill(stroke.createStrokedShape(path));
+            }
+            else {
+                g2.setStroke(stroke);
+                g2.draw(path);
+            }
         }
     }

Original comment by mr0...@mro.name on 29 Jul 2009 at 8:58

GoogleCodeExporter commented 9 years ago
Could you throw that check into a static method or field, in say PUtil?

Feel free to borrow implementation style from commons-lang SystemUtils:

http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commo
ns/lang/SystemUtils.java?revision=754485

Original comment by heue...@gmail.com on 29 Jul 2009 at 4:09

GoogleCodeExporter commented 9 years ago
sure. Something like PUtil.isAppleVm(); or so. 

I always hesitate to expand the API.

Otherwise: code should be platform neutral if anyhow possible. Existence of 
such a
method might have led e.g. 
http://code.google.com/p/piccolo2d/issues/detail?id=48 to
a quick hack rather than a profound solution.

Original comment by mr0...@mro.name on 29 Jul 2009 at 4:20

GoogleCodeExporter commented 9 years ago
so I favour a private static method for the moment.

Original comment by mr0...@mro.name on 29 Jul 2009 at 4:22

GoogleCodeExporter commented 9 years ago
If we can come up with a profound solution that works on all platforms, I'm all 
for it.

If we have to do OS & java version checks (if jdk 1.6+ is not a problem on Mac 
OSX,
for instance) then it'd be best to do them robustly with consideration to
SecurityExceptions as in commons-lang.

Then, since PNode is already too big of a class, I would want to add the static
checks to PUtil, even if that means adding to the API.

Or we might add our own SystemUtils or similarly named class package-private to
edu.umd.cs.piccolo.

Original comment by heue...@gmail.com on 29 Jul 2009 at 4:56

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Such a drag:

http://files.getdropbox.com/u/965005/java-puzzle-what%27s%20wrong%20here%3F.png

I wrote this yesterday:
http://code.google.com/p/piccolo2d/source/diff?spec=svn601&r=601&path=/piccolo2d
.java/trunk/swt/src/main/java/edu/umd/cs/piccolox/swt/PSWTPath.java

Original comment by mr0...@mro.name on 29 Jul 2009 at 7:33

GoogleCodeExporter commented 9 years ago
Such a fail: http://mro.name/drop/java-puzzle-solved.png

Maybe we'll make PFixedWidthStroke inherit BasicStroke?

Original comment by mr0...@mro.name on 29 Jul 2009 at 9:17

GoogleCodeExporter commented 9 years ago
that's a problem with JDK 1.4.2 that's fixed in 1.5.0

Original comment by mr0...@mro.name on 29 Jul 2009 at 9:22

GoogleCodeExporter commented 9 years ago

Original comment by allain.lalonde on 30 Oct 2009 at 4:13