Permalink
Browse files

Refines report formats. (#139)

* adjusts formatting for reports and explores spotname audit
  • Loading branch information...
bowring committed Jul 30, 2018
1 parent dbcf8c7 commit 4d96d6360615a36b5d2e1773457877fd19346e47
@@ -6,7 +6,7 @@ apply plugin: 'java'
apply plugin: 'maven'
String mavenGroupId = 'org.cirdles'
String mavenVersion = '0.3.11'
String mavenVersion = '0.3.15'
sourceCompatibility = '1.8'
@@ -16,15 +16,18 @@
package org.cirdles.squid.gui;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.CheckBox;
import javafx.scene.control.CheckBoxTreeItem;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import static org.cirdles.squid.gui.SquidUI.PIXEL_OFFSET_FOR_MENU;
import static org.cirdles.squid.gui.SquidUI.primaryStageWindow;
@@ -48,15 +51,19 @@
private VBox sessionVBox;
@FXML
private CheckBox checkbox;
private static char[] spaces = new char[100];
static{
for (int i = 0; i < 100; i ++){
static {
for (int i = 0; i < 100; i++) {
spaces[i] = ' ';
}
}
@FXML
private TreeView<SampleNameTreeNodeInterface> prawnAuditTree1;
private static ObservableList<SampleNameTreeNodeInterface> nameNodes;
/**
* Initializes the controller class.
*/
@@ -65,8 +72,11 @@ public void initialize(URL url, ResourceBundle rb) {
prawnAuditTree.prefWidthProperty().bind(primaryStageWindow.getScene().widthProperty());
prawnAuditTree.prefHeightProperty().bind(primaryStageWindow.getScene().heightProperty().subtract(PIXEL_OFFSET_FOR_MENU));
setUpPrawnFileAuditTreeView(false);
prawnAuditTree1.prefWidthProperty().bind(primaryStageWindow.getScene().widthProperty());
prawnAuditTree1.prefHeightProperty().bind(primaryStageWindow.getScene().heightProperty().subtract(PIXEL_OFFSET_FOR_MENU));
setUpPrawnFileAuditTree1View(false);
}
/**
@@ -90,6 +100,24 @@ private void setUpPrawnFileAuditTreeView(boolean showDupesOnly) {
populatePrefixTreeView(rootItem, spotPrefixTree, showDupesOnly, 0, true);
}
private void setUpPrawnFileAuditTree1View(boolean showDupesOnly) {
prawnAuditTree1.setStyle(SquidUI.SPOT_LIST_CSS_STYLE_SPECS);
SquidPrefixTree spotPrefixTree = squidProject.getPrefixTree();
String summaryStatsString = spotPrefixTree.buildSummaryDataString();
boolean hasDuplicates = spotPrefixTree.getCountOfDups() > 0;
// checkbox.setVisible(hasDuplicates);
CheckBoxTreeItem<SampleNameTreeNodeInterface> rootItem
= customizeRootItem1(summaryStatsString, hasDuplicates);
rootItem.setExpanded(true);
prawnAuditTree1.setRoot(rootItem);
List<SampleNameTreeNodeInterface> sampleNameNodes = new ArrayList<>();
populatePrefixTreeView1(sampleNameNodes, rootItem, spotPrefixTree, showDupesOnly, 0, true);
nameNodes = FXCollections.observableArrayList(sampleNameNodes);
}
/**
* Initializes root item of prawnAuditTree TreeView based on whether the
* SquidPrefixTree has duplicates
@@ -112,6 +140,20 @@ private void setUpPrawnFileAuditTreeView(boolean showDupesOnly) {
return rootItem;
}
private CheckBoxTreeItem<SampleNameTreeNodeInterface> customizeRootItem1(String summaryStatsString, boolean hasDuplicates) {
CheckBoxTreeItem<SampleNameTreeNodeInterface> rootItem
= new CheckBoxTreeItem<>(new SampleNameNode("Spots"), null);
if (hasDuplicates) {
rootItem.setValue(new SampleNameNode(
"***This file has duplicate names. Change names of duplicates in PrawnFile > Manage Spots & "
+ "Choose Reference Materials***"
+ "\n\nSpots by prefix: " + summaryStatsString));
} else {
rootItem.setValue(new SampleNameNode("Spots by prefix:" + summaryStatsString));
}
return rootItem;
}
/**
* Displays all nodes in the tree starting from the root. Displays only
* duplicate spot tree if showDupesOnly is true. Displays entire spot tree
@@ -135,9 +177,9 @@ private void populatePrefixTreeView(TreeItem<String> parentItem, SquidPrefixTree
parentItem.setExpanded(endExpansion && doExpand);
parentItem.setValue(
parentItem.getValue()
+ String.copyValueOf(spaces, 0, 100 - parentItem.getValue().length() - depth)
+ ((String) (!(endExpansion && doExpand) && parentItem.getParent().isExpanded() ? "SAMPLE" : "")));
parentItem.getValue()
+ String.copyValueOf(spaces, 0, 100 - parentItem.getValue().length() - depth)
+ ((String) (!(endExpansion && doExpand) && parentItem.getParent().isExpanded() ? "SAMPLE" : "")));
for (int i = 0; i < children.size(); i++) {
if (!children.get(i).isleaf()) {
@@ -168,6 +210,63 @@ private void populatePrefixTreeView(TreeItem<String> parentItem, SquidPrefixTree
}
}
private void populatePrefixTreeView1(
List<SampleNameTreeNodeInterface> sampleNameNodes,
CheckBoxTreeItem<SampleNameTreeNodeInterface> parentItem,
SquidPrefixTree squidPrefixTree,
boolean showDupesOnly,
int depth,
boolean doExpand) {
List<SquidPrefixTree> children = squidPrefixTree.getChildren();
boolean endExpansion = false;
if (children.size() > 0) {
endExpansion = children.get(0).getNode().getValue().compareTo("-") != 0;
}
parentItem.setExpanded(endExpansion && doExpand);
SampleNameTreeNodeInterface parentNode = new SampleNameNode(
parentItem.getValue().getSampleContents()
+ String.copyValueOf(spaces, 0, 100 - parentItem.getValue().getContentsLength() - depth)
+ ((String) (!(endExpansion && doExpand) && parentItem.getParent().isExpanded() ? "SAMPLE" : "")));
sampleNameNodes.add(parentNode);
parentItem.setValue(parentNode);
for (int i = 0; i < children.size(); i++) {
if (!children.get(i).isleaf()) {
SampleNameTreeNodeInterface childNode = new SampleNameNode(
children.get(i).getStringValue()
+ children.get(i).buildSummaryDataString());
CheckBoxTreeItem<SampleNameTreeNodeInterface> childItem
= new CheckBoxTreeItem<>(childNode);
sampleNameNodes.add(childNode);
if (showDupesOnly) {
if (children.get(i).getCountOfDups() > 0) {
parentItem.getChildren().add(childItem);
}
} else {
parentItem.getChildren().add(childItem);
}
if (children.get(i).hasChildren()) {
populatePrefixTreeView1(sampleNameNodes, childItem, children.get(i), showDupesOnly, depth + 1, endExpansion && doExpand);
}
} else {
parentNode = new SampleNameNode(children.get(i).getParent().getStringValue()
+ " Dups=" + String.format("%1$ 2d", children.get(i).getParent().getCountOfDups())
+ " Species=" + String.format("%1$ 2d", children.get(i).getCountOfSpecies())
+ " Scans=" + String.format("%1$ 2d", children.get(i).getCountOfScans())
+ ((String) (children.size() > 1 ? " ** see duplicates below **" : ""))
);
sampleNameNodes.add(parentNode);
parentItem.setValue(parentNode);
}
}
}
@FXML
/**
* Calls method displaying appropriate tree dependent on the state of the
@@ -176,4 +275,38 @@ private void populatePrefixTreeView(TreeItem<String> parentItem, SquidPrefixTree
private void duplicatesChecked(ActionEvent event) {
setUpPrawnFileAuditTreeView(checkbox.isSelected());
}
}
// classes to support tree with checkboxes
private interface SampleNameTreeNodeInterface {
public String getSampleContents();
public int getContentsLength();
}
private class SampleNameNode implements SampleNameTreeNodeInterface {
private String sampleContents;
public SampleNameNode(String sampleContents) {
this.sampleContents = sampleContents;
}
@Override
public String getSampleContents() {
return sampleContents;
}
@Override
public int getContentsLength() {
return sampleContents.length();
}
@Override
public String toString() {
return sampleContents;
}
}
}
@@ -28,5 +28,10 @@
<Insets />
</opaqueInsets>
</TreeView>
<TreeView fx:id="prawnAuditTree1" layoutX="10.0" layoutY="40.0" style="-fx-background-color: #f4f4f4;">
<opaqueInsets>
<Insets />
</opaqueInsets>
</TreeView>
</children>
</VBox>
@@ -513,16 +513,29 @@ public static String FormatNumericStringAlignDecimalPoint(String numericString)
if (getUncertaintyColumn().isVisible()) {
// check for reporting mode
if ((vm[0] > 0.0) && (vm[0] < 10e-20)) {
// may 2013 for tiny numbers due to below detection
retVal[1] = " bd "; // below detection
} else if (vm[0] == 0.0) {//oct 2014
retVal[1] = " - ";
} else if (isNumeric) {
retVal[1]
= getOneSigma(vm[0], vm[1], getUncertaintyType(), getUnits()).toPlainString().trim();
// if ((vm[0] > 0.0) && (vm[0] < 10e-20)) {
// // may 2013 for tiny numbers due to below detection
// retVal[1] = " bd "; // below detection
//
// } else
// if (vm[0] == 0.0) {//oct 2014
// retVal[1] = " - ";
//
// } else
if (isNumeric) {
try {
// check on size of vm[1] - if already rounded, then preserve for output
int countDigits = countSigDigits(String.valueOf(vm[1]));
int roundingCount = 15;
if (countDigits <= 12) {
roundingCount = 12;
}
retVal[1] = String.valueOf(Utilities.roundedToSize(
getOneSigma(vm[0], vm[1], getUncertaintyType(), getUnits()).doubleValue(), roundingCount));
// = getOneSigma(vm[0], vm[1], getUncertaintyType(), getUnits()).toPlainString().trim();
} catch (Exception e) {
}
} else if (getUncertaintyColumn().isDisplayedWithArbitraryDigitCount()) {
retVal[1]
= formatBigDecimalForPublicationArbitraryMode(//
@@ -715,4 +728,17 @@ static int calculateCountOfDigitsAfterDecPoint(String oneSigError) {
return countOfDigitsAfterDecPointInError;
}
public static int countSigDigits(String number) {
String digits = number.replaceFirst("\\.", "");
int index = digits.lastIndexOf("E");
if (index > 0) {
digits = digits.substring(0, index);
}
while ("0".equals(digits.substring(0, 1))) {
digits = digits.replaceFirst("0", "");
}
return digits.length();
}
}
@@ -52,7 +52,7 @@
{"", "", "U", "(ppm)", "", "getTaskExpressionsEvaluationsPerSpotByField", SQUID_PPM_PARENT_EQN_NAME_U, "",
"", "true", "false", "20", "", "concentration of U", "false", "false"
},
{"", "", "Th", "alse\", \"6\"(ppm)", "", "getTaskExpressionsEvaluationsPerSpotByField", SQUID_PPM_PARENT_EQN_NAME_TH_S, "",
{"", "", "Th", "(ppm)", "", "getTaskExpressionsEvaluationsPerSpotByField", SQUID_PPM_PARENT_EQN_NAME_TH_S, "",
"", "true", "false", "20", "", "concentration of Th", "true", "false"
},
{"", "", "232Th", "/238U", "", "getTaskExpressionsEvaluationsPerSpotByField", SQUID_TH_U_EQN_NAME_S, "PCT",
@@ -1189,7 +1189,7 @@ private void evaluateExpressionForSpotSet(
// update spotSummaryDetails
spotSummaryDetails.setExpressionTree(expressionTree);
// special case for WieghtedMean in which auto rejection is possible
// special case for WeightedMean in which auto rejection is possible
boolean noReject = false;
if (((ExpressionTree) expressionTree).getOperation() instanceof WtdMeanACalc) {
// discover what the flags say - repeats logic of WtdMeanACalc()
@@ -1962,4 +1962,17 @@ public boolean isShowQt1z() {
public void setShowQt1z(boolean aShowQt1z) {
showQt1z = aShowQt1z;
}
@Override
public boolean expressionIsNuSwitched(String expressionName) {
boolean retVal = false;
for (Expression exp : taskExpressionsOrdered) {
if ((exp.getName().compareToIgnoreCase(expressionName) == 0)
&& (exp.isSquidSwitchNU())) {
retVal = true;
break;
}
}
return retVal;
}
}
@@ -444,4 +444,6 @@ public default boolean isPbU() {
* @param aShowQt1z the showQt1z to set
*/
public void setShowQt1z(boolean aShowQt1z);
public boolean expressionIsNuSwitched(String expressionName);
}
@@ -54,7 +54,7 @@ public TaskExpressionEvaluatedPerSpotPerScanModel(
// April 2017 Rounding per Bodorkos
int sigDigs = 12;
////System.out.println("ROUNDING " + expression.getName());
this.expression = expression;
this.ratEqVal = ratEqVal.clone();
this.ratEqTime = ratEqTime.clone();
@@ -113,10 +113,12 @@ public void customizeXstream(XStream xstream) {
double[] values = ((double[][]) method.invoke(shrimpFractions.get(i), new Object[]{name}))[0].clone();
if (values.length > 1) {
// to return uncertainty, copy index 1 to index 0
// July 2018 force to 12 sig digs - abs value should be already
// org.cirdles.ludwig.squid25.Utilities.roundedToSize(retVal, 12);
if (uncertaintyDirective.compareTo("%") == 0) {
values[0] = values[1] / values[0] * 100;
values[0] = org.cirdles.ludwig.squid25.Utilities.roundedToSize(values[1] / values[0] * 100, 12);
} else if (uncertaintyDirective.compareTo("±") == 0) {
values[0] = values[1];
values[0] = org.cirdles.ludwig.squid25.Utilities.roundedToSize(values[1], 12);
}
}
retVal[i] = convertArrayToObjects(values);
@@ -136,6 +136,11 @@ public void customizeXstream(XStream xstream) {
// index should be 1 from constructor
values[1] = values[1] / values[0] * 100;
}
// july 2018
if (task.expressionIsNuSwitched(name)){
values[1]= org.cirdles.ludwig.squid25.Utilities.roundedToSize(values[1], 12);
}
if (index > 0) {
// we have a call to retrieve into [0] another output of this expression, such as 1-sigma abs
@@ -6,5 +6,5 @@ Chuck Magee,
Casey Wilson,
Ryan Barrett,
Maël Gaonach,
Nicole Rayner,
Nicole Rayner,
Andrew Cross

0 comments on commit 4d96d63

Please sign in to comment.