Skip to content

CompaJ WorkSpace

Danila Rassokhin edited this page Mar 23, 2023 · 2 revisions

WorkSpace tab contains visual widgets such as charts, tables, e.t.c.

Built-in widgets

CompaJ can display charts, tables and other JavaFX objects which are instances of Node class.

To display some widget simply call: CompaJ.addWorkSpaceWidget(WorkSpaceWidget) in Terminal or Editor tab.

LineChart

You can create line charts with simple LineChartBuilder:

t = (0..10) //Create range
s = sin(t) //Calculate sin for range t

chart = :LineChartBuilder("t", "func", true) // Create chart with X axis called "t", Y axis called "func"
  .with("sin(t)", t, s) // Add line on chart with name "sin(t)", t values for X axis and s values for Y axis
  .build() // Build chart

CompaJ.addWorkSpaceWidget("Sin func chart", chart) // Add chart widget

Table

You can create tables with simple TableBuilder:

t = (0..10) //Create range
s = sin(t) //Calculate sin for range t

table = :TableBuilder // Create table
  .addColumn(0, "sin(t)", s) // Add column with index = 0, named "sin(t)" with values from s
  .build() // Build table

CompaJ.addWorkSpaceWidget("Sin func table", table) // Add table widget

Creating widgets

JavaFX

You can display any instance of JavaFX Node:

myJavaFXNode = createNode() // Get your JavaFX node here
CompaJ.addWorkSpaceWidget("MyWidget", myJavaFXNode) // Add myJavaFXNode as Widget with name "MyWidget"
CompaJ.addWorkSpaceWidget(myJavaFXNode) // Add myJavaFXNode as Widget with default name

WorkSpaceWidget

You can create new widgets by implementing WorkSpaceWidget interface in your class. See example in SIRModelWidget

Clone this wiki locally