66 * %%
77 * Redistribution and use in source and binary forms, with or without
88 * modification, are permitted provided that the following conditions are met:
9- *
9+ *
1010 * 1. Redistributions of source code must retain the above copyright notice,
1111 * this list of conditions and the following disclaimer.
1212 * 2. Redistributions in binary form must reproduce the above copyright notice,
1313 * this list of conditions and the following disclaimer in the documentation
1414 * and/or other materials provided with the distribution.
15- *
15+ *
1616 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4444
4545import sc .fiji .ome .zarr .settings .ZarrDragAndDropOpenSettings ;
4646import sc .fiji .ome .zarr .settings .ZarrOpenBehavior ;
47+ import sc .fiji .ome .zarr .settings .ZarrReaderBackend ;
4748
4849/**
4950 * A FIJI/ImageJ command to select what to do when an OME-Zarr image is Drag & Dropped into Fiji.
@@ -86,15 +87,29 @@ public class DragAndDropBehaviorSettings extends DynamicCommand
8687 + "</body>"
8788 + "</html>" ;
8889
90+ @ SuppressWarnings ( "all" )
91+ @ Parameter ( label = "Reader backend" , description = "Choose which library is used to read OME-Zarr datasets" , initializer = "initZarrReaderBackends" )
92+ private String readerBackendChoice ;
93+
94+ @ SuppressWarnings ( "all" )
95+ @ Parameter ( visibility = ItemVisibility .MESSAGE , required = false , persist = false )
96+ private String readerBackendInfo = "<html>"
97+ + "<body width=" + WIDTH + "cm align=left>"
98+ + "N5 supports OME-Zarr v0.4 (Zarr v2) - v0.5 (Zarr v3).<br>"
99+ + "zarr-java supports OME-Zarr v0.4 (Zarr v2) - v0.3 (Zarr v3)."
100+ + "</body>"
101+ + "</html>" ;
102+
89103 private ZarrDragAndDropOpenSettings settings ;
90104
91105 @ Override
92106 public void run ()
93107 {
94108 settings .setCurrentChoice ( ZarrOpenBehavior .getByDescription ( defaultZarrOpenBehavior ) );
95109 settings .setPreferredMaxWidth ( preferredWidth );
96- logger .debug ( "Now saving OME-Zarr Drag & Drop settings to user preferences. Behavior: {}, preferredWidth: {}" ,
97- settings .getOpenBehavior (), preferredWidth );
110+ settings .setReaderBackend ( ZarrReaderBackend .getByDescription ( readerBackendChoice ) );
111+ logger .debug ( "Now saving OME-Zarr Drag & Drop settings to user preferences. Behavior: {}, preferredWidth: {}, readerBackend: {}" ,
112+ settings .getOpenBehavior (), preferredWidth , settings .getReaderBackend () );
98113 settings .saveSettingsToPreferences ( prefService );
99114 }
100115
@@ -104,6 +119,7 @@ private void init()
104119 settings = ZarrDragAndDropOpenSettings .loadSettingsFromPreferences ( prefService );
105120 defaultZarrOpenBehavior = settings .getOpenBehavior ().getDescription ();
106121 preferredWidth = settings .getPreferredMaxWidth ();
122+ readerBackendChoice = settings .getReaderBackend ().getDescription ();
107123 }
108124
109125 @ SuppressWarnings ( "unused" )
@@ -112,8 +128,20 @@ private void initZarrOpenBehaviors()
112128 getInfo ().getMutableInput ( "defaultZarrOpenBehavior" , String .class ).setChoices ( enumNamesAsList ( ZarrOpenBehavior .values () ) );
113129 }
114130
131+ @ SuppressWarnings ( "unused" )
132+ private void initZarrReaderBackends ()
133+ {
134+ getInfo ().getMutableInput ( "readerBackendChoice" , String .class )
135+ .setChoices ( readerBackendDescriptions ( ZarrReaderBackend .values () ) );
136+ }
137+
115138 static List < String > enumNamesAsList ( final ZarrOpenBehavior [] values )
116139 {
117140 return Arrays .stream ( values ).map ( ZarrOpenBehavior ::getDescription ).collect ( Collectors .toList () );
118141 }
142+
143+ static List < String > readerBackendDescriptions ( final ZarrReaderBackend [] values )
144+ {
145+ return Arrays .stream ( values ).map ( ZarrReaderBackend ::getDescription ).collect ( Collectors .toList () );
146+ }
119147}
0 commit comments