Permalink
Browse files

Miscellaneous improvements. (#163)

* fixes #162

* improves peek views in expression manager
  • Loading branch information...
bowring committed Aug 30, 2018
1 parent 7d18762 commit 59a03e5d84115c046674d813903e471ff528f0c8
View
@@ -21,9 +21,9 @@ if (!hasProperty('mainClass')) {
mainClassName = 'org.cirdles.squid.gui.SquidUI'
dependencies {
implementation project(":squidCore")
compile project(":squidCore")
//compile 'com.github.cirdles.topsoil:app:master-SNAPSHOT'
implementation 'com.github.cirdles.topsoil:app:master-SNAPSHOT'
compile 'com.github.cirdles.topsoil:app:master-SNAPSHOT'
//compile group: 'com.proudapes', name: 'jlatexmathfx', version: '0.3.3'
//compile 'com.github.bitstormGER:jlatexmathfx:-SNAPSHOT'
@@ -132,12 +132,12 @@
import static org.cirdles.squid.tasks.expressions.operations.Operation.OPERATIONS_MAP;
import org.cirdles.squid.tasks.expressions.parsing.ShuntingYard;
import org.cirdles.squid.tasks.expressions.parsing.ShuntingYard.TokenTypes;
import org.cirdles.squid.tasks.expressions.spots.SpotFieldNode;
import org.cirdles.squid.tasks.expressions.spots.SpotSummaryDetails;
import org.cirdles.squid.tasks.expressions.variables.VariableNodeForIsotopicRatios;
import static org.cirdles.squid.gui.constants.Squid3GuiConstants.EXPRESSION_BUILDER_DEFAULT_FONTSIZE;
import static org.cirdles.squid.gui.constants.Squid3GuiConstants.EXPRESSION_BUILDER_MAX_FONTSIZE;
import static org.cirdles.squid.gui.constants.Squid3GuiConstants.EXPRESSION_BUILDER_MIN_FONTSIZE;
import org.cirdles.squid.tasks.expressions.variables.VariableNodeForPerSpotTaskExpressions;
import org.cirdles.squid.tasks.expressions.variables.VariableNodeForSummary;
/**
* FXML Controller class
@@ -1732,13 +1732,13 @@ private String createPeekRM(Expression exp, boolean forcePercentUn) {
res = "Reference Materials not processed.";
if (exp.getExpressionTree().isSquidSwitchSTReferenceMaterialCalculation()) {
if (refMatSpots.size() > 0) {
res = peekDetailsPerSpot(refMatSpots, exp.getExpressionTree(), forcePercentUn);
res = peekDetailsPerSpot(refMatSpots, exp.getExpressionTree());
} else {
res = "No Reference Materials";
}
} else if (exp.getExpressionTree().isSquidSwitchConcentrationReferenceMaterialCalculation()) {
if (concRefMatSpots.size() > 0) {
res = peekDetailsPerSpot(concRefMatSpots, exp.getExpressionTree(), forcePercentUn);
res = peekDetailsPerSpot(concRefMatSpots, exp.getExpressionTree());
} else {
res = "No Concentration Reference Materials";
}
@@ -1779,7 +1779,7 @@ private String createPeekUN(Expression exp, boolean forcePercentUn) {
res = "Unknowns not processed.";
if (exp.getExpressionTree().isSquidSwitchSAUnknownCalculation()) {
if (unSpots.size() > 0) {
res = peekDetailsPerSpot(unSpots, exp.getExpressionTree(), forcePercentUn);
res = peekDetailsPerSpot(unSpots, exp.getExpressionTree());
} else {
res = "No Unknowns";
}
@@ -2029,104 +2029,136 @@ private String peekDetailsPerSummary(SpotSummaryDetails spotSummary) {
return sb.toString();
}
private String peekDetailsPerSpot(List<ShrimpFractionExpressionInterface> spots, ExpressionTreeInterface exp, boolean forcePercentUn) {
private String peekDetailsPerSpot(List<ShrimpFractionExpressionInterface> spots, ExpressionTreeInterface expTree) {
StringBuilder sb = new StringBuilder();
int sigDigits = 15;
// if (expTree instanceof ShrimpSpeciesNode) {
// sb.append("Please specify property of species such as totalCps.");
// }
// else if (expTree instanceof VariableNodeForIsotopicRatios) {
// // special case where the expressionTree is a ratio
// sb.append(String.format("%1$-" + 15 + "s", "Spot name"));
// // first determine if uncertainty directive is present
// String uncertaintyDirective = ((VariableNodeForIsotopicRatios) expTree).getUncertaintyDirective();
// if (uncertaintyDirective.length() > 0) {
// sb.append(String.format("%1$-" + 20 + "s", "1\u03C3 " + uncertaintyDirective + " " + expTree.getName()));
// } else {
// sb.append(String.format("%1$-" + 20 + "s", expTree.getName()));
// sb.append(String.format("%1$-" + 20 + "s", "1\u03C3 ABS"));
// }
// sb.append("\n");
//
// for (ShrimpFractionExpressionInterface spot : spots) {
// sb.append(String.format("%1$-" + 15 + "s", spot.getFractionID()));
// double[][] results
// = Arrays.stream(spot.getIsotopicRatioValuesByStringName(expTree.getName())).toArray(double[][]::new);
// for (int i = 0; i < (int)((uncertaintyDirective.length() == 0) ? results[0].length : 1); i++) {
// try {
// sb.append(String.format("%1$-" + 20 + "s", Utilities.roundedToSize(results[0][i], 15)));
// } catch (Exception e) {
// }
// }
// sb.append("\n");
// }
//
// }
//// else
//// if (expTree instanceof SpotFieldNode) {
//// // special case where the expressionTree is a field in spot (non-ratio)
//// sb.append(String.format("%1$-" + 15 + "s", "Spot name"));
//// sb.append(String.format("%1$-" + 20 + "s", expTree.getName()));
//// sb.append("\n");
////
//// for (ShrimpFractionExpressionInterface spot : spots) {
//// sb.append(String.format("%1$-" + 15 + "s", spot.getFractionID()));
//// List<ShrimpFractionExpressionInterface> singleSpot = new ArrayList<>();
//// singleSpot.add(spot);
////
//// try {
//// double[][] results
//// = Arrays.stream(ExpressionTreeInterface.convertObjectArrayToDoubles(expTree.eval(singleSpot, null))).toArray(double[][]::new);
//// for (int i = 0; i < results[0].length; i++) {
//// try {
//// sb.append(String.format("%1$-" + 20 + "s", Utilities.roundedToSize(results[0][i], 15)));
//// } catch (Exception e) {
//// }
//// }
//// sb.append("\n");
//// } catch (SquidException squidException) {
//// }
////
//// }
////
//// } else {
if (expTree.isSquidSwitchConcentrationReferenceMaterialCalculation()) {
sb.append("Concentration Reference Materials Only\n\n");
}
sb.append(String.format("%1$-" + 15 + "s", "Spot name"));
String[][] resultLabels;
if (((ExpressionTree) expTree).getOperation() != null) {
if ((((ExpressionTree) expTree).getOperation().getName().compareToIgnoreCase("Value") == 0)) {
if (exp instanceof ShrimpSpeciesNode) {
sb.append("Please specify property of species such as totalCps.");
} else if (exp instanceof VariableNodeForIsotopicRatios) {
// special case where the expressionTree is a ratio
sb.append(String.format("%1$-" + 15 + "s", "Spot name"));
sb.append(String.format("%1$-" + 20 + "s", exp.getName()));
sb.append(String.format("%1$-" + 20 + "s", "1-sigma ABS"));
sb.append("\n");
for (ShrimpFractionExpressionInterface spot : spots) {
sb.append(String.format("%1$-" + 15 + "s", spot.getFractionID()));
double[][] results
= Arrays.stream(spot.getIsotopicRatioValuesByStringName(exp.getName())).toArray(double[][]::new);
for (int i = 0; i < results[0].length; i++) {
try {
sb.append(String.format("%1$-" + 20 + "s", Utilities.roundedToSize(results[0][i], 15)));
} catch (Exception e) {
if (((ExpressionTree) expTree).getChildrenET().get(0) instanceof VariableNodeForSummary) {
String uncertaintyDirective
= ((VariableNodeForSummary) ((ExpressionTree) expTree).getChildrenET().get(0)).getUncertaintyDirective();
if (uncertaintyDirective.length() > 0) {
resultLabels = new String[][]{{"1\u03C3 " + uncertaintyDirective}, {}};
} else {
resultLabels = new String[][]{{"Value", "1\u03C3 Abs"}, {}};
}
} else {
// i.e., ConstantNode
resultLabels = ((ExpressionTree) expTree).getOperation().getLabelsForOutputValues();
}
} else if (((ExpressionTree) expTree).getLeftET() instanceof ShrimpSpeciesNode) {
// case of ratio
resultLabels = new String[][]{{"Value", "1\u03C3 Abs"}, {}};
} else if (((ExpressionTree) expTree).hasRatiosOfInterest()) {
// case of NU switch
String uncertaintyDirective
= ((ExpressionTree) expTree).getUncertaintyDirective();
if (uncertaintyDirective.length() > 0) {
resultLabels = new String[][]{{"1\u03C3 " + uncertaintyDirective}, {}};
} else {
resultLabels = new String[][]{{"Value", "1\u03C3 Abs"}, {}};
}
sb.append("\n");
} else {
resultLabels = ((ExpressionTree) expTree).getOperation().getLabelsForOutputValues();
}
} else if (exp instanceof SpotFieldNode) {
// special case where the expressionTree is a field in spot (non-ratio)
sb.append(String.format("%1$-" + 15 + "s", "Spot name"));
sb.append(String.format("%1$-" + 20 + "s", exp.getName()));
sb.append("\n");
for (ShrimpFractionExpressionInterface spot : spots) {
sb.append(String.format("%1$-" + 15 + "s", spot.getFractionID()));
List<ShrimpFractionExpressionInterface> singleSpot = new ArrayList<>();
singleSpot.add(spot);
for (int i = 0; i < resultLabels[0].length; i++) {
try {
double[][] results
= Arrays.stream(ExpressionTreeInterface.convertObjectArrayToDoubles(exp.eval(singleSpot, null))).toArray(double[][]::new);
for (int i = 0; i < results[0].length; i++) {
try {
sb.append(String.format("%1$-" + 20 + "s", Utilities.roundedToSize(results[0][i], 15)));
} catch (Exception e) {
}
}
sb.append("\n");
} catch (SquidException squidException) {
sb.append(String.format("%1$-" + 20 + "s", resultLabels[0][i]));
} catch (Exception e) {
}
}
} else {
if (exp.isSquidSwitchConcentrationReferenceMaterialCalculation()) {
sb.append("Concentration Reference Materials Only\n\n");
}
sb.append(String.format("%1$-" + 15 + "s", "Spot name"));
if (((ExpressionTree) exp).getOperation() != null) {
String[][] resultLabels = ((ExpressionTree) exp).getOperation().getLabelsForOutputValues();
for (int i = 0; i < resultLabels[0].length; i++) {
try {
sb.append(String.format("%1$-" + 20 + "s", resultLabels[0][i]));
} catch (Exception e) {
}
}
if (((ExpressionTree) exp).hasRatiosOfInterest()) {
sb.append(String.format("%1$-" + 20 + "s", (forcePercentUn ? "1-sigma %" : "1-sigma ABS")));
}
}
sb.append("\n");
if (((ExpressionTree) exp).getLeftET() instanceof ShrimpSpeciesNode) {
if (((ExpressionTree) expTree).getLeftET() instanceof ShrimpSpeciesNode) {
// case of ratio
for (ShrimpFractionExpressionInterface spot : spots) {
sb.append(String.format("%1$-" + 15 + "s", spot.getFractionID()));
double[][] results
= Arrays.stream(spot.getIsotopicRatioValuesByStringName(exp.getName())).toArray(double[][]::new);
if (results[0].length == 2 && forcePercentUn) {
results[0][1] = (results[0][1] / results[0][0]) * 100;
}
= Arrays.stream(spot.getIsotopicRatioValuesByStringName(expTree.getName())).toArray(double[][]::new);
for (int i = 0; i < results[0].length; i++) {
try {
sb.append(String.format("%1$-" + 20 + "s", Utilities.roundedToSize(results[0][i], 15)));
sb.append(String.format("%1$-" + 20 + "s", Utilities.roundedToSize(results[0][i], sigDigits)));
} catch (Exception e) {
}
}
sb.append("\n");
}
} else {
for (ShrimpFractionExpressionInterface spot : spots) {
if (spot.getTaskExpressionsEvaluationsPerSpot().get(exp) != null) {
if (spot.getTaskExpressionsEvaluationsPerSpot().get(expTree) != null) {
sb.append(String.format("%1$-" + 15 + "s", spot.getFractionID()));
double[][] results
= Arrays.stream(spot.getTaskExpressionsEvaluationsPerSpot().get(exp)).toArray(double[][]::new);
if (results[0].length == 2 && forcePercentUn) {
results[0][1] = (results[0][1] / results[0][0]) * 100;
}
for (int i = 0; i < results[0].length; i++) {
= Arrays.stream(spot.getTaskExpressionsEvaluationsPerSpot().get(expTree)).toArray(double[][]::new);
for (int i = 0; i < resultLabels[0].length; i++) {
try {
sb.append(String.format("%1$-" + 20 + "s", Utilities.roundedToSize(results[0][i], 15)));
sb.append(String.format("%1$-" + 20 + "s", Utilities.roundedToSize(results[0][i], sigDigits)));
} catch (Exception e) {
}
}
@@ -2135,6 +2167,7 @@ private String peekDetailsPerSpot(List<ShrimpFractionExpressionInterface> spots,
}
}
}
return sb.toString();
}
@@ -2979,6 +3012,7 @@ private void graphExpressionTree(ExpressionTreeInterface expTree) {
try {
Files.write(Paths.get("EXPRESSION.HTML"), graphContents.getBytes());
BrowserControl.showURI("EXPRESSION.HTML");
} catch (IOException iOException) {
}
}
@@ -3544,7 +3578,7 @@ public OperationTextNode(String text) {
}
}
// this node signals user can edit in context menu
// this node signals user can edit in context menu
private class NumberTextNode extends ExpressionTextNode {
public NumberTextNode(String text) {
@@ -3564,6 +3598,7 @@ private void initNodeSelection() {
}
}
});
}
private class ExpressionTextNode extends Text {
@@ -29,7 +29,7 @@
<?import javafx.scene.text.TextFlow?>
<?import javafx.scene.web.WebView?>
<SplitPane fx:id="mainPane" dividerPositions="0.0" maxHeight="-Infinity" maxWidth="-Infinity" styleClass="backgroundCalamari" stylesheets="@../css/projectManager.css" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.cirdles.squid.gui.expressions.ExpressionBuilderController">
<SplitPane fx:id="mainPane" dividerPositions="0.0" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="702.0" prefWidth="1220.0" styleClass="backgroundCalamari" stylesheets="@../css/projectManager.css" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.cirdles.squid.gui.expressions.ExpressionBuilderController">
<items>
<SplitPane fx:id="leftSplitPane" dividerPositions="0.75" maxWidth="500.0" minWidth="275.0" orientation="VERTICAL" styleClass="backgroundCalamari">
<items>
@@ -214,7 +214,7 @@
<CheckBox fx:id="concRefMatSwitchCheckBox" mnemonicParsing="false" onAction="#concRefMatCheckBoxAction" opacity="0.99" text="Conc RefMat" />
<CheckBox fx:id="summaryCalculationSwitchCheckBox" layoutX="316.0" layoutY="10.0" mnemonicParsing="false" onAction="#summaryCalculationCheckBoxAction" opacity="0.99" text="Summary Calculation" />
<CheckBox fx:id="NUSwitchCheckBox" layoutX="601.0" layoutY="10.0" mnemonicParsing="false" onAction="#NUSwitchCheckBoxAction" opacity="0.99" text="NU Switch" />
<CheckBox fx:id="specialUPbThSwitchCheckBox" disable="true" layoutX="433.0" layoutY="10.0" mnemonicParsing="false" onAction="#specialUPbThCheckBoxAction" opacity="0.99" text="Squid 3 Expression" />
<CheckBox fx:id="specialUPbThSwitchCheckBox" disable="true" layoutX="433.0" layoutY="10.0" mnemonicParsing="false" onAction="#specialUPbThCheckBoxAction" opacity="0.99" text="Built-in Expression" />
</children>
<VBox.margin>
<Insets bottom="5.0" left="7.0" right="7.0" />
@@ -60,12 +60,12 @@ public Age7CorrPb8Th2WithErr() {
precedence = 4;
rowCount = 1;
colCount = 2;
labelsForOutputValues = new String[][]{{"Age", "1SigmaUnct"}};
labelsForOutputValues = new String[][]{{"Age", "1\u03C3 Unct"}};
labelsForInputValues = new String[]{
"Total 206/238, Total 206/238 1%Unct,"
+ "Total 208/232, Total 208/232 1%Unct, "
+ "Total 208/206, Total 208/206 1%Unct,"
+ "\"Total 207/206, Total 207/206 1%Unct,"
"Total 206/238, Total 206/238 1\u03C3 %Unct,"
+ "Total 208/232, Total 208/232 1\u03C3 %Unct, "
+ "Total 208/206, Total 208/206 1\u03C3 %Unct,"
+ "\"Total 207/206, Total 207/206 1\u03C3 %Unct,"
+ "sComm_64, sComm_6476, sComm_86"};
}
@@ -53,8 +53,8 @@ public Age7corrWithErr() {
precedence = 4;
rowCount = 1;
colCount = 2;
labelsForOutputValues = new String[][]{{"Age", "1SigmaUnct"}};
labelsForInputValues = new String[]{"Total 206/238, Total 206/238 1SigmaUnct, Total 207/206, Total 207/206 1SigmaUnct, sComm_76"};
labelsForOutputValues = new String[][]{{"Age", "1\u03C3 Unct"}};
labelsForInputValues = new String[]{"Total 206/238, Total 206/238 1\u03C3 Unct, Total 207/206, Total 207/206 1\u03C3 Unct, sComm_76"};
}
/**
@@ -56,11 +56,11 @@ public Age8corrWithErr() {
precedence = 4;
rowCount = 1;
colCount = 2;
labelsForOutputValues = new String[][]{{"Age", "1SigmaUnct"}};
labelsForOutputValues = new String[][]{{"Age", "1\u03C3 Unct"}};
labelsForInputValues = new String[]{
"Total 206/238, Total 206/238 1SigmaUnct, "
+ "Total 208/232, Total 208/232 1SigmaUnct,"
+ "232/238, 232/238 1SigmaUnct, sComm_86"};
"Total 206/238, Total 206/238 1\u03C3 Unct, "
+ "Total 208/232, Total 208/232 1\u03C3 Unct,"
+ "232/238, 232/238 1\u03C3 Unct, sComm_86"};
}
/**
Oops, something went wrong.

0 comments on commit 59a03e5

Please sign in to comment.