Plots refactoring

This commit is contained in:
Alexander Nozik 2016-09-04 19:40:36 +03:00
parent 2cfe2e45e3
commit 4550c9bf57
11 changed files with 79 additions and 54 deletions

View File

@ -8,16 +8,16 @@ mainClassName = mainClass
description = """The main head of all numass projects"""
dependencies {
compile group: 'commons-cli', name: 'commons-cli', version:'1.+'
compile group: 'commons-io', name: 'commons-io', version:'2.+'
compile group: 'commons-cli', name: 'commons-cli', version: '1.+'
compile group: 'commons-io', name: 'commons-io', version: '2.+'
compile project(':dataforge-stat:dataforge-minuit')
compile project(':dataforge-fx')
compile project(':dataforge-plots')
compile project(':dataforge-plots:plots-jfc')
compile project(':numass-storage')
compile project(':dataforge-grind')
}
task workbench(dependsOn: classes, type: JavaExec){
task workbench(dependsOn: classes, type: JavaExec) {
main 'inr.numass.workbench.Workbench'
classpath = sourceSets.main.runtimeClasspath
description "start visual numass workbench"

View File

@ -8,7 +8,11 @@ import hep.dataforge.workspace.Workspace
* Created by darksnake on 29-Aug-16.
*/
GrindShell shell = new GrindShell()
Workspace numass = new GrindLauncher().withSpec(NumassWorkspaceSpec).from(new File("D:\\Work\\Numass\\sterile2016\\workspace.groovy")).buildWorkspace()
shell.bind("numass", numass)
shell.start()
new GrindShell().start {
Workspace numass = new GrindLauncher()
.withSpec(NumassWorkspaceSpec)
.from(new File("D:\\Work\\Numass\\sterile2016\\workspace.groovy"))
.buildWorkspace()
setContext(numass.getContext())
bind("numass", numass)
}

View File

@ -23,6 +23,9 @@ import hep.dataforge.maths.MathPlugin;
import hep.dataforge.meta.Meta;
import hep.dataforge.plotfit.PlotFitResultAction;
import hep.dataforge.plots.PlotDataAction;
import hep.dataforge.plots.fx.FXPlotUtils;
import hep.dataforge.plots.fx.PlotContainer;
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
import hep.dataforge.stat.fit.FitManager;
import hep.dataforge.stat.fit.FitPlugin;
import hep.dataforge.stat.models.ModelManager;
@ -41,10 +44,31 @@ import org.apache.commons.math3.util.FastMath;
* @author Alexander Nozik
*/
@PluginDef(group = "inr.numass", name = "numass",
dependsOn = {"hep.dataforge:actions", "hep.dataforge:math", "hep.dataforge:MINUIT", "hep.dataforge:plots"},
dependsOn = {"hep.dataforge:actions", "hep.dataforge:math", "hep.dataforge:MINUIT", "hep.dataforge:plots-jfc"},
description = "Numass data analysis tools")
public class NumassPlugin extends BasicPlugin {
/**
* Display a JFreeChart plot frame in a separate stage window
*
* @param title
* @param width
* @param height
* @return
*/
public static JFreeChartFrame displayJFreeChart(String title, double width, double height, Meta meta) {
PlotContainer container = FXPlotUtils.displayContainer(title, width, height);
JFreeChartFrame frame = new JFreeChartFrame(meta);
frame.configureValue("title", title);
container.setPlot(frame);
return frame;
}
public static JFreeChartFrame displayJFreeChart(String title, Meta meta) {
return displayJFreeChart(title, 800, 600, meta);
}
@Override
public void attach(Context context) {
// StorageManager.buildFrom(context);

View File

@ -30,9 +30,22 @@ import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.plots.PlotFrame;
import hep.dataforge.plots.PlotHolder;
import hep.dataforge.plots.PlotsPlugin;
import hep.dataforge.utils.ContextMetaFactory;
import hep.dataforge.values.Value;
import inr.numass.NumassIO;
import inr.numass.NumassProperties;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.stage.FileChooser;
import org.controlsfx.control.StatusBar;
import java.io.File;
import java.io.IOException;
import java.net.URL;
@ -43,23 +56,6 @@ import java.util.Map;
import java.util.ResourceBundle;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Accordion;
import javafx.scene.control.Alert;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TitledPane;
import javafx.scene.control.ToggleButton;
import javafx.stage.FileChooser;
import org.controlsfx.control.StatusBar;
import hep.dataforge.utils.ContextMetaFactory;
/**
* FXML Controller class
@ -165,7 +161,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
this.context = this.contextFactory.build(parentContext, config);
// attachig visual process manager
processWindow.setManager(context.workManager());
processWindow.setManager(context.taskManager());
// setting io manager
context.setIO(new WorkbenchIOManager(new NumassIO(), this));
@ -340,7 +336,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
runActions();
}
} else {
this.context.workManager().shutdown();
this.context.taskManager().shutdown();
}
}

View File

@ -7,8 +7,6 @@ package inr.numass.workbench;
import hep.dataforge.context.GlobalContext;
import inr.numass.Numass;
import java.io.IOException;
import java.text.ParseException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
@ -16,12 +14,22 @@ import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import java.io.IOException;
import java.text.ParseException;
/**
*
* @author Alexander Nozik
*/
public class Workbench extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws IOException, ParseException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/NumassWorkbench.fxml"));
@ -38,7 +46,7 @@ public class Workbench extends Application {
scene.getWindow().setOnCloseRequest((WindowEvent event) -> {
try {
controller.getContext().workManager().getRoot().cancel(true);
controller.getContext().taskManager().getRoot().cancel(true);
} catch (Exception e) {
}
@ -51,11 +59,4 @@ public class Workbench extends Application {
super.stop();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}

View File

@ -16,7 +16,7 @@
package inr.numass.models;
import hep.dataforge.stat.fit.ParamSet;
import hep.dataforge.plots.fx.FXPlotUtils;
import inr.numass.NumassPlugin;
/**
*
@ -36,6 +36,6 @@ public class PlotScatter {
+ "'ionW' = 11.33 ± 0.43\n"
+ "'exIonRatio' = 4.83 ± 0.36"
);
LossCalculator.plotScatter(FXPlotUtils.displayJFreeChart("Loss function", null),pars);
LossCalculator.plotScatter(NumassPlugin.displayJFreeChart("Loss function", null), pars);
}
}

View File

@ -18,7 +18,7 @@ package inr.numass.models;
import hep.dataforge.maths.integration.GaussRuleIntegrator;
import hep.dataforge.plots.PlotFrame;
import hep.dataforge.plots.data.PlottableXYFunction;
import hep.dataforge.plots.fx.FXPlotUtils;
import inr.numass.NumassPlugin;
import org.apache.commons.math3.analysis.UnivariateFunction;
/**
@ -31,7 +31,7 @@ public class TestNeLossParametrisation {
* @param args the command line arguments
*/
public static void main(String[] args) {
PlotFrame frame = FXPlotUtils.displayJFreeChart("Loss parametrisation test", null);
PlotFrame frame = NumassPlugin.displayJFreeChart("Loss parametrisation test", null);
//JFreeChartFrame.drawFrame("Loss parametrisation test", null);
UnivariateFunction oldFunction = LossCalculator.getSingleScatterFunction();
UnivariateFunction newFunction = getSingleScatterFunction(12.86, 16.78, 1.65, 12.38, 4.79);

View File

@ -18,8 +18,8 @@ package inr.numass.models;
import hep.dataforge.context.GlobalContext;
import hep.dataforge.plots.data.PlottableData;
import hep.dataforge.plots.data.PlottableXYFunction;
import hep.dataforge.plots.fx.FXPlotUtils;
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
import inr.numass.NumassPlugin;
/**
*
@ -28,7 +28,7 @@ import hep.dataforge.plots.jfreechart.JFreeChartFrame;
public class TransmissionInterpolatorTest {
public static void main(String[] args) {
JFreeChartFrame frame = FXPlotUtils.displayJFreeChart("TransmissionInterpolatorTest", null);
JFreeChartFrame frame = NumassPlugin.displayJFreeChart("TransmissionInterpolatorTest", null);
//JFreeChartFrame.drawFrame("TransmissionInterpolatorTest", null);
TransmissionInterpolator interpolator = TransmissionInterpolator.fromFile(GlobalContext.instance(),
"d:\\sterile-new\\loss2014-11\\.dataforge\\merge\\empty_sum.onComplete", "Uset", "CR", 15, 0.8, 19002d);

View File

@ -129,7 +129,7 @@ public class MainViewerController implements Initializable {
}
private void loadDirectory(String path) {
getContext().workManager().submit("viewer.loadDirectory", (ProgressCallback callback) -> {
getContext().taskManager().submit("viewer.loadDirectory", (ProgressCallback callback) -> {
callback.updateTitle("Load storage (" + path + ")");
callback.setProgress(-1);
callback.updateMessage("Building numass storage tree...");
@ -151,8 +151,8 @@ public class MainViewerController implements Initializable {
public void setRootStorage(NumassStorage root) {
getContext().workManager().cleanup();
getContext().workManager().submit("viewer.storage.load", (ProgressCallback callback) -> {
getContext().taskManager().cleanup();
getContext().taskManager().submit("viewer.storage.load", (ProgressCallback callback) -> {
callback.updateTitle("Fill data to UI (" + root.getName() + ")");
callback.setProgress(-1);
Platform.runLater(() -> statusBar.setProgress(-1));

View File

@ -87,7 +87,7 @@ public class MspViewController {
public void fillMspData(Storage rootStorage) {
if (rootStorage != null) {
context.workManager().submit("viewer.msp.fill", (ProgressCallback callback) -> {
context.taskManager().submit("viewer.msp.fill", (ProgressCallback callback) -> {
try {
// callback.updateTitle("Fill msp data (" + rootStorage.getName() + ")");

View File

@ -214,7 +214,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
public void loadData(NumassData data) {
this.data = data;
if (data != null) {
context.workManager().<List<NMPoint>>submit("viewer.numass.load", (ProgressCallback callback) -> {
context.taskManager().<List<NMPoint>>submit("viewer.numass.load", (ProgressCallback callback) -> {
callback.updateTitle("Load numass data (" + data.getName() + ")");
points = data.getNMPoints();
@ -239,7 +239,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
}
private void setupHVPane(Supplier<Table> hvData) {
context.workManager().submit("viewer.numass.hv", (ProgressCallback callback) -> {
context.taskManager().submit("viewer.numass.hv", (ProgressCallback callback) -> {
Table t = hvData.get();
Platform.runLater(() -> {
if (t != null) {
@ -343,7 +343,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
detectorPlot.removePlot();
}
context.workManager().submit("viewer.numass.load.detector", (ProgressCallback callback) -> {
context.taskManager().submit("viewer.numass.load.detector", (ProgressCallback callback) -> {
Meta plottableConfig = new MetaBuilder("plot")
.setValue("connectionType", "step")
.setValue("thickness", 2)