Skip to content

Commit

Permalink
Merge pull request #161 from bowring/converge
Browse files Browse the repository at this point in the history
Interactive converge and various improvements to plots.
  • Loading branch information
bowring authored Sep 24, 2023
2 parents e4fd914 + 8069df3 commit 61a762b
Show file tree
Hide file tree
Showing 52 changed files with 1,548 additions and 844 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

public interface AnalysisManagerCallbackI {
public void callbackRefreshBlocksStatus();

public void reviewAndSculptDataAction();
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class AnalysisManagerController implements Initializable, AnalysisManager
public static AnalysisInterface analysis;
public static MCMCPlotsWindow MCMCPlotsWindow;
public static OGTripoliPlotsWindow ogTripoliPlotsWindow;
public static OGTripoliPlotsWindow ogTripoliPreviewPlotsWindow;
private final Map<String, boolean[][]> mapOfGridPanesToCellUse = new TreeMap<>();
public Tab detectorDetailTab;
public TabPane analysiMethodTabPane;
Expand Down Expand Up @@ -112,6 +113,18 @@ public class AnalysisManagerController implements Initializable, AnalysisManager
@FXML
private Button addRatioButton;

public static void closePlotWindows() {
if (ogTripoliPreviewPlotsWindow != null) {
ogTripoliPreviewPlotsWindow.close();
}
if (ogTripoliPlotsWindow != null) {
ogTripoliPlotsWindow.close();
}
if (MCMCPlotsWindow != null) {
MCMCPlotsWindow.close();
}
}

public static StackPane makeMassStackPane(String massName, String color) {
Text massText = new Text(massName);
massText.setFont(new Font("Monospaced Bold", 14));
Expand Down Expand Up @@ -375,6 +388,8 @@ private void populateAnalysisMethodRatioSelectorPane() {

private void populateAnalysisMethodRatioBuilderPane() {
addRatioButton.setStyle(addRatioButton.getStyle() + ";-fx-font-size:15");
numeratorMassesListTextFlow.getChildren().clear();
denominatorMassesListTextFlow.getChildren().clear();
if (null != analysis.getAnalysisMethod()) {
activeRatiosList = new TreeSet<>();
List<SpeciesRecordInterface> species = analysis.getAnalysisMethod().getSpeciesListSortedByMass();
Expand Down Expand Up @@ -590,7 +605,7 @@ private void selectDataFileButtonAction() {
@FXML
private void selectMethodFileButtonAction() {
try {
File selectedFile = selectMethodFile(TripoliGUI.primaryStage);
File selectedFile = selectMethodFile(null);
if ((null != selectedFile) && (selectedFile.exists())) {
AnalysisMethod analysisMethod = analysis.extractAnalysisMethodfromPath(Path.of(selectedFile.toURI()));
String compareInfo = compareAnalysisMethodToDataFileSpecs(analysisMethod, analysis.getMassSpecExtractedData());
Expand All @@ -615,6 +630,7 @@ private void selectMethodFileButtonAction() {
// initialize block processing state
for (Integer blockID : analysis.getMassSpecExtractedData().getBlocksData().keySet()) {
analysis.getMapOfBlockIdToProcessStatus().put(blockID, RUN);
analysis.getMapOfBlockIdToModelsBurnCount().put(blockID, 0);
}
populateAnalysisManagerGridPane();
}
Expand All @@ -635,18 +651,29 @@ final void initializeMonteCarloTechniqueAction() {
}


public void reviewAndSculptDataAction() throws TripoliException {
public void previewAndSculptDataAction() throws TripoliException {
// ogTripoli view
if (null != ogTripoliPlotsWindow) {
ogTripoliPlotsWindow.close();
if (null != ogTripoliPreviewPlotsWindow) {
ogTripoliPreviewPlotsWindow.close();
}
ogTripoliPlotsWindow = new OGTripoliPlotsWindow(TripoliGUI.primaryStage);
ogTripoliPreviewPlotsWindow = new OGTripoliPlotsWindow(TripoliGUI.primaryStage, this);
OGTripoliViewController.analysis = analysis;
OGTripoliViewController.plottingData = AllBlockInitForOGTripoli.initBlockModels(analysis);
ogTripoliPlotsWindow.loadPlotsWindow();
ogTripoliPreviewPlotsWindow.loadPlotsWindow();

}

public void reviewAndSculptDataAction() {
// fire up OGTripoli style session plots
if (null != ogTripoliPlotsWindow) {
ogTripoliPlotsWindow.close();
}
ogTripoliPlotsWindow = new OGTripoliPlotsWindow(TripoliGUI.primaryStage, this);
AllBlockInitForOGTripoli.PlottingData plottingData = analysis.assemblePostProcessPlottingData();
OGTripoliViewController.plottingData = plottingData;
ogTripoliPlotsWindow.loadPlotsWindow();
}

public void selectRunAllAction() {
for (Node button : blockStatusHBox.getChildren()) {
if (button instanceof Button) {
Expand All @@ -672,6 +699,9 @@ public void selectShowsAction() {
}
}

/**
* Restores block status buttons to their saved state
*/
public void restoreAllAction() {
for (Node button : blockStatusHBox.getChildren()) {
if ((button instanceof Button) && (null != analysis.getMapOfBlockIdToProcessStatus().get(Integer.parseInt(button.getId())))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,24 @@ public class OGTripoliPlotsWindow {

public static final double PLOT_WINDOW_WIDTH = 1000.0;
public static final double PLOT_WINDOW_HEIGHT = 700.0;
public static final double SCROLLBAR_THICKNESS = 15.0;

private final double xOffset = 0;
private final double yOffset = 0;
public Stage plottingStage;
public Window plottingWindow;
private Stage primaryStage;

private OGTripoliPlotsWindow() {
}

public OGTripoliPlotsWindow(Stage primaryStage) {//}, AnalysisManagerCallbackI analysisManagerCallbackI) {
public OGTripoliPlotsWindow(Stage primaryStage, AnalysisManagerCallbackI analysisManagerCallbackI) {
this.primaryStage = primaryStage;
plottingStage = new Stage();
plottingStage.setMinWidth(PLOT_WINDOW_WIDTH);
plottingStage.setMinHeight(PLOT_WINDOW_HEIGHT);
// plottingStage.setTitle("Tripoli Preview and Sculpt Data");

plottingStage.setOnCloseRequest((WindowEvent e) -> {
plottingStage.hide();
plottingStage.setScene(null);
e.consume();
});

// MCMCPlotsController.analysisManagerCallbackI = analysisManagerCallbackI;
OGTripoliViewController.analysisManagerCallbackI = analysisManagerCallbackI;
}

public void close() {
Expand All @@ -66,17 +59,18 @@ public void close() {

public void loadPlotsWindow() {
if (!plottingStage.isShowing()) {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/org/cirdles/tripoli/gui/OGTripoliView.fxml"));
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/org/cirdles/tripoli/gui/OGTripoliView.fxml"));
Scene scene = new Scene(loader.load());
plottingStage.setScene(scene);

} catch (IOException iOException) {
iOException.printStackTrace();
}
plottingWindow = plottingStage.getScene().getWindow();
plottingStage.setTitle("Tripoli " + (plottingData.preview() ? "PREVIEW" : "REVIEW") + " and Sculpt Data");
// ((OGTripoliViewController) loader.getController()).populatePlots();
plottingStage.show();

}

// center on app window
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package org.cirdles.tripoli.gui;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.TabPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
import org.cirdles.tripoli.gui.dataViews.plots.AbstractPlot;
Expand Down Expand Up @@ -35,29 +39,61 @@
public class OGTripoliViewController {
public static AnalysisInterface analysis;
public static AllBlockInitForOGTripoli.PlottingData plottingData;
public static AnalysisManagerCallbackI analysisManagerCallbackI;
@FXML
public VBox plotWindowVBox;
@FXML
public TabPane plotTabPane;
@FXML
public AnchorPane ogtSpeciesIntensitiesPlotAnchorPane;
@FXML
private AnchorPane ogtCycleRatioPlotsAnchorPane;

@FXML
void initialize() {
public void initialize() {
plotWindowVBox.widthProperty().addListener((observable, oldValue, newValue) -> {
plotTabPane.setMinWidth((Double) newValue);
ogtCycleRatioPlotsAnchorPane.setMinWidth((Double) newValue);
ogtSpeciesIntensitiesPlotAnchorPane.setMinWidth((Double) newValue);
});

plotWindowVBox.heightProperty().addListener((observable, oldValue, newValue) -> {
plotTabPane.setMinHeight(((Double) newValue) - 30.0);
ogtCycleRatioPlotsAnchorPane.setMinHeight(((Double) newValue) - 65.0);
ogtSpeciesIntensitiesPlotAnchorPane.setMinHeight(((Double) newValue) - 100.0);
});

populatePlots();
}

private void populatePlots() {
public void populatePlots() {
plotRatios();
plotOnPeakIntensities();
}

private void plotRatios() {
public void plotRatios() {
ogtCycleRatioPlotsAnchorPane.getChildren().clear();

PlotWallPane plotsWallPane = PlotWallPane.createPlotWallPane("OGTripoliSession");
PlotWallPane plotsWallPane = PlotWallPane.createPlotWallPane("OGTripoliSession", analysis, null, analysisManagerCallbackI);
PlotWallPane.menuOffset = 0.0;
plotsWallPane.setBackground(new Background(new BackgroundFill(Paint.valueOf("LINEN"), null, null)));
plotsWallPane.setPrefSize(ogtCycleRatioPlotsAnchorPane.getPrefWidth(), ogtCycleRatioPlotsAnchorPane.getPrefHeight());

plotsWallPane.prefWidthProperty().bind(ogtCycleRatioPlotsAnchorPane.widthProperty());
plotsWallPane.prefHeightProperty().bind(ogtCycleRatioPlotsAnchorPane.heightProperty());

ogtCycleRatioPlotsAnchorPane.getChildren().add(plotsWallPane);
plotWindowVBox.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
plotsWallPane.stackPlots();
}
});
plotWindowVBox.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
plotsWallPane.stackPlots();
}
});

SingleBlockModelRecord[] singleBlockModelRecords = plottingData.singleBlockModelRecords();
int countOfOnPeakCycles = singleBlockModelRecords[0].cycleCount();
Expand All @@ -82,6 +118,7 @@ private void plotRatios() {

for (IsotopicRatio isotopicRatio : ratiosToPlot) {
TripoliPlotPane tripoliPlotPane = TripoliPlotPane.makePlotPane(plotsWallPane);

List<BlockRatioCyclesRecord> blockRatioCyclesRecords = new ArrayList<>();
for (int blockIndex = 0; blockIndex < singleBlockModelRecords.length; blockIndex++) {
int blockStatus = analysis.getMapOfBlockIdToProcessStatus().get(blockIndex + 1);
Expand All @@ -102,8 +139,11 @@ private void plotRatios() {
blockRatioCyclesRecords, new String[]{isotopicRatio.prettyPrint()},
"Blocks & Cycles by Time", "Ratio");
AbstractPlot plot = BlockRatioCyclesSessionPlot.generatePlot(
new Rectangle(minPlotWidth, minPlotHeight), blockRatioCyclesSessionBuilder.getBlockRatioCyclesSessionRecord());
new Rectangle(minPlotWidth, minPlotHeight), blockRatioCyclesSessionBuilder.getBlockRatioCyclesSessionRecord(), plotsWallPane);

tripoliPlotPane.addPlot(plot);
plot.refreshPanel(false, false);

}
plotsWallPane.buildScaleControlsToolbar();
plotsWallPane.stackPlots();
Expand All @@ -115,8 +155,25 @@ private void plotOnPeakIntensities() {
PlotWallPane.menuOffset = 0.0;
plotsWallPane.setBackground(new Background(new BackgroundFill(Paint.valueOf("LINEN"), null, null)));
plotsWallPane.setPrefSize(ogtSpeciesIntensitiesPlotAnchorPane.getPrefWidth(), ogtSpeciesIntensitiesPlotAnchorPane.getPrefHeight() + PlotWallPaneOGTripoli.toolBarHeight * 2.0);

plotsWallPane.prefWidthProperty().bind(ogtSpeciesIntensitiesPlotAnchorPane.widthProperty());
plotsWallPane.prefHeightProperty().bind(ogtSpeciesIntensitiesPlotAnchorPane.heightProperty());

ogtSpeciesIntensitiesPlotAnchorPane.getChildren().add(plotsWallPane);

plotWindowVBox.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
plotsWallPane.stackPlots();
}
});
plotWindowVBox.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
plotsWallPane.stackPlots();
}
});

SingleBlockRawDataSetRecord[] singleBlockRawDataSetRecords = plottingData.singleBlockRawDataSetRecords();
SingleBlockModelRecord[] singleBlockModelRecords = plottingData.singleBlockModelRecords();
// only plotting onPeaks
Expand Down Expand Up @@ -195,11 +252,13 @@ private void plotOnPeakIntensities() {
}

PlotBuilder plotBuilder = SpeciesIntensitySessionBuilder.initializeSpeciesIntensitySessionPlot(
xAxis, onPeakDataCounts, onPeakDataAmpResistance, onPeakBaseline, onPeakGain, new String[]{"Species Intensity by Session"}, "Time", "Intensity (counts)");
xAxis, onPeakDataCounts, onPeakDataAmpResistance, onPeakBaseline, onPeakGain, new String[]{"Species Intensity by Session"}, "Time (secs)", "Intensity (counts)");

TripoliPlotPane tripoliPlotPane = TripoliPlotPane.makePlotPane(plotsWallPane);
AbstractPlot plot = SpeciesIntensitySessionPlot.generatePlot(new Rectangle(minPlotWidth, minPlotHeight), (SpeciesIntensitySessionBuilder) plotBuilder);
tripoliPlotPane.addPlot(plot);
plot.refreshPanel(false, false);

plotsWallPane.buildOGTripoliToolBar(analysis.getAnalysisMethod().getSpeciesList());
plotsWallPane.buildScaleControlsToolbar();
plotsWallPane.stackPlots();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static void quit() {
} catch (TripoliException squidException) {
TripoliMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
}
// todo: confirmSaveOnProjectClose();
// todo: confirmSaveOnSessionClose();
System.out.println("Tripoli quitting normally.");
Platform.exit();
System.exit(0);
Expand Down Expand Up @@ -156,6 +156,8 @@ private void removeAllManagers() throws TripoliException {
manager.setVisible(false);
}

AnalysisManagerController.closePlotWindows();

// prevent stacking of panes
splashAnchor.getChildren().remove(sessionManagerUI);
splashAnchor.getChildren().remove(analysesManagerUI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public enum ConstantsTripoliApp {
//https://docs.oracle.com/javase/8/javafx/api/javafx/scene/paint/Color.html
public static final String[] TRIPOLI_PALLETTE_FOUR = {"RED", "BLUE", "GREEN", "BLACK", "ORANGE", "INDIGO", "#35978f", "#01665e"};

public static final Color TRIPOLI_MOVING_SHADE = new Color(255.0 / 256.0, 182.0 / 256.0, 193.0 / 256.0, 0.5);

public static @NonNls String convertColorToHex(Color color) {
String red = Integer.toHexString((int) (color.getRed() * 255));
String green = Integer.toHexString((int) (color.getGreen() * 255));
Expand All @@ -49,5 +51,11 @@ public enum ConstantsTripoliApp {
return "#" + red + green + blue;
}

public static enum PlotLayoutStyle {
TILE(),
STACK(),
CASCADE();
}


}
Loading

0 comments on commit 61a762b

Please sign in to comment.