Changing the value of dashboard symbol parameters dynamically
Once you have created your dashboard, you need to be able to add it to an application and change the parameter values to display dynamic data.
To retrieve a dashboard symbol and change the value of a parameter:
Write the following code.
public class dashboardUpdater extends JRootPane implements Runnable
{
private IlvDashboardDiagram _dashboard;
public void init()
{
// create the dashboard.
IlvDashboardContext context = new IlvDashboardContext();
_dashboard = new IlvDashboardDiagram(context);
try {
// Load the dashboard diagram.
url = new URL("file:./" + <path to dashboard>);
_dashboard.readDashboard(url);
} catch (IlvDiagrammerException er) {
er.getCause().printStackTrace();
System.exit(-1);
} catch (Exception e) {
...
}
getContentPane().add(_dashboard);
}
...
public void updateDashBoard() {
_dashboard.setAdjusting(true);
Object dial1 = _dashboard.getObject("Dial_1");
_dashboard.setObjectProperty(dial1, "value", 8);
_dashboard.setAdjusting(false);
}
public void run()
{
...
updateDashBoard();
...
}
public static void main(String[] args) {
dashboardUpdater dashboard = new dashboardUpdater();
dashboard.init();
dashboard.run();
}
}
The value passed as third argument to the
setObjectProperty method must have the right type for the symbol parameter given as second argument.
Symbols in the charts palette as shown in
Adding charts, have array parameter types.
To replace an entire array with values:
Pass the new array to the
setObjectProperty method.
To change a single value in the array:
1. Copy the array.
2. Change the value in the copied array.
3. Pass the copied array to the setObjectProperty method.
Changing the value in the array passed to the setObjectProperty method will not work.
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.