G4P > Gwindow with for loop
in
Contributed Library Questions
•
2 months ago
Hello there,
I've started to use Gwindow of G4P and faced with an error.
################ EXCEPTION IN EVENT HANDLER ################
An error occured during execution of the eventhandler:
CLASS: interactive_20130813 METHOD: windowDraw
Caused by java.lang.NullPointerException
interactive_20130813.windowDraw(interactive_20130813.java:739)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
g4p_controls.GWinApplet.draw(Unknown Source)
processing.core.PApplet.handleDraw(PApplet.java:2270)
processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:243)
processing.core.PApplet.run(PApplet.java:2141)
java.lang.Thread.run(Thread.java:680)
##############################################################
My code is as follows :
void windowDraw(GWinApplet appc, GWinData data)
{
appc.strokeWeight(typoWidth*s4cw);
appc.noFill();
for (int i=0 ; i < letters.length() ; i++)
{
for (int j = 0; j < alph[i].lpn; j++)
{
appc.pushMatrix();
if (!alph[i].isBezier[j]) //line
{
appc.translate(alph[i].sp[j].x*s4cw, alph[i].sp[j].y*s4cw);
if ( alph[i].spinning[j] || alph[i].process2stop[j] ) appc.rotate(alph[i].ra[j]);
appc.line(0, 0, alph[i].tp[j].x*s4cw, alph[i].tp[j].y*s4cw);
}
else //bezier
{
appc.translate(alph[i].sp[j].x*s4cw, alph[i].sp[j].y*s4cw);
if ( alph[i].spinning[j] || alph[i].process2stop[j] ) appc.rotate(alph[i].ra[j]);
appc.bezier(0, 0, alph[i].tp1[j].x*s4cw, alph[i].tp1[j].y*s4cw, alph[i].tp2[j].x*s4cw, alph[i].tp2[j].y*s4cw, alph[i].tp[j].x*s4cw, alph[i].tp[j].y*s4cw);
}
appc.popMatrix();
}
}
}
What I've found out is when I remove
for loop, the error doesn't occur. But I really need
for loop to draw things. How can I do? Can I ignore this error????? Actually the program is running though.
1