Skip to content

Commit 9c795cb

Browse files
authored
Merge pull request #722 from bowring/fixit
Bug fix and refactoring
2 parents 31c82c9 + acb8517 commit 9c795cb

File tree

19 files changed

+407
-525
lines changed

19 files changed

+407
-525
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.10.2'
10+
String mavenVersion = '1.10.3'
1111

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

squidAPI/src/main/java/org/cirdles/squid/Squid3Ink.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class Squid3Ink implements Squid3API {
6666
private static SquidPersistentState squidPersistentState;
6767
private Squid3ProjectBasicAPI squid3Project;
6868

69-
private Squid3Ink(String squidUserHomeDirectory) throws SquidException {
69+
private Squid3Ink(String squidUserHomeDirectory) throws SquidException, IOException {
7070
System.setProperty("user.home", squidUserHomeDirectory);
7171
CalamariFileUtilities.initSampleParametersModels();
7272
squidLabData = SquidLabData.getExistingSquidLabData();
@@ -89,7 +89,7 @@ public static SquidPersistentState getSquidPersistentState() {
8989
return squidPersistentState;
9090
}
9191

92-
public static Squid3API spillSquid3Ink(String squidUserHomeDirectory) throws SquidException {
92+
public static Squid3API spillSquid3Ink(String squidUserHomeDirectory) throws SquidException, IOException {
9393
return new Squid3Ink(squidUserHomeDirectory);
9494
}
9595

squidApp/src/main/java/org/cirdles/squid/gui/RatiosManagerController.java

+55-78
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,14 @@ public class RatiosManagerController implements Initializable {
7272
private static final String STYLE_RATIO_LABEL = "-fx-font-family: 'SansSerif';\n"
7373
+ " -fx-font-weight: bold;\n"
7474
+ " -fx-font-size: 7pt;\n";
75-
76-
@FXML
77-
private GridPane ratiosGridPane;
78-
7975
private final int BUTTON_WIDTH = 45;
8076
private final int BUTTON_HEIGHT = 30;
81-
82-
private List<SquidSpeciesModel> squidSpeciesList;
83-
private int indexOfBackgroundSpecies;
84-
8577
List<Button> rowButtons = new ArrayList<>();
8678
List<Button> colButtons = new ArrayList<>();
79+
@FXML
80+
private GridPane ratiosGridPane;
81+
private List<SquidSpeciesModel> squidSpeciesList;
82+
private int indexOfBackgroundSpecies;
8783

8884
/**
8985
* Initializes the controller class.
@@ -124,44 +120,25 @@ private void prepareRatioGrid() {
124120
int rowCounter = 0;
125121
int colCounter = 0;
126122
for (int i = 0; i < squidSpeciesList.size(); i++) {
127-
if (squidSpeciesList.get(i).getIsBackground()) {
128-
// indexOfBackgroundSpecies = squidSpeciesList.get(i).getMassStationIndex();
129-
// squidProject.getTask().setIndexOfBackgroundSpecies(indexOfBackgroundSpecies);
130-
//
131-
// if (squidSpeciesList.get(i).isNumeratorRole()) {
132-
// Label rowBackgroundLabel = new SquidLabel(rowCounter + 1, 0, squidSpeciesList.get(i).getIsotopeName());
133-
// ratiosGridPane.add(rowBackgroundLabel, 0, rowCounter + 1);
134-
// rowButtons.add(null);
135-
// rowCounter++;
136-
// }
137-
//
138-
// if (squidSpeciesList.get(i).isDenominatorRole()) {
139-
// Label colBackgroundLabel = new SquidLabel(0, colCounter + 1, squidSpeciesList.get(i).getIsotopeName());
140-
// ratiosGridPane.add(colBackgroundLabel, colCounter + 1, 0);
141-
// colButtons.add(null);
142-
// colCounter++;
143-
// }
144123

145-
} else {
146-
if (squidSpeciesList.get(i).isNumeratorRole()) {
147-
Button rowNumeratorButton = new SquidRowColButton(i, -1, squidSpeciesList.get(i).getIsotopeName());
148-
ratiosGridPane.add(rowNumeratorButton, 0, rowCounter + 1);
149-
rowButtons.add(rowNumeratorButton);
150-
rowCounter++;
151-
}
152-
153-
if (squidSpeciesList.get(i).isDenominatorRole()) {
154-
Button colDenominatorButton = new SquidRowColButton(-1, i, squidSpeciesList.get(i).getIsotopeName());
155-
ratiosGridPane.add(colDenominatorButton, colCounter + 1, 0);
156-
colButtons.add(colDenominatorButton);
157-
colCounter++;
158-
}
124+
if (squidSpeciesList.get(i).isNumeratorRole()) {
125+
Button rowNumeratorButton = new SquidRowColButton(i, -1, squidSpeciesList.get(i).getIsotopeName());
126+
ratiosGridPane.add(rowNumeratorButton, 0, rowCounter + 1);
127+
rowButtons.add(rowNumeratorButton);
128+
rowCounter++;
159129
}
160130

161-
Label cornerLabel = new SquidLabel(0, 0, "Num/\nDen");
162-
ratiosGridPane.add(cornerLabel, 0, 0);
131+
if (squidSpeciesList.get(i).isDenominatorRole()) {
132+
Button colDenominatorButton = new SquidRowColButton(-1, i, squidSpeciesList.get(i).getIsotopeName());
133+
ratiosGridPane.add(colDenominatorButton, colCounter + 1, 0);
134+
colButtons.add(colDenominatorButton);
135+
colCounter++;
136+
}
163137
}
164138

139+
Label cornerLabel = new SquidLabel(0, 0, "Num/\nDen");
140+
ratiosGridPane.add(cornerLabel, 0, 0);
141+
165142
populateRatioGrid();
166143
}
167144

@@ -183,11 +160,11 @@ private void populateRatioGrid() {
183160
if (!selected) {
184161
try {
185162
((SquidRowColButton) rowButtons.get(rowCounter)).setSelected(false);
186-
} catch (Exception e) {
163+
} catch (Exception ignored) {
187164
}
188165
try {
189166
((SquidRowColButton) colButtons.get(colCounter)).setSelected(false);
190-
} catch (Exception e) {
167+
} catch (Exception ignored) {
191168
}
192169
}
193170
}
@@ -198,6 +175,37 @@ private void populateRatioGrid() {
198175
}
199176
}
200177

178+
static class SquidRatioButtonEventHandler implements EventHandler<Event> {
179+
180+
private final int row;
181+
private final int col;
182+
private final String ratioName;
183+
private final Button btn;
184+
private boolean selected;
185+
186+
public SquidRatioButtonEventHandler(int row, int col, String ratioName, boolean selected, Button btn) {
187+
this.row = row;
188+
this.col = col;
189+
this.ratioName = ratioName;
190+
this.selected = selected;
191+
this.btn = btn;
192+
}
193+
194+
@Override
195+
public void handle(Event event) {
196+
selected = !selected;
197+
((Button) event.getSource()).setText(selected ? ratioName : "");
198+
199+
if (selected) {
200+
btn.setStyle(STYLE_RATIO_SELECTED);
201+
} else {
202+
btn.setStyle(STYLE_RATIO_UNSELECTED);
203+
}
204+
205+
squidProject.getTask().updateTableOfSelectedRatiosByMassStationIndex(row, col, selected);
206+
}
207+
}
208+
201209
class SquidRatioButton extends Button {
202210

203211
public SquidRatioButton(int row, int col, String ratioName, boolean selected) {
@@ -231,7 +239,7 @@ class SquidRowColButton extends Button {
231239
public SquidRowColButton(int row, int col, String ratioName) {
232240
super(ratioName);
233241

234-
ratioToolTip = new Tooltip("Click to select entire " + (String) (row == -1 ? "column" : "row"));
242+
ratioToolTip = new Tooltip("Click to select entire " + (row == -1 ? "column" : "row"));
235243
setTooltip(ratioToolTip);
236244

237245
selected = false;
@@ -272,60 +280,29 @@ public SquidLabel(int row, int col, String text) {
272280

273281
}
274282

275-
class SquidRatioButtonEventHandler implements EventHandler<Event> {
283+
class SquidRowColButtonEventHandler implements EventHandler<Event> {
276284

277285
private final int row;
278286
private final int col;
279-
private final String ratioName;
280287
private boolean selected;
281-
private final Button btn;
282288

283-
public SquidRatioButtonEventHandler(int row, int col, String ratioName, boolean selected, Button btn) {
289+
public SquidRowColButtonEventHandler(int row, int col, boolean selected) {
284290
this.row = row;
285291
this.col = col;
286-
this.ratioName = ratioName;
287292
this.selected = selected;
288-
this.btn = btn;
289293
}
290294

291-
@Override
292-
public void handle(Event event) {
293-
selected = !selected;
294-
((Button) event.getSource()).setText(selected ? ratioName : "");
295-
296-
if (selected) {
297-
btn.setStyle(STYLE_RATIO_SELECTED);
298-
} else {
299-
btn.setStyle(STYLE_RATIO_UNSELECTED);
300-
}
301-
302-
squidProject.getTask().updateTableOfSelectedRatiosByMassStationIndex(row, col, selected);
303-
}
304-
}
305-
306-
class SquidRowColButtonEventHandler implements EventHandler<Event> {
307-
308295
/**
309296
* @param selected the selected to set
310297
*/
311298
public void setSelected(boolean selected) {
312299
this.selected = selected;
313300
}
314301

315-
private final int row;
316-
private final int col;
317-
private boolean selected;
318-
319-
public SquidRowColButtonEventHandler(int row, int col, boolean selected) {
320-
this.row = row;
321-
this.col = col;
322-
this.selected = selected;
323-
}
324-
325302
@Override
326303
public void handle(Event event) {
327304
selected = !selected;
328-
((SquidRowColButton) event.getSource()).setToolTipText("Click to " + (selected ? "de-" : "") + "select entire " + (String) (row == -1 ? "column" : "row"));
305+
((SquidRowColButton) event.getSource()).setToolTipText("Click to " + (selected ? "de-" : "") + "select entire " + (row == -1 ? "column" : "row"));
329306
((SquidRowColButton) event.getSource()).setSelected(selected);
330307
squidProject.getTask().updateTableOfSelectedRatiosByRowOrCol(row, col, selected);
331308
populateRatioGrid();

0 commit comments

Comments
 (0)