[no commit message]

This commit is contained in:
darksnake 2015-12-21 16:40:21 +03:00
parent 4bdc1d492e
commit 9721b173c5
7 changed files with 164 additions and 108 deletions

4
.nb-gradle-properties Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gradle-project-properties>
<!--DO NOT EDIT THIS FILE! - Used by the Gradle plugin of NetBeans.-->
</gradle-project-properties>

View File

@ -27,34 +27,19 @@ import inr.numass.workbench.Workbench;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.Locale; import java.util.Locale;
import static java.util.Locale.setDefault;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options; import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException; import org.apache.commons.cli.ParseException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
/** /**
* *
@ -74,7 +59,7 @@ public class Main {
Logger logger = LoggerFactory.getLogger("numass-main"); Logger logger = LoggerFactory.getLogger("numass-main");
Options options = prepareOptions(); Options options = prepareOptions();
CommandLineParser parser = new BasicParser(); CommandLineParser parser = new DefaultParser();
CommandLine line; CommandLine line;
try { try {
// parse the command line arguments // parse the command line arguments

View File

@ -15,7 +15,6 @@
*/ */
package inr.numass.storage; package inr.numass.storage;
import inr.numass.data.NumassData;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.io.envelopes.DefaultEnvelopeReader; import hep.dataforge.io.envelopes.DefaultEnvelopeReader;
import hep.dataforge.io.envelopes.Envelope; import hep.dataforge.io.envelopes.Envelope;
@ -26,10 +25,12 @@ import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.loaders.AbstractLoader; import hep.dataforge.storage.loaders.AbstractLoader;
import inr.numass.data.NMEvent; import inr.numass.data.NMEvent;
import inr.numass.data.NMPoint; import inr.numass.data.NMPoint;
import inr.numass.data.NumassData;
import inr.numass.data.RawNMPoint; import inr.numass.data.RawNMPoint;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.time.Instant; import java.time.Instant;
@ -100,7 +101,6 @@ public class NumassDataLoader extends AbstractLoader implements BinaryLoader<Env
if (directory.getType() != FOLDER || !directory.exists()) { if (directory.getType() != FOLDER || !directory.exists()) {
throw new IllegalArgumentException("numass data directory reuired"); throw new IllegalArgumentException("numass data directory reuired");
} }
Meta annotation = new MetaBuilder("loader") Meta annotation = new MetaBuilder("loader")
.putValue("type", "numass") .putValue("type", "numass")
.putValue("numass.loaderFormat", "dir") .putValue("numass.loaderFormat", "dir")
@ -110,20 +110,34 @@ public class NumassDataLoader extends AbstractLoader implements BinaryLoader<Env
name = directory.getName().getBaseName(); name = directory.getName().getBaseName();
} }
URL url = directory.getURL();
return new NumassDataLoader(storage, name, annotation, () -> { return new NumassDataLoader(storage, name, annotation, () -> {
FileObject dir = null;
try { try {
Map<String, Envelope> items1 = new HashMap<>(); dir = VFS.getManager().resolveFile(url.toString());
for (FileObject it : directory.getChildren()) {
Map<String, Envelope> items = new HashMap<>();
for (FileObject it : dir.getChildren()) {
Envelope envelope = readFile(it); Envelope envelope = readFile(it);
if (envelope != null) { if (envelope != null) {
items1.put(it.getName().getBaseName(), envelope); items.put(it.getName().getBaseName(), envelope);
} }
} }
return items1; return items;
} catch (FileSystemException ex) { } catch (Exception ex) {
LoggerFactory.getLogger(NumassDataLoader.class) LoggerFactory.getLogger(NumassDataLoader.class)
.error("Can't load numass data directory " + directory.getName().getBaseName(), ex); .error("Can't load numass data directory " + directory.getName().getBaseName(), ex);
return null; return null;
} finally {
if (dir != null) {
try {
dir.close();
} catch (FileSystemException ex) {
LoggerFactory.getLogger(NumassDataLoader.class)
.error("Can't close remote directory", ex);
}
}
} }
}); });
} }
@ -163,6 +177,8 @@ public class NumassDataLoader extends AbstractLoader implements BinaryLoader<Env
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
} }
// LocalDateTime startTime = envelope.meta().get
RawNMPoint raw = new RawNMPoint(envelope.meta().getDouble("external_meta.HV1_value", 0), RawNMPoint raw = new RawNMPoint(envelope.meta().getDouble("external_meta.HV1_value", 0),
events, events,
envelope.meta().getValue("external_meta.acquisition_time").doubleValue()); envelope.meta().getValue("external_meta.acquisition_time").doubleValue());
@ -235,6 +251,7 @@ public class NumassDataLoader extends AbstractLoader implements BinaryLoader<Env
this.getPoints().stream().forEach((point) -> { this.getPoints().stream().forEach((point) -> {
res.add(readPoint(point)); res.add(readPoint(point));
}); });
// res.sort((NMPoint o1, NMPoint o2) -> o1.getAbsouteTime().compareTo(o2.getAbsouteTime()));
return res; return res;
} }

View File

@ -18,6 +18,7 @@ package inr.numass.storage;
import hep.dataforge.events.Event; import hep.dataforge.events.Event;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.storage.filestorage.FileStorage; import hep.dataforge.storage.filestorage.FileStorage;
import hep.dataforge.storage.filestorage.VFSUtils; import hep.dataforge.storage.filestorage.VFSUtils;
import inr.numass.data.NMFile; import inr.numass.data.NMFile;
@ -62,7 +63,11 @@ public class NumassStorage extends FileStorage {
*/ */
public static NumassStorage buildLocalNumassRoot(File dir, boolean readOnly) throws StorageException { public static NumassStorage buildLocalNumassRoot(File dir, boolean readOnly) throws StorageException {
try { try {
return new NumassStorage(VFSUtils.getLocalFile(dir), readOnly); Meta meta = new MetaBuilder("storage")
.setValue("type", "file.numass")
.setValue("readOnly", readOnly)
.setValue("monitor", true);
return new NumassStorage(VFSUtils.getLocalFile(dir), meta);
} catch (FileSystemException ex) { } catch (FileSystemException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
@ -70,19 +75,27 @@ public class NumassStorage extends FileStorage {
public static NumassStorage buildRemoteNumassRoot(String ip, int port, String login, String password, String path) throws StorageException { public static NumassStorage buildRemoteNumassRoot(String ip, int port, String login, String password, String path) throws StorageException {
try { try {
return new NumassStorage(VFSUtils.getRemoteFile(ip, port, login, password, path), true); Meta meta = new MetaBuilder("storage")
.setValue("type", "file.numass")
.setValue("readOnly", true)
.setValue("monitor", false);
return new NumassStorage(VFSUtils.getRemoteFile(ip, port, login, password, path), meta);
} catch (FileSystemException ex) { } catch (FileSystemException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
} }
public static NumassStorage buildRemoteNumassRoot(String uri) throws StorageException { public static NumassStorage buildRemoteNumassRoot(String uri) throws StorageException {
try { try {
return new NumassStorage(VFSUtils.getRemoteFile(uri), true); Meta meta = new MetaBuilder("storage")
.setValue("type", "file.numass")
.setValue("readOnly", true)
.setValue("monitor", false);
return new NumassStorage(VFSUtils.getRemoteFile(uri), meta);
} catch (FileSystemException ex) { } catch (FileSystemException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
} }
public NumassStorage(FileStorage parent, String path, Meta config) throws StorageException { public NumassStorage(FileStorage parent, String path, Meta config) throws StorageException {
super(parent, path, config); super(parent, path, config);
@ -95,12 +108,11 @@ public class NumassStorage extends FileStorage {
super.refresh(); super.refresh();
} }
protected NumassStorage(FileObject dir, boolean readOnly) throws StorageException { // protected NumassStorage(FileObject dir, boolean readOnly) throws StorageException {
super(dir, null); // super(dir, null);
super.setReadOnly(readOnly); // super.setReadOnly(readOnly);
super.refresh(); // super.refresh();
} // }
@Override @Override
protected void updateDirectoryLoaders() { protected void updateDirectoryLoaders() {
try { try {
@ -114,7 +126,7 @@ public class NumassStorage extends FileStorage {
NumassDataLoader.fromDir(this, file, null)); NumassDataLoader.fromDir(this, file, null));
} else { } else {
this.shelves.put(file.getName().getBaseName(), this.shelves.put(file.getName().getBaseName(),
new NumassStorage(this, file.getName().getBaseName(), null)); new NumassStorage(this, file.getName().getBaseName(), meta()));
} }
} else if (file.getName().toString().endsWith(NUMASS_ZIP_EXTENSION)) { } else if (file.getName().toString().endsWith(NUMASS_ZIP_EXTENSION)) {
this.loaders.put(file.getName().getBaseName(), NumassDataLoader.fromZip(this, file)); this.loaders.put(file.getName().getBaseName(), NumassDataLoader.fromZip(this, file));

View File

@ -17,7 +17,6 @@ package inr.numass.viewer;
import de.jensd.shichimifx.utils.ConsoleDude; import de.jensd.shichimifx.utils.ConsoleDude;
import de.jensd.shichimifx.utils.SplitPaneDividerSlider; import de.jensd.shichimifx.utils.SplitPaneDividerSlider;
import de.jensd.shichimifx.utils.TabPaneDetacher;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import inr.numass.data.NumassData; import inr.numass.data.NumassData;
import inr.numass.storage.NumassStorage; import inr.numass.storage.NumassStorage;
@ -46,7 +45,6 @@ import javafx.scene.control.TextArea;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleButton;
import javafx.scene.control.TreeTableView; import javafx.scene.control.TreeTableView;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.stage.DirectoryChooser; import javafx.stage.DirectoryChooser;
@ -109,7 +107,7 @@ public class MainViewerController implements Initializable, ProgressUpdateCallba
*/ */
@Override @Override
public void initialize(URL url, ResourceBundle rb) { public void initialize(URL url, ResourceBundle rb) {
TabPaneDetacher.create().makeTabsDetachable(tabPane); // TabPaneDetacher.create().makeTabsDetachable(tabPane);
ConsoleDude.hookStdStreams(consoleArea); ConsoleDude.hookStdStreams(consoleArea);
SplitPaneDividerSlider slider = new SplitPaneDividerSlider(consoleSplit, 0, SplitPaneDividerSlider.Direction.DOWN); SplitPaneDividerSlider slider = new SplitPaneDividerSlider(consoleSplit, 0, SplitPaneDividerSlider.Direction.DOWN);
@ -117,7 +115,7 @@ public class MainViewerController implements Initializable, ProgressUpdateCallba
consoleButton.selectedProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> { consoleButton.selectedProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> {
slider.setAimContentVisible(t1); slider.setAimContentVisible(t1);
}); });
consoleButton.setSelected(false); slider.setAimContentVisible(false);
} }
@FXML @FXML
@ -205,9 +203,6 @@ public class MainViewerController implements Initializable, ProgressUpdateCallba
dialog.setTitle("Remote storage selection"); dialog.setTitle("Remote storage selection");
dialog.setHeaderText("Select remote storage login options and run"); dialog.setHeaderText("Select remote storage login options and run");
// Set the icon (must be included in the project).
// dialog.setGraphic(new ImageView(this.getClass().getResource("login.png").toString()));
// Set the button types.
ButtonType loginButtonType = new ButtonType("Load", ButtonData.OK_DONE); ButtonType loginButtonType = new ButtonType("Load", ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
@ -228,13 +223,6 @@ public class MainViewerController implements Initializable, ProgressUpdateCallba
grid.add(new Label("Run name:"), 0, 1); grid.add(new Label("Run name:"), 0, 1);
grid.add(runText, 1, 1); grid.add(runText, 1, 1);
// Enable/Disable login button depending on whether a username was entered.
// Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
// loginButton.setDisable(true);
// Do some validation (using the Java 8 lambda syntax).
// storageText.textProperty().addListener((observable, oldValue, newValue) -> {
// loginButton.setDisable(newValue.trim().isEmpty());
// });
dialog.getDialogPane().setContent(grid); dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default. // Request focus on the username field by default.

View File

@ -20,27 +20,30 @@ package inr.numass.viewer;
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
import hep.dataforge.data.DataPoint;
import hep.dataforge.data.DataSet; import hep.dataforge.data.DataSet;
import hep.dataforge.data.MapDataPoint;
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.XYPlotFrame; import hep.dataforge.plots.XYPlotFrame;
import hep.dataforge.plots.XYPlottable; import hep.dataforge.plots.XYPlottable;
import hep.dataforge.plots.data.ChangeablePlottableData;
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.jfreechart.JFreeChartFrame; import hep.dataforge.plots.jfreechart.JFreeChartFrame;
import hep.dataforge.storage.commons.JSONMetaWriter; import hep.dataforge.storage.commons.JSONMetaWriter;
import inr.numass.data.NMPoint; import inr.numass.data.NMPoint;
import inr.numass.data.NumassData; import inr.numass.data.NumassData;
import static inr.numass.viewer.NumassViewerUtils.displayPlot;
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.ArrayList;
import java.util.List; import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.function.Function; import java.util.stream.Collectors;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
@ -53,16 +56,13 @@ import javafx.scene.control.ChoiceBox;
import javafx.scene.control.SelectionMode; import javafx.scene.control.SelectionMode;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import javafx.util.converter.NumberStringConverter;
import org.controlsfx.control.CheckListView; import org.controlsfx.control.CheckListView;
import org.jfree.chart.JFreeChart; import org.controlsfx.control.RangeSlider;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYErrorRenderer;
import org.jfree.data.xy.XYIntervalSeries;
import org.jfree.data.xy.XYIntervalSeriesCollection;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -88,11 +88,13 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
component.setData(numassLoader); component.setData(numassLoader);
return component; return component;
} }
Logger logger = LoggerFactory.getLogger(NumassLoaderViewComponent.class); Logger logger = LoggerFactory.getLogger(NumassLoaderViewComponent.class);
private NumassData data; private NumassData data;
private XYPlotFrame detectorPlotFrame; private XYPlotFrame detectorPlotFrame;
private XYPlotFrame spectrumPlotFrame;
private ChangeablePlottableData spectrumData;
private List<NMPoint> points;
@FXML @FXML
private AnchorPane detectorPlotPane; private AnchorPane detectorPlotPane;
@ -119,8 +121,18 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
@FXML @FXML
private Button detectorDataExportButton; private Button detectorDataExportButton;
@FXML
private TextField lowChannelField;
@FXML
private TextField upChannelField;
@FXML
private RangeSlider channelSlider;
/** /**
* Initializes the controller class. * Initializes the controller class.
*
* @param url * @param url
* @param rb * @param rb
*/ */
@ -133,6 +145,18 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
detectorPointListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); detectorPointListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
detectorDataExportButton.setOnAction(this::onExportButtonClick); detectorDataExportButton.setOnAction(this::onExportButtonClick);
lowChannelField.textProperty().bindBidirectional(channelSlider.lowValueProperty(), new NumberStringConverter());
upChannelField.textProperty().bindBidirectional(channelSlider.highValueProperty(), new NumberStringConverter());
channelSlider.setLowValue(300);
channelSlider.setHighValue(1900);
ChangeListener<? super Number> rangeChangeListener = (ObservableValue<? extends Number> observable, Number oldValue, Number newValue) -> {
updateSpectrumPane();
};
channelSlider.lowValueProperty().addListener(rangeChangeListener);
channelSlider.highValueProperty().addListener(rangeChangeListener);
} }
public NumassData getData() { public NumassData getData() {
@ -142,11 +166,11 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
public void setData(NumassData data) { public void setData(NumassData data) {
this.data = data; this.data = data;
if (data != null) { if (data != null) {
List<NMPoint> points = data.getNMPoints(); points = data.getNMPoints();
//setup detector data //setup detector data
setupDetectorPane(points); setupDetectorPane(points);
//setup spectrum plot //setup spectrum plot
setupSpectrumPane(points); updateSpectrumPane();
setupInfo(data); setupInfo(data);
@ -183,23 +207,51 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
replace("\\r", "\r").replace("\\n", "\n")); replace("\\r", "\r").replace("\\n", "\n"));
} }
private void setupSpectrumPane(List<NMPoint> points) { private void updateSpectrumPane() {
updateSpectrumData(fillSpectrumData(points, (point) -> point.getEventsCount())); if (spectrumPlotFrame == null) {
spectrumPlotFrame = new JFreeChartFrame("spectrum", null, spectrumPlotPane);
}
if (spectrumData == null) {
spectrumData = new ChangeablePlottableData("", null);
spectrumPlotFrame.add(spectrumData);
}
int lowChannel = (int) channelSlider.getLowValue();
int highChannel = (int) channelSlider.getHighValue();
if (points == null || points.isEmpty()) {
spectrumData.clear();
} else {
spectrumData.fillData(points.stream()
.<DataPoint>map((NMPoint point) -> getSpectrumPoint(point, lowChannel, highChannel))
.collect(Collectors.toList()));
}
} }
private void updateSpectrumData(XYIntervalSeriesCollection data) { private DataPoint getSpectrumPoint(NMPoint point, int lowChannel, int highChannel) {
spectrumPlotPane.getChildren().clear(); double u = point.getUread();
NumberAxis xAxis = new NumberAxis("HV"); double count = point.getCountInWindow(lowChannel, highChannel);
NumberAxis yAxis = new NumberAxis("count rate"); double time = point.getLength();
double err = Math.sqrt(count);
xAxis.setAutoRangeIncludesZero(false); return new MapDataPoint(new String[]{"x", "y", "yErr"}, u, count / time, err / time);
yAxis.setAutoRangeIncludesZero(false);
XYPlot plot = new XYPlot(data, xAxis, yAxis, new XYErrorRenderer());
JFreeChart spectrumPlot = new JFreeChart("spectrum", plot);
displayPlot(spectrumPlotPane, spectrumPlot);
} }
// private void setupSpectrumPane(List<NMPoint> points, int lowChannel, int upChannel) {
// updateSpectrumData(fillSpectrumData(points, (point) -> point.getCountInWindow(lowChannel, upChannel)));
// }
//
// private void updateSpectrumData(XYIntervalSeriesCollection data) {
// spectrumPlotPane.getChildren().clear();
// NumberAxis xAxis = new NumberAxis("HV");
// NumberAxis yAxis = new NumberAxis("count rate");
//
// xAxis.setAutoRangeIncludesZero(false);
// yAxis.setAutoRangeIncludesZero(false);
//
// XYPlot plot = new XYPlot(data, xAxis, yAxis, new XYErrorRenderer());
// JFreeChart spectrumPlot = new JFreeChart("spectrum", plot);
// displayPlot(spectrumPlotPane, spectrumPlot);
// }
/** /**
* update detector pane with new data * update detector pane with new data
*/ */
@ -258,28 +310,27 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
return plottables; return plottables;
} }
/** // /**
* Fill spectrum with custom window calculator // * Fill spectrum with custom window calculator
* // *
* @param points // * @param points
* @param lowerBoundCalculator // * @param lowerBoundCalculator
* @param upperBoundCalculator // * @param upperBoundCalculator
* @return // * @return
*/ // */
private XYIntervalSeriesCollection fillSpectrumData(List<NMPoint> points, Function<NMPoint, Number> calculator) { // private XYIntervalSeriesCollection fillSpectrumData(List<NMPoint> points, Function<NMPoint, Number> calculator) {
XYIntervalSeriesCollection collection = new XYIntervalSeriesCollection(); // XYIntervalSeriesCollection collection = new XYIntervalSeriesCollection();
XYIntervalSeries ser = new XYIntervalSeries("spectrum"); // XYIntervalSeries ser = new XYIntervalSeries("spectrum");
for (NMPoint point : points) { // for (NMPoint point : points) {
double u = point.getUread(); // double u = point.getUread();
double count = calculator.apply(point).doubleValue(); // double count = calculator.apply(point).doubleValue();
double time = point.getLength(); // double time = point.getLength();
double err = Math.sqrt(count); // double err = Math.sqrt(count);
ser.add(u, u, u, count / time, (count - err) / time, (count + err) / time); // ser.add(u, u, u, count / time, (count - err) / time, (count + err) / time);
} // }
collection.addSeries(ser); // collection.addSeries(ser);
return collection; // return collection;
} // }
@FXML @FXML
private void checkAllAction(ActionEvent event) { private void checkAllAction(ActionEvent event) {
detectorPointListView.getCheckModel().checkAll(); detectorPointListView.getCheckModel().checkAll();

View File

@ -97,16 +97,15 @@ limitations under the License.
<center> <center>
<AnchorPane fx:id="spectrumPlotPane" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" /> <AnchorPane fx:id="spectrumPlotPane" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</center> </center>
<right> <top>
<VBox fx:id="spectrumOptionsPane" minWidth="-Infinity" prefWidth="140.0" spacing="2.0" style="-fx-border-color: blue;" BorderPane.alignment="CENTER"> <ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<BorderPane.margin> <items>
<Insets /> <TextField fx:id="lowChannelField" prefWidth="60.0" />
</BorderPane.margin> <RangeSlider fx:id="channelSlider" accessibleRole="SLIDER" highValue="1900.0" lowValue="300.0" majorTickUnit="500.0" max="4000.0" minorTickCount="5" prefHeight="38.0" prefWidth="336.0" showTickLabels="true" showTickMarks="true" />
<padding> <TextField fx:id="upChannelField" prefWidth="60.0" />
<Insets bottom="2.0" left="2.0" right="2.0" top="2.0" /> </items>
</padding> </ToolBar>
</VBox> </top>
</right>
</BorderPane> </BorderPane>
</children></AnchorPane> </children></AnchorPane>
</content> </content>