[no commit message]
This commit is contained in:
parent
ec76341522
commit
a38a770f5e
@ -25,14 +25,13 @@ import hep.dataforge.context.ProcessManager;
|
|||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
|
import hep.dataforge.plots.PlotFrame;
|
||||||
import hep.dataforge.plots.XYPlotFrame;
|
import hep.dataforge.plots.XYPlotFrame;
|
||||||
import hep.dataforge.plots.XYPlottable;
|
|
||||||
import hep.dataforge.plots.data.ChangeablePlottableData;
|
import hep.dataforge.plots.data.ChangeablePlottableData;
|
||||||
import hep.dataforge.plots.data.DynamicPlottable;
|
import hep.dataforge.plots.data.DynamicPlottable;
|
||||||
import hep.dataforge.plots.data.DynamicPlottableSet;
|
import hep.dataforge.plots.data.DynamicPlottableSet;
|
||||||
import hep.dataforge.plots.data.PlotDataUtils;
|
import hep.dataforge.plots.data.PlotDataUtils;
|
||||||
import hep.dataforge.plots.data.PlottableData;
|
import hep.dataforge.plots.data.PlottableData;
|
||||||
import hep.dataforge.plots.data.PlottableSet;
|
|
||||||
import hep.dataforge.plots.fx.PlotContainer;
|
import hep.dataforge.plots.fx.PlotContainer;
|
||||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||||
import hep.dataforge.storage.commons.JSONMetaWriter;
|
import hep.dataforge.storage.commons.JSONMetaWriter;
|
||||||
@ -46,7 +45,6 @@ import inr.numass.storage.NumassData;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@ -280,15 +278,15 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
private void setupDetectorPane(List<NMPoint> points) {
|
private void setupDetectorPane(List<NMPoint> points) {
|
||||||
boolean normalize = detectorNormalizeSwitch.isSelected();
|
boolean normalize = detectorNormalizeSwitch.isSelected();
|
||||||
int binning = detectorBinningSelector.getValue();
|
int binning = detectorBinningSelector.getValue();
|
||||||
updateDetectorPane(fillDetectorData(points, binning, normalize));
|
updateDetectorPane(points, binning, normalize);
|
||||||
detectorBinningSelector.getSelectionModel().selectedItemProperty()
|
detectorBinningSelector.getSelectionModel().selectedItemProperty()
|
||||||
.addListener((ObservableValue<? extends Integer> observable, Integer oldValue, Integer newValue) -> {
|
.addListener((ObservableValue<? extends Integer> observable, Integer oldValue, Integer newValue) -> {
|
||||||
boolean norm = detectorNormalizeSwitch.isSelected();
|
boolean norm = detectorNormalizeSwitch.isSelected();
|
||||||
updateDetectorPane(fillDetectorData(NumassLoaderViewComponent.this.points, newValue, norm));
|
updateDetectorPane(NumassLoaderViewComponent.this.points, newValue, norm);
|
||||||
});
|
});
|
||||||
detectorNormalizeSwitch.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
|
detectorNormalizeSwitch.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
|
||||||
int bin = detectorBinningSelector.getValue();
|
int bin = detectorBinningSelector.getValue();
|
||||||
updateDetectorPane(fillDetectorData(NumassLoaderViewComponent.this.points, bin, newValue));
|
updateDetectorPane(NumassLoaderViewComponent.this.points, bin, newValue);
|
||||||
});
|
});
|
||||||
detectorDataExportButton.setDisable(false);
|
detectorDataExportButton.setDisable(false);
|
||||||
}
|
}
|
||||||
@ -334,16 +332,11 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
/**
|
/**
|
||||||
* update detector pane with new data
|
* update detector pane with new data
|
||||||
*/
|
*/
|
||||||
private void updateDetectorPane(List<XYPlottable> detectorData) {
|
private void updateDetectorPane(List<NMPoint> points, int binning, boolean normalize) {
|
||||||
Platform.runLater(() -> {
|
PlotFrame detectorPlotFrame;
|
||||||
if (detectorData == null) {
|
if (detectorPlot.getPlot() == null) {
|
||||||
throw new IllegalArgumentException("Detector data not defined");
|
|
||||||
}
|
|
||||||
|
|
||||||
// detectorPointListView.getItems().clear();//removing all checkboxes
|
|
||||||
// detectorPlotPane.getChildren().clear();//removing plot
|
|
||||||
Meta frameMeta = new MetaBuilder("frame")
|
Meta frameMeta = new MetaBuilder("frame")
|
||||||
.setValue("frameTitle", "Detector response plot")
|
.setValue("title", "Detector response plot")
|
||||||
.setNode(new MetaBuilder("xAxis")
|
.setNode(new MetaBuilder("xAxis")
|
||||||
.setValue("axisTitle", "ADC")
|
.setValue("axisTitle", "ADC")
|
||||||
.setValue("axisUnits", "channels")
|
.setValue("axisUnits", "channels")
|
||||||
@ -355,36 +348,35 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
.setNode(new MetaBuilder("legend")
|
.setNode(new MetaBuilder("legend")
|
||||||
.setValue("show", false))
|
.setValue("show", false))
|
||||||
.build();
|
.build();
|
||||||
|
detectorPlotFrame = new JFreeChartFrame(frameMeta);
|
||||||
|
} else {
|
||||||
|
detectorPlotFrame = detectorPlot.getPlot();
|
||||||
|
detectorPlot.removePlot();
|
||||||
|
}
|
||||||
|
|
||||||
// detectorPlot = PlotContainer.anchorTo(detectorPlotPane);
|
context.processManager().post("viewer.numass.load.detector", (ProcessManager.Callback callback) -> {
|
||||||
XYPlotFrame detectorPlotFrame = new JFreeChartFrame(frameMeta);
|
Meta plottableConfig = new MetaBuilder("plot")
|
||||||
|
.setValue("connectionType", "step")
|
||||||
|
.setValue("thickness", 2)
|
||||||
|
.setValue("showLine", true)
|
||||||
|
.setValue("showSymbol", false)
|
||||||
|
.setValue("showErrors", false)
|
||||||
|
.build();
|
||||||
|
|
||||||
for (XYPlottable pl : detectorData) {
|
// detectorPlotFrame.clear();
|
||||||
detectorPlotFrame.add(pl);
|
callback.setMaxProgress(points.size());
|
||||||
|
callback.setProgress(0);
|
||||||
|
for (NMPoint point : points) {
|
||||||
|
String seriesName = String.format("%d: %.2f", points.indexOf(point), point.getUset());
|
||||||
|
PlottableData datum = PlottableData.plot(seriesName, new XYAdapter("chanel", "count"), point.getData(binning, normalize));
|
||||||
|
datum.configure(plottableConfig);
|
||||||
|
detectorPlotFrame.add(datum);
|
||||||
|
callback.increaseProgress(1d);
|
||||||
//TODO add update instead of replace action
|
//TODO add update instead of replace action
|
||||||
}
|
}
|
||||||
detectorPlot.setPlot(detectorPlotFrame);
|
detectorPlot.setPlot(detectorPlotFrame);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
private List<XYPlottable> fillDetectorData(List<NMPoint> points, int binning, boolean normalize) {
|
|
||||||
List<XYPlottable> plottables = new ArrayList<>();
|
|
||||||
Meta plottableConfig = new MetaBuilder("plot")
|
|
||||||
.setValue("connectionType", "step")
|
|
||||||
.setValue("thickness", 2)
|
|
||||||
.setValue("showLine", true)
|
|
||||||
.setValue("showSymbol", false)
|
|
||||||
.setValue("showErrors", false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
for (NMPoint point : points) {
|
|
||||||
String seriesName = String.format("%d: %.2f (%.2f)", points.indexOf(point), point.getUset(), point.getUread());
|
|
||||||
|
|
||||||
PlottableData datum = PlottableData.plot(seriesName, new XYAdapter("chanel", "count"), point.getData(binning, normalize));
|
|
||||||
datum.configure(plottableConfig);
|
|
||||||
plottables.add(datum);
|
|
||||||
}
|
|
||||||
return plottables;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
Loading…
Reference in New Issue
Block a user