Canvas Widget

    In version 20.19.0, the Canvas widget has been implemented. It is intended for displaying various graphical objects and custom drawings – new charts and column renderers can be added using external libraries. For instance, pie charts, spectrums, dose-response curves can be displayed. Furthermore, the widget can respond to mouse and keyboard input. A new renderer has also been added – the Canvas Cell Renderer for custom drawing in tables with user code in Java. Visualization can be configured using settings in JSON map format.

    The Canvas widget calls users' code for data retrieval and drawing. This code can be either a Groovy script or a Java handler from plugin - both can be used in the Canvas widget both in grid and form views. In the case of a form view, the Canvas widget can be added to the view in Design mode in a similar way as other widgets: by dragging and dropping the Canvas icon (images/download/thumbnails/20426846/Canvas_icon.png) from the right panel to the desired location in the form, or by right clicking anywhere in the form and selecting the Canvas icon from the popup menu. Then the widget settings need to be customized – the Groovy script or the Handler class must be added in the Visual properties section of the widget customizer.

    images/download/attachments/20426846/Customize_settings.png

    By default, an example Groovy script for capturing mouse movements and clicks is included. This script can be replaced by a custom script – e.g. for drawing a chart. Some examples are available in api-examples, which can be downloaded as a .zip package from the IJC download page.

    The other option for achieving the visualization functionality is using a plugin. The plugin can be installed via IJC main menu > Tools > Plugins. After installation, the plugin name appears in the list of installed plugins. A plugin can be called in the Canvas widget by the appropriate Java handler. The plugin can be used in a grid view or a table widget by changing the cell renderer to Canvas Cell Renderer. If the handler class name is set correctly, the Canvas looks for the class and executes it. If the class is not found or the row is empty, the Groovy script is executed.

    images/download/attachments/20426846/Canvas_cell_renderer.png

    Tutorials for building plugins in IJC can be found on the documentation page here.