Search in sources :

Example 11 with SeriesDataSet

use of kutch.biff.marvin.utility.SeriesDataSet in project Board-Instrumentation-Framework by intel.

the class StackedBarChartWidget method setupListeners.

@Override
@SuppressWarnings("unchecked")
protected void setupListeners(DataManager dataMgr) {
    for (String key : _SeriesOrder) {
        SeriesSet objSeriesSet = _SeriesMap.get(key);
        if (null == objSeriesSet) {
            LOGGER.severe("Invalid Key in setupListeners");
            return;
        }
        XYChart.Series objSeries = new XYChart.Series<>();
        String strTitle = objSeriesSet.getTitle();
        if (null == strTitle) {
            strTitle = "untitled";
        }
        objSeries.setName(strTitle);
        for (SeriesDataSet objDs : objSeriesSet.getSeriesList()) {
            XYChart.Data objData;
            if (isHorizontal()) {
                objData = new XYChart.Data(0, objDs.getTitle());
            } else {
                objData = new XYChart.Data(objDs.getTitle(), 0);
            }
            objSeries.getData().add(objData);
            dataMgr.AddListener(objDs.getID(), objDs.getNamespace(), new ChangeListener() {

                @Override
                public void changed(ObservableValue o, Object oldVal, Object newVal) {
                    if (IsPaused()) {
                        return;
                    }
                    String strVal = newVal.toString();
                    double newValue;
                    try {
                        newValue = Double.parseDouble(strVal);
                    } catch (Exception ex) {
                        LOGGER.severe("Invalid data for Line Chart received: " + strVal);
                        return;
                    }
                    if (isHorizontal()) {
                        objData.XValueProperty().set(newValue);
                    } else {
                        objData.YValueProperty().set(newValue);
                    }
                }
            });
        }
        ((StackedBarChart) getChart()).getData().add(objSeries);
    }
}
Also used : SeriesSet(kutch.biff.marvin.utility.SeriesSet) ObservableValue(javafx.beans.value.ObservableValue) XYChart(javafx.scene.chart.XYChart) ChangeListener(javafx.beans.value.ChangeListener) SeriesDataSet(kutch.biff.marvin.utility.SeriesDataSet)

Aggregations

SeriesDataSet (kutch.biff.marvin.utility.SeriesDataSet)11 ChangeListener (javafx.beans.value.ChangeListener)4 ObservableValue (javafx.beans.value.ObservableValue)4 XYChart (javafx.scene.chart.XYChart)4 FrameworkNode (kutch.biff.marvin.utility.FrameworkNode)2 SeriesSet (kutch.biff.marvin.utility.SeriesSet)2 ArrayList (java.util.ArrayList)1 StackedBarChart (javafx.scene.chart.StackedBarChart)1