88 * it under the terms of the GNU General Public License as
99 * published by the Free Software Foundation, either version 3 of the
1010 * License, or (at your option) any later version.
11- *
11+ *
1212 * This program is distributed in the hope that it will be useful,
1313 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1414 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515 * GNU General Public License for more details.
16- *
16+ *
1717 * You should have received a copy of the GNU General Public
1818 * License along with this program. If not, see
1919 * <http://www.gnu.org/licenses/gpl-3.0.html>.
@@ -102,16 +102,15 @@ public class WekaDetectorConfigurationPanel extends ConfigurationPanel
102102
103103 private final boolean is3D ;
104104
105- /**
106- * Create the panel.
107- */
108105 public WekaDetectorConfigurationPanel ( final Settings settings , final Model model )
109106 {
110107 @ SuppressWarnings ( "rawtypes" )
111108 final ImgPlus img = TMUtils .rawWraps ( settings .imp );
112109 this .is3D = img .dimensionIndex ( Axes .Z ) >= 0 ;
113110 this .prefService = TMUtils .getContext ().getService ( PrefService .class );
114111
112+ int gridy = 0 ;
113+
115114 final GridBagLayout gridBagLayout = new GridBagLayout ();
116115 gridBagLayout .columnWidths = new int [] { 144 , 0 , 32 };
117116 gridBagLayout .rowHeights = new int [] { 0 , 84 , 0 , 27 , 0 , 0 , 0 , 0 , 37 , 23 };
@@ -127,40 +126,45 @@ public WekaDetectorConfigurationPanel( final Settings settings, final Model mode
127126 gbcLblDetector .insets = new Insets ( 5 , 5 , 5 , 0 );
128127 gbcLblDetector .fill = GridBagConstraints .HORIZONTAL ;
129128 gbcLblDetector .gridx = 0 ;
130- gbcLblDetector .gridy = 0 ;
129+ gbcLblDetector .gridy = gridy ;
131130 add ( lblDetector , gbcLblDetector );
132131
133132 /*
134133 * Help text.
135134 */
135+
136+ gridy ++;
137+
136138 final GridBagConstraints gbcLblHelptext = new GridBagConstraints ();
137139 gbcLblHelptext .anchor = GridBagConstraints .NORTH ;
138140 gbcLblHelptext .fill = GridBagConstraints .BOTH ;
139141 gbcLblHelptext .gridwidth = 3 ;
140142 gbcLblHelptext .insets = new Insets ( 5 , 10 , 5 , 10 );
141143 gbcLblHelptext .gridx = 0 ;
142- gbcLblHelptext .gridy = 1 ;
144+ gbcLblHelptext .gridy = gridy ;
143145 add ( GuiUtils .textInScrollPanel ( GuiUtils .infoDisplay ( WekaDetectorFactory .INFO_TEXT ) ), gbcLblHelptext );
144146
145147 /*
146148 * Channel selector.
147149 */
148150
151+ gridy ++;
152+
149153 final JLabel lblSegmentInChannel = new JLabel ( "Segment in channel:" );
150154 lblSegmentInChannel .setFont ( SMALL_FONT );
151155 final GridBagConstraints gbcLblSegmentInChannel = new GridBagConstraints ();
152156 gbcLblSegmentInChannel .anchor = GridBagConstraints .EAST ;
153157 gbcLblSegmentInChannel .insets = new Insets ( 5 , 5 , 5 , 5 );
154158 gbcLblSegmentInChannel .gridx = 0 ;
155- gbcLblSegmentInChannel .gridy = 2 ;
159+ gbcLblSegmentInChannel .gridy = gridy ;
156160 add ( lblSegmentInChannel , gbcLblSegmentInChannel );
157161
158162 sliderChannel = new JSlider ();
159163 final GridBagConstraints gbcSliderChannel = new GridBagConstraints ();
160164 gbcSliderChannel .fill = GridBagConstraints .HORIZONTAL ;
161165 gbcSliderChannel .insets = new Insets ( 5 , 5 , 5 , 5 );
162166 gbcSliderChannel .gridx = 1 ;
163- gbcSliderChannel .gridy = 2 ;
167+ gbcSliderChannel .gridy = gridy ;
164168 add ( sliderChannel , gbcSliderChannel );
165169
166170 final JLabel labelChannel = new JLabel ( "1" );
@@ -169,7 +173,7 @@ public WekaDetectorConfigurationPanel( final Settings settings, final Model mode
169173 final GridBagConstraints gbcLabelChannel = new GridBagConstraints ();
170174 gbcLabelChannel .insets = new Insets ( 5 , 5 , 5 , 0 );
171175 gbcLabelChannel .gridx = 2 ;
172- gbcLabelChannel .gridy = 2 ;
176+ gbcLabelChannel .gridy = gridy ;
173177 add ( labelChannel , gbcLabelChannel );
174178
175179 sliderChannel .addChangeListener ( l -> labelChannel .setText ( "" + sliderChannel .getValue () ) );
@@ -178,13 +182,15 @@ public WekaDetectorConfigurationPanel( final Settings settings, final Model mode
178182 * Model file.
179183 */
180184
185+ gridy ++;
186+
181187 final JLabel lblCusstomModelFile = new JLabel ( "Weka model file:" );
182188 lblCusstomModelFile .setFont ( FONT );
183189 final GridBagConstraints gbcLblCusstomModelFile = new GridBagConstraints ();
184190 gbcLblCusstomModelFile .anchor = GridBagConstraints .SOUTHWEST ;
185191 gbcLblCusstomModelFile .insets = new Insets ( 0 , 5 , 5 , 5 );
186192 gbcLblCusstomModelFile .gridx = 0 ;
187- gbcLblCusstomModelFile .gridy = 3 ;
193+ gbcLblCusstomModelFile .gridy = gridy ;
188194 add ( lblCusstomModelFile , gbcLblCusstomModelFile );
189195
190196 btnBrowse = new JButton ( "Browse" );
@@ -194,31 +200,35 @@ public WekaDetectorConfigurationPanel( final Settings settings, final Model mode
194200 gbcBtnBrowse .anchor = GridBagConstraints .SOUTHEAST ;
195201 gbcBtnBrowse .gridwidth = 2 ;
196202 gbcBtnBrowse .gridx = 1 ;
197- gbcBtnBrowse .gridy = 3 ;
203+ gbcBtnBrowse .gridy = gridy ;
198204 add ( btnBrowse , gbcBtnBrowse );
199205
206+ gridy ++;
207+
200208 modelFileTextField = new JTextField ( "" );
201209 modelFileTextField .setFont ( SMALL_FONT );
202210 final GridBagConstraints gbcTextField = new GridBagConstraints ();
203211 gbcTextField .gridwidth = 3 ;
204212 gbcTextField .insets = new Insets ( 0 , 5 , 5 , 5 );
205213 gbcTextField .fill = GridBagConstraints .BOTH ;
206214 gbcTextField .gridx = 0 ;
207- gbcTextField .gridy = 4 ;
215+ gbcTextField .gridy = gridy ;
208216 add ( modelFileTextField , gbcTextField );
209217 modelFileTextField .setColumns ( 10 );
210218
211219 /*
212220 * Class index.
213221 */
214222
223+ gridy ++;
224+
215225 final JLabel lblClassId = new JLabel ( "Target class:" );
216226 lblClassId .setFont ( SMALL_FONT );
217227 final GridBagConstraints gbcLblOverlapThreshold = new GridBagConstraints ();
218228 gbcLblOverlapThreshold .anchor = GridBagConstraints .EAST ;
219229 gbcLblOverlapThreshold .insets = new Insets ( 5 , 5 , 5 , 5 );
220230 gbcLblOverlapThreshold .gridx = 0 ;
221- gbcLblOverlapThreshold .gridy = 5 ;
231+ gbcLblOverlapThreshold .gridy = gridy ;
222232 add ( lblClassId , gbcLblOverlapThreshold );
223233
224234 // For now we simply put a list of dummy class names.
@@ -231,20 +241,22 @@ public WekaDetectorConfigurationPanel( final Settings settings, final Model mode
231241 gbcSliderClassId .fill = GridBagConstraints .HORIZONTAL ;
232242 gbcSliderClassId .insets = new Insets ( 0 , 0 , 5 , 5 );
233243 gbcSliderClassId .gridx = 1 ;
234- gbcSliderClassId .gridy = 5 ;
244+ gbcSliderClassId .gridy = gridy ;
235245 add ( cmbboxClassId , gbcSliderClassId );
236246
237247 /*
238248 * Proba threshold.
239249 */
250+
251+ gridy ++;
240252
241253 final JLabel lblScoreTreshold = new JLabel ( "Threshold on probability:" );
242254 lblScoreTreshold .setFont ( SMALL_FONT );
243255 final GridBagConstraints gbcLblScoreTreshold = new GridBagConstraints ();
244256 gbcLblScoreTreshold .anchor = GridBagConstraints .EAST ;
245257 gbcLblScoreTreshold .insets = new Insets ( 5 , 5 , 5 , 5 );
246258 gbcLblScoreTreshold .gridx = 0 ;
247- gbcLblScoreTreshold .gridy = 6 ;
259+ gbcLblScoreTreshold .gridy = gridy ;
248260 add ( lblScoreTreshold , gbcLblScoreTreshold );
249261
250262 ftfProbaThreshold = new JFormattedTextField ( THRESHOLD_FORMAT );
@@ -255,12 +267,14 @@ public WekaDetectorConfigurationPanel( final Settings settings, final Model mode
255267 gbcScore .fill = GridBagConstraints .HORIZONTAL ;
256268 gbcScore .insets = new Insets ( 5 , 5 , 5 , 5 );
257269 gbcScore .gridx = 1 ;
258- gbcScore .gridy = 6 ;
270+ gbcScore .gridy = gridy ;
259271 add ( ftfProbaThreshold , gbcScore );
260272
261273 /*
262274 * Refresh class names.
263275 */
276+
277+ gridy ++;
264278
265279 final JButton btnClassNames = new JButton ( "Refresh class names" , MAGNIFIER_ICON );
266280 btnClassNames .setFont ( FONT );
@@ -269,7 +283,7 @@ public WekaDetectorConfigurationPanel( final Settings settings, final Model mode
269283 gbcBtnClassNames .anchor = GridBagConstraints .SOUTHWEST ;
270284 gbcBtnClassNames .insets = new Insets ( 5 , 5 , 5 , 5 );
271285 gbcBtnClassNames .gridx = 0 ;
272- gbcBtnClassNames .gridy = 7 ;
286+ gbcBtnClassNames .gridy = gridy ;
273287 add ( btnClassNames , gbcBtnClassNames );
274288
275289 /*
@@ -283,19 +297,21 @@ public WekaDetectorConfigurationPanel( final Settings settings, final Model mode
283297 gbcBtnLastProba .anchor = GridBagConstraints .SOUTHEAST ;
284298 gbcBtnLastProba .insets = new Insets ( 5 , 5 , 5 , 5 );
285299 gbcBtnLastProba .gridx = 1 ;
286- gbcBtnLastProba .gridy = 7 ;
300+ gbcBtnLastProba .gridy = gridy ;
287301 add ( btnLastProba , gbcBtnLastProba );
288302
289303 /*
290304 * Preview.
291305 */
292306
307+ gridy ++;
308+
293309 final GridBagConstraints gbcBtnPreview = new GridBagConstraints ();
294310 gbcBtnPreview .gridwidth = 3 ;
295311 gbcBtnPreview .fill = GridBagConstraints .BOTH ;
296312 gbcBtnPreview .insets = new Insets ( 5 , 5 , 5 , 5 );
297313 gbcBtnPreview .gridx = 0 ;
298- gbcBtnPreview .gridy = 8 ;
314+ gbcBtnPreview .gridy = gridy ;
299315
300316 previewer = new WekaDetectionPreviewer <>(
301317 model ,
0 commit comments