WISE-Community / WISE-VLE--Deprecated--

Virtual Learning Environment (VLE) for the Web-based Inquiry Science Environment (WISE). *Note: deprecated and has been merged into the main 'WISE' repository*
8 stars 8 forks source link

Improving NetLogo Support #289

Closed TheBizzle closed 10 years ago

TheBizzle commented 10 years ago

Hey, sorry it took me so long to submit this. Working with applets is depressing....

  1. I'm not sure that merging this directly into your master branch is really what you'll want to do, but maybe it is. Essentially, some changes are going to still need to be made on your end after merging this, in order to get out the behavior that you want.
    1. You'll want to update the Airbags model on Berkeley WISE to use the modified versions that I created of the files. The files can be found in this Gist that I created, or individually (Airbags and data-export-modular).
    2. You'll also want to make use of the imageStr that I'm pulling out of NetLogo in netlogo.js. It's a Base64-encoded PNG. (Not sure if you guys are aware of this or not, but, in modern browsers, you don't actually have to do any decoding, yourselves, in order to display a Base64-encoded image: http://css-tricks.com/data-uris/). You may even want to remove the generation of that image string from netlogo.js and force steps that want to generate images to do so, themselves.
  2. I've thrown out some old NetLogoLite5.jar.bak file that was sitting around, because, well... it was in version control, so it didn't actually need to stick around. (i.e. If you need that back-up of the .jar, just get the old copy from version control.)
  3. I've replaced the old NetLogoLite5.jar with a NetLogoLite-5.0.x-zzzzzzz.jar whose name contains the SHA hash for the NetLogo commit that is being used. People who, in the future, attempt to debug broken NetLogo applets might thank me for the versioning of this .jar
  4. I created a NetLogo extension for exporting images from NetLogo for the web. It's called the "Web Image" extension. It exports images as arrays of bytes, and it also has primitives for Base64-encoding byte arrays and Base64-decoding strings into byte arrays.
  5. This new NetLogo .jar mentioned in (3) includes some important fixes for being able to use the Web Image extension sanely. It doesn't strip out two chunks of the Scala library needed by the Web Image extension (commit) and it allows you to look up extension URLs in applets from a property that you can pass into the applet (commit). These changes exist on the NetLogo 5.0.x-appletland branch—the branch that any future NetLogo .jars you guys use for applets ought to come from (which I'm telling you in case you, for some reason, need a new .jar in the future and I mysteriously die before then). This is cordoned off onto its own branch because we, at Northwestern, are making minimal efforts to support applets—hadn't I sworn to myself that I'd never deal with applets again before I undertook all this?—and because I decided that I didn't have time to write Java code for this that was actually good, so I just threw something together for it. At the height of my writing it, I even decided to mock and insult myself a bit, but... maybe that was unfair, as Java is the problem, not me!.
  6. I changed the netlogo.js file a lot to get rid of some very crufty stuff. There was an awful lot of unnecessary polling, juggling of globals, needlessly getting handles on objects, and unnecessary functions laying around. So... I trashed most of that. Also, did you know that I hate mutable state?
    • Obligatory Functional Programming Plug: I'd like to take this opportunity to tell you that leveraging a powerful static type system and utilizing functional programming constructs to avoid mutable state can help to you easily write clear, concise, easily-understandable, nearly-bug-free code in record time. Try it out today!
  7. I didn't alter the model to be able to reimport the data that's being exported by this.nlCmdReport("data-export:make-model-data")—first, because the model is massive and scary, and, second, because I'm not sure how to do so meaningfully with that model. It looks like the data being exported is already processed data, so I'm not sure how to import it back in while still being meaningful to the activity. I would suggest that, if Concord wants that data getting back into the model, someone from Concord should write the NetLogo code (or NetLogo extension) to handle that.
  8. Lastly (and mostly unrelated), not sure if you saw or not, but documentation for setting up the WISE development environment in IntelliJ is now available here.
breity commented 10 years ago

Sorry, we didn't notice the pull request until this week! Not sure why we didn't get a notification. But anyways, this is awesome. We're hoping to get back to the NetLogo data persistence and import/export work soon. So we'll take a look and let you know how it goes. Thanks so much! And thanks also for writing up the IntelliJ documentation.

hirokiterashima commented 10 years ago

I enjoyed reading your list.

TheBizzle commented 10 years ago

Cool, I look forward to hearing about progress made with this!