Hey Sven,
If you need to recreate some functionality from an existing core primitive, the easiest way would be to check out the code in the NetLogo code. Prim files and classes are prefixed with an underscore, so usually aren't too hard to find. In this case the _resizeworld code <https://github.com/NetLogo/NetLogo/blob/hexy/netlogo-gui/src/main/prim/etc/_resizeworld.java#L39-L52> and _setpatchsize code <https://github.com/NetLogo/NetLogo/blob/hexy/netlogo-gui/src/main/prim/etc/_setpatchsize.java#L22-L34> look pretty close to what you're doing, but they are wrapping the setDimensions() call in a waitFor(). I believe this is because the setDimensions() method is running the change on an event queue for the GUI. That might cause the weird behavior you're seeing, so it'd be worth trying the same waitFor() call to see if it helps. -Jeremy On Tuesday, October 1, 2019 at 4:05:48 PM UTC-5, Sven Anderson wrote: > > I have isolated the problem and recognize that it results because I don't > know how to resize the world. I decided to resize patches in my extension, > which also involves rescaling drawings that I place over the world > (guidelines for measures and music voices). > > Here is how I have attempted to resize the world after I have changed > P.PATCHSIZE or its pycor. This appears to disappear (infinite recursion?) > in ws.setDimensions(). * Is there a more standard way to resize the world > within an extension?* I've seen some ideas in ImporterJ.java, but have > not yet got these to work. Thanks! > > > public static void resizeWorld(Context context) > throws ExtensionException { > > ExtensionContext ec = (ExtensionContext) context; > Workspace ws = ec.workspace(); > ws.setDimensions(new > WorldDimensions3D(0, P.XMAX - 1, 0, > P.YMAX, 0, 1, > P.PATCHSIZE, > P.WRAP, P.WRAP, P.WRAP), > P.PATCHSIZE); > World w = ws.world(); > > // w.patchSize(P.PATCHSIZE); > //ws.resizeView(); // not in event thread > //ws.setDimensions(w.getDimensions(), P.PATCHSIZE); > > int pcoloridx = getPcolorID(w); > > initDrawing(w, ec); > updateAgentsPositions(w); > } > > > On Tuesday, October 1, 2019 at 2:31:48 PM UTC-4, Jeremy Baker wrote: >> >> Sven, >> >> Thank you for the update, glad you got your problem resolved. Feel free >> to reach back out if you have any other issues, it sounds like a very >> interesting extension! >> >> -Jeremy >> >> On Tuesday, October 1, 2019 at 12:42:01 PM UTC-5, Sven Anderson wrote: >>> >>> I was able to pinpoint that it is due to a later custom command that >>> changes PATCHSIZE. I have enough to probably solve this myself. Sorry! >>> >>> On Monday, September 30, 2019 at 12:03:30 PM UTC-4, Sven Anderson wrote: >>>> >>>> >>>> I've added a large number of additional functions (in Java) to the >>>> original Sound extension to support visual music composition. When I call >>>> a regular NetLogo method, setup, within which I call clear-all and my own >>>> sound:init() method which modifies the world's size, draws various lines, >>>> and adds a set of time-locked Turtles to represent drums and voices, I >>>> find >>>> that all code in sound:init() completes, but the call does not return, as >>>> if there were some infinite loop or recursion. If, however, I first call >>>> my sound:init() from the Command Center, then there is no problem using >>>> the >>>> setup command later. >>>> >>>> I'm having a hard time debugging this and was wondering if these >>>> symptoms indicate the nature of my error? >>>> >>>> Thanks! >>>> >>> -- You received this message because you are subscribed to the Google Groups "netlogo-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-devel/3c4a4c7e-0e8e-4309-8b61-d224839835b4%40googlegroups.com.