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:
The following global variables are defined in the script blocks that can be used in Dakara:
VisualInterfaceViewInstance
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.
var text = controller.getElement ( "textElement" ); // if the element is a Text element, it returns an TextController text.setText ( "Hello World" );
Element | Description | Controller |
---|---|---|
Arc | An arc | ArcController |
Ellipse | An ellipse | EllipseController |
Image | Display an image | ImageController |
Line | A line | LineController |
Rectangle | A rectangle | RectangleController |
SymbolReference | An embedded symbol | SymbolReferenceController |
Text | A text label | TextController |