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:dataforge-control" //project(':dataforge-control')
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;
}
if (line.hasOption("lc")) {
printDescription(context, true);
return;
} else if (line.hasOption("l")) {
printDescription(context, false);
if (line.hasOption("l")) {
printDescription(context);
return;
}

View File

@ -42,7 +42,7 @@ public class Numass {
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()
.addText("***Data description***", "red")
@ -56,14 +56,14 @@ public class Numass {
.ln();
for (ActionDescriptor descriptor : context.getFeature(ActionManager.class).list()) {
builder
.addText("\t")
.addContent(
MarkupUtils.markupDescriptor(descriptor)
ActionManager am = context.getFeature(ActionManager.class);
am.getAllActions()
.map(name -> am.optAction(name).get())
.map(action -> ActionDescriptor.build(action)).forEach(descriptor ->
builder.addText("\t").addContent(MarkupUtils.markupDescriptor(descriptor))
);
}
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);
actions.attach(context);
actions.register(PrepareDataAction.class);
actions.register(ReadLegacyDataAction.class);
actions.register(MergeDataAction.class);
actions.register(FindBorderAction.class);
actions.register(MonitorCorrectAction.class);
actions.register(SummaryAction.class);
actions.register(PlotDataAction.class);
actions.register(PlotFitResultAction.class);
actions.register(AdjustErrorsAction.class);
actions.register(ShowEnergySpectrumAction.class);
actions.register(SubstractSpectrumAction.class);
actions.putAction(PrepareDataAction.class);
actions.putAction(ReadLegacyDataAction.class);
actions.putAction(MergeDataAction.class);
actions.putAction(FindBorderAction.class);
actions.putAction(MonitorCorrectAction.class);
actions.putAction(SummaryAction.class);
actions.putAction(PlotDataAction.class);
actions.putAction(PlotFitResultAction.class);
actions.putAction(AdjustErrorsAction.class);
actions.putAction(ShowEnergySpectrumAction.class);
actions.putAction(SubstractSpectrumAction.class);
}
@Override

View File

@ -28,5 +28,5 @@ task runClient(type: JavaExec) {
dependencies {
compile project(':numass-client')
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.Global
import hep.dataforge.data.Data
import hep.dataforge.fx.work.Work
import hep.dataforge.fx.work.WorkManager
import hep.dataforge.io.ColumnedDataWriter
import hep.dataforge.meta.MetaBuilder
@ -29,6 +28,7 @@ import javafx.geometry.Insets
import javafx.geometry.Orientation
import javafx.scene.control.*
import javafx.scene.layout.AnchorPane
import javafx.scene.layout.BorderPane
import javafx.stage.FileChooser
import javafx.util.converter.NumberStringConverter
import org.controlsfx.control.RangeSlider
@ -49,30 +49,31 @@ class NumassLoaderView : View() {
override val root: AnchorPane by fxml("/fxml/NumassLoaderView.fxml")
lateinit var main: MainView
var data: NumassData? = null
val spectrumData = PlottableData("spectrum")
val hvPlotData = PlottableGroup<TimePlottable>()
private val detectorPlotPane: AnchorPane by fxid();
private val detectorPlotPane: BorderPane by fxid();
private val tabPane: TabPane 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 upChannelField: TextField by fxid();
private val channelSlider: RangeSlider 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 detectorPlot: PlotContainer = PlotContainer.anchorTo(detectorPlotPane)
private val spectrumPlot: PlotContainer = PlotContainer.anchorTo(spectrumPlotPane)
private val hvPlot: PlotContainer = PlotContainer.anchorTo(hvPane)
// private var spectrumData: PlottableData? = null
private var points = FXCollections.observableArrayList<NumassPoint>()
private val detectorPlot: PlotContainer = PlotContainer.centerIn(detectorPlotPane)
private val spectrumPlot: PlotContainer = PlotContainer.centerIn(spectrumPlotPane)
private val hvPlot: PlotContainer = PlotContainer.centerIn(hvPane)
private val detectorBinningSelector: ChoiceBox<Int> = ChoiceBox(FXCollections.observableArrayList(1, 2, 5, 10, 20, 50))
private val detectorNormalizeSwitch: CheckBox = CheckBox("Normailize")
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 {
//setup detector pane plot and sidebar
val l = Label("Bin size:")
@ -92,7 +93,7 @@ class NumassLoaderView : View() {
detectorPlot.setSideBarPosition(0.7)
//setup spectrum pane
spectrumExportButton.onAction = EventHandler { this::onSpectrumExportClick }
spectrumExportButton.onAction = EventHandler { this.onSpectrumExportClick(it) }
val spectrumPlotMeta = MetaBuilder("plot")
.setValue("xAxis.axisTitle", "U")
.setValue("xAxis.axisUnits", "V")
@ -177,7 +178,7 @@ class NumassLoaderView : View() {
runAsync {
hvData.get()
} ui {
for (pl in hvPlotData){
for (pl in hvPlotData) {
pl.clear()
}
for (dp in it) {
@ -271,11 +272,10 @@ class NumassLoaderView : View() {
detectorPlotFrame = JFreeChartFrame(frameMeta)
} else {
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)
@ -285,15 +285,15 @@ class NumassLoaderView : View() {
.setValue("JFreeChart.cache", true)
.build()
callback.maxProgress = points.size.toDouble()
callback.progress = 0.0
work.maxProgress = points.size.toDouble()
work.progress = 0.0
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)
work.increaseProgress(1.0)
datum;
}
} ui {
@ -301,9 +301,7 @@ class NumassLoaderView : View() {
}
detectorPlot.plot = detectorPlotFrame
callback.setProgressToMax()
}
work.setProgressToMax()
}
private fun onSpectrumExportClick(event: ActionEvent) {

View File

@ -35,22 +35,19 @@ limitations under the License.
</Tab>
<Tab fx:id="detectorTab" text="Detector">
<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>
</Tab>
<Tab fx:id="hvTab" text="HV">
<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>
</Tab>
<Tab fx:id="spectrumTab" text="Spectrum">
<content>
<AnchorPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0">
<children>
<BorderPane 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>
<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">
<top>
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items>