Overview

The visual interface (VI) makes heavy use of scripting for creating a dynamic user interface, reflecting the actual process data. The following sections describe the scripting abilities and how to use them in order to create a dynamic user interface. The scripting system is based on the Java Scripting as defined in JSR-223. However the only script language that is supported at the moment is JavaScript. Java comes with two variants of JavaScript. Rhino for Java 7 and Nashorn for Java 8. The engine used depends on which Java version is running the actual application that contains the visualization.

See also:

Script Context

The following global variables are defined in the script blocks that can be used in Dakara:

Using the method controller.getElement(String) it is possible to fetch an element from the current symbol. For this to work the element must have the name> attribute set with a name that is unique for the symbol. The object returned is a controller object for the figure element. The following table shows how symbol elements are mapped to controllers. All public mehtods of the controller class and its parent classes are available from JavaScript.

Example

var text = controller.getElement ( "textElement" ); // if the element is a Text element, it returns an TextController

text.setText ( "Hello World" );
ElementDescriptionController
ArcAn arc ArcController
EllipseAn ellipse EllipseController
ImageDisplay an image ImageController
LineA line LineController
RectangleA rectangle RectangleController
SymbolReferenceAn embedded symbol SymbolReferenceController
TextA text label TextController