Viewer to Kotlin!
This commit is contained in:
parent
9a1de9b6f2
commit
4f228abf30
@ -37,7 +37,7 @@ public interface NumassPoint {
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (i < RawNMPoint.MAX_CHANEL - binning) {
|
while (i < getMaxChannel() - binning) {
|
||||||
int start = i;
|
int start = i;
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
while (i < start + binning) {
|
while (i < start + binning) {
|
||||||
@ -60,4 +60,8 @@ public interface NumassPoint {
|
|||||||
double getVoltage();
|
double getVoltage();
|
||||||
|
|
||||||
int[] getSpectrum();
|
int[] getSpectrum();
|
||||||
|
|
||||||
|
default int getMaxChannel(){
|
||||||
|
return getSpectrum().length - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import javafx.application.Platform
|
|||||||
import javafx.beans.property.SimpleObjectProperty
|
import javafx.beans.property.SimpleObjectProperty
|
||||||
import javafx.geometry.Insets
|
import javafx.geometry.Insets
|
||||||
import javafx.scene.control.*
|
import javafx.scene.control.*
|
||||||
|
import javafx.scene.control.TreeTableView.CONSTRAINED_RESIZE_POLICY
|
||||||
import javafx.scene.input.MouseEvent
|
import javafx.scene.input.MouseEvent
|
||||||
import javafx.scene.layout.AnchorPane
|
import javafx.scene.layout.AnchorPane
|
||||||
import javafx.scene.layout.BorderPane
|
import javafx.scene.layout.BorderPane
|
||||||
@ -84,16 +85,18 @@ class MainView : View() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
storageProperty.addListener { ob, old, value ->
|
columnResizePolicy = CONSTRAINED_RESIZE_POLICY
|
||||||
|
|
||||||
|
storageProperty.addListener { _, _, value ->
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
Platform.runLater {
|
Platform.runLater {
|
||||||
root = TreeItem(Item(value));
|
root = TreeItem(Item(value));
|
||||||
|
|
||||||
populate { parent ->
|
populate { parent ->
|
||||||
val value = parent.value.content;
|
val storage = parent.value.content;
|
||||||
if (value is Storage) {
|
if (storage is Storage) {
|
||||||
//TODO add legacy loaders here?
|
//TODO add legacy loaders here?
|
||||||
value.shelves().map(::Item) + value.loaders().map(::Item)
|
storage.shelves().map(::Item) + storage.loaders().map(::Item)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@ -216,7 +219,11 @@ class MainView : View() {
|
|||||||
|
|
||||||
fun getTime(): String {
|
fun getTime(): String {
|
||||||
if (content is NumassData) {
|
if (content is NumassData) {
|
||||||
return content.startTime().toString();
|
if(content.startTime() == null){
|
||||||
|
return ""
|
||||||
|
} else {
|
||||||
|
return content.startTime().toString()
|
||||||
|
}
|
||||||
} else if (content is Annotated) {
|
} else if (content is Annotated) {
|
||||||
return content.meta().getString("file.timeModified", "")
|
return content.meta().getString("file.timeModified", "")
|
||||||
} else {
|
} else {
|
||||||
|
@ -24,7 +24,6 @@ import javafx.beans.value.ObservableValue
|
|||||||
import javafx.collections.FXCollections
|
import javafx.collections.FXCollections
|
||||||
import javafx.event.ActionEvent
|
import javafx.event.ActionEvent
|
||||||
import javafx.event.EventHandler
|
import javafx.event.EventHandler
|
||||||
import javafx.fxml.FXMLLoader
|
|
||||||
import javafx.geometry.Insets
|
import javafx.geometry.Insets
|
||||||
import javafx.geometry.Orientation
|
import javafx.geometry.Orientation
|
||||||
import javafx.scene.control.*
|
import javafx.scene.control.*
|
||||||
@ -72,23 +71,6 @@ class NumassLoaderView : View() {
|
|||||||
private val detectorNormalizeSwitch: CheckBox = CheckBox("Normailize")
|
private val detectorNormalizeSwitch: CheckBox = CheckBox("Normailize")
|
||||||
private val detectorDataExportButton: Button = Button("Export")
|
private val detectorDataExportButton: Button = Button("Export")
|
||||||
|
|
||||||
init {
|
|
||||||
val loader = FXMLLoader(javaClass.getResource("/fxml/NumassLoaderView.fxml"))
|
|
||||||
|
|
||||||
loader.setRoot(this)
|
|
||||||
loader.setController(this)
|
|
||||||
|
|
||||||
try {
|
|
||||||
loader.load<Any>()
|
|
||||||
} catch (ex: IOException) {
|
|
||||||
throw RuntimeException(ex)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the controller class.
|
|
||||||
*/
|
|
||||||
init {
|
init {
|
||||||
//setup detector pane plot and sidebar
|
//setup detector pane plot and sidebar
|
||||||
val l = Label("Bin size:")
|
val l = Label("Bin size:")
|
||||||
@ -191,7 +173,7 @@ class NumassLoaderView : View() {
|
|||||||
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.plottables().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")
|
||||||
@ -269,7 +251,7 @@ class NumassLoaderView : View() {
|
|||||||
*/
|
*/
|
||||||
private fun updateDetectorPane(points: List<NumassPoint>, binning: Int, normalize: Boolean) {
|
private fun updateDetectorPane(points: List<NumassPoint>, binning: Int, normalize: Boolean) {
|
||||||
val detectorPlotFrame: FXPlotFrame
|
val detectorPlotFrame: FXPlotFrame
|
||||||
if (detectorPlot.plot.config.isEmpty) {
|
if (detectorPlot.plot == null) {
|
||||||
val frameMeta = MetaBuilder("frame")
|
val frameMeta = MetaBuilder("frame")
|
||||||
.setValue("title", "Detector response plot")
|
.setValue("title", "Detector response plot")
|
||||||
.setNode(MetaBuilder("xAxis")
|
.setNode(MetaBuilder("xAxis")
|
||||||
|
@ -1,120 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 Alexander Nozik.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package inr.numass.viewer
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
* @author darksnake
|
|
||||||
*/
|
|
||||||
class TreeBuilder {
|
|
||||||
// @Throws(StorageException::class)
|
|
||||||
// fun build(callback: Work,
|
|
||||||
// numassLoaderDataTree: TreeTableView<Item>,
|
|
||||||
// rootStorage: NumassStorage,
|
|
||||||
// numassViewBuilder: (NumassData) -> Unit) {
|
|
||||||
//
|
|
||||||
// val root = buildNode(rootStorage, numassViewBuilder, callback)
|
|
||||||
// root.isExpanded = true
|
|
||||||
//
|
|
||||||
// Platform.runLater {
|
|
||||||
// numassLoaderDataTree.root = root
|
|
||||||
//
|
|
||||||
// val numassLoaderNameColumn = TreeTableColumn<Item, String>("name")
|
|
||||||
//
|
|
||||||
// numassLoaderNameColumn.setCellValueFactory { param: TreeTableColumn.CellDataFeatures<Item, String> -> SimpleStringProperty(param.value.value.name) }
|
|
||||||
//
|
|
||||||
// val numassLoaderTimeColumn = TreeTableColumn<Item, String>("time")
|
|
||||||
// numassLoaderTimeColumn.setCellValueFactory { param: TreeTableColumn.CellDataFeatures<Item, String> -> SimpleStringProperty(param.value.value.time) }
|
|
||||||
//
|
|
||||||
// val nummassLoaderDescriptionColumn = TreeTableColumn<Item, String>("description")
|
|
||||||
// nummassLoaderDescriptionColumn.setCellValueFactory { param: TreeTableColumn.CellDataFeatures<Item, String> -> SimpleStringProperty(param.value.value.description) }
|
|
||||||
//
|
|
||||||
// numassLoaderDataTree.columns.setAll(numassLoaderNameColumn, numassLoaderTimeColumn, nummassLoaderDescriptionColumn)
|
|
||||||
//
|
|
||||||
// numassLoaderNameColumn.sortType = TreeTableColumn.SortType.ASCENDING
|
|
||||||
// numassLoaderDataTree.sortOrder.addAll(numassLoaderTimeColumn, numassLoaderNameColumn)
|
|
||||||
// numassLoaderDataTree.addEventHandler(MouseEvent.MOUSE_CLICKED) { e: MouseEvent ->
|
|
||||||
// if (e.clickCount == 2) {
|
|
||||||
// val value = numassLoaderDataTree.focusModel.focusedCell.treeItem.value
|
|
||||||
// if (value.isLoader) {
|
|
||||||
// numassViewBuilder(value.loader)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// numassLoaderTimeColumn.isVisible = false
|
|
||||||
// nummassLoaderDescriptionColumn.setVisible(false)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Throws(StorageException::class)
|
|
||||||
// private fun buildNode(storage: NumassStorage, numassViewBuilder: (NumassData) -> Unit, callback: Work): TreeItem<Item> {
|
|
||||||
// val node = TreeItem(NumassDataItem(storage))
|
|
||||||
// node.children.setAll(buildChildren(storage, numassViewBuilder, callback))
|
|
||||||
// return node
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private val logger: Logger
|
|
||||||
// get() = LoggerFactory.getLogger(javaClass)
|
|
||||||
//
|
|
||||||
// @Throws(StorageException::class)
|
|
||||||
// private fun buildChildren(storage: NumassStorage, numassViewBuilder: (NumassData) -> Unit, callback: Work): List<TreeItem<Item>> {
|
|
||||||
// val list = ArrayList<TreeItem<Item>>()
|
|
||||||
//
|
|
||||||
// storage.shelves().stream().forEach { subStorage ->
|
|
||||||
// if (subStorage is NumassStorage) {
|
|
||||||
// try {
|
|
||||||
// val numassSubStorage = subStorage
|
|
||||||
// val childNode = buildNode(numassSubStorage, numassViewBuilder, callback)
|
|
||||||
// if (!childNode.isLeaf) {
|
|
||||||
// list.add(buildNode(numassSubStorage, numassViewBuilder, callback))
|
|
||||||
// }
|
|
||||||
// } catch (ex: StorageException) {
|
|
||||||
// logger.error("Error while loading numass storage node", ex)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// callback.status = "Building storage " + storage.name
|
|
||||||
// callback.progress = 0.0
|
|
||||||
// callback.maxProgress = storage.loaders().size.toDouble()
|
|
||||||
// storage.loaders().stream()
|
|
||||||
// .forEach { loader ->
|
|
||||||
// if (loader is NumassData) {
|
|
||||||
// callback.status = "Building numass data loader " + loader.getName()
|
|
||||||
// val numassLoaderTreeItem = TreeItem(NumassDataItem(loader))
|
|
||||||
// list.add(numassLoaderTreeItem)
|
|
||||||
// }
|
|
||||||
// callback.increaseProgress(1.0)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// callback.status = "Loading legacy DAT files"
|
|
||||||
// callback.progress = 0.0
|
|
||||||
// val legacyFiles = storage.legacyFiles()
|
|
||||||
// callback.maxProgress = legacyFiles.size.toDouble()
|
|
||||||
// //adding legacy data files
|
|
||||||
// for (legacyDat in legacyFiles) {
|
|
||||||
// callback.status = "Loading numass DAT file " + legacyDat.name
|
|
||||||
// val numassLoaderTreeItem = TreeItem(NumassDataItem(legacyDat))
|
|
||||||
// callback.increaseProgress(1.0)
|
|
||||||
// list.add(numassLoaderTreeItem)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return list
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
}
|
|
@ -2,6 +2,7 @@ package inr.numass.viewer
|
|||||||
|
|
||||||
import ch.qos.logback.classic.Level
|
import ch.qos.logback.classic.Level
|
||||||
import ch.qos.logback.classic.Logger
|
import ch.qos.logback.classic.Logger
|
||||||
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.fx.work.WorkManager
|
import hep.dataforge.fx.work.WorkManager
|
||||||
import hep.dataforge.storage.commons.StorageManager
|
import hep.dataforge.storage.commons.StorageManager
|
||||||
import javafx.stage.Stage
|
import javafx.stage.Stage
|
||||||
@ -15,6 +16,7 @@ class Viewer : App(MainView::class) {
|
|||||||
|
|
||||||
override fun start(stage: Stage) {
|
override fun start(stage: Stage) {
|
||||||
(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger).level = Level.INFO
|
(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger).level = Level.INFO
|
||||||
|
Global.setDefaultContext(Global.instance())
|
||||||
StorageManager().startGlobal()
|
StorageManager().startGlobal()
|
||||||
WorkManager().startGlobal()
|
WorkManager().startGlobal()
|
||||||
super.start(stage)
|
super.start(stage)
|
||||||
|
@ -20,7 +20,7 @@ limitations under the License.
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import org.controlsfx.control.RangeSlider?>
|
<?import org.controlsfx.control.RangeSlider?>
|
||||||
<fx:root id="AnchorPane" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" type="AnchorPane" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
|
<AnchorPane id="AnchorPane" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<children>
|
<children>
|
||||||
<TabPane fx:id="tabPane" layoutX="200.0" layoutY="100.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<TabPane fx:id="tabPane" layoutX="200.0" layoutY="100.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<tabs>
|
<tabs>
|
||||||
@ -92,4 +92,4 @@ limitations under the License.
|
|||||||
</tabs>
|
</tabs>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</children>
|
</children>
|
||||||
</fx:root>
|
</AnchorPane>
|
||||||
|
Loading…
Reference in New Issue
Block a user