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;
}
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();
}
}
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);
}
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);
}
Aggregations