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 {
val channels = device.chanels
//plot config from device configuration
//frame config from device configuration
//Do not use view config here, it is applyed separately
channels.stream()
.filter { channel -> !plottables.has(channel.name) }
.forEachOrdered { channel ->
//plot config from device configuration
//frame config from device configuration
val plottable = TimePlot(channel.name)
plottable.configure(channel.meta())
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 {
val meta = KMetaBuilder("plotFrame");

View File

@ -62,7 +62,7 @@ new GrindShell(ctx).eval {
// 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)
@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> {
@Override
@ -67,7 +67,7 @@ public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
Function<Double, Double> function = (x) -> model.getSpectrum().value(x, input.getParameters());
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");
fit.setDensity(100, false);

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ class ViewerTest : View(title = "Numass viewer test", icon = ImageView(dfIcon))
action {
runAsync {
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") }
update(set);
}
@ -60,8 +60,8 @@ class ViewerTest : View(title = "Numass viewer test", icon = ImageView(dfIcon))
fun update(set: NumassSet) {
amp.update(set.points.filter { it.voltage != 16000.0 }.collect(Collectors.toMap({ "point_${it.voltage}" }, { it })));
sp.update(mapOf("test" to set));
hv.update(set)
//sp.update(mapOf("test" to set));
//hv.update(set)
}
}