Search in sources :

Example 6 with TimeSeriesBinding

use of eu.fthevenet.binjr.data.adapters.TimeSeriesBinding in project selenium_java by sergueik.

the class CsvFileAdapter method getBindingTree.

@Override
public TreeItem<TimeSeriesBinding<Double>> getBindingTree() throws DataAdapterException {
    TreeItem<TimeSeriesBinding<Double>> tree = new TreeItem<>(new TimeSeriesBinding<>("", "/", null, getSourceName(), UnitPrefixes.METRIC, ChartType.STACKED, "-", "/" + getSourceName(), this));
    try (InputStream in = Files.newInputStream(csvPath)) {
        this.headers = getDecoder().getDataColumnHeaders(in);
        for (String header : headers) {
            TimeSeriesBinding<Double> b = new TimeSeriesBinding<>(header, header, null, header, UnitPrefixes.METRIC, ChartType.STACKED, "-", "/" + getSourceName() + "/" + header, this);
            tree.getChildren().add(new TreeItem<>(b));
        }
    } catch (IOException e) {
        throw new FetchingDataFromAdapterException(e);
    }
    return tree;
}
Also used : TimeSeriesBinding(eu.fthevenet.binjr.data.adapters.TimeSeriesBinding) TreeItem(javafx.scene.control.TreeItem) FetchingDataFromAdapterException(eu.fthevenet.binjr.data.exceptions.FetchingDataFromAdapterException) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 7 with TimeSeriesBinding

use of eu.fthevenet.binjr.data.adapters.TimeSeriesBinding in project selenium_java by sergueik.

the class MainViewController method handleDragDroppedOnWorksheetView.

private void handleDragDroppedOnWorksheetView(DragEvent event) {
    Dragboard db = event.getDragboard();
    if (db.hasContent(TIME_SERIES_BINDING_FORMAT)) {
        TreeView<TimeSeriesBinding<Double>> treeView = getSelectedTreeView();
        if (treeView != null) {
            TreeItem<TimeSeriesBinding<Double>> item = treeView.getSelectionModel().getSelectedItem();
            if (item != null) {
                Stage targetStage = (Stage) ((Node) event.getSource()).getScene().getWindow();
                if (targetStage != null) {
                    targetStage.requestFocus();
                }
                if (TransferMode.COPY.equals(event.getAcceptedTransferMode())) {
                    addToNewChartInCurrentWorksheet(item);
                } else if (TransferMode.MOVE.equals(event.getAcceptedTransferMode())) {
                    if (getSelectedWorksheetController().getWorksheet().getCharts().size() > 1) {
                        getChartListContextMenu(treeView).show((Node) event.getTarget(), event.getScreenX(), event.getSceneY());
                    } else {
                        addToCurrentWorksheet(treeView.getSelectionModel().getSelectedItem(), getSelectedWorksheetController().getWorksheet().getDefaultChart());
                    }
                } else {
                    logger.warn("Unsupported drag and drop transfer mode: " + event.getAcceptedTransferMode());
                }
            } else {
                logger.warn("Cannot complete drag and drop operation: selected TreeItem is null");
            }
        } else {
            logger.warn("Cannot complete drag and drop operation: selected TreeView is null");
        }
        event.consume();
    }
}
Also used : TimeSeriesBinding(eu.fthevenet.binjr.data.adapters.TimeSeriesBinding) Node(javafx.scene.Node) Stage(javafx.stage.Stage)

Example 8 with TimeSeriesBinding

use of eu.fthevenet.binjr.data.adapters.TimeSeriesBinding in project selenium_java by sergueik.

the class JrdsSeriesBindingFactory method of.

/**
 * Creates a new instance of the {@link TimeSeriesBinding} class with the following parameters
 *
 * @param parentName the name of the parent tree node.
 * @param legend     the legend for the timeseries
 * @param graphdesc  the graph description from JRDS
 * @param path       the id of the JRDS graph
 * @param adapter    the {@link JrdsDataAdapter} for the binding.
 * @return a JRDS series binding
 */
public TimeSeriesBinding<Double> of(String parentName, String legend, Graphdesc graphdesc, String path, DataAdapter<Double, CsvDecoder<Double>> adapter) {
    final String label;
    final UnitPrefixes prefix;
    final ChartType graphType;
    final String unitName;
    label = isNullOrEmpty(graphdesc.name) ? (isNullOrEmpty(graphdesc.graphName) ? "???" : graphdesc.graphName) : graphdesc.name;
    graphType = ChartType.STACKED;
    prefix = findPrefix(graphdesc);
    unitName = graphdesc.verticalLabel;
    return new TimeSeriesBinding<>(label, path, null, legend, prefix, graphType, unitName, parentName + "/" + legend, adapter);
}
Also used : TimeSeriesBinding(eu.fthevenet.binjr.data.adapters.TimeSeriesBinding) ChartType(eu.fthevenet.binjr.data.workspace.ChartType) UnitPrefixes(eu.fthevenet.binjr.data.workspace.UnitPrefixes)

Example 9 with TimeSeriesBinding

use of eu.fthevenet.binjr.data.adapters.TimeSeriesBinding in project selenium_java by sergueik.

the class JrdsSeriesBindingFactory method of.

/**
 * Creates a new instance of the {@link TimeSeriesBinding} class with the following parameters
 *
 * @param parentName the name of the parent tree node.
 * @param graphdesc  the graph description from JRDS
 * @param idx        the index of the series in the graphdesc
 * @param path       the id of the JRDS graph
 * @param adapter    the {@link JrdsDataAdapter} for the binding.
 * @return a JRDS series binding
 */
public TimeSeriesBinding<Double> of(String parentName, Graphdesc graphdesc, int idx, String path, DataAdapter<Double, CsvDecoder<Double>> adapter) {
    final String label;
    final Color color;
    final String legend;
    final UnitPrefixes prefix;
    final ChartType graphType;
    final String unitName;
    Graphdesc.SeriesDesc desc = graphdesc.seriesDescList.get(idx);
    label = isNullOrEmpty(desc.name) ? (isNullOrEmpty(desc.dsName) ? (isNullOrEmpty(desc.legend) ? "???" : desc.legend) : desc.dsName) : desc.name;
    Color c = null;
    try {
        if (!isNullOrEmpty(desc.color)) {
            c = Color.web(desc.color);
        }
    } catch (IllegalArgumentException e) {
        logger.warn("Invalid color string for binding " + label);
    }
    color = c;
    legend = isNullOrEmpty(desc.legend) ? (isNullOrEmpty(desc.name) ? (isNullOrEmpty(desc.dsName) ? "???" : desc.dsName) : desc.name) : desc.legend;
    switch(desc.graphType.toLowerCase()) {
        case "area":
            graphType = ChartType.AREA;
            break;
        case "stacked":
            graphType = ChartType.STACKED;
            break;
        case "line":
            graphType = ChartType.LINE;
            break;
        case "none":
        default:
            graphType = ChartType.STACKED;
            break;
    }
    prefix = findPrefix(graphdesc);
    unitName = graphdesc.verticalLabel;
    return new TimeSeriesBinding<>(label, path, color, legend, prefix, graphType, unitName, parentName + "/" + legend, adapter);
}
Also used : TimeSeriesBinding(eu.fthevenet.binjr.data.adapters.TimeSeriesBinding) Color(javafx.scene.paint.Color) ChartType(eu.fthevenet.binjr.data.workspace.ChartType) UnitPrefixes(eu.fthevenet.binjr.data.workspace.UnitPrefixes)

Aggregations

TimeSeriesBinding (eu.fthevenet.binjr.data.adapters.TimeSeriesBinding)9 IOException (java.io.IOException)5 NoAdapterFoundException (eu.fthevenet.binjr.data.exceptions.NoAdapterFoundException)3 ZonedDateTime (java.time.ZonedDateTime)3 Node (javafx.scene.Node)3 Stage (javafx.stage.Stage)3 DataAdapter (eu.fthevenet.binjr.data.adapters.DataAdapter)2 ChartType (eu.fthevenet.binjr.data.workspace.ChartType)2 UnitPrefixes (eu.fthevenet.binjr.data.workspace.UnitPrefixes)2 Dialogs (eu.fthevenet.binjr.dialogs.Dialogs)2 JsonJrdsItem (eu.fthevenet.binjr.sources.jrds.adapters.json.JsonJrdsItem)2 InputStream (java.io.InputStream)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 ZoneId (java.time.ZoneId)2 DateTimeFormatter (java.time.format.DateTimeFormatter)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 TreeItem (javafx.scene.control.TreeItem)2 Color (javafx.scene.paint.Color)2