diff --git a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java
index 78d4e8e3..81138b37 100644
--- a/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java
+++ b/numass-storage/numass-server/src/main/java/inr/numass/server/NumassRootHandler.java
@@ -100,7 +100,7 @@ public class NumassRootHandler implements Handler {
}
private void renderLoader(Context ctx, StringBuilder b, Loader loader) {
- String href = "/storage?path=" + loader.getPath();
+ String href = "/storage?path=" + loader.getFullPath();
b.append(String.format("
%s (%s)
", href, loader.getName(), loader.getType()));
}
}
diff --git a/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java b/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java
index b2084225..b3b24e1e 100644
--- a/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java
+++ b/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java
@@ -311,7 +311,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader {
+ return SetDirectionUtility.isReversed(getFullPath(), n -> {
List points = getPoints();
if (getPoints().size() >= 2) {
return readTime(points.get(0).meta()).isAfter(readTime(points.get(1).meta()));
diff --git a/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java b/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java
index 4a10bb8c..4feee2b9 100644
--- a/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java
+++ b/numass-viewer/src/main/java/inr/numass/viewer/MainViewerController.java
@@ -59,8 +59,8 @@ public class MainViewerController implements Initializable {
@FXML
private Button loadDirectoryButton;
private MspViewController mspController;
- @FXML
- private AnchorPane mspPlotPane;
+ // @FXML
+// private AnchorPane mspContainer;
//main pane views
@FXML
private AnchorPane numassLoaderViewContainer;
@@ -181,7 +181,7 @@ public class MainViewerController implements Initializable {
callback.setProgressToMax();
});
- mspController = new MspViewController(getContext(), mspPlotPane);
+ mspController = new MspViewController(getContext(), mspTab);
mspController.fillMspData(root);
pressuresTab.getContent().setVisible(false);
diff --git a/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java b/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java
index 5a0ec03b..ecc76991 100644
--- a/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java
+++ b/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java
@@ -21,7 +21,6 @@ package inr.numass.viewer;
* and open the template in the editor.
*/
-import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.context.Context;
import hep.dataforge.names.Name;
import hep.dataforge.plots.PlotUtils;
@@ -36,11 +35,17 @@ import hep.dataforge.tables.DataPoint;
import hep.dataforge.tables.MapPoint;
import hep.dataforge.values.Value;
import javafx.application.Platform;
+import javafx.fxml.FXML;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.control.Tab;
import javafx.scene.layout.AnchorPane;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/**
@@ -50,27 +55,27 @@ import java.util.stream.StreamSupport;
*/
public class MspViewController {
- private final AnchorPane mspPlotPane;
private final Context context;
+ @FXML
+ private AnchorPane mspPlotPane;
- public MspViewController(Context context, AnchorPane mspPlotPane) {
+ public MspViewController(Context context, Tab mspTab) {
this.context = context;
- this.mspPlotPane = mspPlotPane;
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/MspView.fxml"));
+ loader.setController(this);
+ try {
+ loader.load();
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ mspTab.setContent(loader.getRoot());
+// this.mspPlotPane = mspContainer;
}
/**
* update detector pane with new data
*/
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();
PlotUtils.setYAxis(frame, "partial pressure", "mbar", "log");
frame.getConfig().setValue("yAxis.range.lower", 1e-10);
@@ -81,66 +86,122 @@ public class MspViewController {
.sorted((DynamicPlottable o1, DynamicPlottable o2)
-> Integer.valueOf(o1.getName()).compareTo(Integer.valueOf(o2.getName()))).forEach((pl) -> frame.add(pl));
Platform.runLater(() -> {
+ mspPlotPane.getChildren().clear();
PlotContainer container = PlotContainer.anchorTo(mspPlotPane);
container.setPlot(frame);
});
}
- public void fillMspData(Storage rootStorage) {
- if (rootStorage != null) {
- context.taskManager().submit("viewer.msp.fill", (ProgressCallback callback) -> {
- // callback.updateTitle("Fill msp data (" + rootStorage.getName() + ")");
- callback.updateTitle("Load msp data (" + rootStorage.getName() + ")");
+ public List listMspLoaders(Storage rootStorage) {
+ return StorageUtils.loaderStream(rootStorage)
+ .filter(pair -> Name.of(pair.getKey()).getLast().toString().startsWith("msp"))
+ .map(pair -> pair.getValue())
+ .filter(loader -> PointLoader.POINT_LOADER_TYPE.equals(loader.getType()))
+ .map(loader -> (PointLoader) loader)
+ .collect(Collectors.toList());
+ }
- List mspData = new ArrayList<>();
-
- StorageUtils.loaderStream(rootStorage)
- .filter(pair -> pair.getValue() instanceof PointLoader)
- .filter(pair -> Name.of(pair.getKey()).getLast().toString().startsWith("msp"))
- .map(pair -> pair.getValue())
- .filter(loader -> PointLoader.POINT_LOADER_TYPE.equals(loader.getType()))
- .forEach(loader -> {
- try {
- PointLoader mspLoader = (PointLoader) loader;
- mspLoader.open();
- callback.updateMessage("Loading mass spectrometer data from " + mspLoader.getName());
- DataPoint last = null;
- for (DataPoint dp : mspLoader) {
- mspData.add(dp);
- last = dp;
- }
- if (last != null) {
- mspData.add(terminatorPoint(last));
- }
- } catch (Exception ex) {
- LoggerFactory.getLogger(getClass()).error("Can't read msp loader data", ex);
- }
- });
- callback.updateMessage("Loading msp data finished");
-// return mspData;
-// List mspData = (List) loadProcess.getTask().get();
-
- if (!mspData.isEmpty()) {
- DynamicPlottableSet plottables = new DynamicPlottableSet();
-
- for (DataPoint point : mspData) {
- for (String name : point.names()) {
- if (!name.equals("timestamp")) {
- if (!plottables.hasPlottable(name)) {
- plottables.addPlottable(new DynamicPlottable(name, name));
+ public void plotData(List loaders) {
+ DynamicPlottableSet plottables = new DynamicPlottableSet();
+ loaders.stream()
+ .flatMap(loader -> getLoaderData(loader))
+ .distinct()
+ .forEach(point -> {
+ for (String name : point.names()) {
+ if (!name.equals("timestamp")) {
+ if (!plottables.hasPlottable(name)) {
+ plottables.addPlottable(new DynamicPlottable(name, name));
+ }
}
}
+ plottables.put(point);
}
- plottables.put(point);
- }
+ );
+ updateMspPane(plottables);
+ }
- updateMspPane(plottables);
- }
- });
+ private Stream getLoaderData(PointLoader loader) {
+ try {
+ loader.open();
+ List points = new ArrayList<>();
+// callback.updateMessage("Loading mass spectrometer data from " + loader.getName());
+
+ DataPoint last = null;
+
+ for (DataPoint dp : loader) {
+ points.add(dp);
+ last = dp;
+ }
+ if (last != null) {
+ points.add(terminatorPoint(last));
+ }
+ return points.stream();
+ } catch (Exception ex) {
+ LoggerFactory.getLogger(getClass()).error("Can't read msp loader data", ex);
+ return Stream.empty();
}
}
+ public void fillMspData(Storage rootStorage) {
+ plotData(listMspLoaders(rootStorage));
+ }
+
+// public void fillMspData(Storage rootStorage) {
+// if (rootStorage != null) {
+// context.taskManager().submit("viewer.msp.fill", (ProgressCallback callback) -> {
+// // callback.updateTitle("Fill msp data (" + rootStorage.getName() + ")");
+//
+// callback.updateTitle("Load msp data (" + rootStorage.getName() + ")");
+//
+// List mspData = new ArrayList<>();
+//
+// StorageUtils.loaderStream(rootStorage)
+// .filter(pair -> pair.getValue() instanceof PointLoader)
+// .filter(pair -> Name.of(pair.getKey()).getLast().toString().startsWith("msp"))
+// .map(pair -> pair.getValue())
+// .filter(loader -> PointLoader.POINT_LOADER_TYPE.equals(loader.getType()))
+// .forEach(loader -> {
+// try {
+// PointLoader mspLoader = (PointLoader) loader;
+// mspLoader.open();
+// callback.updateMessage("Loading mass spectrometer data from " + mspLoader.getName());
+// DataPoint last = null;
+// for (DataPoint dp : mspLoader) {
+// mspData.add(dp);
+// last = dp;
+// }
+// if (last != null) {
+// mspData.add(terminatorPoint(last));
+// }
+// } catch (Exception ex) {
+// LoggerFactory.getLogger(getClass()).error("Can't read msp loader data", ex);
+// }
+// });
+// callback.updateMessage("Loading msp data finished");
+//// return mspData;
+//// List mspData = (List) loadProcess.getTask().get();
+//
+// if (!mspData.isEmpty()) {
+// DynamicPlottableSet plottables = new DynamicPlottableSet();
+//
+// for (DataPoint point : mspData) {
+// for (String name : point.names()) {
+// if (!name.equals("timestamp")) {
+// if (!plottables.hasPlottable(name)) {
+// plottables.addPlottable(new DynamicPlottable(name, name));
+// }
+// }
+// }
+// plottables.put(point);
+// }
+//
+// updateMspPane(plottables);
+// }
+// });
+// }
+// }
+
/**
* Create a null value point to terminate msp series
*
diff --git a/numass-viewer/src/main/resources/fxml/MainView.fxml b/numass-viewer/src/main/resources/fxml/MainView.fxml
index 73af8da1..0a539ccb 100644
--- a/numass-viewer/src/main/resources/fxml/MainView.fxml
+++ b/numass-viewer/src/main/resources/fxml/MainView.fxml
@@ -73,7 +73,7 @@ limitations under the License.
-
+
diff --git a/numass-viewer/src/main/resources/fxml/MspView.fxml b/numass-viewer/src/main/resources/fxml/MspView.fxml
index 588d5556..f26b4c48 100644
--- a/numass-viewer/src/main/resources/fxml/MspView.fxml
+++ b/numass-viewer/src/main/resources/fxml/MspView.fxml
@@ -16,13 +16,10 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
-
-
-
-
-
-
+