Search in sources :

Example 1 with SeriesDataSet

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

the class StackedAreaChartWidget_MS method _CreateChart.

@Override
@SuppressWarnings("unchecked")
protected void _CreateChart() {
    CreateChart();
    for (SeriesDataSet ds : getSeries()) {
        // Stacked Charts will crash if you don't have any data in a series.
        ds.getSeries().getData().add(new XYChart.Data<>(0, 0));
        ((StackedAreaChart) (getChart())).getData().add(ds.getSeries());
    }
}
Also used : XYChart(javafx.scene.chart.XYChart) SeriesDataSet(kutch.biff.marvin.utility.SeriesDataSet)

Example 2 with SeriesDataSet

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

the class StackedBarChartWidget method CreateChartObject.

@Override
protected Chart CreateChartObject() {
    ArrayList<String> list = new ArrayList<>();
    for (String key : _SeriesOrder) {
        if (null == _SeriesMap.get(key)) {
            LOGGER.severe("Unexpected probelm in CreateChartObject");
            break;
        }
        ArrayList<SeriesDataSet> setList = _SeriesMap.get(key).getSeriesList();
        if (null == setList) {
            LOGGER.severe("Unexpected probelm in CreateChartObject");
            break;
        }
        for (SeriesDataSet set : setList) {
            list.add(set.getTitle());
        }
        break;
    }
    getAxis_X().setCategories(FXCollections.observableArrayList(list));
    return new StackedBarChart<String, Number>(getAxis_X(), getyAxis());
}
Also used : ArrayList(java.util.ArrayList) StackedBarChart(javafx.scene.chart.StackedBarChart) SeriesDataSet(kutch.biff.marvin.utility.SeriesDataSet)

Example 3 with SeriesDataSet

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

the class BaseChartWidget method ReadSeriesSet.

protected boolean ReadSeriesSet(FrameworkNode setNode) {
    String title = "";
    if (setNode.hasAttributes()) {
        Utility.ValidateAttributes(new String[] { "Title" }, setNode);
        if (setNode.hasAttribute("Title")) {
            title = setNode.getAttribute("Title");
        }
    }
    for (FrameworkNode node : setNode.getChildNodes()) {
        if (node.getNodeName().equalsIgnoreCase("MinionSrc")) {
            Utility.ValidateAttributes(new String[] { "ID", "Namespace", "SeriesID" }, node);
            String ID, Namespace, SeriesID;
            if (node.hasAttribute("ID")) {
                ID = node.getAttribute("ID");
            } else {
                LOGGER.severe("Chart SeriesSet defined with invalid MinionSrc - no ID");
                return false;
            }
            if (node.hasAttribute("Namespace")) {
                Namespace = node.getAttribute("Namespace");
            } else {
                LOGGER.severe("hart SeriesSedefined with invalid MinionSrc - no Namespace");
                return false;
            }
            if (node.hasAttribute("SeriesID")) {
                SeriesID = node.getAttribute("SeriesID");
            } else {
                LOGGER.severe("Chart SeriesSet defined with invalid MinionSrc - no SeriesID");
                return false;
            }
            if (false == _SeriesMap.containsKey(SeriesID.toUpperCase())) {
                LOGGER.severe("Chart SeriesSet defined with invalid MinionSrc - the Series ID has not been defined in a <Series> section. SeriesID=" + SeriesID);
                return false;
            }
            SeriesDataSet objDS = new SeriesDataSet(title, ID, Namespace);
            _SeriesMap.get(SeriesID.toUpperCase()).AddSeries(objDS);
        }
    }
    return true;
}
Also used : SeriesDataSet(kutch.biff.marvin.utility.SeriesDataSet) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 4 with SeriesDataSet

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

the class LineChartWidget method Create.

@Override
@SuppressWarnings("unchecked")
public boolean Create(GridPane pane, DataManager dataMgr) {
    SetParent(pane);
    if (getSeries().isEmpty()) {
        if (getyAxisMaxCount() > 0) {
            for (int iLoop = 0; iLoop < getyAxisMaxCount(); iLoop++) {
                SeriesDataSet objDS = new SeriesDataSet(Integer.toString(iLoop), "", "");
                getSeries().add(objDS);
            }
        } else {
            LOGGER.severe("Chart created with no series defined and no count defined for yAxis");
            return false;
        }
    }
    _CreateChart();
    ConfigureDimentions();
    ConfigureAlignment();
    SetupPeekaboo(dataMgr);
    pane.add(getChart(), getColumn(), getRow(), getColumnSpan(), getRowSpan());
    // hmm, only get called if different, that could be a problem for a chart
    dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {

        @Override
        @SuppressWarnings("unchecked")
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            if (IsPaused()) {
                return;
            }
            String[] strList = newVal.toString().split(",");
            int iIndex = 0;
            for (String strValue : strList) {
                double newValue;
                try {
                    newValue = Double.parseDouble(strValue);
                } catch (NumberFormatException ex) {
                    LOGGER.severe("Invalid data for Line Chart received: " + strValue);
                    return;
                }
                if (iIndex < getSeries().size()) {
                    SeriesDataSet ds = getSeries().get(iIndex++);
                    ShiftSeries(ds.getSeries(), getxAxisMaxCount());
                    ds.getSeries().getData().add(new XYChart.Data<>(ds.getSeries().getData().size(), newValue));
                } else {
                    LOGGER.severe("Received More datapoints for Line Chart than was defined in application definition file. Received " + Integer.toString(strList.length) + " expecting " + Integer.toString(getSeries().size()));
                    return;
                }
            }
        }
    });
    SetupTaskAction();
    return ApplyCSS();
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) SeriesDataSet(kutch.biff.marvin.utility.SeriesDataSet)

Example 5 with SeriesDataSet

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

the class LineChartWidget method HandleWidgetSpecificSettings.

/**
 * @param node
 * @return
 */
@Override
public boolean HandleWidgetSpecificSettings(FrameworkNode node) {
    if (true == HandleChartSpecificAppSettings(node)) {
        return true;
    }
    if (node.getNodeName().equalsIgnoreCase("Series")) {
        String Label;
        if (node.hasAttribute("Label")) {
            Label = node.getAttribute("Label");
        } else {
            Label = "";
        }
        SeriesDataSet objDS = new SeriesDataSet(Label, "", "");
        getSeries().add(objDS);
        return true;
    }
    return false;
}
Also used : 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