Search in sources :

Example 1 with SeriesSet

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

the class BaseChartWidget method HandleChartSpecificAppSettings.

public boolean HandleChartSpecificAppSettings(FrameworkNode node) {
    if (node.getNodeName().equalsIgnoreCase("xAxis")) {
        if (node.hasAttribute("Label")) {
            setxAxisLabel(node.getAttribute("Label"));
        }
        if (node.hasAttribute("MaxEntries")) {
            String strVal = node.getAttribute("MaxEntries");
            try {
                setxAxisMaxCount(Integer.parseInt(strVal));
            } catch (NumberFormatException ex) {
                LOGGER.severe("Invalid value for chart MaxEntires: " + strVal + " - ignoring.");
                return false;
            }
        }
        // For a bar chart, isn't max entries, is count.  Is same thing, but gramatically Count is better
        if (node.hasAttribute("Count")) {
            String strVal = node.getAttribute("Count");
            try {
                setxAxisMaxCount(Integer.parseInt(strVal));
            } catch (NumberFormatException ex) {
                LOGGER.severe("Invalid value for chart Count: " + strVal + " - ignoring.");
                return false;
            }
        }
        return true;
    }
    if (node.getNodeName().equalsIgnoreCase("Series")) {
        String Label;
        String ID;
        if (node.hasAttribute("Label")) {
            Label = node.getAttribute("Label");
        } else {
            Label = "";
        }
        if (node.hasAttribute("ID")) {
            ID = node.getAttribute("ID");
        } else {
            // LOGGER.warning("Series declaration for Chart Widget requires an ID");
            return false;
        }
        if (_SeriesMap.containsKey(ID.toUpperCase())) {
            LOGGER.severe("Seried ID must be unique per Bar Chart, repeat found: " + ID);
            return false;
        }
        _SeriesMap.put(ID.toUpperCase(), new SeriesSet(Label));
        _SeriesOrder.add(ID.toUpperCase());
        return true;
    } else if (node.getNodeName().equalsIgnoreCase("SeriesSet")) {
        return ReadSeriesSet(node);
    }
    if (node.getNodeName().equalsIgnoreCase("yAxis")) {
        if (node.hasAttribute("Label")) {
            yAxisLabel = node.getAttribute("Label");
        }
        if (node.hasAttribute("MaxValue")) {
            String strVal = node.getAttribute("MaxValue");
            try {
                yAxisMaxValue = Double.parseDouble(strVal);
            } catch (NumberFormatException ex) {
                LOGGER.severe("Invalid value for chart MaxValue: " + strVal + " - ignoring.");
                return false;
            }
        }
        if (node.hasAttribute("MinValue")) {
            String strVal = node.getAttribute("MinValue");
            try {
                yAxisMinValue = Double.parseDouble(strVal);
            } catch (NumberFormatException ex) {
                LOGGER.severe("Invalid value for chart MinValue: " + strVal + " - ignoring.");
                return false;
            }
        }
        if (node.hasAttribute("Count")) {
            String strVal = node.getAttribute("Count");
            try {
                setyAxisMaxCount(Integer.parseInt(strVal));
            } catch (NumberFormatException ex) {
                LOGGER.severe("Invalid value for chart Count: " + strVal + " - ignoring.");
                return false;
            }
        }
        return true;
    }
    return false;
}
Also used : SeriesSet(kutch.biff.marvin.utility.SeriesSet)

Example 2 with SeriesSet

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

the class BaseChartWidget method SetupSeriesSets.

protected void SetupSeriesSets(DataManager dataMgr) {
    for (String key : _SeriesOrder) {
        SeriesSet objSeriesSet = _SeriesMap.get(key);
        if (null == objSeriesSet) {
            return;
        }
        XYChart.Series objSeries = new XYChart.Series();
        String strTitle = objSeriesSet.getTitle();
        if (null == strTitle) {
            return;
        }
        objSeries.setName(strTitle);
        for (SeriesDataSet objDs : objSeriesSet.getSeriesList()) {
            XYChart.Data objChartDataSet;
            if (isHorizontal()) {
                objChartDataSet = new XYChart.Data<>(0, objDs.getTitle());
            } else {
                objChartDataSet = new XYChart.Data<>(objDs.getTitle(), 0);
            }
            objSeries.getData().add(objChartDataSet);
            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 (NumberFormatException ex) {
                        LOGGER.severe("Invalid data for Line Chart received: " + strVal);
                        return;
                    }
                    if (isHorizontal()) {
                        objChartDataSet.XValueProperty().set(newValue);
                    } else {
                        objChartDataSet.YValueProperty().set(newValue);
                    }
                }
            });
        }
        boolean fReturn = ((XYChart) getChart()).getData().add(objSeries);
    }
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) SeriesDataSet(kutch.biff.marvin.utility.SeriesDataSet) SeriesSet(kutch.biff.marvin.utility.SeriesSet) XYChart(javafx.scene.chart.XYChart) ChangeListener(javafx.beans.value.ChangeListener)

Example 3 with SeriesSet

use of kutch.biff.marvin.utility.SeriesSet 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

SeriesSet (kutch.biff.marvin.utility.SeriesSet)3 ChangeListener (javafx.beans.value.ChangeListener)2 ObservableValue (javafx.beans.value.ObservableValue)2 XYChart (javafx.scene.chart.XYChart)2 SeriesDataSet (kutch.biff.marvin.utility.SeriesDataSet)2