Changed plots plugin behaviour from composition to inheritance.

This commit is contained in:
Alexander Nozik 2017-03-29 21:18:53 +03:00
parent 0a261ad466
commit a768e63831
5 changed files with 16 additions and 20 deletions

View File

@ -23,8 +23,8 @@ import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.ContentException; import hep.dataforge.exceptions.ContentException;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.plots.PlotsPlugin; import hep.dataforge.plots.PlotFrame;
import hep.dataforge.plots.XYPlotFrame; import hep.dataforge.plots.PlotUtils;
import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.PlottableData;
import hep.dataforge.plots.data.PlottableXYFunction; import hep.dataforge.plots.data.PlottableXYFunction;
import hep.dataforge.stat.fit.FitState; import hep.dataforge.stat.fit.FitState;
@ -36,7 +36,6 @@ import java.util.function.Function;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
/** /**
*
* @author darksnake * @author darksnake
*/ */
@TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState.class, outputType = FitState.class) @TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState.class, outputType = FitState.class)
@ -65,9 +64,8 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
Function<Double, Double> function = (x) -> model.getSpectrum().value(x, input.getParameters()); Function<Double, Double> function = (x) -> model.getSpectrum().value(x, input.getParameters());
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin PlotFrame frame = PlotUtils.getPlotManager(context)
.buildFrom(context).buildPlotFrame(getName(), name, .buildPlotFrame(getName(), name, metaData.getMeta("plot", Meta.empty()));
metaData.getMeta("plot", Meta.empty()));
PlottableXYFunction fit = new PlottableXYFunction("fit"); PlottableXYFunction fit = new PlottableXYFunction("fit");
fit.setDensity(100, false); fit.setDensity(100, false);

View File

@ -12,8 +12,8 @@ import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.plots.PlotsPlugin; import hep.dataforge.plots.PlotFrame;
import hep.dataforge.plots.XYPlotFrame; import hep.dataforge.plots.PlotUtils;
import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.PlottableData;
import hep.dataforge.plots.data.XYPlottable; import hep.dataforge.plots.data.XYPlottable;
import hep.dataforge.tables.*; import hep.dataforge.tables.*;
@ -82,11 +82,10 @@ public class ShowEnergySpectrumAction extends OneToOneAction<NumassData, Table>
ColumnedDataWriter.writeDataSet(out, table, inputMeta.toString()); ColumnedDataWriter.writeDataSet(out, table, inputMeta.toString());
if (inputMeta.hasMeta("plot") || inputMeta.getBoolean("plot", false)) { if (inputMeta.hasMeta("plot") || inputMeta.getBoolean("plot", false)) {
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin PlotFrame frame = PlotUtils.getPlotManager(context)
.buildFrom(context).buildPlotFrame(getName(), name, .buildPlotFrame(getName(), name,
inputMeta.getMeta("plot", Meta.empty())); inputMeta.getMeta("plot", Meta.empty()));
fillDetectorData(valueMap).forEach(frame::add); fillDetectorData(valueMap).forEach(frame::add);
} }
return table; return table;
} }

View File

@ -25,8 +25,8 @@ import hep.dataforge.maths.NamedMatrix;
import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.maths.integration.UnivariateIntegrator;
import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.plots.PlotsPlugin; import hep.dataforge.plots.PlotFrame;
import hep.dataforge.plots.XYPlotFrame; import hep.dataforge.plots.PlotUtils;
import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.PlottableData;
import hep.dataforge.plots.data.PlottableXYFunction; import hep.dataforge.plots.data.PlottableXYFunction;
import hep.dataforge.stat.fit.FitState; import hep.dataforge.stat.fit.FitState;
@ -124,7 +124,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
UnivariateFunction scatterFunction; UnivariateFunction scatterFunction;
boolean calculateRatio = false; boolean calculateRatio = false;
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(context) PlotFrame frame = PlotUtils.getPlotManager(context)
.buildPlotFrame(getName(), name + ".loss", .buildPlotFrame(getName(), name + ".loss",
new MetaBuilder("plot") new MetaBuilder("plot")
.setValue("plotTitle", "Differential scattering crossection for " + name) .setValue("plotTitle", "Differential scattering crossection for " + name)
@ -266,11 +266,10 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
Histogram hist = new Histogram(0.3, 0.5, 0.002); Histogram hist = new Histogram(0.3, 0.5, 0.002);
hist.fill(res); hist.fill(res);
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(context) PlotFrame frame = PlotUtils.getPlotManager(context)
.buildPlotFrame(getName(), name + ".ionRatio", .buildPlotFrame(getName(), name + ".ionRatio",
new MetaBuilder("plot").setValue("plotTitle", "Ion ratio Distribution for " + name) new MetaBuilder("plot").setValue("plotTitle", "Ion ratio Distribution for " + name)
); );
// XYPlotFrame frame = JFreeChartFrame.drawFrame("Ion ratio Distribution for " + name, null);
frame.add(PlottableData.plot("ionRatio", new XYAdapter("binCenter", "count"), hist)); frame.add(PlottableData.plot("ionRatio", new XYAdapter("binCenter", "count"), hist));
return new DescriptiveStatistics(res).getStandardDeviation(); return new DescriptiveStatistics(res).getStandardDeviation();

View File

@ -17,7 +17,7 @@ package inr.numass.models;
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.plots.XYPlotFrame; import hep.dataforge.plots.PlotFrame;
import hep.dataforge.plots.data.PlottableXYFunction; import hep.dataforge.plots.data.PlottableXYFunction;
import hep.dataforge.stat.parametric.FunctionCaching; import hep.dataforge.stat.parametric.FunctionCaching;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
@ -153,7 +153,7 @@ public class LossCalculator {
return instance; return instance;
} }
public static void plotScatter(XYPlotFrame frame, NamedValueSet set) { public static void plotScatter(PlotFrame frame, NamedValueSet set) {
//"X", "shift", "exPos", "ionPos", "exW", "ionW", "exIonRatio" //"X", "shift", "exPos", "ionPos", "exW", "ionW", "exIonRatio"
// JFreeChartFrame frame = JFreeChartFrame.drawFrame("Differential scattering crosssection", null); // JFreeChartFrame frame = JFreeChartFrame.drawFrame("Differential scattering crosssection", null);

View File

@ -7,7 +7,7 @@ package inr.numass;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.maths.MathPlugin; import hep.dataforge.maths.MathPlugin;
import hep.dataforge.plots.PlotsPlugin; import hep.dataforge.plots.PlotUtils;
import org.junit.Test; import org.junit.Test;
/** /**
@ -27,7 +27,7 @@ public class NumassTest {
Context context = Numass.buildContext(); Context context = Numass.buildContext();
MathPlugin.buildFrom(context); MathPlugin.buildFrom(context);
PlotsPlugin.buildFrom(context); PlotUtils.getPlotManager(context);
} }
} }