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.MetaBuilder;
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.jfreechart.JFreeChartFrame;
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 DEFAULT_CONFIG_LOCATION = "msp-config.xml";
private final DynamicPlottableSet plottables = new DynamicPlottableSet();
private final DynamicPlottableGroup plottables = new DynamicPlottableGroup();
private final String mspName = "msp";
private MspDevice device;
private Configuration viewConfig;

View File

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

View File

@ -311,7 +311,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
public boolean isReversed() {
//TODO replace by meta tag in later revisions
return SetDirectionUtility.isReversed(getFullPath(), n -> {
return SetDirectionUtility.isReversed(getPath(), n -> {
List<Envelope> points = getPoints();
if (getPoints().size() >= 2) {
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 {
// private ConsoleFragment consoleFragment;
// private WorkManagerFragment processFragment = WorkManagerFragment.attachToContext(GlobalContext.instance());
@FXML
private ToggleButton consoleButton;
@FXML
private Button loadDirectoryButton;
private MspViewController mspController;
// @FXML
// private AnchorPane mspContainer;
//main pane views
@FXML
private AnchorPane numassLoaderViewContainer;
@ -106,6 +104,9 @@ public class MainViewerController implements Initializable {
consoleFragment.hookStd();
consoleFragment.bindTo(consoleButton);
WorkManagerFragment.attachToContext(GlobalContext.instance()).bindTo(processManagerButton);
mspController = new MspViewController(getContext());
this.mspTab.setContent(mspController.getRoot());
}
@FXML
@ -181,7 +182,7 @@ public class MainViewerController implements Initializable {
callback.setProgressToMax();
});
mspController = new MspViewController(getContext(), mspTab);
mspController.fillMspData(root);
pressuresTab.getContent().setVisible(false);

View File

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

View File

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

View File

@ -17,12 +17,22 @@ limitations under the License.
-->
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.Button?>
<?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 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>
<BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<top>
@ -71,11 +81,7 @@ limitations under the License.
</AnchorPane>
</content>
</Tab>
<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="mspTab" closable="false" text="Mass-spectrum" />
<Tab fx:id="pressuresTab" closable="false" text="Pressures">
<content>
<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.
-->
<?import javafx.scene.layout.*?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" id="AnchorPane" minHeight="0.0" minWidth="0.0" prefHeight="180.0"
prefWidth="200.0" xmlns="http://javafx.com/javafx/8.0.76-ea"
fx:controller="inr.numass.viewer.MspViewController">
<children>
<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>
<AnchorPane fx:id="mspPlotPane" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</center>
</BorderPane>
</children>
</AnchorPane>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<fx:root type="BorderPane" xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1">
<center>
<AnchorPane fx:id="mspPlotPane" BorderPane.alignment="CENTER"/>
</center>
</fx:root>