Added progress indicator to plot container
This commit is contained in:
parent
8dca28960b
commit
7de7187f08
@ -43,6 +43,7 @@ import tornadofx.*
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
|
import java.util.stream.Collectors
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Numass loader view
|
* Numass loader view
|
||||||
@ -77,8 +78,7 @@ class NumassLoaderView : View() {
|
|||||||
val analyzerProperty = SimpleObjectProperty<NumassAnalyzer>(SimpleAnalyzer())
|
val analyzerProperty = SimpleObjectProperty<NumassAnalyzer>(SimpleAnalyzer())
|
||||||
var analyzer: NumassAnalyzer by analyzerProperty
|
var analyzer: NumassAnalyzer by analyzerProperty
|
||||||
|
|
||||||
val spectra = HashMap<Double, Table>();//spectra cache
|
private val spectra = HashMap<Double, Table>();//spectra cache
|
||||||
|
|
||||||
|
|
||||||
val spectrumData = PlottableData("spectrum")
|
val spectrumData = PlottableData("spectrum")
|
||||||
val hvPlotData = PlottableGroup<TimePlottable>()
|
val hvPlotData = PlottableGroup<TimePlottable>()
|
||||||
@ -274,24 +274,24 @@ class NumassLoaderView : View() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSpectrum(data: NumassSet) {
|
private fun updateSpectrum(data: NumassSet) {
|
||||||
spectrumData.clear()
|
|
||||||
runAsync {
|
runAsync {
|
||||||
val loChannel = channelSlider.lowValue.toShort()
|
val loChannel = channelSlider.lowValue.toShort()
|
||||||
val upChannel = channelSlider.highValue.toShort()
|
val upChannel = channelSlider.highValue.toShort()
|
||||||
data.points.forEach { point ->
|
data.points.map { point ->
|
||||||
val count = NumassAnalyzer.countInWindow(getSpectrum(point), loChannel, upChannel);
|
val count = NumassAnalyzer.countInWindow(getSpectrum(point), loChannel, upChannel);
|
||||||
val seconds = point.length.toMillis() / 1000.0;
|
val seconds = point.length.toMillis() / 1000.0;
|
||||||
val nuPoint = ValueMap(
|
spectrumPlot.setProgress(-1.0);
|
||||||
|
ValueMap(
|
||||||
mapOf(
|
mapOf(
|
||||||
XYAdapter.X_AXIS to point.voltage,
|
XYAdapter.X_AXIS to point.voltage,
|
||||||
XYAdapter.Y_AXIS to (count / seconds),
|
XYAdapter.Y_AXIS to (count / seconds),
|
||||||
XYAdapter.Y_ERROR_KEY to Math.sqrt(count.toDouble()) / seconds
|
XYAdapter.Y_ERROR_KEY to Math.sqrt(count.toDouble()) / seconds
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
Platform.runLater {
|
}.collect(Collectors.toList())
|
||||||
spectrumData.append(nuPoint)
|
} ui { points ->
|
||||||
}
|
spectrumData.fillData(points)
|
||||||
}
|
spectrumPlot.setProgress(1.0)
|
||||||
spectrumExportButton.isDisable = false
|
spectrumExportButton.isDisable = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +309,6 @@ class NumassLoaderView : View() {
|
|||||||
* update detector pane with new data
|
* update detector pane with new data
|
||||||
*/
|
*/
|
||||||
private fun updateDetectorPane(data: NumassSet) {
|
private fun updateDetectorPane(data: NumassSet) {
|
||||||
|
|
||||||
Platform.runLater { detectorPlotFrame.clear() }
|
Platform.runLater { detectorPlotFrame.clear() }
|
||||||
|
|
||||||
val work = getWorkManager().getWork("viewer.numass.load.detector")
|
val work = getWorkManager().getWork("viewer.numass.load.detector")
|
||||||
@ -335,15 +334,15 @@ class NumassLoaderView : View() {
|
|||||||
NumassAnalyzer.spectrumWithBinning(getSpectrum(point), 0, 4000, binning)
|
NumassAnalyzer.spectrumWithBinning(getSpectrum(point), 0, 4000, binning)
|
||||||
).apply {
|
).apply {
|
||||||
configure(plottableConfig)
|
configure(plottableConfig)
|
||||||
|
}.also {
|
||||||
|
work.increaseProgress(1.0)
|
||||||
|
detectorPlot.setProgress(work.progress/work.maxProgress)
|
||||||
}
|
}
|
||||||
}.forEach {
|
}.collect(Collectors.toList())
|
||||||
work.increaseProgress(1.0)
|
} ui { plots ->
|
||||||
Platform.runLater {
|
detectorPlotFrame.setAll(plots)
|
||||||
detectorPlotFrame.add(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} ui {
|
|
||||||
work.setProgressToMax()
|
work.setProgressToMax()
|
||||||
|
detectorPlot.setProgress(1.0)
|
||||||
detectorDataExportButton.isDisable = false
|
detectorDataExportButton.isDisable = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user