[no commit message]
This commit is contained in:
parent
2687e82c20
commit
9a4c2f119e
@ -76,10 +76,11 @@ public class MainViewerController implements Initializable, FXTaskManager {
|
|||||||
@FXML
|
@FXML
|
||||||
private Button loadDirectoryButton;
|
private Button loadDirectoryButton;
|
||||||
|
|
||||||
//controllers
|
|
||||||
@FXML
|
|
||||||
private MspViewController mspController;
|
private MspViewController mspController;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private AnchorPane mspPlotPane;
|
||||||
|
|
||||||
//main pane views
|
//main pane views
|
||||||
@FXML
|
@FXML
|
||||||
private AnchorPane numassLoaderViewContainer;
|
private AnchorPane numassLoaderViewContainer;
|
||||||
@ -188,12 +189,8 @@ public class MainViewerController implements Initializable, FXTaskManager {
|
|||||||
postTask(fillTask);
|
postTask(fillTask);
|
||||||
Viewer.runTask(fillTask);
|
Viewer.runTask(fillTask);
|
||||||
|
|
||||||
if (mspController != null) {
|
mspController = new MspViewController(this, mspPlotPane);
|
||||||
mspController.setCallback(this);
|
mspController.fillMspData(root);
|
||||||
mspController.fillMspData(root);
|
|
||||||
} else {
|
|
||||||
mspTab.getContent().setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
pressuresTab.getContent().setVisible(false);
|
pressuresTab.getContent().setVisible(false);
|
||||||
temperaturesTab.getContent().setVisible(false);
|
temperaturesTab.getContent().setVisible(false);
|
||||||
|
@ -22,33 +22,20 @@ package inr.numass.viewer;
|
|||||||
*/
|
*/
|
||||||
import hep.dataforge.data.DataPoint;
|
import hep.dataforge.data.DataPoint;
|
||||||
import hep.dataforge.data.MapDataPoint;
|
import hep.dataforge.data.MapDataPoint;
|
||||||
|
import hep.dataforge.plots.PlotUtils;
|
||||||
|
import hep.dataforge.plots.data.DynamicPlottable;
|
||||||
|
import hep.dataforge.plots.data.DynamicPlottableSet;
|
||||||
|
import hep.dataforge.plots.fx.PlotContainer;
|
||||||
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||||
import hep.dataforge.storage.api.PointLoader;
|
import hep.dataforge.storage.api.PointLoader;
|
||||||
import hep.dataforge.storage.api.Storage;
|
import hep.dataforge.storage.api.Storage;
|
||||||
import hep.dataforge.values.Value;
|
import hep.dataforge.values.Value;
|
||||||
import static inr.numass.viewer.NumassViewerUtils.displayPlot;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.stream.StreamSupport;
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.concurrent.Task;
|
import javafx.concurrent.Task;
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.Initializable;
|
|
||||||
import javafx.scene.control.CheckBox;
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import org.jfree.chart.JFreeChart;
|
|
||||||
import org.jfree.chart.axis.DateAxis;
|
|
||||||
import org.jfree.chart.axis.LogAxis;
|
|
||||||
import org.jfree.chart.plot.XYPlot;
|
|
||||||
import org.jfree.chart.renderer.xy.XYStepRenderer;
|
|
||||||
import org.jfree.data.xy.XYDataset;
|
|
||||||
import org.jfree.data.xy.XYSeries;
|
|
||||||
import org.jfree.data.xy.XYSeriesCollection;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,71 +43,49 @@ import org.slf4j.LoggerFactory;
|
|||||||
*
|
*
|
||||||
* @author darksnake
|
* @author darksnake
|
||||||
*/
|
*/
|
||||||
public class MspViewController implements Initializable {
|
public class MspViewController {
|
||||||
|
|
||||||
private FXTaskManager callback;
|
private FXTaskManager callback;
|
||||||
|
|
||||||
@FXML
|
private final AnchorPane mspPlotPane;
|
||||||
private AnchorPane mspPlotPane;
|
|
||||||
@FXML
|
|
||||||
private VBox mspSelectorPane;
|
|
||||||
|
|
||||||
/**
|
public MspViewController(FXTaskManager callback, AnchorPane mspPlotPane) {
|
||||||
* Initializes the controller class.
|
this.callback = callback;
|
||||||
*
|
this.mspPlotPane = mspPlotPane;
|
||||||
* @param url
|
|
||||||
* @param rb
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void initialize(URL url, ResourceBundle rb) {
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update detector pane with new data
|
* update detector pane with new data
|
||||||
*/
|
*/
|
||||||
private void updateMspPane(XYSeriesCollection detectorData) {
|
private void updateMspPane(DynamicPlottableSet mspData) {
|
||||||
|
// MetaBuilder plotMeta = new MetaBuilder("plot")
|
||||||
|
// .setNode(new MetaBuilder("xAxis")
|
||||||
|
// .setValue("axisTitle", "time")
|
||||||
|
// .setValue("type", "time"))
|
||||||
|
// .setNode(new MetaBuilder("yAxis")
|
||||||
|
// .setValue("axisTitle", "partial pressure")
|
||||||
|
// .setValue("axisUnits", "mbar")
|
||||||
|
// .setValue("type", "log")
|
||||||
|
// );
|
||||||
|
JFreeChartFrame frame = new JFreeChartFrame("mspData", null);
|
||||||
|
PlotUtils.setYAxis(frame, "partial pressure", "mbar", "log");
|
||||||
|
frame.getConfig().setValue("yAxis.range.lower", 1e-10);
|
||||||
|
frame.getConfig().setValue("yAxis.range.upper", 1e-3);
|
||||||
|
PlotUtils.setXAxis(frame, "time", null, "time");
|
||||||
|
|
||||||
|
StreamSupport.stream(mspData.spliterator(), false)
|
||||||
|
.sorted((DynamicPlottable o1, DynamicPlottable o2) ->
|
||||||
|
Integer.valueOf(o1.getName()).compareTo(Integer.valueOf(o2.getName()))).forEach((pl) -> frame.add(pl));
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
if (detectorData == null) {
|
PlotContainer container = PlotContainer.anchorTo(mspPlotPane);
|
||||||
throw new IllegalArgumentException("Detector data not defined");
|
container.setPlot(frame);
|
||||||
}
|
|
||||||
|
|
||||||
mspSelectorPane.getChildren().clear();//removing all checkboxes
|
|
||||||
mspPlotPane.getChildren().clear();//removing plot
|
|
||||||
|
|
||||||
DateAxis xAxis = new DateAxis("time");
|
|
||||||
LogAxis yAxis = new LogAxis("partial pressure (mbar)");
|
|
||||||
yAxis.setAutoRange(true);
|
|
||||||
yAxis.setAutoTickUnitSelection(false);
|
|
||||||
yAxis.setNumberFormatOverride(new DecimalFormat("0E0"));
|
|
||||||
//NumberAxis yAxis = new NumberAxis();
|
|
||||||
|
|
||||||
XYPlot plot = new XYPlot(detectorData, xAxis, yAxis, new XYStepRenderer());
|
|
||||||
|
|
||||||
JFreeChart mspPlot = new JFreeChart("Mass-spectrum peak jump plot", plot);
|
|
||||||
|
|
||||||
displayPlot(mspPlotPane, mspPlot);
|
|
||||||
|
|
||||||
for (int i = 0; i < plot.getDatasetCount(); i++) {
|
|
||||||
final XYDataset dataset = plot.getDataset(i);
|
|
||||||
for (int j = 0; j < dataset.getSeriesCount(); j++) {
|
|
||||||
CheckBox cb = new CheckBox(dataset.getSeriesKey(j).toString());
|
|
||||||
cb.setSelected(true);
|
|
||||||
final int seriesNumber = j;
|
|
||||||
cb.setOnAction((ActionEvent event) -> {
|
|
||||||
boolean checked = cb.isSelected();
|
|
||||||
plot.getRendererForDataset(dataset).setSeriesVisible(seriesNumber, checked);
|
|
||||||
});
|
|
||||||
mspSelectorPane.getChildren().add(cb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillMspData(Storage rootStorage) {
|
public void fillMspData(Storage rootStorage) {
|
||||||
if (rootStorage != null) {
|
if (rootStorage != null) {
|
||||||
MspDataFillTask fillTask = new MspDataFillTask(rootStorage);
|
MspDataFillTask fillTask = new MspDataFillTask(rootStorage);
|
||||||
if(callback!= null){
|
if (callback != null) {
|
||||||
callback.postTask(fillTask);
|
callback.postTask(fillTask);
|
||||||
}
|
}
|
||||||
Viewer.runTask(fillTask);
|
Viewer.runTask(fillTask);
|
||||||
@ -128,51 +93,37 @@ public class MspViewController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MspDataFillTask extends Task<Void> {
|
private class MspDataFillTask extends Task<Void> {
|
||||||
|
|
||||||
private final Storage storage;
|
private final Storage storage;
|
||||||
|
|
||||||
public MspDataFillTask(Storage storage) {
|
public MspDataFillTask(Storage storage) {
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void call() throws Exception {
|
protected Void call() throws Exception {
|
||||||
updateTitle("Fill msp data ("+storage.getName()+")");
|
updateTitle("Fill msp data (" + storage.getName() + ")");
|
||||||
MspDataLoadTask loadTask = new MspDataLoadTask(storage);
|
MspDataLoadTask loadTask = new MspDataLoadTask(storage);
|
||||||
if(callback!= null){
|
if (callback != null) {
|
||||||
callback.postTask(loadTask);
|
callback.postTask(loadTask);
|
||||||
}
|
}
|
||||||
Viewer.runTask(loadTask);
|
Viewer.runTask(loadTask);
|
||||||
List<DataPoint> mspData = loadTask.get();
|
List<DataPoint> mspData = loadTask.get();
|
||||||
Map<String, XYSeries> series = new HashMap<>();
|
|
||||||
|
DynamicPlottableSet plottables = new DynamicPlottableSet();
|
||||||
|
|
||||||
for (DataPoint point : mspData) {
|
for (DataPoint point : mspData) {
|
||||||
for (String name : point.names()) {
|
for (String name : point.names()) {
|
||||||
if (!name.equals("timestamp")) {
|
if (!name.equals("timestamp")) {
|
||||||
if (!series.containsKey(name)) {
|
if (!plottables.hasPlottable(name)) {
|
||||||
series.put(name, new XYSeries(name));
|
plottables.addPlottable(new DynamicPlottable(name, null, name));
|
||||||
}
|
|
||||||
long time = point.getValue("timestamp").timeValue().toEpochMilli();
|
|
||||||
double value = point.getDouble(name);
|
|
||||||
if (value > 0) {
|
|
||||||
series.get(name).add(time, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plottables.put(point);
|
||||||
}
|
}
|
||||||
XYSeriesCollection mspSeriesCollection = new XYSeriesCollection();
|
|
||||||
List<String> names = new ArrayList<>(series.keySet());
|
updateMspPane(plottables);
|
||||||
names.sort((String o1, String o2) -> {
|
|
||||||
try {
|
|
||||||
return Integer.valueOf(o1).compareTo(Integer.valueOf(o2));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (String name : names) {
|
|
||||||
mspSeriesCollection.addSeries(series.get(name));
|
|
||||||
}
|
|
||||||
updateMspPane(mspSeriesCollection);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +139,7 @@ public class MspViewController implements Initializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<DataPoint> call() throws Exception {
|
protected List<DataPoint> call() throws Exception {
|
||||||
updateTitle("Load msp data ("+storage.getName()+")");
|
updateTitle("Load msp data (" + storage.getName() + ")");
|
||||||
List<DataPoint> mspData = new ArrayList<>();
|
List<DataPoint> mspData = new ArrayList<>();
|
||||||
DataPoint last = null;
|
DataPoint last = null;
|
||||||
for (String loaderName : storage.loaders().keySet()) {
|
for (String loaderName : storage.loaders().keySet()) {
|
||||||
|
@ -353,6 +353,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
.setValue("thickness", 2)
|
.setValue("thickness", 2)
|
||||||
.setValue("showLine", true)
|
.setValue("showLine", true)
|
||||||
.setValue("showSymbol", false)
|
.setValue("showSymbol", false)
|
||||||
|
.setValue("showErrors", false)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
for (NMPoint point : points) {
|
for (NMPoint point : points) {
|
||||||
|
@ -56,9 +56,9 @@ limitations under the License.
|
|||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab fx:id="mspTab" closable="false" text="Mass-spectrum">
|
<Tab fx:id="mspTab" closable="false" text="Mass-spectrum">
|
||||||
<content>
|
<content>
|
||||||
<fx:include fx:id="msp" source="MspView.fxml" />
|
<AnchorPane fx:id="mspPlotPane" prefHeight="200.0" prefWidth="200.0" />
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab fx:id="pressuresTab" closable="false" text="Pressures">
|
<Tab fx:id="pressuresTab" closable="false" text="Pressures">
|
||||||
<content>
|
<content>
|
||||||
|
@ -28,26 +28,6 @@ limitations under the License.
|
|||||||
<center>
|
<center>
|
||||||
<AnchorPane fx:id="mspPlotPane" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
|
<AnchorPane fx:id="mspPlotPane" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
|
||||||
</center>
|
</center>
|
||||||
<right>
|
|
||||||
<Accordion>
|
|
||||||
<panes>
|
|
||||||
<TitledPane animated="false" text="General">
|
|
||||||
<content>
|
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
|
|
||||||
</content>
|
|
||||||
</TitledPane>
|
|
||||||
<TitledPane animated="false" text="view">
|
|
||||||
<content>
|
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<VBox fx:id="mspSelectorPane" prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
</content>
|
|
||||||
</TitledPane>
|
|
||||||
</panes>
|
|
||||||
</Accordion>
|
|
||||||
</right>
|
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
Loading…
Reference in New Issue
Block a user