Fixes for numass-viewer

This commit is contained in:
Alexander Nozik 2016-09-23 14:05:07 +03:00
parent 92ff3b5215
commit 84338de011
8 changed files with 58 additions and 43 deletions

View File

@ -29,7 +29,7 @@ import hep.dataforge.meta.Configuration;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.plots.data.DynamicPlottable; import hep.dataforge.plots.data.DynamicPlottable;
import hep.dataforge.plots.data.DynamicPlottableSet; import hep.dataforge.plots.data.DynamicPlottableGroup;
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.api.Storage; import hep.dataforge.storage.api.Storage;
@ -77,7 +77,7 @@ public class MspViewController implements Initializable, MspListener {
public static final String MSP_DEVICE_TYPE = "msp"; public static final String MSP_DEVICE_TYPE = "msp";
public static final String DEFAULT_CONFIG_LOCATION = "msp-config.xml"; public static final String DEFAULT_CONFIG_LOCATION = "msp-config.xml";
private final DynamicPlottableSet plottables = new DynamicPlottableSet(); private final DynamicPlottableGroup plottables = new DynamicPlottableGroup();
private final String mspName = "msp"; private final String mspName = "msp";
private MspDevice device; private MspDevice device;
private Configuration viewConfig; private Configuration viewConfig;

View File

@ -18,7 +18,7 @@ import hep.dataforge.fx.ConsoleFragment;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.plots.data.DynamicPlottable; import hep.dataforge.plots.data.DynamicPlottable;
import hep.dataforge.plots.data.DynamicPlottableSet; import hep.dataforge.plots.data.DynamicPlottableGroup;
import hep.dataforge.plots.fx.FXPlotFrame; import hep.dataforge.plots.fx.FXPlotFrame;
import hep.dataforge.plots.fx.PlotContainer; import hep.dataforge.plots.fx.PlotContainer;
import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.plots.jfreechart.JFreeChartFrame;
@ -75,7 +75,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
private LoaderConnection storageConnection; private LoaderConnection storageConnection;
private VacCollectorDevice device; private VacCollectorDevice device;
private PlotContainer plotContainer; private PlotContainer plotContainer;
private DynamicPlottableSet plottables; private DynamicPlottableGroup plottables;
private BiFunction<VacCollectorDevice, Storage, PointLoader> loaderFactory; private BiFunction<VacCollectorDevice, Storage, PointLoader> loaderFactory;
@FXML @FXML
private AnchorPane plotHolder; private AnchorPane plotHolder;
@ -161,7 +161,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
private void setupView() { private void setupView() {
vacBoxHolder.getChildren().clear(); vacBoxHolder.getChildren().clear();
plottables = new DynamicPlottableSet(); plottables = new DynamicPlottableGroup();
views.stream().forEach((controller) -> { views.stream().forEach((controller) -> {
vacBoxHolder.getChildren().add(controller.getComponent()); vacBoxHolder.getChildren().add(controller.getComponent());
DynamicPlottable plot = new DynamicPlottable(controller.getTitle(), DynamicPlottable plot = new DynamicPlottable(controller.getTitle(),
@ -175,7 +175,7 @@ public class VacCollectorController implements Initializable, DeviceListener, Me
plotContainer.setPlot(setupPlot(plottables)); plotContainer.setPlot(setupPlot(plottables));
} }
private FXPlotFrame setupPlot(DynamicPlottableSet plottables) { private FXPlotFrame setupPlot(DynamicPlottableGroup plottables) {
Meta plotConfig = new MetaBuilder("plotFrame") Meta plotConfig = new MetaBuilder("plotFrame")
.setNode(new MetaBuilder("yAxis") .setNode(new MetaBuilder("yAxis")
.setValue("type", "log") .setValue("type", "log")

View File

@ -311,7 +311,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
public boolean isReversed() { public boolean isReversed() {
//TODO replace by meta tag in later revisions //TODO replace by meta tag in later revisions
return SetDirectionUtility.isReversed(getFullPath(), n -> { return SetDirectionUtility.isReversed(getPath(), n -> {
List<Envelope> points = getPoints(); List<Envelope> points = getPoints();
if (getPoints().size() >= 2) { if (getPoints().size() >= 2) {
return readTime(points.get(0).meta()).isAfter(readTime(points.get(1).meta())); return readTime(points.get(0).meta()).isAfter(readTime(points.get(1).meta()));

View File

@ -52,15 +52,13 @@ import java.util.logging.Logger;
*/ */
public class MainViewerController implements Initializable { public class MainViewerController implements Initializable {
// private ConsoleFragment consoleFragment;
// private WorkManagerFragment processFragment = WorkManagerFragment.attachToContext(GlobalContext.instance());
@FXML @FXML
private ToggleButton consoleButton; private ToggleButton consoleButton;
@FXML @FXML
private Button loadDirectoryButton; private Button loadDirectoryButton;
private MspViewController mspController; private MspViewController mspController;
// @FXML
// private AnchorPane mspContainer;
//main pane views //main pane views
@FXML @FXML
private AnchorPane numassLoaderViewContainer; private AnchorPane numassLoaderViewContainer;
@ -106,6 +104,9 @@ public class MainViewerController implements Initializable {
consoleFragment.hookStd(); consoleFragment.hookStd();
consoleFragment.bindTo(consoleButton); consoleFragment.bindTo(consoleButton);
WorkManagerFragment.attachToContext(GlobalContext.instance()).bindTo(processManagerButton); WorkManagerFragment.attachToContext(GlobalContext.instance()).bindTo(processManagerButton);
mspController = new MspViewController(getContext());
this.mspTab.setContent(mspController.getRoot());
} }
@FXML @FXML
@ -181,7 +182,7 @@ public class MainViewerController implements Initializable {
callback.setProgressToMax(); callback.setProgressToMax();
}); });
mspController = new MspViewController(getContext(), mspTab);
mspController.fillMspData(root); mspController.fillMspData(root);
pressuresTab.getContent().setVisible(false); pressuresTab.getContent().setVisible(false);

View File

@ -22,10 +22,11 @@ package inr.numass.viewer;
*/ */
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.Encapsulated;
import hep.dataforge.names.Name; import hep.dataforge.names.Name;
import hep.dataforge.plots.PlotUtils; import hep.dataforge.plots.PlotUtils;
import hep.dataforge.plots.data.DynamicPlottable; import hep.dataforge.plots.data.DynamicPlottable;
import hep.dataforge.plots.data.DynamicPlottableSet; import hep.dataforge.plots.data.DynamicPlottableGroup;
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.api.PointLoader; import hep.dataforge.storage.api.PointLoader;
@ -37,8 +38,8 @@ import hep.dataforge.values.Value;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.control.Tab;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
@ -53,29 +54,39 @@ import java.util.stream.StreamSupport;
* *
* @author darksnake * @author darksnake
*/ */
public class MspViewController { public class MspViewController implements Encapsulated {
private final Context context; private final Context context;
private BorderPane root = new BorderPane();
@FXML @FXML
private AnchorPane mspPlotPane; private AnchorPane mspPlotPane;
public MspViewController(Context context, Tab mspTab) { public MspViewController(Context context) {
this.context = context; this.context = context;
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/MspView.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/MspView.fxml"));
loader.setController(this); loader.setController(this);
loader.setRoot(root);
try { try {
loader.load(); loader.load();
} catch (IOException e) { } catch (IOException e) {
throw new Error(e); throw new Error(e);
} }
mspTab.setContent(loader.getRoot()); }
// this.mspPlotPane = mspContainer;
public BorderPane getRoot() {
return root;
}
@Override
public Context getContext() {
return context;
} }
/** /**
* update detector pane with new data * update detector pane with new data
*/ */
private void updateMspPane(DynamicPlottableSet mspData) { private void updateMspPane(DynamicPlottableGroup mspData) {
JFreeChartFrame frame = new JFreeChartFrame(); JFreeChartFrame frame = new JFreeChartFrame();
PlotUtils.setYAxis(frame, "partial pressure", "mbar", "log"); PlotUtils.setYAxis(frame, "partial pressure", "mbar", "log");
frame.getConfig().setValue("yAxis.range.lower", 1e-10); frame.getConfig().setValue("yAxis.range.lower", 1e-10);
@ -103,7 +114,7 @@ public class MspViewController {
} }
public void plotData(List<PointLoader> loaders) { public void plotData(List<PointLoader> loaders) {
DynamicPlottableSet plottables = new DynamicPlottableSet(); DynamicPlottableGroup plottables = new DynamicPlottableGroup();
loaders.stream() loaders.stream()
.flatMap(loader -> getLoaderData(loader)) .flatMap(loader -> getLoaderData(loader))
.distinct() .distinct()
@ -183,7 +194,7 @@ public class MspViewController {
//// List<DataPoint> mspData = (List<DataPoint>) loadProcess.getTask().get(); //// List<DataPoint> mspData = (List<DataPoint>) loadProcess.getTask().get();
// //
// if (!mspData.isEmpty()) { // if (!mspData.isEmpty()) {
// DynamicPlottableSet plottables = new DynamicPlottableSet(); // DynamicPlottableGroup plottables = new DynamicPlottableGroup();
// //
// for (DataPoint point : mspData) { // for (DataPoint point : mspData) {
// for (String name : point.names()) { // for (String name : point.names()) {

View File

@ -244,7 +244,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
Platform.runLater(() -> { Platform.runLater(() -> {
if (t != null) { if (t != null) {
hvPlot.getPlot().plottables().clear(); hvPlot.getPlot().plottables().clear();
DynamicPlottableSet set = new DynamicPlottableSet(); DynamicPlottableGroup set = new DynamicPlottableGroup();
for (DataPoint dp : t) { for (DataPoint dp : t) {
String block = dp.getString("block", "default"); String block = dp.getString("block", "default");
if (!set.hasPlottable(block)) { if (!set.hasPlottable(block)) {

View File

@ -17,12 +17,22 @@ limitations under the License.
--> -->
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.Button?>
<?import javafx.scene.layout.*?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import org.controlsfx.control.StatusBar?> <?import org.controlsfx.control.StatusBar?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" id="AnchorPane" prefHeight="768.0" prefWidth="1024.0"
xmlns="http://javafx.com/javafx/8.0.60" fx:controller="inr.numass.viewer.MainViewerController"> <AnchorPane id="AnchorPane" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.viewer.MainViewerController">
<children> <children>
<BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<top> <top>
@ -71,11 +81,7 @@ limitations under the License.
</AnchorPane> </AnchorPane>
</content> </content>
</Tab> </Tab>
<Tab fx:id="mspTab" closable="false" text="Mass-spectrum"> <Tab fx:id="mspTab" closable="false" text="Mass-spectrum" />
<content>
<AnchorPane fx:id="mspContainer" prefHeight="200.0" prefWidth="200.0"/>
</content>
</Tab>
<Tab fx:id="pressuresTab" closable="false" text="Pressures"> <Tab fx:id="pressuresTab" closable="false" text="Pressures">
<content> <content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" /> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />

View File

@ -16,15 +16,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" id="AnchorPane" minHeight="0.0" minWidth="0.0" prefHeight="180.0" <?import javafx.scene.layout.BorderPane?>
prefWidth="200.0" xmlns="http://javafx.com/javafx/8.0.76-ea"
fx:controller="inr.numass.viewer.MspViewController">
<children> <fx:root type="BorderPane" xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1">
<BorderPane layoutX="401.0" layoutY="270.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <center>
<center> <AnchorPane fx:id="mspPlotPane" BorderPane.alignment="CENTER"/>
<AnchorPane fx:id="mspPlotPane" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" /> </center>
</center> </fx:root>
</BorderPane>
</children>
</AnchorPane>