Workaround for PGraphicsJava2D shadowing of public methods with package protected fields.
Fixes
MODIFY
runtime/src/jycessing/core.py
runtime/src/jycessing/core.py
@@ -480,6 +480,20 @@ class PGraphicsPythonModeWrapper(object):
return PGraphicsPythonModeWrapper.popper(
self.g.beginPGL, self.g.endPGL)
+ # The PGraphicsJava2D shadows its ellipse, rect, arc, and line functions
+ # with field declarations, so we must bypass them here.
+ def ellipse(self, *args):
+ PGraphics.ellipse(self, *args)
+
+ def rect(self, *args):
+ PGraphics.rect(self, *args)
+
+ def line(self, *args):
+ PGraphics.line(self, *args)
+
+ def arc(self, *args):
+ PGraphics.arc(self, *args)
+
def __getattr__(self, attr):
return getattr(self.g, attr)

ADD
testing/resources/test_pgraphics_calls.py
+# make sure that ellipse, arc, line, and rect all work as functions
+
+size(100, 100)
+pg = createGraphics(40, 40)
+
+pg.beginDraw()
+
+pg.ellipse(20, 20, 10, 10)
+pg.line(30, 30, 40, 40)
+pg.rect(0, 0, 10, 10)
+pg.arc(30, 35, 30, 30, 0, HALF_PI)
+pg.endDraw()
+image(pg, 9, 30)
+
+print 'OK'
+exit()

MODIFY
testing/src/test/jycessing/JycessingTests.java
testing/src/test/jycessing/JycessingTests.java
@@ -335,4 +335,10 @@ public class JycessingTests {
public void thread() throws Exception {
expectOK("thread");
}
+
+ // https://github.com/jdf/processing.py/issues/326
+ @Test
+ public void pGraphicsJava2d() throws Exception {
+ expectOK("pgraphics_calls");
+ }
}

Workaround for PGraphicsJava2D shadowing of public methods with package protected fields.

Fixes #326.