[no commit message]
This commit is contained in:
parent
2687e82c20
commit
9a4c2f119e
@ -76,10 +76,11 @@ public class MainViewerController implements Initializable, FXTaskManager {
|
||||
@FXML
|
||||
private Button loadDirectoryButton;
|
||||
|
||||
//controllers
|
||||
@FXML
|
||||
private MspViewController mspController;
|
||||
|
||||
@FXML
|
||||
private AnchorPane mspPlotPane;
|
||||
|
||||
//main pane views
|
||||
@FXML
|
||||
private AnchorPane numassLoaderViewContainer;
|
||||
@ -188,12 +189,8 @@ public class MainViewerController implements Initializable, FXTaskManager {
|
||||
postTask(fillTask);
|
||||
Viewer.runTask(fillTask);
|
||||
|
||||
if (mspController != null) {
|
||||
mspController.setCallback(this);
|
||||
mspController.fillMspData(root);
|
||||
} else {
|
||||
mspTab.getContent().setVisible(false);
|
||||
}
|
||||
mspController = new MspViewController(this, mspPlotPane);
|
||||
mspController.fillMspData(root);
|
||||
|
||||
pressuresTab.getContent().setVisible(false);
|
||||
temperaturesTab.getContent().setVisible(false);
|
||||
|
@ -22,33 +22,20 @@ package inr.numass.viewer;
|
||||
*/
|
||||
import hep.dataforge.data.DataPoint;
|
||||
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.Storage;
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.stream.StreamSupport;
|
||||
import javafx.application.Platform;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
@ -56,71 +43,49 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
* @author darksnake
|
||||
*/
|
||||
public class MspViewController implements Initializable {
|
||||
public class MspViewController {
|
||||
|
||||
private FXTaskManager callback;
|
||||
|
||||
@FXML
|
||||
private AnchorPane mspPlotPane;
|
||||
@FXML
|
||||
private VBox mspSelectorPane;
|
||||
private final AnchorPane mspPlotPane;
|
||||
|
||||
/**
|
||||
* Initializes the controller class.
|
||||
*
|
||||
* @param url
|
||||
* @param rb
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
// TODO
|
||||
public MspViewController(FXTaskManager callback, AnchorPane mspPlotPane) {
|
||||
this.callback = callback;
|
||||
this.mspPlotPane = mspPlotPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(() -> {
|
||||
if (detectorData == null) {
|
||||
throw new IllegalArgumentException("Detector data not defined");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
PlotContainer container = PlotContainer.anchorTo(mspPlotPane);
|
||||
container.setPlot(frame);
|
||||
});
|
||||
}
|
||||
|
||||
public void fillMspData(Storage rootStorage) {
|
||||
if (rootStorage != null) {
|
||||
MspDataFillTask fillTask = new MspDataFillTask(rootStorage);
|
||||
if(callback!= null){
|
||||
if (callback != null) {
|
||||
callback.postTask(fillTask);
|
||||
}
|
||||
Viewer.runTask(fillTask);
|
||||
@ -137,42 +102,28 @@ public class MspViewController implements Initializable {
|
||||
|
||||
@Override
|
||||
protected Void call() throws Exception {
|
||||
updateTitle("Fill msp data ("+storage.getName()+")");
|
||||
updateTitle("Fill msp data (" + storage.getName() + ")");
|
||||
MspDataLoadTask loadTask = new MspDataLoadTask(storage);
|
||||
if(callback!= null){
|
||||
if (callback != null) {
|
||||
callback.postTask(loadTask);
|
||||
}
|
||||
Viewer.runTask(loadTask);
|
||||
List<DataPoint> mspData = loadTask.get();
|
||||
Map<String, XYSeries> series = new HashMap<>();
|
||||
|
||||
DynamicPlottableSet plottables = new DynamicPlottableSet();
|
||||
|
||||
for (DataPoint point : mspData) {
|
||||
for (String name : point.names()) {
|
||||
if (!name.equals("timestamp")) {
|
||||
if (!series.containsKey(name)) {
|
||||
series.put(name, new XYSeries(name));
|
||||
}
|
||||
long time = point.getValue("timestamp").timeValue().toEpochMilli();
|
||||
double value = point.getDouble(name);
|
||||
if (value > 0) {
|
||||
series.get(name).add(time, value);
|
||||
if (!plottables.hasPlottable(name)) {
|
||||
plottables.addPlottable(new DynamicPlottable(name, null, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
plottables.put(point);
|
||||
}
|
||||
XYSeriesCollection mspSeriesCollection = new XYSeriesCollection();
|
||||
List<String> names = new ArrayList<>(series.keySet());
|
||||
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);
|
||||
|
||||
updateMspPane(plottables);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -188,7 +139,7 @@ public class MspViewController implements Initializable {
|
||||
|
||||
@Override
|
||||
protected List<DataPoint> call() throws Exception {
|
||||
updateTitle("Load msp data ("+storage.getName()+")");
|
||||
updateTitle("Load msp data (" + storage.getName() + ")");
|
||||
List<DataPoint> mspData = new ArrayList<>();
|
||||
DataPoint last = null;
|
||||
for (String loaderName : storage.loaders().keySet()) {
|
||||
|
@ -353,6 +353,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
||||
.setValue("thickness", 2)
|
||||
.setValue("showLine", true)
|
||||
.setValue("showSymbol", false)
|
||||
.setValue("showErrors", false)
|
||||
.build();
|
||||
|
||||
for (NMPoint point : points) {
|
||||
|
@ -56,9 +56,9 @@ limitations under the License.
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab fx:id="mspTab" closable="false" text="Mass-spectrum">
|
||||
<content>
|
||||
<fx:include fx:id="msp" source="MspView.fxml" />
|
||||
</content>
|
||||
<content>
|
||||
<AnchorPane fx:id="mspPlotPane" prefHeight="200.0" prefWidth="200.0" />
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab fx:id="pressuresTab" closable="false" text="Pressures">
|
||||
<content>
|
||||
|
@ -28,26 +28,6 @@ limitations under the License.
|
||||
<center>
|
||||
<AnchorPane fx:id="mspPlotPane" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="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>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
Loading…
Reference in New Issue
Block a user