Processing topic panel
Wandora's Processing topic panel is used to run Processing scripts. Scripts can access Wandora's public API classes and methods. In effect, a Processing script can ask Wandora which topic is open, what are topic's associations, etc. Especially, a Processing script can access the whole topic map in Wandora. Wandora's Processing topic panel is a powerful tool for topic map visualizations and UI experiments. Processing topic panel starts with a menu option View > Topic panels > Processing topic panel. Below is a screen capture viewing Processing topic panel when you start it for the first time.
Processing topic panel has two tabs labeled as Processing editor and Visual. Editor tab is used to write and edit the Processing script. Processing applet is viewed in Visual tab whenever the script is executed. Processing applet is a running instance of the script written in editor. Both tabs have a button row at the bottom. Editor tab's buttons are
- New clears current script in editor.
- Open is used to restore script in editor. Wandora can restore Processing script either from a file or from an occurrence of current topic.
- Save stores current script in editor. Wandora can store script wither to a file or to an occurrence of current topic. Occurrence script is saved into the topic map and user must export topic map in order to save the script in occurrence.
- Options opens a configuration window for Processing topic panel. Available configuration options are Autoload, Run window, Autorun.
- Check tries to compile current Processing script. If compilation fails, an error dialog views compilation errors.
- Run executes current Processing script. If compilation fails, an error dialog views compilation errors. If compilation is successful, Wandora opens the Visual tab and places running applet into the visual panel.
- Stop stops running Processing applet.
Visual tab contains only one button, Stop used to stop running Processing applet.
Compiling and running Processing script in Wandora
Wandora compiles the Processing script in editor whenever user clicks the Build or Run button or chooses equal menu option. Before compiling the script, Wandora attaches the user script into a Processing applet template. Processing applet template is a Java source file. After filling the template, Wandora tries to compile created Java source file. If compilation fails, Wandora gives user feedback. if compilation is successful, Wandora loads the class, creates an instance of it, and starts the applet. Running Processing applet is placed to Visual tab. Next graph unwraps these steps visually.
Supported Processing language
Wandora injects the script in editor into a Java template without preprocessing. Template is then compiled with a Java compiler. As a consequence, user script must be valid Java code. Thus, Wandora's Processing support is not perfect and you can't use all features of Processing language. Unsupported Processing language features are
- color primitive. Use int primitive instead. Notice, highest eight bits of the color value specify alpha. Thus, color value has four sets of eight bits (from lower to upper): blue, green, red and alpha component.
- You can't omit the method visibility of overridden methods. Thus, you need explicitly specify draw, setup (and some others) methods as public. Usually these methods have underlying implementation in Processing applet and you just override them in your Processing script. Building a source without explicit visibility setting generates a compilation error.
Example
First, Wandora user clicks the Open button. A popup menu is shown. User chooses to load script from file.
User selects one of the example scripts, AssociationArches.
Selected script is loaded to the editor.
Now user clicks the Run button. User can change the association arch from left to right or vice verse by clicking black edge rectangles. Mouse over highlights the edge arches and target nodes.
See also
The documentation provided here doesn't cover Processing language at all. To learn Processing, see documentation at Processing.org