Fixing charts
This commit is contained in:
parent
4f228abf30
commit
5e4ddcdfd5
@ -127,7 +127,7 @@ public class PKT8PlotController implements Initializable, MeasurementListener<PK
|
||||
plottables.setMaxItems(1000);
|
||||
plottables.setPrefItems(400);
|
||||
}
|
||||
// plottables.applyConfig(plotFrame.getConfig());
|
||||
// getPlottables.applyConfig(plotFrame.getConfig());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,7 +24,7 @@ public class PointBuilders {
|
||||
.stream().mapToInt(it -> it.intValue()),
|
||||
block.getEventsList().stream()
|
||||
.mapToInt(event -> peakFinder.apply(event))
|
||||
))
|
||||
)),0
|
||||
);
|
||||
|
||||
return new NMPoint(u, startTime, pointLength, spectrum);
|
||||
@ -32,7 +32,7 @@ public class PointBuilders {
|
||||
|
||||
private static int[] calculateSpectrum(RawNMPoint point) {
|
||||
assert point.getEventsCount() > 0;
|
||||
return count(point.getEvents().stream().mapToInt(event -> event.getChanel()));
|
||||
return count(point.getEvents().stream().mapToInt(event -> event.getChanel()),RawNMPoint.MAX_CHANEL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@ -40,8 +40,12 @@ public class PointBuilders {
|
||||
return new NMPoint(point.getUset(), point.getStartTime(), point.getLength(), calculateSpectrum(point));
|
||||
}
|
||||
|
||||
private static int[] count(IntStream stream) {
|
||||
private static int[] count(IntStream stream, int maxChannel) {
|
||||
List<AtomicInteger> list = new ArrayList<>();
|
||||
while (list.size() <= maxChannel) {
|
||||
list.add(new AtomicInteger(0));
|
||||
}
|
||||
|
||||
stream.forEach(i -> {
|
||||
while (list.size() <= i) {
|
||||
list.add(new AtomicInteger(0));
|
||||
|
@ -4,7 +4,7 @@ plugins{
|
||||
}
|
||||
|
||||
if (!hasProperty('mainClass')) {
|
||||
ext.mainClass = 'inr.numass.viewer.Viewer'
|
||||
ext.mainClass = 'inr.numass.viewer.Viewer'//"inr.numass.viewer.test.TestApp"
|
||||
}
|
||||
mainClassName = mainClass
|
||||
|
||||
|
@ -115,19 +115,19 @@ public class MspViewController implements Encapsulated {
|
||||
}
|
||||
|
||||
public void plotData(List<PointLoader> loaders) {
|
||||
// TimePlottableGroup plottables = new TimePlottableGroup();
|
||||
// TimePlottableGroup getPlottables = new TimePlottableGroup();
|
||||
// loaders.stream()
|
||||
// .flatMap(loader -> getLoaderData(loader))
|
||||
// .distinct()
|
||||
// .forEach(point -> {
|
||||
// for (String name : point.names()) {
|
||||
// if (!name.equals("timestamp")) {
|
||||
// if (!plottables.has(name)) {
|
||||
// plottables.addPlottable(new TimePlottable(name, name));
|
||||
// if (!getPlottables.has(name)) {
|
||||
// getPlottables.addPlottable(new TimePlottable(name, name));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// plottables.put(point);
|
||||
// getPlottables.put(point);
|
||||
// }
|
||||
// );
|
||||
|
||||
@ -216,20 +216,20 @@ public class MspViewController implements Encapsulated {
|
||||
//// List<DataPoint> mspData = (List<DataPoint>) loadProcess.getTask().get();
|
||||
//
|
||||
// if (!mspData.isEmpty()) {
|
||||
// TimePlottableGroup plottables = new TimePlottableGroup();
|
||||
// TimePlottableGroup getPlottables = new TimePlottableGroup();
|
||||
//
|
||||
// for (DataPoint point : mspData) {
|
||||
// for (String name : point.names()) {
|
||||
// if (!name.equals("timestamp")) {
|
||||
// if (!plottables.has(name)) {
|
||||
// plottables.add(new TimePlottable(name, name));
|
||||
// if (!getPlottables.has(name)) {
|
||||
// getPlottables.add(new TimePlottable(name, name));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// plottables.put(point);
|
||||
// getPlottables.put(point);
|
||||
// }
|
||||
//
|
||||
// updateMspPane(plottables);
|
||||
// updateMspPane(getPlottables);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
@ -9,6 +9,7 @@ import hep.dataforge.fx.work.Work
|
||||
import hep.dataforge.fx.work.WorkManager
|
||||
import hep.dataforge.fx.work.WorkManagerFragment
|
||||
import hep.dataforge.meta.Annotated
|
||||
import hep.dataforge.names.AlphanumComparator
|
||||
import hep.dataforge.names.Named
|
||||
import hep.dataforge.storage.api.Storage
|
||||
import inr.numass.NumassProperties
|
||||
@ -72,8 +73,15 @@ class MainView : View() {
|
||||
|
||||
treePane.center {
|
||||
treetableview<Item> {
|
||||
column("name", Item::getName)
|
||||
column("time", Item::getTime)
|
||||
val nameColumnt = column("name", Item::getName).apply {
|
||||
sortType = TreeTableColumn.SortType.ASCENDING
|
||||
}
|
||||
|
||||
val timeColumn = column("time", Item::getTime).apply {
|
||||
isVisible = false
|
||||
}
|
||||
|
||||
sortOrder.add(nameColumnt)
|
||||
|
||||
addEventHandler(MouseEvent.MOUSE_CLICKED) { e: MouseEvent ->
|
||||
if (e.clickCount == 2) {
|
||||
@ -85,6 +93,7 @@ class MainView : View() {
|
||||
}
|
||||
}
|
||||
|
||||
isTableMenuButtonVisible = true
|
||||
columnResizePolicy = CONSTRAINED_RESIZE_POLICY
|
||||
|
||||
storageProperty.addListener { _, _, value ->
|
||||
@ -92,11 +101,13 @@ class MainView : View() {
|
||||
Platform.runLater {
|
||||
root = TreeItem(Item(value));
|
||||
|
||||
root.isExpanded = true
|
||||
|
||||
populate { parent ->
|
||||
val storage = parent.value.content;
|
||||
if (storage is Storage) {
|
||||
//TODO add legacy loaders here?
|
||||
storage.shelves().map(::Item) + storage.loaders().map(::Item)
|
||||
storage.shelves().map(::Item).sorted() + storage.loaders().map(::Item).sorted()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
@ -212,7 +223,11 @@ class MainView : View() {
|
||||
}
|
||||
}
|
||||
|
||||
class Item(val content: Named) {
|
||||
class Item(val content: Named): Comparable<Item> {
|
||||
override fun compareTo(other: Item): Int {
|
||||
return AlphanumComparator.INSTANCE.compare(this.getName(),other.getName())
|
||||
}
|
||||
|
||||
fun getName(): String {
|
||||
return content.name;
|
||||
}
|
||||
|
@ -142,43 +142,45 @@ class NumassLoaderView : View() {
|
||||
}
|
||||
|
||||
fun loadData(data: NumassData?) {
|
||||
this.data = data
|
||||
if (data != null) {
|
||||
getWorkManager().startWork("viewer.numass.load") { work ->
|
||||
work.title = "Load numass data (" + data.name + ")"
|
||||
points.setAll(data.nmPoints)
|
||||
synchronized(this) {
|
||||
this.data = data
|
||||
if (data != null) {
|
||||
getWorkManager().startWork("viewer.numass.load") { work ->
|
||||
work.title = "Load numass data (" + data.name + ")"
|
||||
points.setAll(data.nmPoints)
|
||||
|
||||
Platform.runLater {
|
||||
//setup detector data
|
||||
setupDetectorPane(points)
|
||||
//setup spectrum plot
|
||||
setupSpectrumPane(points)
|
||||
Platform.runLater {
|
||||
//setup detector data
|
||||
setupDetectorPane(points)
|
||||
//setup spectrum plot
|
||||
setupSpectrumPane(points)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//setup hv plot
|
||||
val hvData = data.hvData
|
||||
if (hvData != null) {
|
||||
setupHVPane(hvData)
|
||||
}
|
||||
setupInfo(data)
|
||||
//setup hv plot
|
||||
val hvData = data.hvData
|
||||
if (hvData != null) {
|
||||
setupHVPane(hvData)
|
||||
}
|
||||
setupInfo(data)
|
||||
|
||||
} else {
|
||||
log.severe("The data model is null")
|
||||
} else {
|
||||
log.severe("The data model is null")
|
||||
}
|
||||
// tabPane.selectionModel.select(1)
|
||||
}
|
||||
tabPane.selectionModel.select(1)
|
||||
}
|
||||
|
||||
private fun setupHVPane(hvData: Supplier<Table>) {
|
||||
getWorkManager().startWork("viewer.numass.hv") { callback: Work ->
|
||||
val t = hvData.get()
|
||||
Platform.runLater {
|
||||
hvPlot.plot.clear()
|
||||
// hvPlot.plot.clear()
|
||||
val set = PlottableGroup<TimePlottable>()
|
||||
for (dp in t) {
|
||||
val block = dp.getString("block", "default")
|
||||
if (!set.has(block)) {
|
||||
set.add(TimePlottable(block, block))
|
||||
set.add(TimePlottable(block))
|
||||
}
|
||||
set.get(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value"))
|
||||
}
|
||||
@ -268,8 +270,8 @@ class NumassLoaderView : View() {
|
||||
detectorPlotFrame = JFreeChartFrame(frameMeta)
|
||||
} else {
|
||||
detectorPlotFrame = detectorPlot.plot
|
||||
detectorPlotFrame.clear()
|
||||
detectorPlot.removePlot()
|
||||
// detectorPlotFrame.clear()
|
||||
// detectorPlot.removePlot()
|
||||
}
|
||||
|
||||
getWorkManager().startWork("viewer.numass.load.detector") { callback: Work ->
|
||||
@ -284,14 +286,19 @@ class NumassLoaderView : View() {
|
||||
|
||||
callback.maxProgress = points.size.toDouble()
|
||||
callback.progress = 0.0
|
||||
for (point in points) {
|
||||
val seriesName = String.format("%d: %.2f", points.indexOf(point), point.voltage)
|
||||
val datum = PlottableData.plot(seriesName, XYAdapter("chanel", "count"), point.getData(binning, normalize))
|
||||
datum.configure(plottableConfig)
|
||||
detectorPlotFrame.add(datum)
|
||||
callback.increaseProgress(1.0)
|
||||
//TODO add update instead of replace action
|
||||
|
||||
runAsync {
|
||||
points.map { point ->
|
||||
val seriesName = String.format("%d: %.2f", points.indexOf(point), point.voltage)
|
||||
val datum = PlottableData.plot(seriesName, XYAdapter("chanel", "count"), point.getData(binning, normalize))
|
||||
datum.configure(plottableConfig)
|
||||
callback.increaseProgress(1.0)
|
||||
datum;
|
||||
}
|
||||
} ui{
|
||||
detectorPlotFrame.setAll(it)
|
||||
}
|
||||
|
||||
detectorPlot.plot = detectorPlotFrame
|
||||
callback.setProgressToMax()
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package inr.numass.viewer.test
|
||||
|
||||
import hep.dataforge.plots.data.PlottableData
|
||||
import hep.dataforge.plots.fx.PlotContainer
|
||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame
|
||||
import hep.dataforge.tables.MapPoint
|
||||
import hep.dataforge.tables.XYAdapter
|
||||
import tornadofx.*
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Created by darksnake on 16-Apr-17.
|
||||
*/
|
||||
class JFCTest : View("My View") {
|
||||
val rnd = Random();
|
||||
|
||||
val plot = JFreeChartFrame();
|
||||
val container = PlotContainer();
|
||||
val data = PlottableData("data");
|
||||
|
||||
val button = button("test") {
|
||||
action {
|
||||
|
||||
data.fillData(
|
||||
(1..1000).map { MapPoint(arrayOf(XYAdapter.X_VALUE_KEY, XYAdapter.Y_VALUE_KEY), it, rnd.nextDouble()) }
|
||||
)
|
||||
plot.add(data)
|
||||
}
|
||||
};
|
||||
|
||||
override val root = borderpane {
|
||||
center {
|
||||
container.plot = plot
|
||||
add(container.root)
|
||||
}
|
||||
bottom {
|
||||
add(button)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package inr.numass.viewer.test
|
||||
|
||||
import tornadofx.*
|
||||
|
||||
/**
|
||||
* Created by darksnake on 16-Apr-17.
|
||||
*/
|
||||
class TestApp: App(JFCTest::class) {
|
||||
}
|
Loading…
Reference in New Issue
Block a user