Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

15may2024 #238

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.Dragboard;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.input.*;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
Expand All @@ -26,7 +24,6 @@
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import org.cirdles.tripoli.constants.TripoliConstants;
import org.cirdles.tripoli.expressions.species.IsotopicRatio;
import org.cirdles.tripoli.expressions.species.SpeciesRecordInterface;
import org.cirdles.tripoli.expressions.userFunctions.UserFunction;
Expand All @@ -37,8 +34,6 @@
import org.cirdles.tripoli.gui.dialogs.TripoliMessageDialog;
import org.cirdles.tripoli.sessions.analysis.Analysis;
import org.cirdles.tripoli.sessions.analysis.AnalysisInterface;
import org.cirdles.tripoli.sessions.analysis.AnalysisStatsRecord;
import org.cirdles.tripoli.sessions.analysis.GeometricMeanStatsRecord;
import org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataModels.dataLiteOne.initializers.AllBlockInitForDataLiteOne;
import org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataModels.mcmc.initializers.AllBlockInitForMCMC;
import org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataSourceProcessors.MassSpecOutputBlockRecordFull;
Expand All @@ -47,7 +42,6 @@
import org.cirdles.tripoli.sessions.analysis.methods.baseline.BaselineCell;
import org.cirdles.tripoli.sessions.analysis.methods.sequence.SequenceCell;
import org.cirdles.tripoli.sessions.analysis.outputs.etRedux.ETReduxFraction;
import org.cirdles.tripoli.sessions.analysis.outputs.etRedux.MeasuredRatioModel;
import org.cirdles.tripoli.utilities.exceptions.TripoliException;
import org.cirdles.tripoli.utilities.stateUtilities.TripoliPersistentState;

Expand All @@ -59,15 +53,13 @@
import java.util.*;
import java.util.stream.Collectors;

import static java.lang.StrictMath.exp;
import static org.cirdles.tripoli.constants.TripoliConstants.MISSING_STRING_FIELD;
import static org.cirdles.tripoli.constants.TripoliConstants.TRIPOLI_RATIO_FLIPPER_URL;
import static org.cirdles.tripoli.constants.TripoliConstants.ReductionModeEnum;
import static org.cirdles.tripoli.gui.constants.ConstantsTripoliApp.*;
import static org.cirdles.tripoli.gui.dialogs.TripoliMessageDialog.showChoiceDialog;
import static org.cirdles.tripoli.gui.utilities.UIUtilities.showTab;
import static org.cirdles.tripoli.gui.utilities.fileUtilities.FileHandlerUtil.*;
import static org.cirdles.tripoli.sessions.analysis.Analysis.*;
import static org.cirdles.tripoli.sessions.analysis.GeometricMeanStatsRecord.generateGeometricMeanStats;
import static org.cirdles.tripoli.sessions.analysis.methods.AnalysisMethod.compareAnalysisMethodToDataFileSpecs;

public class AnalysisManagerController implements Initializable, AnalysisManagerCallbackI {
Expand Down Expand Up @@ -107,6 +99,7 @@ public class AnalysisManagerController implements Initializable, AnalysisManager
public ScrollPane ratiosScrollPane;
public ScrollPane functionsScrollPane;
public Button exportToETReduxButton;
public Button exportToClipBoardButton;
@FXML
private GridPane analysisManagerGridPane;
@FXML
Expand Down Expand Up @@ -260,8 +253,16 @@ public void initialize(URL location, ResourceBundle resources) {
// throw new RuntimeException(e);
}

ImageView imageView = new ImageView(getClass().getResource("/" + TRIPOLI_CLIPBOARD_ICON).toExternalForm());
exportToClipBoardButton.setGraphic(imageView);
exportToClipBoardButton.setPadding(new Insets(0, 0, 0, 0));
exportToClipBoardButton.setMaxHeight(35);

exportToETReduxButton.setDisable(analysis.getMassSpecExtractedData().getBlocksDataLite().isEmpty());
reviewSculptData.setDisable(analysis.getMassSpecExtractedData().getBlocksDataLite().isEmpty());
reviewSculptData.setDisable(
analysis.getMassSpecExtractedData().getBlocksDataLite().isEmpty()
&& analysis.getMassSpecExtractedData().getBlocksDataFull().isEmpty());
exportToClipBoardButton.setDisable(analysis.getMassSpecExtractedData().getBlocksDataLite().isEmpty());

}

Expand Down Expand Up @@ -650,17 +651,19 @@ private void populateAnalysisMethodColumnsSelectorPane() {
blockRB.setToggleGroup(meanTG);
blockRB.setUserData(userFunction);
blockRB.selectedProperty().addListener((observable, oldValue, newValue)
-> userFunction.setReductionMode(TripoliConstants.ReductionModeEnum.BLOCK));
blockRB.setSelected(userFunction.getReductionMode().equals(TripoliConstants.ReductionModeEnum.BLOCK));
-> userFunction.setReductionMode(ReductionModeEnum.BLOCK));
blockRB.setSelected(userFunction.getReductionMode().equals(ReductionModeEnum.BLOCK));
blockRB.setDisable(!userFunction.isDisplayed());
blockRB.setPrefWidth(100);
blockMeanRBs.add(blockRB);

RadioButton cycleRB = new RadioButton(userFunction.showCycleMean());
cycleRB.setToggleGroup(meanTG);
cycleRB.setUserData(userFunction);
cycleRB.selectedProperty().addListener((observable, oldValue, newValue)
-> userFunction.setReductionMode(TripoliConstants.ReductionModeEnum.CYCLE));
cycleRB.setSelected(userFunction.getReductionMode().equals(TripoliConstants.ReductionModeEnum.CYCLE));
-> userFunction.setReductionMode(ReductionModeEnum.CYCLE));
cycleRB.setSelected(userFunction.getReductionMode().equals(ReductionModeEnum.CYCLE));
cycleRB.setDisable(!userFunction.isDisplayed());
cycleRB.setPrefWidth(100);
cycleMeanRBs.add(cycleRB);

Expand Down Expand Up @@ -907,15 +910,17 @@ public void selectDataFileButtonAction() {
// Proceed based on analysis case per https://docs.google.com/drawings/d/1U6-8LC55mHjHv8N7p6MAfKcdW8NibJSei3iTMT7E1A8/edit?usp=sharing
populateAnalysisManagerGridPane(analysis.getAnalysisCaseNumber());

processingToolBar.setDisable(null == analysis.getAnalysisMethod());
exportToETReduxButton.setDisable(analysis.getMassSpecExtractedData().getBlocksDataLite().isEmpty());
reviewSculptData.setDisable(analysis.getMassSpecExtractedData().getBlocksDataLite().isEmpty());

try {
previewAndSculptDataAction();
} catch (TripoliException e) {
throw new RuntimeException(e);
}
processingToolBar.setDisable(null == analysis.getAnalysisMethod());
exportToETReduxButton.setDisable(analysis.getMassSpecExtractedData().getBlocksDataLite().isEmpty());
reviewSculptData.setDisable(
analysis.getMassSpecExtractedData().getBlocksDataLite().isEmpty()
&& analysis.getMassSpecExtractedData().getBlocksDataFull().isEmpty());
exportToClipBoardButton.setDisable(analysis.getMassSpecExtractedData().getBlocksDataLite().isEmpty());

}
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | IOException |
Expand Down Expand Up @@ -1099,41 +1104,8 @@ public void knotsChoiceAction() {
}

public void exportToETReduxButtonAction() {
((Analysis) analysis).setEtReduxExportType(analysis.getAnalysisMethod().getUserFunctions().get(0).getEtReduxExportType());

ETReduxFraction etReduxFraction = ETReduxFraction.buildExportFraction(
analysis.getAnalysisSampleName(), analysis.getAnalysisFractionName(), ((Analysis) analysis).getEtReduxExportType(), 0.00205);
for (UserFunction uf : analysis.getAnalysisMethod().getUserFunctions()) {
String etReduxName = uf.getCorrectETReduxName();
if (!etReduxName.isBlank() && etReduxFraction.getMeasuredRatioByName(etReduxName) != null) {
AnalysisStatsRecord analysisStatsRecord = uf.getAnalysisStatsRecord();
MeasuredRatioModel measuredRatioModel = etReduxFraction.getMeasuredRatioByName(etReduxName);
double selectedMean;
double selectedOneSigmaPct;
if (uf.getReductionMode().equals(TripoliConstants.ReductionModeEnum.BLOCK)) {
double geoWeightedMeanRatio = exp(analysisStatsRecord.blockModeWeightedMean());
double geoWeightedMeanRatioPlusOneSigma = exp(analysisStatsRecord.blockModeWeightedMean() + analysisStatsRecord.blockModeWeightedMeanOneSigma());
double geoWeightedMeanRatioPlusOneSigmaPct = (geoWeightedMeanRatioPlusOneSigma - geoWeightedMeanRatio) / geoWeightedMeanRatio * 100.0;

selectedMean = geoWeightedMeanRatio;
selectedOneSigmaPct = geoWeightedMeanRatioPlusOneSigmaPct;

} else {
GeometricMeanStatsRecord geometricMeanStatsRecord =
generateGeometricMeanStats(analysisStatsRecord.cycleModeMean(), analysisStatsRecord.cycleModeStandardDeviation(), analysisStatsRecord.cycleModeStandardError());
double geoMean = geometricMeanStatsRecord.geoMean();
double geoMeanPlusOneStandardError = geometricMeanStatsRecord.geoMeanPlusOneStdErr();
double geoMeanRatioPlusOneStdErrPct = (geoMeanPlusOneStandardError - geoMean) / geoMean * 100.0;

selectedMean = geoMean;
selectedOneSigmaPct = geoMeanRatioPlusOneStdErrPct;
}
measuredRatioModel.setValue(selectedMean);
measuredRatioModel.setOneSigma(selectedOneSigmaPct);
measuredRatioModel.setUncertaintyType("PCT");
measuredRatioModel.setOxideCorr(uf.isOxideCorrected());
}
}
ETReduxFraction etReduxFraction = analysis.prepareFractionForETReduxExport();
String fileName = etReduxFraction.getSampleName() + "_" + etReduxFraction.getFractionID() + "_" + etReduxFraction.getEtReduxExportType() + ".xml";
etReduxFraction.serializeXMLObject(fileName);
try {
Expand All @@ -1143,7 +1115,14 @@ public void exportToETReduxButtonAction() {
} catch (TripoliException e) {
throw new RuntimeException(e);
}
}

public void exportToClipboardAction() {
String clipBoardString = analysis.prepareFractionForClipboardExport();
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(clipBoardString);
clipboard.setContent(content);
}

class RatioClickHandler implements EventHandler<MouseEvent> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
import java.util.List;
import java.util.ResourceBundle;

import static org.cirdles.tripoli.constants.TripoliConstants.TRIPOLI_LOGO_SANS_TEXT_URL;
import static org.cirdles.tripoli.gui.constants.ConstantsTripoliApp.TRIPOLI_LOGO_SANS_TEXT_URL;


/**
* @author James F. Bowring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import static org.cirdles.tripoli.constants.TripoliConstants.MISSING_STRING_FIELD;
import static org.cirdles.tripoli.gui.AnalysisManagerController.analysis;
import static org.cirdles.tripoli.gui.TripoliGUIController.tripoliPersistentState;
import static org.cirdles.tripoli.gui.TripoliGUIController.tripoliSession;
import static org.cirdles.tripoli.gui.constants.ConstantsTripoliApp.TRIPOLI_SESSION_LINEN;
import static org.cirdles.tripoli.gui.constants.ConstantsTripoliApp.convertColorToHex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.AnchorPane;
Expand All @@ -40,6 +42,7 @@
import org.cirdles.tripoli.sessions.Session;
import org.cirdles.tripoli.sessions.SessionBuiltinFactory;
import org.cirdles.tripoli.sessions.analysis.AnalysisInterface;
import org.cirdles.tripoli.sessions.analysis.outputs.etRedux.ETReduxFraction;
import org.cirdles.tripoli.utilities.exceptions.TripoliException;
import org.cirdles.tripoli.utilities.stateUtilities.TripoliPersistentState;
import org.cirdles.tripoli.utilities.stateUtilities.TripoliSerializer;
Expand Down Expand Up @@ -96,6 +99,7 @@ public class TripoliGUIController implements Initializable {
public HBox latestVersionHBox;
@FXML
public Label newVersionLabel;
public Menu reportsMenu;
@FXML // ResourceBundle that was given to the FXMLLoader
private ResourceBundle resources;
@FXML // URL location of the FXML file that was given to the FXMLLoader
Expand Down Expand Up @@ -397,7 +401,7 @@ private void saveAsSession() throws TripoliException {
void closeSessionMenuItemAction() throws TripoliException, IOException {
confirmSaveOnProjectClose();
removeAllManagers();
// launchSessionManager();
// launchSessionManager();
TripoliGUI.updateStageTitle("");
tripoliSession = null;
SessionManagerController.tripoliSession = tripoliSession;
Expand Down Expand Up @@ -539,4 +543,24 @@ public void visitLatestVersionAction() {
}


public void etReduxExportAction() {
ETReduxFraction etReduxFraction = analysis.prepareFractionForETReduxExport();
String fileName = etReduxFraction.getSampleName() + "_" + etReduxFraction.getFractionID() + "_" + etReduxFraction.getEtReduxExportType() + ".xml";
etReduxFraction.serializeXMLObject(fileName);
try {
saveExportFile(etReduxFraction, null);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (TripoliException e) {
throw new RuntimeException(e);
}
}

public void clipboardExportAction() {
String clipBoardString = analysis.prepareFractionForClipboardExport();
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(clipBoardString);
clipboard.setContent(content);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
*/
public enum ConstantsTripoliApp {
;
public static final String TRIPOLI_LOGO_SANS_TEXT_URL = "org/cirdles/tripoli/gui/images/TripoliJune2022.png";
public static final String TRIPOLI_RATIO_FLIPPER_URL = "org/cirdles/tripoli/gui/images/RotateFlip.png";
public static final String TRIPOLI_MICHAELANGELO_URL = "org/cirdles/tripoli/gui/images/noun-michelangelo-5298215.png";
public static final String TRIPOLI_CLIPBOARD_ICON = "org/cirdles/tripoli/gui/images/noun-copy-to-clipboard-3401852c.png";

public static final Color TRIPOLI_STARTING_YELLOW = new Color(243.0 / 256.0, 227.0 / 256.0, 118.0 / 256.0, 1.0);
public static final Color TRIPOLI_SESSION_LINEN = Color.LINEN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import java.util.List;

import static org.cirdles.tripoli.constants.TripoliConstants.TRIPOLI_MICHAELANGELO_URL;
import static org.cirdles.tripoli.gui.constants.ConstantsTripoliApp.TRIPOLI_MICHAELANGELO_URL;

/**
* @author James F. Bowring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.cirdles.tripoli.gui.utilities.TripoliColor;
import org.jetbrains.annotations.NotNull;

import static org.cirdles.tripoli.constants.TripoliConstants.TRIPOLI_MICHAELANGELO_URL;
import static org.cirdles.tripoli.gui.constants.ConstantsTripoliApp.TRIPOLI_MICHAELANGELO_URL;
import static org.cirdles.tripoli.gui.dataViews.plots.PlotWallPane.gridCellDim;
import static org.cirdles.tripoli.gui.dataViews.plots.PlotWallPane.menuOffset;
import static org.cirdles.tripoli.gui.dataViews.plots.plotsControllers.ogTripoliPlots.OGTripoliViewController.analysis;
Expand Down Expand Up @@ -305,7 +305,7 @@ public void addPlot(AbstractPlot plot) {

public void builtSculptingHBox(String message) {
// Michaelangelo sculpting
final ImageView michaelangeloImageView = new ImageView();
ImageView michaelangeloImageView = new ImageView();
Image ratioFlipper = new Image(TRIPOLI_MICHAELANGELO_URL);
michaelangeloImageView.setImage(ratioFlipper);
michaelangeloImageView.setFitHeight(18);
Expand Down Expand Up @@ -453,6 +453,8 @@ public void updateAnalysisRatiosPlotted(boolean blockMode, boolean logScale, boo
if (plot != null && (plot instanceof AnalysisBlockCyclesPlotI)) {
((AnalysisBlockCyclesPlotI) plot).setBlockMode(blockMode);
((AnalysisBlockCyclesPlotI) plot).setLogScale(logScale);
((AnalysisBlockCyclesPlotI) plot).getUserFunction().setReductionMode(
blockMode ? TripoliConstants.ReductionModeEnum.BLOCK : TripoliConstants.ReductionModeEnum.CYCLE);

cycleCB.selectedProperty().removeListener(cycleCheckBoxChangeListener);
cycleCB.setSelected(!blockMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import org.cirdles.tripoli.expressions.userFunctions.UserFunction;
import org.cirdles.tripoli.gui.dataViews.plots.AbstractPlot;
import org.cirdles.tripoli.gui.dataViews.plots.PlotWallPane;
import org.cirdles.tripoli.gui.dataViews.plots.PlotWallPaneInterface;
Expand Down Expand Up @@ -128,6 +129,14 @@ public boolean detectAllIncludedStatus() {
return false;
}

/**
* @return
*/
@Override
public UserFunction getUserFunction() {
return null;
}

public Map<Integer, PlotBlockCyclesRecord> getMapBlockIdToBlockCyclesRecord() {
return mapBlockIdToBlockCyclesRecord;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cirdles.tripoli.gui.dataViews.plots.plotsControllers.ogTripoliPlots.analysisPlots;

import org.cirdles.tripoli.expressions.userFunctions.UserFunction;
import org.cirdles.tripoli.plots.analysisPlotBuilders.AnalysisBlockCyclesRecord;
import org.cirdles.tripoli.plots.compoundPlotBuilders.PlotBlockCyclesRecord;

Expand Down Expand Up @@ -39,4 +40,6 @@ public interface AnalysisBlockCyclesPlotI {
void performChauvenets();

boolean detectAllIncludedStatus();

UserFunction getUserFunction();
}
Loading