Total plot refactoring

This commit is contained in:
Alexander Nozik 2015-12-31 16:09:05 +03:00
parent 37477e5f2c
commit 71928a8894
19 changed files with 152 additions and 149 deletions

View File

@ -166,7 +166,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
plotConfig = new MetaBuilder("plotFrame") plotConfig = new MetaBuilder("plotFrame")
.setValue("xAxis.timeAxis", true); .setValue("xAxis.timeAxis", true);
} }
plotFrame = new JFreeChartFrame("plot", plotConfig, plotArea); plotFrame = new JFreeChartFrame("plot", plotConfig).display(plotArea);
} }
public void setupDevice(Meta deviceMeta) throws ControlException { public void setupDevice(Meta deviceMeta) throws ControlException {

View File

@ -191,7 +191,7 @@ public class MspViewController implements Initializable, MspListener {
.setValue("axisUnits", "mbar") .setValue("axisUnits", "mbar")
) )
.setValue("xAxis.timeAxis", true); .setValue("xAxis.timeAxis", true);
this.plotFrame = new JFreeChartFrame(mspName, plotConfig, plotPane); this.plotFrame = new JFreeChartFrame(mspName, plotConfig).display(plotPane);
updatePlot(); updatePlot();
// this.plot = DynamicPlot.attachToFX(plotPane, new AnnotationBuilder("plot-config").putValue("logY", true).build()); // this.plot = DynamicPlot.attachToFX(plotPane, new AnnotationBuilder("plot-config").putValue("logY", true).build());
// plot.setAutoRange(30 * 60); // plot.setAutoRange(30 * 60);

View File

@ -433,7 +433,7 @@ public class VACFrame extends javax.swing.JFrame {
.setValue("axisUnits", "mbar") .setValue("axisUnits", "mbar")
) )
.setValue("xAxis.timeAxis", true); .setValue("xAxis.timeAxis", true);
this.plotFrame = new JFreeChartFrame("pressures", plotConfig, chartPannel); this.plotFrame = new JFreeChartFrame("pressures", plotConfig).display(chartPannel);
XYPlot xyPlot = plotFrame.getChart().getXYPlot(); XYPlot xyPlot = plotFrame.getChart().getXYPlot();
LogarithmicAxis logAxis = new LogarithmicAxis("Pressure (mbar)"); LogarithmicAxis logAxis = new LogarithmicAxis("Pressure (mbar)");

View File

@ -28,12 +28,10 @@ import hep.dataforge.description.ValueDef;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.io.log.Logable; import hep.dataforge.io.log.Logable;
import hep.dataforge.plots.PlotFrame;
import hep.dataforge.plots.PlotsPlugin; import hep.dataforge.plots.PlotsPlugin;
import hep.dataforge.plots.XYPlotFrame; import hep.dataforge.plots.XYPlotFrame;
import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.PlottableData;
import hep.dataforge.plots.data.PlottableFunction; import hep.dataforge.plots.data.PlottableFunction;
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction;
@ -66,18 +64,20 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
adapter = new XYDataAdapter(metaData.getNode("adapter")); adapter = new XYDataAdapter(metaData.getNode("adapter"));
} else if (input.getModel() instanceof XYModel) { } else if (input.getModel() instanceof XYModel) {
adapter = model.getAdapter(); adapter = model.getAdapter();
} else throw new ContentException("No adapter defined for data interpretation"); } else {
throw new ContentException("No adapter defined for data interpretation");
}
UnivariateFunction function = (double x) -> model.getSpectrum().value(x, input.getParameters()); UnivariateFunction function = (double x) -> model.getSpectrum().value(x, input.getParameters());
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(getContext()).buildPlotFrame(getName(), input.getName(), metaData); XYPlotFrame frame = (XYPlotFrame) PlotsPlugin
.buildFrom(getContext()).buildPlotFrame(getName(), input.getName(),
metaData.getNode("plot", null));
//JFreeChartFrame.drawFrame(reader.getString("plotTitle", "Fit result plot for "+input.getName()), null); //JFreeChartFrame.drawFrame(reader.getString("plotTitle", "Fit result plot for "+input.getName()), null);
double[] x = new double[data.size()]; double[] x = new double[data.size()];
// double[] y = new double[data.size()]; // double[] y = new double[data.size()];
double xMin = Double.POSITIVE_INFINITY; double xMin = Double.POSITIVE_INFINITY;
double xMax = Double.NEGATIVE_INFINITY; double xMax = Double.NEGATIVE_INFINITY;
@ -102,7 +102,6 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
frame.add(new PlottableData("data", null, points)); frame.add(new PlottableData("data", null, points));
return input; return input;
} }

View File

@ -66,7 +66,7 @@ public class NumassPlugin extends BasicPlugin {
@Override @Override
public void apply(Context context) { public void apply(Context context) {
FitManager fm = context.provide("hep.dataforge:fitting", FitPlugin.class).getFitManager(); FitManager fm = context.provide("fitting", FitPlugin.class).getFitManager();
ModelManager mm = fm.getModelManager(); ModelManager mm = fm.getModelManager();
loadModels(mm); loadModels(mm);

View File

@ -53,7 +53,7 @@ public class MergeDataAction extends ManyToOneAction<DataSet, DataSet> {
@Override @Override
protected List<NamedGroup<DataSet>> buildGroups(Meta reader, List<DataSet> input) { protected List<NamedGroup<DataSet>> buildGroups(Meta reader, List<DataSet> input) {
List<NamedGroup<DataSet>> groups; List<NamedGroup<DataSet>> groups;
if (reader.hasNode("grouping")) { if (reader.hasValue("grouping.byValue")) {
groups = super.buildGroups(reader, input); groups = super.buildGroups(reader, input);
} else { } else {
groups = GroupBuilder.byValue(MERGE_NAME, reader.getString(MERGE_NAME, "merge")).group(input); groups = GroupBuilder.byValue(MERGE_NAME, reader.getString(MERGE_NAME, "merge")).group(input);

View File

@ -19,6 +19,7 @@ import hep.dataforge.actions.OneToOneAction;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.plots.fx.FXPlotUtils;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.log.Logable; import hep.dataforge.io.log.Logable;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
@ -154,7 +155,7 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
axisName += " per " + binning + " chanels"; axisName += " per " + binning + " chanels";
} }
JFreeChartFrame frame = JFreeChartFrame.drawFrame(head, null); JFreeChartFrame frame = FXPlotUtils.displayJFreeChart(head, null);
frame.getYAxisConfig().putValue("title", axisName); frame.getYAxisConfig().putValue("title", axisName);

View File

@ -26,7 +26,9 @@ import java.util.List;
*/ */
public class RawNMPoint implements Cloneable { public class RawNMPoint implements Cloneable {
public static final int MAX_EVENTS_PER_POINT = 260000;
public static int MAX_CHANEL = 4095; public static int MAX_CHANEL = 4095;
private Instant startTime; private Instant startTime;
private final List<NMEvent> events; private final List<NMEvent> events;
private double length; private double length;
@ -103,6 +105,9 @@ public class RawNMPoint implements Cloneable {
if (Double.isNaN(length)) { if (Double.isNaN(length)) {
throw new Error(); throw new Error();
} }
if(events.size()>MAX_EVENTS_PER_POINT){
return events.get(events.size()-1).getTime()-events.get(0).getTime();
}
return length; return length;
} }

View File

@ -15,19 +15,12 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.context.Context;
import hep.dataforge.context.GlobalContext;
import hep.dataforge.functions.FunctionCaching; import hep.dataforge.functions.FunctionCaching;
import hep.dataforge.io.log.Logable;
import hep.dataforge.maths.NamedDoubleSet; import hep.dataforge.maths.NamedDoubleSet;
import hep.dataforge.maths.integration.GaussRuleIntegrator; import hep.dataforge.maths.integration.GaussRuleIntegrator;
import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.maths.integration.UnivariateIntegrator;
import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.plots.PlotFrame;
import hep.dataforge.plots.PlotsPlugin;
import hep.dataforge.plots.XYPlotFrame; import hep.dataforge.plots.XYPlotFrame;
import hep.dataforge.plots.data.PlottableFunction; import hep.dataforge.plots.data.PlottableFunction;
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
import static java.lang.Math.exp; import static java.lang.Math.exp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

View File

@ -5,26 +5,30 @@
*/ */
package inr.numass.workbench; package inr.numass.workbench;
import hep.dataforge.plots.fx.PlotContainer;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.plots.jfreechart.JFreeChartFrame;
import javafx.scene.layout.AnchorPane;
public class PlotOutputTab extends OutputTab { public class PlotOutputTab extends OutputTab {
private JFreeChartFrame frame; private final JFreeChartFrame frame;
public PlotOutputTab(String name, Meta meta) { public PlotOutputTab(String name, Meta meta) {
super(name); super(name);
AnchorPane pane = new AnchorPane(); PlotContainer container = new PlotContainer();
frame = new JFreeChartFrame(name, meta, pane); frame = new JFreeChartFrame(name, meta);
setContent(pane); container.setPlot(frame);
// AnchorPane pane = new AnchorPane();
// frame = new JFreeChartFrame(name, meta).display(pane);
setContent(container);
} }
public PlotOutputTab(String name, String title, Meta meta) { public PlotOutputTab(String name, String title, Meta meta) {
super(name, title); super(name, title);
AnchorPane pane = new AnchorPane(); PlotContainer container = new PlotContainer();
frame = new JFreeChartFrame(name, meta, pane); frame = new JFreeChartFrame(name, meta);
setContent(pane); container.setPlot(frame);
setContent(container);
} }
@Override @Override

View File

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

View File

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

View File

@ -16,6 +16,7 @@
package inr.numass.models; package inr.numass.models;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.GlobalContext;
import hep.dataforge.plots.fx.FXPlotUtils;
import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.PlottableData;
import hep.dataforge.plots.data.PlottableFunction; import hep.dataforge.plots.data.PlottableFunction;
import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.plots.jfreechart.JFreeChartFrame;
@ -27,14 +28,14 @@ import hep.dataforge.plots.jfreechart.JFreeChartFrame;
public class TransmissionInterpolatorTest { public class TransmissionInterpolatorTest {
public static void main(String[] args) { public static void main(String[] args) {
JFreeChartFrame frame = JFreeChartFrame.drawFrame("TransmissionInterpolatorTest", null); JFreeChartFrame frame = FXPlotUtils.displayJFreeChart("TransmissionInterpolatorTest", null);
//JFreeChartFrame.drawFrame("TransmissionInterpolatorTest", null);
TransmissionInterpolator interpolator = TransmissionInterpolator.fromFile(GlobalContext.instance(), TransmissionInterpolator interpolator = TransmissionInterpolator.fromFile(GlobalContext.instance(),
"d:\\sterile-new\\loss2014-11\\.dataforge\\merge\\empty_sum.out", "Uset", "CR", 15, 0.8, 19002d); "d:\\sterile-new\\loss2014-11\\.dataforge\\merge\\empty_sum.out", "Uset", "CR", 15, 0.8, 19002d);
frame.add(new PlottableData("data", interpolator.getX(), interpolator.getY())); frame.add(new PlottableData("data", interpolator.getX(), interpolator.getY()));
frame.add(new PlottableFunction("interpolated", null, interpolator, interpolator.getXmin(), interpolator.getXmax(), 2000)); frame.add(new PlottableFunction("interpolated", null, interpolator, interpolator.getXmin(), interpolator.getXmax(), 2000));
// PrintFunction.printFuntionSimple(new PrintWriter(System.out), interpolator, interpolator.getXmin(), interpolator.getXmax(), 500); // PrintFunction.printFuntionSimple(new PrintWriter(System.out), interpolator, interpolator.getXmin(), interpolator.getXmax(), 500);
} }
} }

View File

@ -19,6 +19,7 @@ import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.GlobalContext;
import hep.dataforge.data.FileData; import hep.dataforge.data.FileData;
import hep.dataforge.plots.fx.FXPlotUtils;
import inr.numass.prop.ar.JNAEpisode; import inr.numass.prop.ar.JNAEpisode;
import inr.numass.prop.ar.JNASpectrum; import inr.numass.prop.ar.JNASpectrum;
import inr.numass.prop.ar.ReadJNADataAction; import inr.numass.prop.ar.ReadJNADataAction;
@ -57,7 +58,7 @@ public class TestReader {
System.out.printf("%g\t%d%n", entry.getKey(), entry.getValue()); System.out.printf("%g\t%d%n", entry.getKey(), entry.getValue());
} }
PlotFrame frame = JFreeChartFrame.drawFrame("JNA_Test", null); PlotFrame frame = FXPlotUtils.displayJFreeChart("JNA test", null);
frame.add(new PlottableData(sp.asDataSet(), "chanel", "count")); frame.add(new PlottableData(sp.asDataSet(), "chanel", "count"));

View File

@ -162,12 +162,13 @@ public class NumassDataLoader extends AbstractLoader implements BinaryLoader<Env
ByteBuffer buffer = envelope.getData(); ByteBuffer buffer = envelope.getData();
buffer.position(0); buffer.position(0);
buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.order(ByteOrder.LITTLE_ENDIAN);
double timeCoef = envelope.meta().getDouble("time_coeff",50);
while (buffer.hasRemaining()) { while (buffer.hasRemaining()) {
try { try {
short channel = (short) Short.toUnsignedInt(buffer.getShort()); short channel = (short) Short.toUnsignedInt(buffer.getShort());
long time = Integer.toUnsignedLong(buffer.getInt()); long time = Integer.toUnsignedLong(buffer.getInt());
byte status = buffer.get(); byte status = buffer.get();
NMEvent event = new NMEvent(channel, time); NMEvent event = new NMEvent(channel, (double)time*timeCoef*1e-9);
events.add(event); events.add(event);
} catch (Exception ex) { } catch (Exception ex) {
//LoggerFactory.getLogger(MainDataReader.class).error("Error in data format", ex); //LoggerFactory.getLogger(MainDataReader.class).error("Error in data format", ex);

View File

@ -5,7 +5,7 @@ if (!hasProperty('mainClass')) {
} }
mainClassName = mainClass mainClassName = mainClass
version = "0.2.3" version = "0.2.4"
description = "The viewer for numass data" description = "The viewer for numass data"

View File

@ -39,6 +39,7 @@ import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog; import javafx.scene.control.Dialog;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.SplitPane; import javafx.scene.control.SplitPane;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.control.TabPane; import javafx.scene.control.TabPane;
@ -103,7 +104,7 @@ public class MainViewerController implements Initializable, FXTaskManager {
@FXML @FXML
private Label storagePathLabel; private Label storagePathLabel;
@FXML @FXML
private AnchorPane taskPane; private ScrollPane taskPane;
private TaskProgressView progressView; private TaskProgressView progressView;
@ -126,10 +127,10 @@ public class MainViewerController implements Initializable, FXTaskManager {
consoleButton.setSelected(false); consoleButton.setSelected(false);
loadRemoteButton.setDisable(true); loadRemoteButton.setDisable(true);
mspController.setCallback(this);
progressView = new TaskProgressView(); progressView = new TaskProgressView();
taskPane.getChildren().add(progressView); taskPane.setContent(progressView);
// taskPane.setPrefWidth(510);
} }
@FXML @FXML

View File

@ -270,7 +270,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
.setValue("yAxis.axisUnits", "Hz") .setValue("yAxis.axisUnits", "Hz")
.setValue("legend.show", false); .setValue("legend.show", false);
spectrumPlotFrame = new JFreeChartFrame("spectrum", plotMeta, spectrumPlotPane); spectrumPlotFrame = new JFreeChartFrame("spectrum", plotMeta).display(spectrumPlotPane);
} }
if (spectrumData == null) { if (spectrumData == null) {
@ -328,7 +328,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
.build()) .build())
.build(); .build();
detectorPlotFrame = new JFreeChartFrame("detectorSignal", frameMeta, detectorPlotPane); detectorPlotFrame = new JFreeChartFrame("detectorSignal", frameMeta).display(detectorPlotPane);
for (XYPlottable pl : detectorData) { for (XYPlottable pl : detectorData) {
detectorPlotFrame.add(pl); detectorPlotFrame.add(pl);

View File

@ -72,16 +72,12 @@ limitations under the License.
</Tab> </Tab>
</tabs> </tabs>
</TabPane> </TabPane>
<SplitPane dividerPositions="0.0"> <AnchorPane prefHeight="200.0" prefWidth="200.0">
<items> <children>
<ScrollPane minWidth="300.0" prefWidth="300.0"> <ScrollPane fx:id="taskPane" hbarPolicy="NEVER" minWidth="510.0" prefWidth="510.0" vmax="510.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<content> <TextArea fx:id="consoleArea" editable="false" minHeight="0.0" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="510.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
<AnchorPane fx:id="taskPane" minWidth="300.0" prefWidth="300.0" /> </children>
</content> </AnchorPane>
</ScrollPane>
<TextArea fx:id="consoleArea" editable="false" minHeight="0.0" wrapText="true" />
</items>
</SplitPane>
</items> </items>
</SplitPane> </SplitPane>
</center> </center>