@@ -75,15 +75,22 @@ public class ImageJ2Options extends OptionsPlugin implements Interactive {
75
75
* This system leverages the <a href="http://imagej.net/SCIFIO">SCIFIO</a>
76
76
* library to open image files.
77
77
*/
78
- @ Parameter (
79
- label = "Use SCIFIO when opening files (BETA!)" ,
80
- description = "<html>Whether to use ImageJ2's file I/O mechanism when "
81
- + "opening files.<br>Image files will be opened using the SCIFIO library "
82
- + "(SCientific Image<br>Format Input and Output), which provides truly "
83
- + "extensible support for<br>reading and writing image file formats." ,
78
+ @ Parameter (label = "Use SCIFIO when opening files (BETA!)" ,
79
+ description = "<html>Whether to use ImageJ2's file I/O mechanism when " +
80
+ "opening files.<br>Image files will be opened using the SCIFIO library " +
81
+ "(SCientific Image<br>Format Input and Output), which provides truly " +
82
+ "extensible support for<br>reading and writing image file formats." ,
84
83
callback = "run" )
85
84
private boolean sciJavaIO = false ;
86
85
86
+ @ Parameter (label = "SciJava log level" ,
87
+ description = "<html>Log level for SciJava" ,
88
+ initializer = "initializeLogLevel" , //
89
+ callback = "setLogLevel" , //
90
+ choices = { "ERROR" , "WARN" , "INFO" , "DEBUG" , "TRACE" }, //
91
+ persist = false )
92
+ private String logLevel ;
93
+
87
94
@ Parameter (label = "What is ImageJ2?" , persist = false , callback = "help" )
88
95
private Button help ;
89
96
@@ -201,4 +208,56 @@ private void help() {
201
208
System .err .println (message );
202
209
}
203
210
}
211
+
212
+ @ SuppressWarnings ("unused" )
213
+ private void initializeLogLevel () {
214
+ logLevel = parseLogLevel (log .getLevel ());
215
+ }
216
+
217
+ @ SuppressWarnings ("unused" )
218
+ private void setLogLevel () {
219
+ log .setLevel (parseLogLevel (logLevel ));
220
+ }
221
+
222
+ /**
223
+ * Parses a log level from a {@code String}.
224
+ *
225
+ * @param level
226
+ * @return the {@code int} associated with the level
227
+ */
228
+ private int parseLogLevel (final String level ) {
229
+ switch (level ) {
230
+ case "NONE" : return LogService .NONE ;
231
+ case "ERROR" : return LogService .ERROR ;
232
+ case "WARN" : return LogService .WARN ;
233
+ case "INFO" : return LogService .INFO ;
234
+ case "DEBUG" : return LogService .DEBUG ;
235
+ case "TRACE" : return LogService .TRACE ;
236
+ }
237
+
238
+ return LogService .WARN ;
239
+ }
240
+
241
+ /**
242
+ * Parses a log level from an {@code int}.
243
+ *
244
+ * @param level
245
+ * @return the {@code String} associated with the level
246
+ */
247
+ private String parseLogLevel (int level ) {
248
+ if (level == LogService .NONE )
249
+ return "NONE" ;
250
+ if (level == LogService .ERROR )
251
+ return "ERROR" ;
252
+ if (level == LogService .WARN )
253
+ return "WARN" ;
254
+ if (level == LogService .INFO )
255
+ return "INFO" ;
256
+ if (level == LogService .DEBUG )
257
+ return "DEBUG" ;
258
+ if (level == LogService .TRACE )
259
+ return "TRACE" ;
260
+
261
+ return "" + level ;
262
+ }
204
263
}
0 commit comments