I'm writing a class to add HTML textarea functionality to Processing's built-in
text(String, int, int, int, int) function. I'd like to subclass PGraphics so I can gain access to the protected fields
int[] textBreakStart and
int[] textBreakStop. I found
this forum post from 2010 where antiplastik explains the proper way to subclass PGraphics is to call:
- Classname varname = (Classname) createGraphics(width, height, "packagename.Classname")
What parameters would I use to call this with a class declared in the anonymous package, inside a processing sketch? This doesn't work:
- class MyPG extends PGraphics2D {
- }
- void setup() {
- MyPG mypg = (MyPG) createGraphics( width, height, "MyPG" );
- }
- // result:
- //
- // Exception in thread "Animation Thread" java.lang.RuntimeException: You need to use "Import Library" to add MyPG to your sketch.
- // at processing.core.PApplet.makeGraphics(Unknown Source)
- // at processing.core.PApplet.createGraphics(Unknown Source)
- // at subclass_pgraphics.setup(subclass_pgraphics.java:21)
- // at processing.core.PApplet.handleDraw(Unknown Source)
- // at processing.core.PApplet.run(Unknown Source)
- // at java.lang.Thread.run(Thread.java:662)
1