PlotContainer fixed

This commit is contained in:
Alexander Nozik 2017-10-19 10:31:11 +03:00
parent 4904825bf2
commit 97f27cdad1
8 changed files with 20 additions and 18 deletions

View File

@ -176,12 +176,12 @@ class PKT8ViewConnection : DeviceViewConnection<PKT8Device>(), MeasurementListen
init { init {
val channels = device.chanels val channels = device.chanels
//plot config from device configuration //frame config from device configuration
//Do not use view config here, it is applyed separately //Do not use view config here, it is applyed separately
channels.stream() channels.stream()
.filter { channel -> !plottables.has(channel.name) } .filter { channel -> !plottables.has(channel.name) }
.forEachOrdered { channel -> .forEachOrdered { channel ->
//plot config from device configuration //frame config from device configuration
val plottable = TimePlot(channel.name) val plottable = TimePlot(channel.name)
plottable.configure(channel.meta()) plottable.configure(channel.meta())
plottables.add(plottable) plottables.add(plottable)

View File

@ -137,7 +137,7 @@ fun EventTarget.switch(text: String = "", op: (ToggleSwitch.() -> Unit)? = null)
} }
/** /**
* Add plot * Add frame
*/ */
fun BorderPane.plot(plottables: Iterable<Plot> = Collections.emptyList(), metaTransform: (KMetaBuilder.() -> Unit)? = null): PlotFrame { fun BorderPane.plot(plottables: Iterable<Plot> = Collections.emptyList(), metaTransform: (KMetaBuilder.() -> Unit)? = null): PlotFrame {
val meta = KMetaBuilder("plotFrame"); val meta = KMetaBuilder("plotFrame");

View File

@ -62,7 +62,7 @@ new GrindShell(ctx).eval {
// ValueMap.ofMap("x.value": it + delta / 2, "y.value": result); // ValueMap.ofMap("x.value": it + delta / 2, "y.value": result);
// } // }
// //
// plot.plot(name: hv, frame: "discrepancy", discrepancyPlotPoints) // frame.frame(name: hv, frame: "discrepancy", discrepancyPlotPoints)
} }

View File

@ -40,7 +40,7 @@ import java.util.stream.StreamSupport;
*/ */
@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)
@NodeDef(name = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.") @NodeDef(name = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.")
@ValueDef(name = "plotTitle", def = "", info = "The title of the plot.") @ValueDef(name = "plotTitle", def = "", info = "The title of the frame.")
public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> { public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
@Override @Override
@ -67,7 +67,7 @@ public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
Function<Double, Double> function = (x) -> model.getSpectrum().value(x, input.getParameters()); Function<Double, Double> function = (x) -> model.getSpectrum().value(x, input.getParameters());
PlotFrame frame = PlotUtils.getPlotManager(context) PlotFrame frame = PlotUtils.getPlotManager(context)
.getPlotFrame(getName(), name, metaData.getMeta("plot", Meta.empty())); .getPlotFrame(getName(), name, metaData.getMeta("frame", Meta.empty()));
XYFunctionPlot fit = new XYFunctionPlot("fit"); XYFunctionPlot fit = new XYFunctionPlot("fit");
fit.setDensity(100, false); fit.setDensity(100, false);

View File

@ -52,7 +52,7 @@ public class NumassFitTask extends SingleActionTask<Table, FitResult> {
@Override @Override
protected Action<Table, FitResult> getAction(TaskModel model) { protected Action<Table, FitResult> getAction(TaskModel model) {
Action<Table, FitResult> action = new FitAction(); Action<Table, FitResult> action = new FitAction();
if (model.meta().getBoolean("plot", false)) { if (model.meta().getBoolean("frame", false)) {
return ActionUtils.compose(action, new PlotFitResultAction()); return ActionUtils.compose(action, new PlotFitResultAction());
} else { } else {
return action; return action;

View File

@ -118,7 +118,7 @@ class NumassLoaderView : View() {
private val hvPlot: PlotContainer; private val hvPlot: PlotContainer;
init { init {
//setup detector pane plot and sidebar //setup detector pane frame and sidebar
val l = Label("Bin size:") val l = Label("Bin size:")
l.padding = Insets(5.0) l.padding = Insets(5.0)
detectorBinningSelector.maxWidth = java.lang.Double.MAX_VALUE detectorBinningSelector.maxWidth = java.lang.Double.MAX_VALUE
@ -194,7 +194,7 @@ class NumassLoaderView : View() {
validationSupport.registerValidator(dTimeField, Validator.createPredicateValidator(isNumber, "Must be number")) validationSupport.registerValidator(dTimeField, Validator.createPredicateValidator(isNumber, "Must be number"))
//setup HV plot //setup HV frame
val hvPlotMeta = MetaBuilder("plot") val hvPlotMeta = MetaBuilder("plot")
.setValue("xAxis.axisTitle", "time") .setValue("xAxis.axisTitle", "time")
.setValue("xAxis.type", "time") .setValue("xAxis.type", "time")
@ -214,9 +214,9 @@ class NumassLoaderView : View() {
//setup info //setup info
updateInfo(newData) updateInfo(newData)
//setup hv plot //setup hv frame
updateHV(newData) updateHV(newData)
//setup spectrum plot //setup spectrum frame
updateSpectrum(newData) updateSpectrum(newData)
//setup detector data //setup detector data
updateDetectorPane(newData) updateDetectorPane(newData)
@ -259,7 +259,7 @@ class NumassLoaderView : View() {
(hvPlotData.opt(block).orElseThrow{RuntimeException()} as TimePlot) (hvPlotData.opt(block).orElseThrow{RuntimeException()} as TimePlot)
.put(dp.getValue("timestamp").timeValue(), dp.getValue("value")) .put(dp.getValue("timestamp").timeValue(), dp.getValue("value"))
} }
hvPlot.plot.add(hvPlotData) hvPlot.frame.add(hvPlotData)
} }
} }
@ -401,7 +401,7 @@ class NumassLoaderView : View() {
fileChooser.initialFileName = data!!.name + "_detector.out" fileChooser.initialFileName = data!!.name + "_detector.out"
val destination = fileChooser.showSaveDialog(detectorPlotPane.scene.window) val destination = fileChooser.showSaveDialog(detectorPlotPane.scene.window)
if (destination != null) { if (destination != null) {
val detectorData = DataPlotUtils.collectXYDataFromPlot(detectorPlot.plot as XYPlotFrame, true) val detectorData = DataPlotUtils.collectXYDataFromPlot(detectorPlot.frame as XYPlotFrame, true)
try { try {
ColumnedDataWriter.writeTable( ColumnedDataWriter.writeTable(
destination, destination,

View File

@ -43,12 +43,12 @@ class SpectrumView(
private val container = PlotContainer(frame); private val container = PlotContainer(frame);
private val loChannelProperty = SimpleIntegerProperty(0).apply { private val loChannelProperty = SimpleIntegerProperty(500).apply {
addListener { _ -> updateView() } addListener { _ -> updateView() }
} }
private var loChannel by loChannelProperty private var loChannel by loChannelProperty
private val upChannelProperty = SimpleIntegerProperty(4000).apply { private val upChannelProperty = SimpleIntegerProperty(3100).apply {
addListener { _ -> updateView() } addListener { _ -> updateView() }
} }
private var upChannel by upChannelProperty private var upChannel by upChannelProperty
@ -103,6 +103,8 @@ class SpectrumView(
} }
items += RangeSlider().apply { items += RangeSlider().apply {
lowValue = 500.0
highValue = 3100.0
highValueProperty().bindBidirectional(upChannelProperty) highValueProperty().bindBidirectional(upChannelProperty)
lowValueProperty().bindBidirectional(loChannelProperty) lowValueProperty().bindBidirectional(loChannelProperty)
majorTickUnit = 500.0 majorTickUnit = 500.0

View File

@ -36,7 +36,7 @@ class ViewerTest : View(title = "Numass viewer test", icon = ImageView(dfIcon))
action { action {
runAsync { runAsync {
val rootDir = File("D:\\Work\\Numass\\data\\2017_05\\Fill_2") val rootDir = File("D:\\Work\\Numass\\data\\2017_05\\Fill_2")
val set: NumassSet = NumassStorageFactory.buildLocal(rootDir).provide("loader::set_3", NumassSet::class.java) val set: NumassSet = NumassStorageFactory.buildLocal(rootDir).provide("loader::set_2", NumassSet::class.java)
.orElseThrow { RuntimeException("err") } .orElseThrow { RuntimeException("err") }
update(set); update(set);
} }
@ -60,8 +60,8 @@ class ViewerTest : View(title = "Numass viewer test", icon = ImageView(dfIcon))
fun update(set: NumassSet) { fun update(set: NumassSet) {
amp.update(set.points.filter { it.voltage != 16000.0 }.collect(Collectors.toMap({ "point_${it.voltage}" }, { it }))); amp.update(set.points.filter { it.voltage != 16000.0 }.collect(Collectors.toMap({ "point_${it.voltage}" }, { it })));
sp.update(mapOf("test" to set)); //sp.update(mapOf("test" to set));
hv.update(set) //hv.update(set)
} }
} }