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 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. Using Processing topic panel in Wandora requires no additional installations as Processing core is enclosed in Wandora's distribution packages.
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. If compilation fails, Wandora gives user an error message. if compilation is successful, Wandora loads the compiled class, creates an instance of it, and starts the applet. Running Processing applet is placed to Visual tab. Next image illustrates described execution model.
Notice: Wandora version 2012-04-30 has changed the templating mechanism of Processing scripts. Previous version of Processing topic panel injected user code into a predefined Java template that made the user code a PApplet. New version does not wrap user code into a predefined template but tries to compile the user code as such. All enclosed sample sketches have been adjusted to follow this change. If you have written your own Processing sketches and try to use them in Wandora version 2012-04-30 or above, you have to add wrapper explicitly into your sketch in order to compile and run sketches.
Accessing topics and topic maps from Processing
You can request topics and topic maps from your Processing script. Supported methods are
Topic currentTopic = getCurrentTopic(); TopicMap topicMap = getTopicMap();
Method getCurrentTopic returns current topic opened in topic panel. Method getTopicMap returns the topic map in Wandora. Returned objects are real Java objects in Wandora. You can access these object as described in Wandora's API documentation. Perhaps the most important Wandora objects (and interfaces) you need in Processing code are
There is no restrictions in accessing Wandora's topic or topic map objects. Script may contain operations that change topics and the topic map in Wandora. See also TopicTools. It offers some shortcut methods to collect and simplify topic and association data.
Unsupported Processing language features
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. 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 and 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.
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.
The documentation provided here doesn't cover Processing language at all. To learn Processing, see documentation at Processing.org
More information about Wandora's topic panels:
- Traditional topic panel
- Tabbed topic panel
- Graph topic panel
- Custom topic panel
- Treemap topic panel
- R topic panel