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.setMaxItems(1000);
|
||||||
plottables.setPrefItems(400);
|
plottables.setPrefItems(400);
|
||||||
}
|
}
|
||||||
// plottables.applyConfig(plotFrame.getConfig());
|
// getPlottables.applyConfig(plotFrame.getConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,7 +24,7 @@ public class PointBuilders {
|
|||||||
.stream().mapToInt(it -> it.intValue()),
|
.stream().mapToInt(it -> it.intValue()),
|
||||||
block.getEventsList().stream()
|
block.getEventsList().stream()
|
||||||
.mapToInt(event -> peakFinder.apply(event))
|
.mapToInt(event -> peakFinder.apply(event))
|
||||||
))
|
)),0
|
||||||
);
|
);
|
||||||
|
|
||||||
return new NMPoint(u, startTime, pointLength, spectrum);
|
return new NMPoint(u, startTime, pointLength, spectrum);
|
||||||
@ -32,7 +32,7 @@ public class PointBuilders {
|
|||||||
|
|
||||||
private static int[] calculateSpectrum(RawNMPoint point) {
|
private static int[] calculateSpectrum(RawNMPoint point) {
|
||||||
assert point.getEventsCount() > 0;
|
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
|
@NotNull
|
||||||
@ -40,8 +40,12 @@ public class PointBuilders {
|
|||||||
return new NMPoint(point.getUset(), point.getStartTime(), point.getLength(), calculateSpectrum(point));
|
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<>();
|
List<AtomicInteger> list = new ArrayList<>();
|
||||||
|
while (list.size() <= maxChannel) {
|
||||||
|
list.add(new AtomicInteger(0));
|
||||||
|
}
|
||||||
|
|
||||||
stream.forEach(i -> {
|
stream.forEach(i -> {
|
||||||
while (list.size() <= i) {
|
while (list.size() <= i) {
|
||||||
list.add(new AtomicInteger(0));
|
list.add(new AtomicInteger(0));
|
||||||
|
@ -4,7 +4,7 @@ plugins{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hasProperty('mainClass')) {
|
if (!hasProperty('mainClass')) {
|
||||||
ext.mainClass = 'inr.numass.viewer.Viewer'
|
ext.mainClass = 'inr.numass.viewer.Viewer'//"inr.numass.viewer.test.TestApp"
|
||||||
}
|
}
|
||||||
mainClassName = mainClass
|
mainClassName = mainClass
|
||||||
|
|
||||||
|
@ -115,19 +115,19 @@ public class MspViewController implements Encapsulated {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void plotData(List<PointLoader> loaders) {
|
public void plotData(List<PointLoader> loaders) {
|
||||||
// TimePlottableGroup plottables = new TimePlottableGroup();
|
// TimePlottableGroup getPlottables = new TimePlottableGroup();
|
||||||
// loaders.stream()
|
// loaders.stream()
|
||||||
// .flatMap(loader -> getLoaderData(loader))
|
// .flatMap(loader -> getLoaderData(loader))
|
||||||
// .distinct()
|
// .distinct()
|
||||||
// .forEach(point -> {
|
// .forEach(point -> {
|
||||||
// for (String name : point.names()) {
|
// for (String name : point.names()) {
|
||||||
// if (!name.equals("timestamp")) {
|
// if (!name.equals("timestamp")) {
|
||||||
// if (!plottables.has(name)) {
|
// if (!getPlottables.has(name)) {
|
||||||
// plottables.addPlottable(new TimePlottable(name, 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();
|
//// List<DataPoint> mspData = (List<DataPoint>) loadProcess.getTask().get();
|
||||||
//
|
//
|
||||||
// if (!mspData.isEmpty()) {
|
// if (!mspData.isEmpty()) {
|
||||||
// TimePlottableGroup plottables = new TimePlottableGroup();
|
// TimePlottableGroup getPlottables = new TimePlottableGroup();
|
||||||
//
|
//
|
||||||
// for (DataPoint point : mspData) {
|
// for (DataPoint point : mspData) {
|
||||||
// for (String name : point.names()) {
|
// for (String name : point.names()) {
|
||||||
// if (!name.equals("timestamp")) {
|
// if (!name.equals("timestamp")) {
|
||||||
// if (!plottables.has(name)) {
|
// if (!getPlottables.has(name)) {
|
||||||
// plottables.add(new TimePlottable(name, 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.WorkManager
|
||||||
import hep.dataforge.fx.work.WorkManagerFragment
|
import hep.dataforge.fx.work.WorkManagerFragment
|
||||||
import hep.dataforge.meta.Annotated
|
import hep.dataforge.meta.Annotated
|
||||||
|
import hep.dataforge.names.AlphanumComparator
|
||||||
import hep.dataforge.names.Named
|
import hep.dataforge.names.Named
|
||||||
import hep.dataforge.storage.api.Storage
|
import hep.dataforge.storage.api.Storage
|
||||||
import inr.numass.NumassProperties
|
import inr.numass.NumassProperties
|
||||||
@ -72,8 +73,15 @@ class MainView : View() {
|
|||||||
|
|
||||||
treePane.center {
|
treePane.center {
|
||||||
treetableview<Item> {
|
treetableview<Item> {
|
||||||
column("name", Item::getName)
|
val nameColumnt = column("name", Item::getName).apply {
|
||||||
column("time", Item::getTime)
|
sortType = TreeTableColumn.SortType.ASCENDING
|
||||||
|
}
|
||||||
|
|
||||||
|
val timeColumn = column("time", Item::getTime).apply {
|
||||||
|
isVisible = false
|
||||||
|
}
|
||||||
|
|
||||||
|
sortOrder.add(nameColumnt)
|
||||||
|
|
||||||
addEventHandler(MouseEvent.MOUSE_CLICKED) { e: MouseEvent ->
|
addEventHandler(MouseEvent.MOUSE_CLICKED) { e: MouseEvent ->
|
||||||
if (e.clickCount == 2) {
|
if (e.clickCount == 2) {
|
||||||
@ -85,6 +93,7 @@ class MainView : View() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isTableMenuButtonVisible = true
|
||||||
columnResizePolicy = CONSTRAINED_RESIZE_POLICY
|
columnResizePolicy = CONSTRAINED_RESIZE_POLICY
|
||||||
|
|
||||||
storageProperty.addListener { _, _, value ->
|
storageProperty.addListener { _, _, value ->
|
||||||
@ -92,11 +101,13 @@ class MainView : View() {
|
|||||||
Platform.runLater {
|
Platform.runLater {
|
||||||
root = TreeItem(Item(value));
|
root = TreeItem(Item(value));
|
||||||
|
|
||||||
|
root.isExpanded = true
|
||||||
|
|
||||||
populate { parent ->
|
populate { parent ->
|
||||||
val storage = parent.value.content;
|
val storage = parent.value.content;
|
||||||
if (storage is Storage) {
|
if (storage is Storage) {
|
||||||
//TODO add legacy loaders here?
|
//TODO add legacy loaders here?
|
||||||
storage.shelves().map(::Item) + storage.loaders().map(::Item)
|
storage.shelves().map(::Item).sorted() + storage.loaders().map(::Item).sorted()
|
||||||
} else {
|
} else {
|
||||||
null
|
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 {
|
fun getName(): String {
|
||||||
return content.name;
|
return content.name;
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,7 @@ class NumassLoaderView : View() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun loadData(data: NumassData?) {
|
fun loadData(data: NumassData?) {
|
||||||
|
synchronized(this) {
|
||||||
this.data = data
|
this.data = data
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
getWorkManager().startWork("viewer.numass.load") { work ->
|
getWorkManager().startWork("viewer.numass.load") { work ->
|
||||||
@ -166,19 +167,20 @@ class NumassLoaderView : View() {
|
|||||||
} else {
|
} else {
|
||||||
log.severe("The data model is null")
|
log.severe("The data model is null")
|
||||||
}
|
}
|
||||||
tabPane.selectionModel.select(1)
|
// tabPane.selectionModel.select(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupHVPane(hvData: Supplier<Table>) {
|
private fun setupHVPane(hvData: Supplier<Table>) {
|
||||||
getWorkManager().startWork("viewer.numass.hv") { callback: Work ->
|
getWorkManager().startWork("viewer.numass.hv") { callback: Work ->
|
||||||
val t = hvData.get()
|
val t = hvData.get()
|
||||||
Platform.runLater {
|
Platform.runLater {
|
||||||
hvPlot.plot.clear()
|
// hvPlot.plot.clear()
|
||||||
val set = PlottableGroup<TimePlottable>()
|
val set = PlottableGroup<TimePlottable>()
|
||||||
for (dp in t) {
|
for (dp in t) {
|
||||||
val block = dp.getString("block", "default")
|
val block = dp.getString("block", "default")
|
||||||
if (!set.has(block)) {
|
if (!set.has(block)) {
|
||||||
set.add(TimePlottable(block, block))
|
set.add(TimePlottable(block))
|
||||||
}
|
}
|
||||||
set.get(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value"))
|
set.get(block).put(dp.getValue("timestamp").timeValue(), dp.getValue("value"))
|
||||||
}
|
}
|
||||||
@ -268,8 +270,8 @@ class NumassLoaderView : View() {
|
|||||||
detectorPlotFrame = JFreeChartFrame(frameMeta)
|
detectorPlotFrame = JFreeChartFrame(frameMeta)
|
||||||
} else {
|
} else {
|
||||||
detectorPlotFrame = detectorPlot.plot
|
detectorPlotFrame = detectorPlot.plot
|
||||||
detectorPlotFrame.clear()
|
// detectorPlotFrame.clear()
|
||||||
detectorPlot.removePlot()
|
// detectorPlot.removePlot()
|
||||||
}
|
}
|
||||||
|
|
||||||
getWorkManager().startWork("viewer.numass.load.detector") { callback: Work ->
|
getWorkManager().startWork("viewer.numass.load.detector") { callback: Work ->
|
||||||
@ -284,14 +286,19 @@ class NumassLoaderView : View() {
|
|||||||
|
|
||||||
callback.maxProgress = points.size.toDouble()
|
callback.maxProgress = points.size.toDouble()
|
||||||
callback.progress = 0.0
|
callback.progress = 0.0
|
||||||
for (point in points) {
|
|
||||||
|
runAsync {
|
||||||
|
points.map { point ->
|
||||||
val seriesName = String.format("%d: %.2f", points.indexOf(point), point.voltage)
|
val seriesName = String.format("%d: %.2f", points.indexOf(point), point.voltage)
|
||||||
val datum = PlottableData.plot(seriesName, XYAdapter("chanel", "count"), point.getData(binning, normalize))
|
val datum = PlottableData.plot(seriesName, XYAdapter("chanel", "count"), point.getData(binning, normalize))
|
||||||
datum.configure(plottableConfig)
|
datum.configure(plottableConfig)
|
||||||
detectorPlotFrame.add(datum)
|
|
||||||
callback.increaseProgress(1.0)
|
callback.increaseProgress(1.0)
|
||||||
//TODO add update instead of replace action
|
datum;
|
||||||
}
|
}
|
||||||
|
} ui{
|
||||||
|
detectorPlotFrame.setAll(it)
|
||||||
|
}
|
||||||
|
|
||||||
detectorPlot.plot = detectorPlotFrame
|
detectorPlot.plot = detectorPlotFrame
|
||||||
callback.setProgressToMax()
|
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