Search in sources :

Example 1 with SquidException

use of org.cirdles.squid.exceptions.SquidException in project Squid by CIRDLES.

the class CommonLeadAssignmentController method init.

private void init() throws SquidException {
    // update
    try {
        squidProject.getTask().setupSquidSessionSpecsAndReduceAndReport(false);
    } catch (SquidException squidException) {
        SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
    }
    spotsTreeViewCommonLeadTools.prefWidthProperty().bind(primaryStageWindow.getScene().widthProperty());
    spotsTreeViewCommonLeadTools.prefHeightProperty().bind(primaryStageWindow.getScene().heightProperty().subtract(PIXEL_OFFSET_FOR_MENU + headerHBox.getPrefHeight() + headerHBoxForCorrections.getPrefHeight() + footerHBox.getPrefHeight()));
    // prime StaceyKramer
    StaceyKramerCommonLeadModel.updatePhysicalConstants(squidProject.getTask().getPhysicalConstantsModel());
    StaceyKramerCommonLeadModel.updateU_Ratio(squidProject.getTask().getReferenceMaterialModel().getDatumByName(REF_238U235U_RM_MODEL_NAME).getValue().doubleValue());
    setupAgeTypes();
    // set up groups and refresh calculations
    mapOfSpotsBySampleNames = squidProject.getTask().getMapOfUnknownsBySampleNames();
    // case of sample names chosen
    if (mapOfSpotsBySampleNames.size() > 1) {
        // task.getMapOfUnknownsBySampleNames restores this global set
        mapOfSpotsBySampleNames.remove(Squid3Constants.SpotTypes.UNKNOWN.getSpotTypeName());
    }
    mapOfWeightedMeansBySampleNames = new TreeMap<>();
    for (Map.Entry<String, List<ShrimpFractionExpressionInterface>> entry : mapOfSpotsBySampleNames.entrySet()) {
        ((Task) squidProject.getTask()).evaluateUnknownsWithChangedParameters(entry.getValue());
        SpotSummaryDetails spotSummaryDetails = ((Task) squidProject.getTask()).evaluateSelectedAgeWeightedMeanForUnknownGroup(entry.getKey(), entry.getValue());
        mapOfWeightedMeansBySampleNames.put(entry.getKey(), spotSummaryDetails);
    }
    showUnknownsWithOvercountCorrections();
    switch(squidProject.getTask().getOvercountCorrectionType()) {
        case NONE:
            correctionNoneRB.setSelected(true);
            break;
        case FR_207:
            correction207RB.setSelected(true);
            break;
        case FR_208:
            correction208RB.setSelected(true);
    }
    setUpHeader();
    setUpFooter();
}
Also used : Task(org.cirdles.squid.tasks.Task) SquidException(org.cirdles.squid.exceptions.SquidException) SpotSummaryDetails(org.cirdles.squid.tasks.expressions.spots.SpotSummaryDetails)

Example 2 with SquidException

use of org.cirdles.squid.exceptions.SquidException in project Squid by CIRDLES.

the class AnyTwoExpressionsControlNode method initNode.

private void initNode() throws SquidException {
    setStyle("-fx-padding: 1;" + "-fx-background-color: white;" + "-fx-border-width: 2;" + "-fx-border-insets: 0 2 0 2;" + "-fx-border-radius: 4;" + "-fx-border-color: blue;-fx-effect: null;");
    setPrefHeight(23);
    setHeight(23);
    setFillHeight(true);
    setAlignment(Pos.CENTER);
    mapOfNamedExpressions = squidProject.getTask().getNamedExpressionsMap();
    List<String> sortedAvailableExpressions = new ArrayList<>();
    for (Entry<String, ExpressionTreeInterface> entry : mapOfNamedExpressions.entrySet()) {
        if (entry.getValue().amHealthy() && entry.getValue().isSquidSwitchSTReferenceMaterialCalculation() && !entry.getValue().isSquidSwitchSCSummaryCalculation() && !(entry.getValue() instanceof ShrimpSpeciesNode) && !(entry.getValue() instanceof ConstantNode) && (!(entry.getValue() instanceof SpotFieldNode) || ((entry.getValue() instanceof SpotFieldNode) && entry.getKey().equals("Hours")))) {
            sortedAvailableExpressions.add(entry.getKey());
        }
    }
    CheckBox showExcludedSpotsCheckBox = new CheckBox("Plot Excluded");
    showExcludedSpotsCheckBox.setSelected(plotExcluded);
    formatNode(showExcludedSpotsCheckBox, 100);
    showExcludedSpotsCheckBox.setOnAction(mouseEvent -> {
        plotsController.showExcludedSpots(showExcludedSpotsCheckBox.isSelected());
        plotExcluded = showExcludedSpotsCheckBox.isSelected();
    });
    getChildren().addAll(showExcludedSpotsCheckBox, separator(20.0F));
    Label xAxisChooseLabel = new Label("Choose X-axis expression:");
    formatNode(xAxisChooseLabel, 160);
    formatNode(xAxisExpressionComboBox, 150);
    xAxisExpressionComboBox.setItems(FXCollections.observableArrayList(sortedAvailableExpressions));
    xAxisExpressionComboBox.setValue(PlotsController.xAxisExpressionName);
    xAxisExpressionComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
        try {
            plotsController.setXAxisExpressionName(newValue);
        } catch (SquidException squidException) {
        }
    });
    Label yAxisChooseLabel = new Label(" Choose Y-axis expression:");
    formatNode(yAxisChooseLabel, 160);
    formatNode(yAxisExpressionComboBox, 150);
    yAxisExpressionComboBox.setItems(FXCollections.observableArrayList(sortedAvailableExpressions));
    yAxisExpressionComboBox.setValue(PlotsController.yAxisExpressionName);
    yAxisExpressionComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
        try {
            plotsController.setYAxisExpressionName(newValue);
        } catch (SquidException squidException) {
        }
    });
    getChildren().addAll(yAxisChooseLabel, yAxisExpressionComboBox, xAxisChooseLabel, xAxisExpressionComboBox, separator(20.0F));
    regressionCheckBox = new CheckBox("2D Regression");
    regressionCheckBox.setSelected(false);
    formatNode(regressionCheckBox, 100);
    regressionCheckBox.setOnAction(mouseEvent -> {
        boolean isRegression = regressionCheckBox.isSelected();
        PlotsController.plot.setProperty(MCLEAN_REGRESSION.getTitle(), isRegression);
    });
    regressionCheckBox.disableProperty().bind(Bindings.not(new SimpleBooleanProperty(hasData)));
    getChildren().add(regressionCheckBox);
    CheckBox regressionUnctEnvelopeCheckBox = new CheckBox("2D Regression Unct");
    regressionUnctEnvelopeCheckBox.setSelected(false);
    formatNode(regressionUnctEnvelopeCheckBox, 125);
    regressionUnctEnvelopeCheckBox.setOnAction(mouseEvent -> {
        PlotsController.plot.setProperty(MCLEAN_REGRESSION_ENVELOPE.getTitle(), regressionUnctEnvelopeCheckBox.isSelected());
    });
    regressionUnctEnvelopeCheckBox.disableProperty().bind(Bindings.not(regressionCheckBox.selectedProperty().and(new SimpleBooleanProperty(((AbstractTopsoilPlot) PlotsController.plot).isHasUncertainties()))));
    getChildren().add(regressionUnctEnvelopeCheckBox);
    Label announce = new Label(" * Means coming soon!");
    formatNode(yAxisChooseLabel, 160);
    getChildren().add(announce);
}
Also used : SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SpotFieldNode(org.cirdles.squid.tasks.expressions.spots.SpotFieldNode) ArrayList(java.util.ArrayList) Label(javafx.scene.control.Label) AbstractTopsoilPlot(org.cirdles.squid.gui.dateInterpretations.plots.topsoil.AbstractTopsoilPlot) ShrimpSpeciesNode(org.cirdles.squid.tasks.expressions.isotopes.ShrimpSpeciesNode) ExpressionTreeInterface(org.cirdles.squid.tasks.expressions.expressionTrees.ExpressionTreeInterface) ConstantNode(org.cirdles.squid.tasks.expressions.constants.ConstantNode) SquidException(org.cirdles.squid.exceptions.SquidException) CheckBox(javafx.scene.control.CheckBox)

Example 3 with SquidException

use of org.cirdles.squid.exceptions.SquidException in project Squid by CIRDLES.

the class PlotsController method showAnyTwoExpressions.

private void showAnyTwoExpressions() throws SquidException {
    spotsTreeViewCheckBox = new CheckTreeView<>();
    spotsTreeViewCheckBox.setStyle(SPOT_TREEVIEW_CSS_STYLE_SPECS);
    final List<ShrimpFractionExpressionInterface> allRefMatShrimpFractions;
    Map<String, List<ShrimpFractionExpressionInterface>> mapOfSpotsBySampleNames;
    // ref mat
    allRefMatShrimpFractions = squidProject.getTask().getReferenceMaterialSpots();
    mapOfSpotsBySampleNames = new TreeMap<>();
    mapOfSpotsBySampleNames.put("Ref Mat " + ((Task) squidProject.getTask()).getFilterForRefMatSpotNames(), squidProject.getTask().getReferenceMaterialSpots());
    // need current physical constants for plotting of data
    ParametersModel physicalConstantsModel = squidProject.getTask().getPhysicalConstantsModel();
    // want plot choices sticky during execution
    if (mapOfPlotsOfSpotSets == null) {
        mapOfPlotsOfSpotSets = new TreeMap<>();
    }
    rootPlot = mapOfPlotsOfSpotSets.get("Ref Mat " + ((Task) squidProject.getTask()).getFilterForRefMatSpotNames() + xAxisExpressionName + yAxisExpressionName);
    if (rootPlot == null) {
        rootPlot = generateAnyTwoPlot(allRefMatShrimpFractions, physicalConstantsModel);
        mapOfPlotsOfSpotSets.put("Ref Mat " + ((Task) squidProject.getTask()).getFilterForRefMatSpotNames() + xAxisExpressionName + yAxisExpressionName, rootPlot);
    }
    rootData = new ArrayList<>();
    plot = rootPlot;
    List<SampleTreeNodeInterface> fractionNodeDetails = new ArrayList<>();
    // build out set of rootData for samples
    CheckBoxTreeItem<SampleTreeNodeInterface> rootItem = new CheckBoxTreeItem<>(new SampleNode(fractionTypeSelected.getSpotTypeName()));
    chosenSample = rootItem;
    rootItem.setExpanded(true);
    rootItem.setIndependent(true);
    rootItem.setSelected(true);
    rootItem.selectedProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            rootItem.getValue().setSelectedProperty(new SimpleBooleanProperty(newValue));
            ObservableList<TreeItem<SampleTreeNodeInterface>> mySamples = rootItem.getChildren();
            Iterator<TreeItem<SampleTreeNodeInterface>> mySamplesIterator = mySamples.iterator();
            while (mySamplesIterator.hasNext()) {
                CheckBoxTreeItem<SampleTreeNodeInterface> mySampleItem = (CheckBoxTreeItem<SampleTreeNodeInterface>) mySamplesIterator.next();
                mySampleItem.setSelected(newValue);
            }
            try {
                provisionAnyTwoToolbox(newValue);
            } catch (SquidException squidException) {
            }
        }
    });
    rootItem.indeterminateProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            try {
                provisionAnyTwoToolbox(newValue || rootItem.isSelected());
            } catch (SquidException squidException) {
            }
        }
    });
    spotsTreeViewCheckBox.setRoot(rootItem);
    spotsTreeViewCheckBox.setShowRoot((fractionTypeSelected.compareTo(SpotTypes.UNKNOWN) == 0));
    for (Map.Entry<String, List<ShrimpFractionExpressionInterface>> entry : mapOfSpotsBySampleNames.entrySet()) {
        CheckBoxTreeItem<SampleTreeNodeInterface> sampleItem = new CheckBoxTreeItem<>(new SampleNode(entry.getKey()));
        sampleItem.setSelected(true);
        rootItem.getChildren().add(sampleItem);
        List<Map<String, Object>> myData = new ArrayList<>();
        PlotDisplayInterface myPlotTry = mapOfPlotsOfSpotSets.get(sampleItem.getValue().getNodeName() + xAxisExpressionName + yAxisExpressionName);
        if (myPlotTry == null) {
            myPlotTry = generateAnyTwoPlot(entry.getValue(), physicalConstantsModel);
            mapOfPlotsOfSpotSets.put(sampleItem.getValue().getNodeName() + xAxisExpressionName + yAxisExpressionName, myPlotTry);
        }
        // final for listener
        final PlotDisplayInterface myPlot = myPlotTry;
        for (ShrimpFractionExpressionInterface spot : entry.getValue()) {
            SampleTreeNodeInterface fractionNode = new PlotAnyTwoFractionNode(spot, xAxisExpressionName, yAxisExpressionName);
            if (((PlotAnyTwoFractionNode) fractionNode).isValid()) {
                fractionNodeDetails.add(fractionNode);
                // handles each spot
                CheckBoxTreeItem<SampleTreeNodeInterface> checkBoxTreeSpotItem = new CheckBoxTreeItem<>(fractionNode);
                sampleItem.getChildren().add(checkBoxTreeSpotItem);
                checkBoxTreeSpotItem.setIndependent(false);
                checkBoxTreeSpotItem.setSelected(fractionNode.getSelectedProperty().getValue());
                myData.add(fractionNode.getDatum());
                // this contains all samples at the tree top
                rootData.add(fractionNode.getDatum());
                checkBoxTreeSpotItem.selectedProperty().addListener(new ChangeListener<Boolean>() {

                    @Override
                    public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                        checkBoxTreeSpotItem.getValue().setSelectedProperty(new SimpleBooleanProperty(newValue));
                        myPlot.setData(myData);
                    }
                });
            }
        }
        myPlot.setData(myData);
        // this sample item contains all the spot item checkboxes
        sampleItem.setIndependent(false);
        sampleItem.setExpanded(fractionTypeSelected.compareTo(SpotTypes.REFERENCE_MATERIAL) == 0);
        sampleItem.selectedProperty().addListener(new ChangeListener<Boolean>() {

            @Override
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                myPlot.setData(myData);
                rootPlot.setData(rootData);
            }
        });
        if (currentlyPlottedSampleTreeNode == null) {
            currentlyPlottedSampleTreeNode = sampleItem;
        }
    }
    rootPlot.setData(rootData);
    fractionNodes = FXCollections.observableArrayList(fractionNodeDetails);
    spotsTreeViewCheckBox.setCellFactory(cell -> new CheckBoxTreeCell<>((TreeItem<SampleTreeNodeInterface> item) -> item.getValue().getSelectedProperty(), new StringConverter<TreeItem<SampleTreeNodeInterface>>() {

        @Override
        public String toString(TreeItem<SampleTreeNodeInterface> object) {
            SampleTreeNodeInterface item = object.getValue();
            String nodeString = "";
            try {
                nodeString = item.getNodeName();
            } catch (SquidException squidException) {
            }
            if ((object.getParent() != null) && !(item instanceof SampleNode)) {
                double[][] expressionValues = item.getShrimpFraction().getTaskExpressionsEvaluationsPerSpotByField((fractionTypeSelected.compareTo(SpotTypes.REFERENCE_MATERIAL) == 0) ? PB4COR206_238AGE_RM : PB4COR206_238AGE);
                double uncertainty = 0.0;
                if (expressionValues[0].length > 1) {
                    uncertainty = expressionValues[0][1];
                }
                String ageOrValueSource = WeightedMeanPlot.makeAgeString(expressionValues[0][0], uncertainty);
                try {
                    nodeString += "  " + ageOrValueSource + " (" + squid3RoundedToSize(((Double) item.getDatum().get(X.getTitle())), 5) + ", " + squid3RoundedToSize(((Double) item.getDatum().get(Y.getTitle())), 5) + ")";
                } catch (Exception e) {
                }
            }
            return nodeString;
        }

        @Override
        public TreeItem<SampleTreeNodeInterface> fromString(String string) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }));
    spotListAnchorPane.getChildren().clear();
    spotListAnchorPane.getChildren().add(spotsTreeViewCheckBox);
    spotsTreeViewCheckBox.prefHeightProperty().bind(spotListAnchorPane.prefHeightProperty());
    spotsTreeViewCheckBox.prefWidthProperty().bind(spotListAnchorPane.prefWidthProperty());
    topsoilPlotsCheckBoxListener = (observable, oldValue, newValue) -> {
        rootPlot.setData(rootData);
        try {
            if (newValue.getValue() instanceof SampleNode) {
                if (newValue.getValue().getNodeName().equals(SpotTypes.UNKNOWN.getSpotTypeName())) {
                    plot = rootPlot;
                } else if (chosenSample != newValue) {
                    plot = mapOfPlotsOfSpotSets.get(newValue.getValue().getNodeName() + xAxisExpressionName + yAxisExpressionName);
                }
                chosenSample = (CheckBoxTreeItem<SampleTreeNodeInterface>) newValue;
                currentlyPlottedSampleTreeNode = chosenSample;
            }
        } catch (Exception e) {
        }
        refreshPlot();
    };
    spotsTreeViewCheckBox.getSelectionModel().selectedItemProperty().addListener(topsoilPlotsCheckBoxListener);
    spotsTreeViewCheckBox.getSelectionModel().select(currentlyPlottedSampleTreeNode);
    currentlyPlottedSampleTreeNode.setExpanded(true);
    provisionAnyTwoToolbox(true);
}
Also used : Task(org.cirdles.squid.tasks.Task) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) ParametersModel(org.cirdles.squid.parameters.parameterModels.ParametersModel) ObservableList(javafx.collections.ObservableList) SampleTreeNodeInterface(org.cirdles.squid.gui.dataViews.SampleTreeNodeInterface) StringConverter(javafx.util.StringConverter) SquidException(org.cirdles.squid.exceptions.SquidException) PlotDisplayInterface(org.cirdles.squid.gui.dateInterpretations.plots.PlotDisplayInterface) SquidException(org.cirdles.squid.exceptions.SquidException) ObservableList(javafx.collections.ObservableList) ShrimpFractionExpressionInterface(org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface) SampleNode(org.cirdles.squid.gui.dataViews.SampleNode)

Example 4 with SquidException

use of org.cirdles.squid.exceptions.SquidException in project Squid by CIRDLES.

the class PlotsController method showConcordiaPlotsOfUnknownsOrRefMat.

private void showConcordiaPlotsOfUnknownsOrRefMat() {
    // may 2020 new approach per Nicole
    if (vboxMaster.getChildren().get(0) instanceof ToolBoxNodeInterface) {
        vboxMaster.getChildren().remove(0);
    }
    HBox toolBox = new ConcordiaControlNode(this);
    vboxMaster.getChildren().add(0, toolBox);
    spotsTreeViewCheckBox = new CheckTreeView<>();
    spotsTreeViewCheckBox.setStyle(SPOT_TREEVIEW_CSS_STYLE_SPECS);
    spotsTreeViewString.setStyle(SPOT_TREEVIEW_CSS_STYLE_SPECS);
    final List<ShrimpFractionExpressionInterface> allUnknownOrRefMatShrimpFractions;
    Map<String, List<ShrimpFractionExpressionInterface>> mapOfSpotsBySampleNames;
    if (fractionTypeSelected.compareTo(SpotTypes.UNKNOWN) == 0) {
        allUnknownOrRefMatShrimpFractions = squidProject.getTask().getUnknownSpots();
        mapOfSpotsBySampleNames = squidProject.getTask().getMapOfUnknownsBySampleNames();
        // case of sample names chosen
        if (mapOfSpotsBySampleNames.size() > 1) {
            mapOfSpotsBySampleNames.remove(SpotTypes.UNKNOWN.getSpotTypeName());
        }
    } else {
        // ref mat
        allUnknownOrRefMatShrimpFractions = squidProject.getTask().getReferenceMaterialSpots();
        mapOfSpotsBySampleNames = new TreeMap<>();
        mapOfSpotsBySampleNames.put("Ref Mat " + ((Task) squidProject.getTask()).getFilterForRefMatSpotNames(), squidProject.getTask().getReferenceMaterialSpots());
        // mapOfSpotsBySampleNames.put("Concentration Ref Mat", squidProject.getTask().getConcentrationReferenceMaterialSpots());
        // used to synchronize rejects between weighted mean and concordia
        spotSummaryDetails = squidProject.getTask().getTaskExpressionsEvaluationsPerSpotSet().get(WTDAV_PREFIX + correction + calibrConstAgeBaseName + "_CalibConst");
    }
    // need current physical contants for plotting of concordia etc.
    ParametersModel physicalConstantsModel = squidProject.getTask().getPhysicalConstantsModel();
    rootPlot = generateConcordiaPlot(fractionTypeSelected.getSpotTypeName(), allUnknownOrRefMatShrimpFractions, physicalConstantsModel);
    rootData = new ArrayList<>();
    List<SampleTreeNodeInterface> fractionNodeDetails = new ArrayList<>();
    // build out set of rootData for samples
    CheckBoxTreeItem<SampleTreeNodeInterface> rootItem = new CheckBoxTreeItem<>(new SampleNode(fractionTypeSelected.getSpotTypeName()));
    chosenSample = rootItem;
    rootItem.setExpanded(true);
    rootItem.setIndependent(true);
    rootItem.setSelected(true);
    rootItem.selectedProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            rootItem.getValue().setSelectedProperty(new SimpleBooleanProperty(newValue));
            ObservableList<TreeItem<SampleTreeNodeInterface>> mySamples = rootItem.getChildren();
            Iterator<TreeItem<SampleTreeNodeInterface>> mySamplesIterator = mySamples.iterator();
            while (mySamplesIterator.hasNext()) {
                CheckBoxTreeItem<SampleTreeNodeInterface> mySampleItem = (CheckBoxTreeItem<SampleTreeNodeInterface>) mySamplesIterator.next();
                mySampleItem.setSelected(newValue);
            }
            plot = rootPlot;
            plot.setData(rootData);
        }
    });
    spotsTreeViewCheckBox.setRoot(rootItem);
    spotsTreeViewCheckBox.setShowRoot((fractionTypeSelected.compareTo(SpotTypes.UNKNOWN) == 0));
    // want plot choices sticky during execution
    if (mapOfPlotsOfSpotSets == null) {
        mapOfPlotsOfSpotSets = new TreeMap<>();
    }
    for (Map.Entry<String, List<ShrimpFractionExpressionInterface>> entry : mapOfSpotsBySampleNames.entrySet()) {
        CheckBoxTreeItem<SampleTreeNodeInterface> sampleItem = new CheckBoxTreeItem<>(new SampleNode(entry.getKey()));
        sampleItem.setSelected(true);
        rootItem.getChildren().add(sampleItem);
        if (currentlyPlottedSampleTreeNode == null) {
            currentlyPlottedSampleTreeNode = sampleItem;
        }
        List<Map<String, Object>> myData = new ArrayList<>();
        PlotDisplayInterface myPlotTry = mapOfPlotsOfSpotSets.get(entry.getKey() + topsoilPlotFlavor);
        if (myPlotTry == null) {
            myPlotTry = generateConcordiaPlot(entry.getKey(), entry.getValue(), physicalConstantsModel);
            mapOfPlotsOfSpotSets.put(entry.getKey() + topsoilPlotFlavor, myPlotTry);
        }
        // final for listener
        final PlotDisplayInterface myPlot = myPlotTry;
        for (ShrimpFractionExpressionInterface spot : entry.getValue()) {
            SampleTreeNodeInterface fractionNode = new ConcordiaFractionNode(topsoilPlotFlavor, spot, correction);
            if (((ConcordiaFractionNode) fractionNode).isValid()) {
                fractionNodeDetails.add(fractionNode);
                // handles each spot
                CheckBoxTreeItem<SampleTreeNodeInterface> checkBoxTreeSpotItem = new CheckBoxTreeItem<>(fractionNode);
                sampleItem.getChildren().add(checkBoxTreeSpotItem);
                // for ref material synchronize rejects
                if (doSynchIncludedSpotsBetweenConcordiaAndWM && (fractionTypeSelected.compareTo(SpotTypes.REFERENCE_MATERIAL) == 0)) {
                    fractionNode.setSelectedProperty(new SimpleBooleanProperty(!spotSummaryDetails.getRejectedIndices()[entry.getValue().indexOf(spot)]));
                }
                checkBoxTreeSpotItem.setIndependent(false);
                checkBoxTreeSpotItem.setSelected(fractionNode.getSelectedProperty().getValue());
                myData.add(fractionNode.getDatum());
                // this contains all samples at the tree top
                rootData.add(fractionNode.getDatum());
                checkBoxTreeSpotItem.selectedProperty().addListener(new ChangeListener<Boolean>() {

                    @Override
                    public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                        checkBoxTreeSpotItem.getValue().setSelectedProperty(new SimpleBooleanProperty(newValue));
                        myPlot.setData(myData);
                    }
                });
            }
        }
        myPlot.setData(myData);
        // this sample item contains all the spot item checkboxes
        sampleItem.setIndependent(false);
        sampleItem.setExpanded(fractionTypeSelected.compareTo(SpotTypes.REFERENCE_MATERIAL) == 0);
        sampleItem.selectedProperty().addListener(new ChangeListener<Boolean>() {

            @Override
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                myPlot.setData(myData);
                rootPlot.setData(rootData);
            }
        });
        if (currentlyPlottedSampleTreeNode == null) {
            currentlyPlottedSampleTreeNode = sampleItem;
        }
    }
    rootPlot.setData(rootData);
    fractionNodes = FXCollections.observableArrayList(fractionNodeDetails);
    spotsTreeViewCheckBox.setCellFactory(cell -> new CheckBoxTreeCell<>((TreeItem<SampleTreeNodeInterface> item) -> item.getValue().getSelectedProperty(), new StringConverter<TreeItem<SampleTreeNodeInterface>>() {

        @Override
        public String toString(TreeItem<SampleTreeNodeInterface> object) {
            SampleTreeNodeInterface item = object.getValue();
            String nodeString = "";
            try {
                nodeString = item.getNodeName();
            } catch (SquidException squidException) {
            }
            if ((object.getParent() != null) && !(item instanceof SampleNode)) {
                double[][] expressionValues = item.getShrimpFraction().getTaskExpressionsEvaluationsPerSpotByField((fractionTypeSelected.compareTo(SpotTypes.REFERENCE_MATERIAL) == 0) ? PB4COR206_238AGE_RM : PB4COR206_238AGE);
                double uncertainty = 0.0;
                if (expressionValues[0].length > 1) {
                    uncertainty = expressionValues[0][1];
                }
                String ageOrValueSource = WeightedMeanPlot.makeAgeString(expressionValues[0][0], uncertainty);
                nodeString += "  " + ageOrValueSource;
            }
            return nodeString;
        }

        @Override
        public TreeItem<SampleTreeNodeInterface> fromString(String string) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }));
    spotListAnchorPane.getChildren().clear();
    spotListAnchorPane.getChildren().add(spotsTreeViewCheckBox);
    spotsTreeViewCheckBox.prefHeightProperty().bind(spotListAnchorPane.prefHeightProperty());
    spotsTreeViewCheckBox.prefWidthProperty().bind(spotListAnchorPane.prefWidthProperty());
    // dec 2018 improvement suggested by Nicole Rayner to use checkboxes to select members
    // thus selecting tree item displays it and checkbox (see above) for a sample will
    // allow toggling of all spots
    topsoilPlotsCheckBoxListener = (observable, oldValue, newValue) -> {
        rootPlot.setData(rootData);
        try {
            if (newValue.getValue() instanceof SampleNode) {
                if (newValue.getValue().getNodeName().equals(SpotTypes.UNKNOWN.getSpotTypeName())) {
                    plot = rootPlot;
                } else if (chosenSample != newValue) {
                    plot = mapOfPlotsOfSpotSets.get(newValue.getValue().getNodeName() + topsoilPlotFlavor);
                }
                chosenSample = (CheckBoxTreeItem<SampleTreeNodeInterface>) newValue;
                currentlyPlottedSampleTreeNode = chosenSample;
            }
        } catch (Exception e) {
        }
        refreshPlot();
    };
    spotsTreeViewCheckBox.getSelectionModel().selectedItemProperty().addListener(topsoilPlotsCheckBoxListener);
    refreshPlot();
    spotsTreeViewCheckBox.getSelectionModel().select(currentlyPlottedSampleTreeNode);
    currentlyPlottedSampleTreeNode.setExpanded(true);
}
Also used : HBox(javafx.scene.layout.HBox) Task(org.cirdles.squid.tasks.Task) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) ParametersModel(org.cirdles.squid.parameters.parameterModels.ParametersModel) ObservableList(javafx.collections.ObservableList) SampleTreeNodeInterface(org.cirdles.squid.gui.dataViews.SampleTreeNodeInterface) StringConverter(javafx.util.StringConverter) SquidException(org.cirdles.squid.exceptions.SquidException) PlotDisplayInterface(org.cirdles.squid.gui.dateInterpretations.plots.PlotDisplayInterface) SquidException(org.cirdles.squid.exceptions.SquidException) ObservableList(javafx.collections.ObservableList) ShrimpFractionExpressionInterface(org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface) SampleNode(org.cirdles.squid.gui.dataViews.SampleNode)

Example 5 with SquidException

use of org.cirdles.squid.exceptions.SquidException in project Squid by CIRDLES.

the class PlotsController method showRMWeightedMeanPlot.

private void showRMWeightedMeanPlot() throws SquidException {
    // MAY 2021 requested by @NicoleRayner
    if (vboxMaster.getChildren().get(0) instanceof ToolBoxNodeInterface) {
        vboxMaster.getChildren().remove(0);
    }
    HBox toolBox = new RefMatWeightedMeanToolBoxNode(this);
    vboxMaster.getChildren().add(0, toolBox);
    removeSpotsTreeViewCheckBoxListener();
    spotsTreeViewCheckBox.setCellFactory(cell -> new CheckBoxTreeCell<>((TreeItem<SampleTreeNodeInterface> item) -> item.getValue().getSelectedProperty(), new StringConverter<TreeItem<SampleTreeNodeInterface>>() {

        @Override
        public String toString(TreeItem<SampleTreeNodeInterface> object) {
            SampleTreeNodeInterface item = object.getValue();
            // the goal is to show the nodename + weightedMean source + value of sorting choice if different
            String nodeStringWM = "";
            if (object.getParent() != null) {
                String wmExpressionName = ((SampleNode) object.getParent().getValue()).getSpotSummaryDetailsWM().getExpressionTree().getName().split("_WM_")[0];
                double[][] wmExpressionValues;
                if (stringIsSquidRatio(wmExpressionName)) {
                    // ratio case
                    wmExpressionValues = Arrays.stream(item.getShrimpFraction().getIsotopicRatioValuesByStringName(wmExpressionName)).toArray(double[][]::new);
                } else {
                    wmExpressionValues = item.getShrimpFraction().getTaskExpressionsEvaluationsPerSpotByField(wmExpressionName);
                }
                String ageOrValueSourceOfWM;
                double uncertainty = 0.0;
                if (wmExpressionValues[0].length > 1) {
                    uncertainty = wmExpressionValues[0][1];
                }
                if (wmExpressionName.contains("Age")) {
                    ageOrValueSourceOfWM = WeightedMeanPlot.makeAgeString(wmExpressionValues[0][0], uncertainty);
                } else {
                    ageOrValueSourceOfWM = WeightedMeanPlot.makeValueString(wmExpressionValues[0][0], uncertainty);
                }
                nodeStringWM = item.getShrimpFraction().getFractionID() + "  " + ageOrValueSourceOfWM;
                String sortingExpression = ((SampleNode) object.getParent().getValue()).getSpotSummaryDetailsWM().getSelectedExpressionName();
                // check to see if sorted by same field
                if ((item instanceof WeightedMeanSpotNode) && (wmExpressionName.compareToIgnoreCase(sortingExpression) != 0)) {
                    nodeStringWM += prettyPrintSortedWM(item.getShrimpFraction(), sortingExpression);
                }
            }
            String nodeName = "";
            try {
                nodeName = object.getValue().getNodeName();
            } catch (SquidException squidException) {
            }
            return (object.getParent() == null) ? nodeName : (item instanceof SampleNode) ? "" : nodeStringWM;
        }

        @Override
        public TreeItem<SampleTreeNodeInterface> fromString(String string) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }));
    spotListAnchorPane.getChildren().clear();
    spotListAnchorPane.getChildren().add(spotsTreeViewCheckBox);
    spotsTreeViewCheckBox.prefHeightProperty().bind(spotListAnchorPane.prefHeightProperty());
    spotsTreeViewCheckBox.prefWidthProperty().bind(spotListAnchorPane.prefWidthProperty());
    refreshPlot();
}
Also used : HBox(javafx.scene.layout.HBox) SampleTreeNodeInterface(org.cirdles.squid.gui.dataViews.SampleTreeNodeInterface) StringConverter(javafx.util.StringConverter) SquidException(org.cirdles.squid.exceptions.SquidException) SampleNode(org.cirdles.squid.gui.dataViews.SampleNode)

Aggregations

SquidException (org.cirdles.squid.exceptions.SquidException)71 IOException (java.io.IOException)27 File (java.io.File)25 FXML (javafx.fxml.FXML)18 HBox (javafx.scene.layout.HBox)18 ActionEvent (javafx.event.ActionEvent)13 ZipUtility.extractZippedFile (org.cirdles.squid.utilities.fileUtilities.ZipUtility.extractZippedFile)13 Task (org.cirdles.squid.tasks.Task)12 SAXException (org.xml.sax.SAXException)12 ObservableList (javafx.collections.ObservableList)11 JAXBException (javax.xml.bind.JAXBException)11 BigDecimal (java.math.BigDecimal)10 ReferenceMaterialModel (org.cirdles.squid.parameters.parameterModels.referenceMaterialModels.ReferenceMaterialModel)10 javafx.scene.control (javafx.scene.control)9 VBox (javafx.scene.layout.VBox)9 SquidMessageDialog (org.cirdles.squid.gui.dialogs.SquidMessageDialog)9 ParametersModelComparator (org.cirdles.squid.parameters.ParametersModelComparator)9 CommonPbModel (org.cirdles.squid.parameters.parameterModels.commonPbModels.CommonPbModel)9 PhysicalConstantsModel (org.cirdles.squid.parameters.parameterModels.physicalConstantsModels.PhysicalConstantsModel)9 ShrimpFractionExpressionInterface (org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface)9