use of org.cirdles.squid.parameters.parameterModels.ParametersModel 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);
}
use of org.cirdles.squid.parameters.parameterModels.ParametersModel 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);
}
use of org.cirdles.squid.parameters.parameterModels.ParametersModel in project Squid by CIRDLES.
the class ParametersManagerGUIController method setUpPhysConstCBItems.
private void setUpPhysConstCBItems() {
final ObservableList<String> cbList = FXCollections.observableArrayList();
for (ParametersModel mod : physConstModels) {
if (mod.equals(squidLabData.getPhysConstDefault())) {
cbList.add(mod.getModelNameWithVersion() + isBuiltin(mod) + " -default");
} else {
cbList.add(mod.getModelNameWithVersion() + isBuiltin(mod));
}
}
physConstCB.setItems(cbList);
}
use of org.cirdles.squid.parameters.parameterModels.ParametersModel in project Squid by CIRDLES.
the class ParametersManagerGUIController method setUpCommonPbCBItems.
private void setUpCommonPbCBItems() {
final ObservableList<String> cbList = FXCollections.observableArrayList();
for (ParametersModel mod : commonPbModels) {
if (mod.equals(squidLabData.getCommonPbDefault())) {
cbList.add(mod.getModelNameWithVersion() + isBuiltin(mod) + " - default");
} else {
cbList.add(mod.getModelNameWithVersion() + isBuiltin(mod));
}
}
commonPbCB.setItems(cbList);
}
use of org.cirdles.squid.parameters.parameterModels.ParametersModel in project Squid by CIRDLES.
the class ParametersManagerTests method testReferenceMaterialValueEntry.
@Test
public void testReferenceMaterialValueEntry() throws SquidException {
BigDecimal num = new BigDecimal(Double.MAX_VALUE);
ParametersModel mod = new ReferenceMaterialModel();
mod.setModelName("a;sldkfjal;sdkfja;lskdfja;slkdfjas;ldkfj");
Task task = new Task();
task.setReferenceMaterialModel(mod);
mod.getValues()[4].setValue(num);
task.updateParametersFromModels();
Expression exp = task.getExpressionByName(BuiltInExpressionsDataDictionary.REF_238U235U);
assertTrue(exp != null && getDoubleValueOfExpressionWithOneConstantNodeChild(exp) == num.doubleValue());
}
Aggregations