Skip to content

Commit 32106c4

Browse files
authored
Refactoring and Issue resolution (#703)
* Refactoring * Fixed #701 * Fixed #702 and refactored
1 parent 8c55689 commit 32106c4

File tree

11 files changed

+98
-43
lines changed

11 files changed

+98
-43
lines changed

common.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'maven-publish'
77

88

99
String mavenGroupId = 'org.cirdles'
10-
String mavenVersion = '1.9.12'
10+
String mavenVersion = '1.10.0'
1111

1212
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
1313

squidApp/src/main/java/org/cirdles/squid/gui/dateInterpretations/commonLeadAssignment/CommonLeadAssignmentController.java

+24-15
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ public class CommonLeadAssignmentController implements Initializable {
109109
@FXML
110110
private Button viewDetailsButton;
111111

112+
private int widthOfSelectedAgeColumn = 105;
113+
private int ageTypeDisplayTranslationX = 70;
114+
112115
/**
113116
* Initializes the controller class.
114117
*/
@@ -312,18 +315,20 @@ private void showUnknownsWithOvercountCorrections() throws SquidException {
312315
}
313316

314317
private void setUpFooter() {
318+
int ageLabelWidth = 88;
315319
footerHBox.getChildren().addAll(
316-
makeLabel("", 135, true, 10),
320+
makeLabel("", 125, true, 10),
317321
makeLabel("206Pb/204Pb", 90, true, 10),
318322
makeLabel("207Pb/204Pb", 90, true, 10),
319323
makeLabel("208Pb/204Pb", 90, true, 10),
320-
makeLabel(PB4CORR + "\n" + PB4COR206_238AGE.replace(PB4CORR, ""), 90, true, 10),
321-
makeLabel(PB4CORR + "\n" + PB4COR208_232AGE.replace(PB4CORR, ""), 90, true, 10),
322-
makeLabel(PB4CORR + "\n" + PB4COR207_206AGE.replace(PB4CORR, ""), 90, true, 10),
323-
makeLabel(PB7CORR + "\n" + PB7COR206_238AGE.replace(PB7CORR, ""), 90, true, 10),
324-
makeLabel(PB7CORR + "\n" + PB7COR208_232AGE.replace(PB7CORR, ""), 90, true, 10),
325-
makeLabel(PB8CORR + "\n" + PB8COR206_238AGE.replace(PB8CORR, ""), 90, true, 10),
326-
makeLabel(PB8CORR + "\n" + PB8COR207_206AGE.replace(PB8CORR, ""), 90, true, 10));
324+
makeLabel("", 35, true, 10),
325+
makeLabel(PB4CORR + "\n" + PB4COR206_238AGE.replace(PB4CORR, "").replace("_Age", ""), ageLabelWidth, true, 10),
326+
makeLabel(PB4CORR + "\n" + PB4COR208_232AGE.replace(PB4CORR, "").replace("_Age", ""), ageLabelWidth, true, 10),
327+
makeLabel(PB4CORR + "\n" + PB4COR207_206AGE.replace(PB4CORR, "").replace("_Age", ""), ageLabelWidth, true, 10),
328+
makeLabel(PB7CORR + "\n" + PB7COR206_238AGE.replace(PB7CORR, "").replace("_Age", ""), ageLabelWidth, true, 10),
329+
makeLabel(PB7CORR + "\n" + PB7COR208_232AGE.replace(PB7CORR, "").replace("_Age", ""), ageLabelWidth, true, 10),
330+
makeLabel(PB8CORR + "\n" + PB8COR206_238AGE.replace(PB8CORR, "").replace("_Age", ""), ageLabelWidth, true, 10),
331+
makeLabel(PB8CORR + "\n" + PB8COR207_206AGE.replace(PB8CORR, "").replace("_Age", ""), ageLabelWidth, true, 10));
327332
}
328333

329334
private Label makeLabel(String label, int width, boolean fontIsBold, int fontSize) {
@@ -433,6 +438,10 @@ public void displayData() {
433438
addVboxFactory("207Pb/204Pb", spot.getCom_207Pb204Pb(), 0.0);
434439
addVboxFactory("208Pb/204Pb", spot.getCom_208Pb204Pb(), 0.0);
435440

441+
Label aValue = new Label("");
442+
aValue.setPrefWidth(35);
443+
getChildren().add(aValue);
444+
436445
addVboxFactory(expPB4COR206_238AGE.getName(),
437446
spot.getTaskExpressionsEvaluationsPerSpot().get(expPB4COR206_238AGE)[0][0],
438447
spot.getTaskExpressionsEvaluationsPerSpot().get(expPB4COR206_238AGE)[0][1]);
@@ -488,7 +497,7 @@ private void addVboxFactory(String label, double value, double unct) throws Squi
488497
aValue.setTextFill(Paint.valueOf("red"));
489498
aValue.setFont(Font.font("Monospaced", FontWeight.BOLD, 12));
490499
}
491-
aValue.setPrefWidth(102);
500+
aValue.setPrefWidth(widthOfSelectedAgeColumn - 5);
492501
aValue.setMinWidth(USE_PREF_SIZE);
493502
aValue.setPrefHeight(20);
494503
aValue.setMinHeight(USE_PREF_SIZE);
@@ -827,7 +836,7 @@ public void changed(ObservableValue<? extends Boolean> observable, Boolean oldVa
827836

828837
VBox groupDetailsVBox = new VBox(-10);
829838
HBox ageChoosersHBox = new HBox();
830-
ageChoosersHBox.setTranslateX(15);
839+
ageChoosersHBox.setTranslateX(ageTypeDisplayTranslationX);
831840

832841
ageChoosersHBox.getChildren().add(ageRadioButtonFactory(sampleGroupName, SampleAgeTypesEnum.PB4COR206_238AGE, PB4CORR));
833842
ageChoosersHBox.getChildren().add(ageRadioButtonFactory(sampleGroupName, SampleAgeTypesEnum.PB4COR208_232AGE, PB4CORR));
@@ -844,9 +853,9 @@ public void changed(ObservableValue<? extends Boolean> observable, Boolean oldVa
844853
// be sure we are on sample group toolbar
845854
if (sampleGroup != null) {
846855
weightedMeansHBox = new HBox();
847-
weightedMeansHBox.setTranslateX(15);
856+
weightedMeansHBox.setTranslateX(ageTypeDisplayTranslationX);
848857

849-
int wmWidth = 107;
858+
int wmWidth = widthOfSelectedAgeColumn;
850859
Label weightedMeanLabel = makeRedLabel("", wmWidth, true, 11, 4.0);
851860
weightedMeanLabel.setId(SampleAgeTypesEnum.PB4COR206_238AGE.getExpressionName());
852861
weightedMeansHBox.getChildren().add(weightedMeanLabel);
@@ -892,7 +901,7 @@ private void updateWeightedMeanLabel(Label wmLabel, String sampleGroupName) {
892901
Formatter formatter = new Formatter();
893902
formatter.format("%5.1f", spotSummaryDetails.getValues()[0][0] / 1e6);
894903
formatter.format(" " + ABS_UNCERTAINTY_DIRECTIVE + "%2.1f", spotSummaryDetails.getValues()[0][1] / 1e6).toString();
895-
wmLabel.setText("WM: " + formatter);
904+
wmLabel.setText("WM:" + formatter);
896905

897906
// tool tip
898907
OperationOrFunctionInterface op = ((ExpressionTree) spotSummaryDetails.getExpressionTree()).getOperation();
@@ -943,11 +952,11 @@ public void handle(MouseEvent event) {
943952
* @param corrString the value of corrString
944953
*/
945954
private RadioButton ageRadioButtonFactory(String sampleGroupName, SampleAgeTypesEnum sampleAgeType, String corrString) {
946-
RadioButton ageRB = new RadioButton(corrString + "\n" + sampleAgeType.getExpressionName().replace(corrString, ""));
955+
RadioButton ageRB = new RadioButton(corrString + "\n" + sampleAgeType.getExpressionName().replace(corrString, "").replace("_Age", ""));
947956
ageRB.setId(sampleAgeType.getExpressionName());
948957
ageRB.setToggleGroup(ageRB_ToggleGroup);
949958
ageRB.setFont(Font.font("Monospaced", FontWeight.BOLD, 10));
950-
ageRB.setPrefWidth(107);
959+
ageRB.setPrefWidth(widthOfSelectedAgeColumn);
951960
ageRB.setMinWidth(USE_PREF_SIZE);
952961
ageRB.setPrefHeight(25);
953962
ageRB.setMinHeight(USE_PREF_SIZE);

squidApp/src/main/resources/org/cirdles/squid/gui/dateInterpretations/commonLeadAssignment/CommonLeadAssignment.fxml

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
</HBox>
6161
<HBox fx:id="headerHBox" minHeight="25.0" prefHeight="25.0" prefWidth="1200.0" spacing="35.0" styleClass="backgroundCalamari">
6262
<children>
63-
<Label style="-fx-font-family: SansSerif; -fx-font-size: 14; -fx-text-fill: #c53d13; -fx-font-weight: bold;" text=" Common Lead Assignment" translateY="-2.0" />
63+
<Label style="-fx-font-family: SansSerif; -fx-font-size: 14; -fx-text-fill: #c53d13; -fx-font-weight: bold;" text=" Common Lead Assignment:" translateY="-2.0" />
64+
<Label layoutX="10.0" layoutY="13.0" style="-fx-font-family: SansSerif; -fx-font-size: 14; -fx-text-fill: #c53d13; -fx-font-weight: bold;" text="Age Type:" translateX="260.0" />
6465
</children>
6566
<padding>
6667
<Insets top="3.0" />
@@ -73,4 +74,4 @@
7374
</padding>
7475
</HBox>
7576
</children>
76-
</VBox>
77+
</VBox>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.cirdles.squid.gui.utilities.fileUtilities;
2+
3+
import junit.framework.TestCase;
4+
import org.cirdles.squid.constants.Squid3Constants;
5+
import org.cirdles.squid.exceptions.SquidException;
6+
import org.cirdles.squid.projects.SquidProject;
7+
import org.cirdles.squid.utilities.stateUtilities.SquidSerializer;
8+
9+
import java.io.File;
10+
import java.io.IOException;
11+
import java.nio.file.Files;
12+
13+
public class FileHandlerTest extends TestCase {
14+
15+
public void setUp() throws Exception {
16+
super.setUp();
17+
}
18+
19+
public void tearDown() throws Exception {
20+
}
21+
22+
// April 2022 example test for Ian Robinson
23+
public void testSelectProjectFile() throws SquidException, IOException {
24+
SquidProject myProject = new SquidProject(Squid3Constants.TaskTypeEnum.GENERAL);
25+
SquidSerializer.serializeObjectToFile(myProject, "Test.ser");
26+
SquidProject myOtherProject = (SquidProject) SquidSerializer.getSerializedObjectFromFile("Test.ser", true);
27+
assertEquals(myProject.getProjectName(), myOtherProject.getProjectName());
28+
Files.deleteIfExists((new File("Test.ser")).toPath());
29+
}
30+
}

squidCore/src/main/java/org/cirdles/squid/shrimp/ShrimpFraction.java

+14
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,20 @@ public String getSelectedAgeExpressionName() throws SquidException {
10341034
return expressionName;
10351035
}
10361036

1037+
@Override
1038+
public String getComPbSelectedAgeType() throws SquidException {
1039+
1040+
String ageName = getSelectedAgeExpressionName();
1041+
1042+
try {
1043+
ageName.replaceFirst("_Age", "");
1044+
} catch (Exception e) {
1045+
//e.printStackTrace();
1046+
}
1047+
1048+
return ageName;
1049+
}
1050+
10371051
@Override
10381052
public int hashCode() {
10391053
int result = Objects.hash(getFractionID(), getSpotNumber(), getSpotIndex(), getNameOfMount(),

squidCore/src/main/java/org/cirdles/squid/shrimp/ShrimpFractionExpressionInterface.java

+7
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,11 @@ public interface ShrimpFractionExpressionInterface {
300300
public String getComPbCorrSKTargetAge();
301301

302302
public String getSelectedAgeExpressionName() throws SquidException;
303+
304+
/**
305+
* Used in custom reports per issue # 701.
306+
* @return
307+
* @throws SquidException
308+
*/
309+
public String getComPbSelectedAgeType() throws SquidException;
303310
}

squidCore/src/main/java/org/cirdles/squid/tasks/expressions/builtinExpressions/BuiltInExpressionsFactory.java

+4
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ public static Map<String, ExpressionTreeInterface> generateSpotMetaDataFields()
149149
ExpressionTreeInterface expDateTime = buildSpotNode("getDateTimeMilliseconds");
150150
spotMetaDataFields.put(expDateTime.getName(), expDateTime);
151151

152+
// april 2022 issue # 701
153+
ExpressionTreeInterface commonLeadAgeType = buildSpotNode("getComPbSelectedAgeType");
154+
spotMetaDataFields.put(commonLeadAgeType.getName(), commonLeadAgeType);
155+
152156
return spotMetaDataFields;
153157
}
154158

squidCore/src/main/java/org/cirdles/squid/utilities/stateUtilities/SquidPersistentState.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ public class SquidPersistentState implements Serializable {
6363
private String MRUTaskXMLFolderPath;
6464
private File customExpressionsFile;
6565

66+
67+
// private void readObject(ObjectInputStream stream) throws IOException,
68+
// ClassNotFoundException {
69+
// stream.defaultReadObject();
70+
//
71+
// ObjectStreamClass myObject = ObjectStreamClass.lookup(
72+
// Class.forName(SquidPersistentState.class.getCanonicalName()));
73+
// long theSUID = myObject.getSerialVersionUID();
74+
//
75+
// System.out.println("Customized De-serialization of SquidPersistentState "
76+
// + theSUID);
77+
// }
78+
6679
/**
6780
*
6881
*/
@@ -131,7 +144,7 @@ public static SquidPersistentState getExistingPersistentState() throws SquidExce
131144
myInstance = new SquidPersistentState();
132145
myInstance.serializeSelf();
133146
myInstance.setTaskDesign(new TaskDesign());
134-
147+
135148
// check to update TaskDesign
136149
TaskDesign sup = myInstance.getTaskDesign();
137150
if (sup == null) {
@@ -198,7 +211,6 @@ public void setTaskDesign(TaskDesign taskDesign) {
198211
private void initMRULists() {
199212
MRUProjectList = new ArrayList<>(MRU_COUNT);
200213
MRUPrawnFileList = new ArrayList<>(MRU_COUNT);
201-
// MRUTaskList = new ArrayList<>(MRU_COUNT);
202214
MRUExpressionList = new ArrayList<>(MRU_COUNT);
203215
}
204216

squidCore/src/main/java/org/cirdles/squid/utilities/stateUtilities/SquidSerializer.java

+1-23
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,6 @@ public static void serializeObjectToFile(Object serializableObject, String fileN
6060
}
6161
}
6262

63-
public static void serializeObjectToFileRAF(Object serializableObject, String fileName) throws SquidException, IOException {
64-
ObjectOutputStream objectOutputStream = null;
65-
try {
66-
RandomAccessFile raf = new RandomAccessFile(fileName, "rwd");
67-
FileOutputStream fos = new FileOutputStream(raf.getFD());
68-
objectOutputStream = new ObjectOutputStream(fos);
69-
objectOutputStream.writeObject(serializableObject);
70-
} catch (IOException ex) {
71-
throw new SquidException("Cannot serialize object of " + serializableObject.getClass().getSimpleName() + " to: " + fileName);
72-
73-
} finally {
74-
if (objectOutputStream != null) {
75-
objectOutputStream.close();
76-
}
77-
}
78-
}
79-
8063
/**
8164
* @param filename
8265
* @return
@@ -95,20 +78,15 @@ public static Object getSerializedObjectFromFile(String filename, boolean verbos
9578
if (verbose) {
9679
throw new SquidException("The file you are attempting to open does not exist:\n"
9780
+ " " + filename);
98-
// SquidMessageDialog.showWarningDialog("The file you are attempting to open does not exist:\n"
99-
// + " " + filename, null);
81+
10082
}
10183
} catch (IOException ex) {
10284
if (verbose) {
10385
throw new SquidException("The file you are attempting to open is not a valid '*.squid' file.");
104-
// SquidMessageDialog.showWarningDialog(
105-
// "The file you are attempting to open is not a valid '*.squid' file.", null);
10686
}
10787
} catch (ClassNotFoundException | ClassCastException ex) {
10888
if (verbose) {
10989
throw new SquidException("The file you are attempting to open is not compatible with this version of Squid3.");
110-
// SquidMessageDialog.showWarningDialog(
111-
// "The file you are attempting to open is not compatible with this version of Squid3.", null);
11290
}
11391
}
11492

Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)