Processing calls void setup() twice, and I need a work around -


i'm working on program reads in images (.jpg) , text source files , assembling them single pdf. know processing isn't best language in, 1 know how in. anyway, having issue processing calls setup 2 times. i've seen issue resolved when size() first line within setup, can't have happen, because have read in , store data, find width of widest image, make sure tall enough accommodate pages more 1 image, , add text before can decide on how wide , tall window is. looking suggestions how might structure code can information without having call setup twice, because that's causing pdf contain 2 copies of data. i've included setup if helps anyone. thanks!

void setup(){   font = loadfont("timesnewromanpsmt-20.vlw");   file clientsfolder = new file("c:/users/[my name]/documents/processing/exerciseprogram/clients");   clients = clientsfolder.listfiles();   for(file x : clients){     println(x.getname());   }   //test files see if end in .txt, , have matching .pdf extension newer   string nextclient = needpdf();    file nextclientdata = new file("c:/users/[my name]/documents/processing/exerciseprogram/clients/" + nextclient);   //println(nextclientdata.getname());    //open file reading   //setup can't throw exception, , needs it, should take care of   try{     scanner scan = new scanner(nextclientdata);      while(scan.hasnextline() ){       exercises.add(scan.nextline());     }     //println(exercises.tostring());     printeddata = new exercise[exercises.size()];     println(exercises.size());     for(int = 0; < exercises.size(); i++){       printeddata[i] = new exercise((string)exercises.get(i));     }      //count width , height     int w = 0, h = 0;     for(exercise e: printeddata){       if(e.getwidest() > w){         w = e.getwidest();       }       if(e.gettallest() > h){         h = e.getheight();       }     }      //and can create freaking window     //                                         cuts .txt off     size(w, h, pdf, "c:/users/[my name]/desktop/" + nextclient.substring(0, nextclient.length() - 4) + ".pdf");    }catch (filenotfoundexception e){     println("unknown error in papplet.setup(). exiting.");     println(e.getmessage() );     exit();    } } 

how moving these functions done before setup()? although processing complains "mixing static , active modes", hack seems work @ processing 2.0.1:

int = beforesetup(); int szx,szy;  int beforesetup() {   println("look! happening before setup()!!");   szx = 800;   szy = 600;   return 0; } void setup() {   size(szx,szy);   println("awww"); } 

you calling function fill int hack run functions want, having compute whatever want before having set window size.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -