Search in sources :

Example 1 with ShrimpFractionExpressionInterface

use of org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface in project Squid by CIRDLES.

the class CountCorrectionsController method showUnknownsWithOvercountCorrections.

private void showUnknownsWithOvercountCorrections() {
    Map<String, List<ShrimpFractionExpressionInterface>> mapOfSpotsBySampleNames;
    mapOfSpotsBySampleNames = squidProject.getTask().getMapOfUnknownsBySampleNames();
    // case of sample names chosen
    if (mapOfSpotsBySampleNames.size() > 1) {
        mapOfSpotsBySampleNames.remove(Squid3Constants.SpotTypes.UNKNOWN.getSpotTypeName());
    }
    TextFlow textFlowSampleType = new TextFlow();
    Text textUnknown = new Text(Squid3Constants.SpotTypes.UNKNOWN.getSpotTypeName());
    textUnknown.setFont(Font.font("Monospaced", FontWeight.BOLD, fontSize));
    textFlowSampleType.getChildren().add(textUnknown);
    TreeItem<TextFlow> rootItemSamples = new TreeItem<>(textFlowSampleType);
    spotsTreeViewTextFlow.setStyle("-fx-font-size: 12px;");
    spotsTreeViewTextFlow.setRoot(rootItemSamples);
    rootItemSamples.setExpanded(true);
    spotsTreeViewTextFlow.setShowRoot(true);
    for (Map.Entry<String, List<ShrimpFractionExpressionInterface>> entry : mapOfSpotsBySampleNames.entrySet()) {
        TextFlow textFlowSampleInfo = new TextFlow();
        Text textSample = new Text(entry.getKey());
        textSample.setFont(Font.font("Monospaced", FontWeight.BOLD, fontSize));
        textFlowSampleInfo.getChildren().add(textSample);
        TreeItem<TextFlow> treeItemSampleInfo = new TreeItem<>(textFlowSampleInfo);
        for (ShrimpFractionExpressionInterface spot : entry.getValue()) {
            double[][] r204_206 = spot.getOriginalIsotopicRatioValuesByStringName("204/206");
            double[][] r204_206_207 = spot.getTaskExpressionsEvaluationsPerSpot().get(squidProject.getTask().getNamedExpressionsMap().get("SWAPCountCorrectionExpression204From207"));
            double[][] r204_206_208 = spot.getTaskExpressionsEvaluationsPerSpot().get(squidProject.getTask().getNamedExpressionsMap().get("SWAPCountCorrectionExpression204From208"));
            TextFlow textFlowI = new TextFlow();
            Text textSampleName = new Text(String.format("%1$-" + 40 + "s", spot.getFractionID()));
            textSampleName.setFont(Font.font("Monospaced", FontWeight.BOLD, fontSize));
            textFlowI.getChildren().add(textSampleName);
            // no correction
            Formatter formatter = new Formatter();
            formatter.format("% 12.6E   % 12.3f         ", r204_206[0][0], StrictMath.abs(r204_206[0][1] / r204_206[0][0] * 100.0));
            Text textNone = new Text(formatter.toString());
            textNone.setFont(Font.font("Monospaced", correctionNoneRB.isSelected() ? FontWeight.BOLD : FontWeight.THIN, fontSize));
            textFlowI.getChildren().add(textNone);
            // 207 correction
            formatter = new Formatter();
            formatter.format("% 12.6E   % 12.3f         ", r204_206_207[0][0], StrictMath.abs(r204_206_207[0][1] / r204_206_207[0][0] * 100.0));
            Text text207 = new Text(formatter.toString());
            text207.setFont(Font.font("Monospaced", correction207RB.isSelected() ? FontWeight.BOLD : FontWeight.THIN, fontSize));
            textFlowI.getChildren().add(text207);
            // 208 correction
            formatter = new Formatter();
            formatter.format("% 12.6E   % 12.3f         ", r204_206_208[0][0], StrictMath.abs(r204_206_208[0][1] / r204_206_208[0][0] * 100.0));
            Text text208 = new Text(formatter.toString());
            text208.setFont(Font.font("Monospaced", correction208RB.isSelected() ? FontWeight.BOLD : FontWeight.THIN, fontSize));
            textFlowI.getChildren().add(text208);
            TreeItem<TextFlow> treeItemSampleI = new TreeItem<>(textFlowI);
            treeItemSampleInfo.getChildren().add(treeItemSampleI);
        }
        rootItemSamples.getChildren().add(treeItemSampleInfo);
    }
    sampleTreeAnchorPane.getChildren().clear();
    sampleTreeAnchorPane.getChildren().add(spotsTreeViewTextFlow);
}
Also used : ShrimpFractionExpressionInterface(org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface) Formatter(java.util.Formatter) List(java.util.List) TextFlow(javafx.scene.text.TextFlow) Text(javafx.scene.text.Text) Map(java.util.Map)

Example 2 with ShrimpFractionExpressionInterface

use of org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface 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 3 with ShrimpFractionExpressionInterface

use of org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface 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 4 with ShrimpFractionExpressionInterface

use of org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface in project Squid by CIRDLES.

the class SquidReportTableHelperMethods method filterShrimpFractionsBySpot.

private static void filterShrimpFractionsBySpot(List<ShrimpFractionExpressionInterface> spots, String unknownSpot) {
    if (unknownSpot.compareToIgnoreCase(Squid3Constants.SpotTypes.UNKNOWN.getSpotTypeName()) != 0) {
        for (int i = 0; i < spots.size(); i++) {
            ShrimpFractionExpressionInterface spot = spots.get(i);
            if (!spot.getFractionID().startsWith(unknownSpot)) {
                spots.remove(i);
                i--;
            }
        }
    }
}
Also used : ShrimpFractionExpressionInterface(org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface)

Example 5 with ShrimpFractionExpressionInterface

use of org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface in project Squid by CIRDLES.

the class WeightedMeanPlot method extractSpotDetails.

private boolean extractSpotDetails() {
    ShrimpFractionExpressionInterface selectedSpot = null;
    if ((indexOfSelectedSpot >= 0) && (shrimpFractions != null)) {
        // prepare to reset indexOfSelectedSpot for visualization
        selectedSpot = shrimpFractions.get(indexOfSelectedSpot);
    }
    storedShrimpFractions = spotSummaryDetails.getSelectedSpots();
    shrimpFractions = new ArrayList<>();
    boolean[] storedRejectedIndices = spotSummaryDetails.getRejectedIndices();
    rejectedIndices = new boolean[storedRejectedIndices.length];
    boolean retVal = storedShrimpFractions.size() > 0;
    if (retVal) {
        for (ShrimpFractionExpressionInterface sf : storedShrimpFractions) {
            shrimpFractions.add(sf);
        }
        Collections.sort(shrimpFractions, (ShrimpFractionExpressionInterface fraction1, ShrimpFractionExpressionInterface fraction2) -> {
            double valueFromNode1 = 0.0;
            double valueFromNode2 = 0.0;
            if (stringIsSquidRatio(spotSummaryDetails.getSelectedExpressionName())) {
                // case of raw ratios
                double[][] resultsFromNode1 = Arrays.stream(fraction1.getIsotopicRatioValuesByStringName(spotSummaryDetails.getSelectedExpressionName())).toArray(double[][]::new);
                valueFromNode1 = resultsFromNode1[0][0];
                double[][] resultsFromNode2 = Arrays.stream(fraction2.getIsotopicRatioValuesByStringName(spotSummaryDetails.getSelectedExpressionName())).toArray(double[][]::new);
                valueFromNode2 = resultsFromNode2[0][0];
            } else {
                // all other expressions
                valueFromNode1 = fraction1.getTaskExpressionsEvaluationsPerSpotByField(spotSummaryDetails.getSelectedExpressionName())[0][0];
                valueFromNode2 = fraction2.getTaskExpressionsEvaluationsPerSpotByField(spotSummaryDetails.getSelectedExpressionName())[0][0];
            }
            return Double.compare(valueFromNode1, valueFromNode2);
        });
        if (indexOfSelectedSpot > -1) {
            // reset indexOfSelectedSpot for visualization
            indexOfSelectedSpot = shrimpFractions.indexOf(selectedSpot);
        }
        countOfIncluded = 0;
        for (int i = 0; i < shrimpFractions.size(); i++) {
            boolean rejected = storedRejectedIndices[storedShrimpFractions.indexOf(shrimpFractions.get(i))];
            rejectedIndices[i] = rejected;
            countOfIncluded = countOfIncluded + (rejected ? 0 : 1);
        }
        agesOrValues = new ArrayList<>();
        agesOrValuesTwoSigma = new ArrayList<>();
        hours = new ArrayList<>();
        double index = 0;
        // special case for reference materials to plot actual calib const instead of ages
        switchRefMatViewToCalibConstLookupString = (switchRefMatViewToCalibConst && spotSummaryDetails.getExpressionTree().getName().endsWith("_CalibConst")) ? ageOrValueLookupString.replace("_Age_RM", "_CalibConst") : ageOrValueLookupString;
        for (ShrimpFractionExpressionInterface spot : shrimpFractions) {
            double[][] results;
            if (stringIsSquidRatio(ageOrValueLookupString)) {
                // ratio case
                results = Arrays.stream(spot.getIsotopicRatioValuesByStringName(ageOrValueLookupString)).toArray(double[][]::new);
            } else {
                results = spot.getTaskExpressionsEvaluationsPerSpotByField(switchRefMatViewToCalibConstLookupString);
            }
            agesOrValues.add(results[0][0]);
            // handle no uncertainty case
            if (results[0].length < 2) {
                agesOrValuesTwoSigma.add(0.0);
            } else {
                agesOrValuesTwoSigma.add(2.0 * results[0][1]);
            }
            if (spotSummaryDetails.getSelectedExpressionName().compareToIgnoreCase("Hours") == 0) {
                hours.add(spot.getHours());
            } else {
                hours.add(index++);
            }
        }
        weightedMeanStats = spotSummaryDetails.getValues()[0];
    }
    return retVal;
}
Also used : ShrimpFractionExpressionInterface(org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface) Paint(javafx.scene.paint.Paint)

Aggregations

ShrimpFractionExpressionInterface (org.cirdles.squid.shrimp.ShrimpFractionExpressionInterface)22 SquidException (org.cirdles.squid.exceptions.SquidException)12 Task (org.cirdles.squid.tasks.Task)7 IOException (java.io.IOException)5 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)5 SampleNode (org.cirdles.squid.gui.dataViews.SampleNode)5 SampleTreeNodeInterface (org.cirdles.squid.gui.dataViews.SampleTreeNodeInterface)5 ArrayList (java.util.ArrayList)4 ObservableValue (javafx.beans.value.ObservableValue)4 ObservableList (javafx.collections.ObservableList)4 HBox (javafx.scene.layout.HBox)4 Paint (javafx.scene.paint.Paint)4 PlotDisplayInterface (org.cirdles.squid.gui.dateInterpretations.plots.PlotDisplayInterface)4 File (java.io.File)3 List (java.util.List)3 Map (java.util.Map)3 Rectangle (javafx.scene.shape.Rectangle)3 WeightedMeanPlot (org.cirdles.squid.gui.dateInterpretations.plots.squid.WeightedMeanPlot)3 ConstantNode (org.cirdles.squid.tasks.expressions.constants.ConstantNode)3 SpotSummaryDetails (org.cirdles.squid.tasks.expressions.spots.SpotSummaryDetails)3