Update in ActionManager.

This commit is contained in:
Alexander Nozik 2017-04-29 20:40:40 +03:00
parent 4d8e4ab28b
commit 77858190e0
7 changed files with 68 additions and 72 deletions

View File

@ -10,4 +10,8 @@ dependencies {
compile "hep.dataforge:plots-jfc" // project(':dataforge-plots:plots-jfc') compile "hep.dataforge:plots-jfc" // project(':dataforge-plots:plots-jfc')
compile "hep.dataforge:dataforge-control" //project(':dataforge-control') compile "hep.dataforge:dataforge-control" //project(':dataforge-control')
compile "hep.dataforge:dataforge-fx" //project(':dataforge-fx') compile "hep.dataforge:dataforge-fx" //project(':dataforge-fx')
// https://mvnrepository.com/artifact/org.controlsfx/controlsfx
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.12'
} }

View File

@ -67,11 +67,8 @@ public class Main {
return; return;
} }
if (line.hasOption("lc")) { if (line.hasOption("l")) {
printDescription(context, true); printDescription(context);
return;
} else if (line.hasOption("l")) {
printDescription(context, false);
return; return;
} }

View File

@ -42,7 +42,7 @@ public class Numass {
return buildContext(Global.instance(), Meta.empty()); return buildContext(Global.instance(), Meta.empty());
} }
public static void printDescription(Context context, boolean allowANSI) throws DescriptorException { public static void printDescription(Context context) throws DescriptorException {
MarkupBuilder builder = new MarkupBuilder() MarkupBuilder builder = new MarkupBuilder()
.addText("***Data description***", "red") .addText("***Data description***", "red")
@ -56,14 +56,14 @@ public class Numass {
.ln(); .ln();
for (ActionDescriptor descriptor : context.getFeature(ActionManager.class).list()) { ActionManager am = context.getFeature(ActionManager.class);
builder
.addText("\t") am.getAllActions()
.addContent( .map(name -> am.optAction(name).get())
MarkupUtils.markupDescriptor(descriptor) .map(action -> ActionDescriptor.build(action)).forEach(descriptor ->
); builder.addText("\t").addContent(MarkupUtils.markupDescriptor(descriptor))
);
}
builder.addText("***End of actions list***", "red"); builder.addText("***End of actions list***", "red");

View File

@ -80,17 +80,17 @@ public class NumassPlugin extends BasicPlugin {
ActionManager actions = context.pluginManager().getOrLoad(ActionManager.class); ActionManager actions = context.pluginManager().getOrLoad(ActionManager.class);
actions.attach(context); actions.attach(context);
actions.register(PrepareDataAction.class); actions.putAction(PrepareDataAction.class);
actions.register(ReadLegacyDataAction.class); actions.putAction(ReadLegacyDataAction.class);
actions.register(MergeDataAction.class); actions.putAction(MergeDataAction.class);
actions.register(FindBorderAction.class); actions.putAction(FindBorderAction.class);
actions.register(MonitorCorrectAction.class); actions.putAction(MonitorCorrectAction.class);
actions.register(SummaryAction.class); actions.putAction(SummaryAction.class);
actions.register(PlotDataAction.class); actions.putAction(PlotDataAction.class);
actions.register(PlotFitResultAction.class); actions.putAction(PlotFitResultAction.class);
actions.register(AdjustErrorsAction.class); actions.putAction(AdjustErrorsAction.class);
actions.register(ShowEnergySpectrumAction.class); actions.putAction(ShowEnergySpectrumAction.class);
actions.register(SubstractSpectrumAction.class); actions.putAction(SubstractSpectrumAction.class);
} }
@Override @Override

View File

@ -28,5 +28,5 @@ task runClient(type: JavaExec) {
dependencies { dependencies {
compile project(':numass-client') compile project(':numass-client')
compile project(':numass-server') compile project(':numass-server')
compile "hep.dataforge:dataforge-grind" //project(':dataforge-grind') compile "hep.dataforge:grind" //project(':dataforge-grind')
} }

View File

@ -3,7 +3,6 @@ package inr.numass.viewer
import hep.dataforge.context.Context import hep.dataforge.context.Context
import hep.dataforge.context.Global import hep.dataforge.context.Global
import hep.dataforge.data.Data import hep.dataforge.data.Data
import hep.dataforge.fx.work.Work
import hep.dataforge.fx.work.WorkManager import hep.dataforge.fx.work.WorkManager
import hep.dataforge.io.ColumnedDataWriter import hep.dataforge.io.ColumnedDataWriter
import hep.dataforge.meta.MetaBuilder import hep.dataforge.meta.MetaBuilder
@ -29,6 +28,7 @@ import javafx.geometry.Insets
import javafx.geometry.Orientation import javafx.geometry.Orientation
import javafx.scene.control.* import javafx.scene.control.*
import javafx.scene.layout.AnchorPane import javafx.scene.layout.AnchorPane
import javafx.scene.layout.BorderPane
import javafx.stage.FileChooser import javafx.stage.FileChooser
import javafx.util.converter.NumberStringConverter import javafx.util.converter.NumberStringConverter
import org.controlsfx.control.RangeSlider import org.controlsfx.control.RangeSlider
@ -49,30 +49,31 @@ class NumassLoaderView : View() {
override val root: AnchorPane by fxml("/fxml/NumassLoaderView.fxml") override val root: AnchorPane by fxml("/fxml/NumassLoaderView.fxml")
lateinit var main: MainView lateinit var main: MainView
var data: NumassData? = null private val detectorPlotPane: BorderPane by fxid();
val spectrumData = PlottableData("spectrum")
val hvPlotData = PlottableGroup<TimePlottable>()
private val detectorPlotPane: AnchorPane by fxid();
private val tabPane: TabPane by fxid(); private val tabPane: TabPane by fxid();
private val infoTextBox: TextArea by fxid(); private val infoTextBox: TextArea by fxid();
private val spectrumPlotPane: AnchorPane by fxid(); private val spectrumPlotPane: BorderPane by fxid();
private val lowChannelField: TextField by fxid(); private val lowChannelField: TextField by fxid();
private val upChannelField: TextField by fxid(); private val upChannelField: TextField by fxid();
private val channelSlider: RangeSlider by fxid(); private val channelSlider: RangeSlider by fxid();
private val dTimeField: TextField by fxid(); private val dTimeField: TextField by fxid();
private val hvPane: AnchorPane by fxid(); private val hvPane: BorderPane by fxid();
private val spectrumExportButton: Button by fxid(); private val spectrumExportButton: Button by fxid();
private val detectorPlot: PlotContainer = PlotContainer.anchorTo(detectorPlotPane) private val detectorPlot: PlotContainer = PlotContainer.centerIn(detectorPlotPane)
private val spectrumPlot: PlotContainer = PlotContainer.anchorTo(spectrumPlotPane) private val spectrumPlot: PlotContainer = PlotContainer.centerIn(spectrumPlotPane)
private val hvPlot: PlotContainer = PlotContainer.anchorTo(hvPane) private val hvPlot: PlotContainer = PlotContainer.centerIn(hvPane)
// private var spectrumData: PlottableData? = null
private var points = FXCollections.observableArrayList<NumassPoint>()
private val detectorBinningSelector: ChoiceBox<Int> = ChoiceBox(FXCollections.observableArrayList(1, 2, 5, 10, 20, 50)) private val detectorBinningSelector: ChoiceBox<Int> = ChoiceBox(FXCollections.observableArrayList(1, 2, 5, 10, 20, 50))
private val detectorNormalizeSwitch: CheckBox = CheckBox("Normailize") private val detectorNormalizeSwitch: CheckBox = CheckBox("Normailize")
private val detectorDataExportButton: Button = Button("Export") private val detectorDataExportButton: Button = Button("Export")
//plots data
var data: NumassData? = null
val spectrumData = PlottableData("spectrum")
val hvPlotData = PlottableGroup<TimePlottable>()
private var points = FXCollections.observableArrayList<NumassPoint>()
init { init {
//setup detector pane plot and sidebar //setup detector pane plot and sidebar
val l = Label("Bin size:") val l = Label("Bin size:")
@ -92,7 +93,7 @@ class NumassLoaderView : View() {
detectorPlot.setSideBarPosition(0.7) detectorPlot.setSideBarPosition(0.7)
//setup spectrum pane //setup spectrum pane
spectrumExportButton.onAction = EventHandler { this::onSpectrumExportClick } spectrumExportButton.onAction = EventHandler { this.onSpectrumExportClick(it) }
val spectrumPlotMeta = MetaBuilder("plot") val spectrumPlotMeta = MetaBuilder("plot")
.setValue("xAxis.axisTitle", "U") .setValue("xAxis.axisTitle", "U")
.setValue("xAxis.axisUnits", "V") .setValue("xAxis.axisUnits", "V")
@ -177,7 +178,7 @@ class NumassLoaderView : View() {
runAsync { runAsync {
hvData.get() hvData.get()
} ui { } ui {
for (pl in hvPlotData){ for (pl in hvPlotData) {
pl.clear() pl.clear()
} }
for (dp in it) { for (dp in it) {
@ -271,39 +272,36 @@ class NumassLoaderView : View() {
detectorPlotFrame = JFreeChartFrame(frameMeta) detectorPlotFrame = JFreeChartFrame(frameMeta)
} else { } else {
detectorPlotFrame = detectorPlot.plot detectorPlotFrame = detectorPlot.plot
// detectorPlotFrame.clear()
// detectorPlot.removePlot()
} }
getWorkManager().startWork("viewer.numass.load.detector") { callback: Work -> val work = getWorkManager().getWork("viewer.numass.load.detector")
val plottableConfig = MetaBuilder("plot")
.setValue("connectionType", "step")
.setValue("thickness", 2)
.setValue("showLine", true)
.setValue("showSymbol", false)
.setValue("showErrors", false)
.setValue("JFreeChart.cache", true)
.build()
callback.maxProgress = points.size.toDouble() val plottableConfig = MetaBuilder("plot")
callback.progress = 0.0 .setValue("connectionType", "step")
.setValue("thickness", 2)
.setValue("showLine", true)
.setValue("showSymbol", false)
.setValue("showErrors", false)
.setValue("JFreeChart.cache", true)
.build()
runAsync { work.maxProgress = points.size.toDouble()
points.map { point -> work.progress = 0.0
val seriesName = String.format("%d: %.2f", points.indexOf(point), point.voltage)
val datum = PlottableData.plot(seriesName, XYAdapter("chanel", "count"), point.getData(binning, normalize)) runAsync {
datum.configure(plottableConfig) points.map { point ->
callback.increaseProgress(1.0) val seriesName = String.format("%d: %.2f", points.indexOf(point), point.voltage)
datum; val datum = PlottableData.plot(seriesName, XYAdapter("chanel", "count"), point.getData(binning, normalize))
} datum.configure(plottableConfig)
} ui { work.increaseProgress(1.0)
detectorPlotFrame.setAll(it) datum;
} }
} ui {
detectorPlot.plot = detectorPlotFrame detectorPlotFrame.setAll(it)
callback.setProgressToMax()
} }
detectorPlot.plot = detectorPlotFrame
work.setProgressToMax()
} }
private fun onSpectrumExportClick(event: ActionEvent) { private fun onSpectrumExportClick(event: ActionEvent) {

View File

@ -35,22 +35,19 @@ limitations under the License.
</Tab> </Tab>
<Tab fx:id="detectorTab" text="Detector"> <Tab fx:id="detectorTab" text="Detector">
<content> <content>
<AnchorPane fx:id="detectorPlotPane" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" /> <BorderPane fx:id="detectorPlotPane" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content> </content>
</Tab> </Tab>
<Tab fx:id="hvTab" text="HV"> <Tab fx:id="hvTab" text="HV">
<content> <content>
<AnchorPane fx:id="hvPane" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" /> <BorderPane fx:id="hvPane" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content> </content>
</Tab> </Tab>
<Tab fx:id="spectrumTab" text="Spectrum"> <Tab fx:id="spectrumTab" text="Spectrum">
<content> <content>
<AnchorPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0"> <AnchorPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0">
<children> <children>
<BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <BorderPane fx:id="spectrumPlotPane" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<center>
<AnchorPane fx:id="spectrumPlotPane" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</center>
<top> <top>
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER"> <ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items> <items>