Plots to kotlin. Multiple fixes to control.

This commit is contained in:
Alexander Nozik 2018-04-01 21:35:05 +03:00
parent 5ada5e76bc
commit 4e19f1e0ed
8 changed files with 14 additions and 14 deletions

View File

@ -148,7 +148,7 @@ class PKT8Display : DeviceDisplay<PKT8Device>(), PKT8ValueListener {
private val plotFrame: PlotFrame by lazy {
JFreeChartFrame(plotFrameMeta).apply {
plots.descriptor = Descriptors.buildDescriptor(TimePlot::class.java)
PlotUtils.setXAxis(this, "timestamp", null, "time")
PlotUtils.setXAxis(this, "timestamp", "", "time")
}
}
@ -190,7 +190,9 @@ class PKT8Display : DeviceDisplay<PKT8Device>(), PKT8ValueListener {
if (rawDataButton.isSelected) {
TimePlot.put(this, rawValue)
} else {
TimePlot.put(this, temperature)
if(temperature != null) {
TimePlot.put(this, temperature)
}
}
}
}

View File

@ -25,9 +25,9 @@ import hep.dataforge.fx.plots.PlotContainer
import hep.dataforge.meta.Meta
import hep.dataforge.meta.MetaBuilder
import hep.dataforge.plots.PlotFrame
import hep.dataforge.plots.PlotGroup
import hep.dataforge.plots.PlotUtils
import hep.dataforge.plots.data.TimePlot
import hep.dataforge.plots.data.TimePlottableGroup
import hep.dataforge.plots.jfreechart.JFreeChartFrame
import hep.dataforge.values.Value
import inr.numass.control.DeviceDisplay
@ -88,7 +88,7 @@ class MspDisplay() : DeviceDisplay<MspDevice>(), DeviceListener, NamedValueListe
configure(plotFrameMeta)
}
}
val plottables: TimePlottableGroup = TimePlottableGroup().apply {
val plottables = PlotGroup().apply {
if (plotFrameMeta.hasMeta("peakJump.peak")) {
for (peakMeta in plotFrameMeta.getMetaList("peakJump.peak")) {
val mass = peakMeta.getString("mass")

View File

@ -13,7 +13,6 @@ import hep.dataforge.control.measurements.MeasurementListener
import hep.dataforge.fx.bindWindow
import hep.dataforge.fx.fragments.LogFragment
import hep.dataforge.plots.data.TimePlot
import hep.dataforge.plots.data.TimePlottableGroup
import hep.dataforge.values.Value
import inr.numass.control.DeviceDisplay
import inr.numass.control.deviceStateToggle

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2015 Alexander Nozik.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -63,10 +63,10 @@ public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
}
PlotFrame frame = PlotUtils.getPlotManager(context)
PlotFrame frame = PlotUtils.INSTANCE.getPlotManager(context)
.getPlotFrame(getName(), name, metaData.getMeta("frame", Meta.empty()));
XYFunctionPlot fit = new XYFunctionPlot("fit",(x) -> model.getSpectrum().value(x, input.getParameters()));
XYFunctionPlot fit = new XYFunctionPlot("fit", Meta.empty(), (Double x) -> model.getSpectrum().value(x, input.getParameters()));
fit.setDensity(100);
fit.setSmoothing(true);
// ensuring all data points are calculated explicitly
@ -75,7 +75,7 @@ public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
frame.add(fit);
frame.add(DataPlot.plot("data", adapter, data));
frame.add(DataPlot.Companion.plot("data", adapter, data));
return input;
}

View File

@ -280,7 +280,7 @@ fun FitResult.display(context: Context, stage: String = "fit") {
val func = { x: Double -> model.spectrum.value(x, parameters) }
val fit = XYFunctionPlot("fit", func)
val fit = XYFunctionPlot("fit", function = func)
fit.density = 100
// ensuring all data points are calculated explicitly
data.rows.map { dp -> Adapters.getXValue(adapter, dp).doubleValue() }.sorted().forEach { fit.calculateIn(it) }

View File

@ -75,14 +75,13 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
}
}
val histogramPlot = DataPlot(name)
val histogramPlot = DataPlot(name, adapter = Adapters.buildXYAdapter("x", "count"))
.configure {
"showLine" to true
"showSymbol" to false
"showErrors" to false
"connectionType" to "step"
}.apply {
adapter = Adapters.buildXYAdapter("x", "count")
configure(inputMeta.getMetaOrEmpty("histogram"))
}.fillData(histogram)

View File

@ -251,7 +251,7 @@ val plotFitTask = task("plotFit") {
val frame = PlotUtils.getPlotManager(context)
.getPlotFrame("numass.plotFit", name, meta.getMeta("frame", Meta.empty()))
val fit = XYFunctionPlot("fit", function).apply {
val fit = XYFunctionPlot("fit", function = function).apply {
density = 100
}

View File

@ -32,7 +32,7 @@ public class TransmissionInterpolatorTest {
//JFreeChartFrame.drawFrame("TransmissionInterpolatorTest", null);
TransmissionInterpolator interpolator = TransmissionInterpolator.fromFile(Global.INSTANCE,
"d:\\sterile-new\\loss2014-11\\.dataforge\\merge\\empty_sum.onComplete", "Uset", "CR", 15, 0.8, 19002d);
frame.add(DataPlot.plot("data", interpolator.getX(), interpolator.getY()));
frame.add(DataPlot.Companion.plot("data", interpolator.getX(), interpolator.getY()));
frame.add(XYFunctionPlot.Companion.plot("interpolated", interpolator.getXmin(), interpolator.getXmax(), 2000, interpolator::value));
// PrintFunction.printFuntionSimple(new PrintWriter(System.onComplete), interpolator, interpolator.getXmin(), interpolator.getXmax(), 500);