Total plot refactoring
This commit is contained in:
parent
37477e5f2c
commit
71928a8894
@ -166,7 +166,7 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
|
||||
plotConfig = new MetaBuilder("plotFrame")
|
||||
.setValue("xAxis.timeAxis", true);
|
||||
}
|
||||
plotFrame = new JFreeChartFrame("plot", plotConfig, plotArea);
|
||||
plotFrame = new JFreeChartFrame("plot", plotConfig).display(plotArea);
|
||||
}
|
||||
|
||||
public void setupDevice(Meta deviceMeta) throws ControlException {
|
||||
|
@ -191,7 +191,7 @@ public class MspViewController implements Initializable, MspListener {
|
||||
.setValue("axisUnits", "mbar")
|
||||
)
|
||||
.setValue("xAxis.timeAxis", true);
|
||||
this.plotFrame = new JFreeChartFrame(mspName, plotConfig, plotPane);
|
||||
this.plotFrame = new JFreeChartFrame(mspName, plotConfig).display(plotPane);
|
||||
updatePlot();
|
||||
// this.plot = DynamicPlot.attachToFX(plotPane, new AnnotationBuilder("plot-config").putValue("logY", true).build());
|
||||
// plot.setAutoRange(30 * 60);
|
||||
|
@ -433,7 +433,7 @@ public class VACFrame extends javax.swing.JFrame {
|
||||
.setValue("axisUnits", "mbar")
|
||||
)
|
||||
.setValue("xAxis.timeAxis", true);
|
||||
this.plotFrame = new JFreeChartFrame("pressures", plotConfig, chartPannel);
|
||||
this.plotFrame = new JFreeChartFrame("pressures", plotConfig).display(chartPannel);
|
||||
XYPlot xyPlot = plotFrame.getChart().getXYPlot();
|
||||
|
||||
LogarithmicAxis logAxis = new LogarithmicAxis("Pressure (mbar)");
|
||||
|
@ -28,12 +28,10 @@ import hep.dataforge.description.ValueDef;
|
||||
import hep.dataforge.description.TypedActionDef;
|
||||
import hep.dataforge.exceptions.ContentException;
|
||||
import hep.dataforge.io.log.Logable;
|
||||
import hep.dataforge.plots.PlotFrame;
|
||||
import hep.dataforge.plots.PlotsPlugin;
|
||||
import hep.dataforge.plots.XYPlotFrame;
|
||||
import hep.dataforge.plots.data.PlottableData;
|
||||
import hep.dataforge.plots.data.PlottableFunction;
|
||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.math3.analysis.UnivariateFunction;
|
||||
@ -52,32 +50,34 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FitState execute(Logable log, Meta metaData, FitState input){
|
||||
protected FitState execute(Logable log, Meta metaData, FitState input) {
|
||||
|
||||
DataSet data = input.getDataSet();
|
||||
if(!(input.getModel() instanceof XYModel)){
|
||||
if (!(input.getModel() instanceof XYModel)) {
|
||||
log.logError("The fit model should be instance of XYModel for this action. Action failed!");
|
||||
return input;
|
||||
}
|
||||
XYModel model = (XYModel)input.getModel();
|
||||
XYModel model = (XYModel) input.getModel();
|
||||
|
||||
XYDataAdapter adapter;
|
||||
if (metaData.hasNode("adapter")){
|
||||
if (metaData.hasNode("adapter")) {
|
||||
adapter = new XYDataAdapter(metaData.getNode("adapter"));
|
||||
} else if(input.getModel() instanceof XYModel){
|
||||
} else if (input.getModel() instanceof XYModel) {
|
||||
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());
|
||||
|
||||
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(getContext()).buildPlotFrame(getName(), input.getName(), metaData);
|
||||
//JFreeChartFrame.drawFrame(reader.getString("plotTitle", "Fit result plot for "+input.getName()), null);
|
||||
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);
|
||||
|
||||
double[] x = new double[data.size()];
|
||||
|
||||
// double[] y = new double[data.size()];
|
||||
|
||||
|
||||
double xMin = Double.POSITIVE_INFINITY;
|
||||
|
||||
double xMax = Double.NEGATIVE_INFINITY;
|
||||
@ -89,11 +89,11 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
||||
// y[i] = adapter.getY(data.get(i));
|
||||
|
||||
points.add(adapter.mapToDefault(data.get(i)));
|
||||
if(x[i]<xMin){
|
||||
if (x[i] < xMin) {
|
||||
xMin = x[i];
|
||||
}
|
||||
|
||||
if(x[i]>xMax){
|
||||
if (x[i] > xMax) {
|
||||
xMax = x[i];
|
||||
}
|
||||
}
|
||||
@ -102,7 +102,6 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
||||
|
||||
frame.add(new PlottableData("data", null, points));
|
||||
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class NumassPlugin extends BasicPlugin {
|
||||
|
||||
@Override
|
||||
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();
|
||||
loadModels(mm);
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class MergeDataAction extends ManyToOneAction<DataSet, DataSet> {
|
||||
@Override
|
||||
protected List<NamedGroup<DataSet>> buildGroups(Meta reader, List<DataSet> input) {
|
||||
List<NamedGroup<DataSet>> groups;
|
||||
if (reader.hasNode("grouping")) {
|
||||
if (reader.hasValue("grouping.byValue")) {
|
||||
groups = super.buildGroups(reader, input);
|
||||
} else {
|
||||
groups = GroupBuilder.byValue(MERGE_NAME, reader.getString(MERGE_NAME, "merge")).group(input);
|
||||
|
@ -19,6 +19,7 @@ import hep.dataforge.actions.OneToOneAction;
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.description.TypedActionDef;
|
||||
import hep.dataforge.exceptions.ContentException;
|
||||
import hep.dataforge.plots.fx.FXPlotUtils;
|
||||
import hep.dataforge.io.ColumnedDataWriter;
|
||||
import hep.dataforge.io.log.Logable;
|
||||
import hep.dataforge.meta.Meta;
|
||||
@ -154,7 +155,7 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
||||
axisName += " per " + binning + " chanels";
|
||||
}
|
||||
|
||||
JFreeChartFrame frame = JFreeChartFrame.drawFrame(head, null);
|
||||
JFreeChartFrame frame = FXPlotUtils.displayJFreeChart(head, null);
|
||||
|
||||
frame.getYAxisConfig().putValue("title", axisName);
|
||||
|
||||
|
@ -26,7 +26,9 @@ import java.util.List;
|
||||
*/
|
||||
public class RawNMPoint implements Cloneable {
|
||||
|
||||
public static final int MAX_EVENTS_PER_POINT = 260000;
|
||||
public static int MAX_CHANEL = 4095;
|
||||
|
||||
private Instant startTime;
|
||||
private final List<NMEvent> events;
|
||||
private double length;
|
||||
@ -103,6 +105,9 @@ public class RawNMPoint implements Cloneable {
|
||||
if (Double.isNaN(length)) {
|
||||
throw new Error();
|
||||
}
|
||||
if(events.size()>MAX_EVENTS_PER_POINT){
|
||||
return events.get(events.size()-1).getTime()-events.get(0).getTime();
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
|
@ -15,19 +15,12 @@
|
||||
*/
|
||||
package inr.numass.models;
|
||||
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.context.GlobalContext;
|
||||
import hep.dataforge.functions.FunctionCaching;
|
||||
import hep.dataforge.io.log.Logable;
|
||||
import hep.dataforge.maths.NamedDoubleSet;
|
||||
import hep.dataforge.maths.integration.GaussRuleIntegrator;
|
||||
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.data.PlottableFunction;
|
||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||
import static java.lang.Math.exp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -5,26 +5,30 @@
|
||||
*/
|
||||
package inr.numass.workbench;
|
||||
|
||||
import hep.dataforge.plots.fx.PlotContainer;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
public class PlotOutputTab extends OutputTab {
|
||||
|
||||
private JFreeChartFrame frame;
|
||||
private final JFreeChartFrame frame;
|
||||
|
||||
public PlotOutputTab(String name, Meta meta) {
|
||||
super(name);
|
||||
AnchorPane pane = new AnchorPane();
|
||||
frame = new JFreeChartFrame(name, meta, pane);
|
||||
setContent(pane);
|
||||
PlotContainer container = new PlotContainer();
|
||||
frame = new JFreeChartFrame(name, meta);
|
||||
container.setPlot(frame);
|
||||
// AnchorPane pane = new AnchorPane();
|
||||
// frame = new JFreeChartFrame(name, meta).display(pane);
|
||||
setContent(container);
|
||||
}
|
||||
|
||||
public PlotOutputTab(String name, String title, Meta meta) {
|
||||
super(name, title);
|
||||
AnchorPane pane = new AnchorPane();
|
||||
frame = new JFreeChartFrame(name, meta, pane);
|
||||
setContent(pane);
|
||||
PlotContainer container = new PlotContainer();
|
||||
frame = new JFreeChartFrame(name, meta);
|
||||
container.setPlot(frame);
|
||||
setContent(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,7 +16,7 @@
|
||||
package inr.numass.models;
|
||||
|
||||
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"
|
||||
+ "'exIonRatio' = 4.83 ± 0.36"
|
||||
);
|
||||
LossCalculator.plotScatter(JFreeChartFrame.drawFrame("Loss function", null),pars);
|
||||
LossCalculator.plotScatter(FXPlotUtils.displayJFreeChart("Loss function", null),pars);
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,10 @@
|
||||
*/
|
||||
package inr.numass.models;
|
||||
|
||||
import hep.dataforge.plots.fx.FXPlotUtils;
|
||||
import hep.dataforge.maths.integration.GaussRuleIntegrator;
|
||||
import hep.dataforge.plots.PlotFrame;
|
||||
import hep.dataforge.plots.data.PlottableFunction;
|
||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||
import org.apache.commons.math3.analysis.UnivariateFunction;
|
||||
|
||||
/**
|
||||
@ -31,7 +31,8 @@ public class TestNeLossParametrisation {
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
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 newFunction = getSingleScatterFunction(12.86, 16.78, 1.65, 12.38, 4.79);
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
package inr.numass.models;
|
||||
|
||||
import hep.dataforge.context.GlobalContext;
|
||||
import hep.dataforge.plots.fx.FXPlotUtils;
|
||||
import hep.dataforge.plots.data.PlottableData;
|
||||
import hep.dataforge.plots.data.PlottableFunction;
|
||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||
@ -27,14 +28,14 @@ import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||
public class TransmissionInterpolatorTest {
|
||||
|
||||
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(),
|
||||
"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 PlottableFunction("interpolated", null, interpolator, interpolator.getXmin(), interpolator.getXmax(), 2000));
|
||||
|
||||
// PrintFunction.printFuntionSimple(new PrintWriter(System.out), interpolator, interpolator.getXmin(), interpolator.getXmax(), 500);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.meta.MetaBuilder;
|
||||
import hep.dataforge.context.GlobalContext;
|
||||
import hep.dataforge.data.FileData;
|
||||
import hep.dataforge.plots.fx.FXPlotUtils;
|
||||
import inr.numass.prop.ar.JNAEpisode;
|
||||
import inr.numass.prop.ar.JNASpectrum;
|
||||
import inr.numass.prop.ar.ReadJNADataAction;
|
||||
@ -57,7 +58,7 @@ public class TestReader {
|
||||
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"));
|
||||
|
||||
|
@ -162,12 +162,13 @@ public class NumassDataLoader extends AbstractLoader implements BinaryLoader<Env
|
||||
ByteBuffer buffer = envelope.getData();
|
||||
buffer.position(0);
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
double timeCoef = envelope.meta().getDouble("time_coeff",50);
|
||||
while (buffer.hasRemaining()) {
|
||||
try {
|
||||
short channel = (short) Short.toUnsignedInt(buffer.getShort());
|
||||
long time = Integer.toUnsignedLong(buffer.getInt());
|
||||
byte status = buffer.get();
|
||||
NMEvent event = new NMEvent(channel, time);
|
||||
NMEvent event = new NMEvent(channel, (double)time*timeCoef*1e-9);
|
||||
events.add(event);
|
||||
} catch (Exception ex) {
|
||||
//LoggerFactory.getLogger(MainDataReader.class).error("Error in data format", ex);
|
||||
|
@ -5,7 +5,7 @@ if (!hasProperty('mainClass')) {
|
||||
}
|
||||
mainClassName = mainClass
|
||||
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
|
||||
description = "The viewer for numass data"
|
||||
|
||||
|
@ -39,6 +39,7 @@ import javafx.scene.control.ButtonBar.ButtonData;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Dialog;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.SplitPane;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
@ -103,7 +104,7 @@ public class MainViewerController implements Initializable, FXTaskManager {
|
||||
@FXML
|
||||
private Label storagePathLabel;
|
||||
@FXML
|
||||
private AnchorPane taskPane;
|
||||
private ScrollPane taskPane;
|
||||
|
||||
private TaskProgressView progressView;
|
||||
|
||||
@ -126,10 +127,10 @@ public class MainViewerController implements Initializable, FXTaskManager {
|
||||
|
||||
consoleButton.setSelected(false);
|
||||
loadRemoteButton.setDisable(true);
|
||||
mspController.setCallback(this);
|
||||
|
||||
progressView = new TaskProgressView();
|
||||
taskPane.getChildren().add(progressView);
|
||||
taskPane.setContent(progressView);
|
||||
// taskPane.setPrefWidth(510);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -270,7 +270,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
||||
.setValue("yAxis.axisUnits", "Hz")
|
||||
.setValue("legend.show", false);
|
||||
|
||||
spectrumPlotFrame = new JFreeChartFrame("spectrum", plotMeta, spectrumPlotPane);
|
||||
spectrumPlotFrame = new JFreeChartFrame("spectrum", plotMeta).display(spectrumPlotPane);
|
||||
}
|
||||
|
||||
if (spectrumData == null) {
|
||||
@ -328,7 +328,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
||||
.build())
|
||||
.build();
|
||||
|
||||
detectorPlotFrame = new JFreeChartFrame("detectorSignal", frameMeta, detectorPlotPane);
|
||||
detectorPlotFrame = new JFreeChartFrame("detectorSignal", frameMeta).display(detectorPlotPane);
|
||||
|
||||
for (XYPlottable pl : detectorData) {
|
||||
detectorPlotFrame.add(pl);
|
||||
|
@ -72,16 +72,12 @@ limitations under the License.
|
||||
</Tab>
|
||||
</tabs>
|
||||
</TabPane>
|
||||
<SplitPane dividerPositions="0.0">
|
||||
<items>
|
||||
<ScrollPane minWidth="300.0" prefWidth="300.0">
|
||||
<content>
|
||||
<AnchorPane fx:id="taskPane" minWidth="300.0" prefWidth="300.0" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<TextArea fx:id="consoleArea" editable="false" minHeight="0.0" wrapText="true" />
|
||||
</items>
|
||||
</SplitPane>
|
||||
<AnchorPane prefHeight="200.0" prefWidth="200.0">
|
||||
<children>
|
||||
<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" />
|
||||
<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" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</items>
|
||||
</SplitPane>
|
||||
</center>
|
||||
|
Loading…
Reference in New Issue
Block a user