@@ -72,18 +72,14 @@ public class RatiosManagerController implements Initializable {
72
72
private static final String STYLE_RATIO_LABEL = "-fx-font-family: 'SansSerif';\n "
73
73
+ " -fx-font-weight: bold;\n "
74
74
+ " -fx-font-size: 7pt;\n " ;
75
-
76
- @ FXML
77
- private GridPane ratiosGridPane ;
78
-
79
75
private final int BUTTON_WIDTH = 45 ;
80
76
private final int BUTTON_HEIGHT = 30 ;
81
-
82
- private List <SquidSpeciesModel > squidSpeciesList ;
83
- private int indexOfBackgroundSpecies ;
84
-
85
77
List <Button > rowButtons = new ArrayList <>();
86
78
List <Button > colButtons = new ArrayList <>();
79
+ @ FXML
80
+ private GridPane ratiosGridPane ;
81
+ private List <SquidSpeciesModel > squidSpeciesList ;
82
+ private int indexOfBackgroundSpecies ;
87
83
88
84
/**
89
85
* Initializes the controller class.
@@ -124,44 +120,25 @@ private void prepareRatioGrid() {
124
120
int rowCounter = 0 ;
125
121
int colCounter = 0 ;
126
122
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
- // }
144
123
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 ++;
159
129
}
160
130
161
- Label cornerLabel = new SquidLabel (0 , 0 , "Num/\n Den" );
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
+ }
163
137
}
164
138
139
+ Label cornerLabel = new SquidLabel (0 , 0 , "Num/\n Den" );
140
+ ratiosGridPane .add (cornerLabel , 0 , 0 );
141
+
165
142
populateRatioGrid ();
166
143
}
167
144
@@ -183,11 +160,11 @@ private void populateRatioGrid() {
183
160
if (!selected ) {
184
161
try {
185
162
((SquidRowColButton ) rowButtons .get (rowCounter )).setSelected (false );
186
- } catch (Exception e ) {
163
+ } catch (Exception ignored ) {
187
164
}
188
165
try {
189
166
((SquidRowColButton ) colButtons .get (colCounter )).setSelected (false );
190
- } catch (Exception e ) {
167
+ } catch (Exception ignored ) {
191
168
}
192
169
}
193
170
}
@@ -198,6 +175,37 @@ private void populateRatioGrid() {
198
175
}
199
176
}
200
177
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
+
201
209
class SquidRatioButton extends Button {
202
210
203
211
public SquidRatioButton (int row , int col , String ratioName , boolean selected ) {
@@ -231,7 +239,7 @@ class SquidRowColButton extends Button {
231
239
public SquidRowColButton (int row , int col , String ratioName ) {
232
240
super (ratioName );
233
241
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" ));
235
243
setTooltip (ratioToolTip );
236
244
237
245
selected = false ;
@@ -272,60 +280,29 @@ public SquidLabel(int row, int col, String text) {
272
280
273
281
}
274
282
275
- class SquidRatioButtonEventHandler implements EventHandler <Event > {
283
+ class SquidRowColButtonEventHandler implements EventHandler <Event > {
276
284
277
285
private final int row ;
278
286
private final int col ;
279
- private final String ratioName ;
280
287
private boolean selected ;
281
- private final Button btn ;
282
288
283
- public SquidRatioButtonEventHandler (int row , int col , String ratioName , boolean selected , Button btn ) {
289
+ public SquidRowColButtonEventHandler (int row , int col , boolean selected ) {
284
290
this .row = row ;
285
291
this .col = col ;
286
- this .ratioName = ratioName ;
287
292
this .selected = selected ;
288
- this .btn = btn ;
289
293
}
290
294
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
-
308
295
/**
309
296
* @param selected the selected to set
310
297
*/
311
298
public void setSelected (boolean selected ) {
312
299
this .selected = selected ;
313
300
}
314
301
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
-
325
302
@ Override
326
303
public void handle (Event event ) {
327
304
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" ));
329
306
((SquidRowColButton ) event .getSource ()).setSelected (selected );
330
307
squidProject .getTask ().updateTableOfSelectedRatiosByRowOrCol (row , col , selected );
331
308
populateRatioGrid ();
0 commit comments