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>.
2424import static fiji .plugin .trackmate .detection .DetectorKeys .DEFAULT_TARGET_CHANNEL ;
2525import static fiji .plugin .trackmate .detection .DetectorKeys .KEY_TARGET_CHANNEL ;
2626import static fiji .plugin .trackmate .detection .ThresholdDetectorFactory .KEY_SIMPLIFY_CONTOURS ;
27- import static fiji .plugin .trackmate .io .IOUtils .readBooleanAttribute ;
28- import static fiji .plugin .trackmate .io .IOUtils .readDoubleAttribute ;
29- import static fiji .plugin .trackmate .io .IOUtils .readIntegerAttribute ;
30- import static fiji .plugin .trackmate .io .IOUtils .writeAttribute ;
31- import static fiji .plugin .trackmate .io .IOUtils .writeTargetChannel ;
32- import static fiji .plugin .trackmate .util .TMUtils .checkMapKeys ;
33- import static fiji .plugin .trackmate .util .TMUtils .checkParameter ;
3427
35- import java .util .ArrayList ;
3628import java .util .HashMap ;
37- import java .util .List ;
3829import java .util .Map ;
3930
4031import javax .swing .ImageIcon ;
4132
42- import org .jdom2 .Element ;
4333import org .scijava .Priority ;
4434import org .scijava .plugin .Plugin ;
4535
4636import fiji .plugin .trackmate .Model ;
4737import fiji .plugin .trackmate .Settings ;
4838import fiji .plugin .trackmate .detection .SpotDetector ;
4939import fiji .plugin .trackmate .detection .SpotDetectorFactory ;
40+ import fiji .plugin .trackmate .gui .GuiUtils ;
5041import fiji .plugin .trackmate .gui .components .ConfigurationPanel ;
5142import fiji .plugin .trackmate .util .TMUtils ;
5243import net .imagej .ImgPlus ;
5748@ Plugin ( type = SpotDetectorFactory .class , priority = Priority .LOW - 5. )
5849public class MorphoLibJDetectorFactory < T extends RealType < T > & NativeType < T > > implements SpotDetectorFactory < T >
5950{
60-
61- /*
62- * CONSTANTS
63- */
64-
6551 /**
6652 * The key to the parameter that stores the tolerance value to use in
6753 * morphological segmentation. Accepted values are doubles.
@@ -99,29 +85,14 @@ public class MorphoLibJDetectorFactory< T extends RealType< T > & NativeType< T
9985 + "also cite the MorphoLibJ paper: <a href=\" https://doi.org/10.1093/bioinformatics/btw413\" >Legland, D.; Arganda-Carreras, I. & Andrey, P. (2016), "
10086 + "'MorphoLibJ: integrated library and plugins for mathematical morphology with ImageJ', "
10187 + "Bioinformatics (Oxford Univ Press) 32(22): 3532-3534.</a> "
102- + "<p>"
103- + "Documentation for this module "
104- + "<a href=\" https://imagej.net/plugins/trackmate/trackmate-morpholibj\" >on the ImageJ Wiki</a>."
105- + "<p>"
10688 + "</html>" ;
10789
108- /*
109- * FIELDS
110- */
111-
112- /** The image to operate on. Multiple frames, single channel. */
113- protected ImgPlus < T > img ;
114-
115- protected Map < String , Object > settings ;
90+ public static final String DOC_URL = "https://imagej.net/plugins/trackmate/trackmate-morpholibj" ;
11691
117- protected String errorMessage ;
118-
119- /*
120- * METHODS
121- */
92+ public static final ImageIcon ICON = new ImageIcon ( GuiUtils .getResource ( "images/TrackMateMorphoLibJ-logo-64px.png" , MorphoLibJDetectorFactory .class ) );
12293
12394 @ Override
124- public SpotDetector < T > getDetector ( final Interval interval , final int frame )
95+ public SpotDetector < T > getDetector ( final ImgPlus < T > img , final Map < String , Object > settings , final Interval interval , final int frame )
12596 {
12697 final int channel = ( Integer ) settings .get ( KEY_TARGET_CHANNEL ) - 1 ;
12798 final ImgPlus < T > input = TMUtils .hyperSlice ( img , channel , frame );
@@ -138,54 +109,6 @@ public SpotDetector< T > getDetector( final Interval interval, final int frame )
138109 return detector ;
139110 }
140111
141- @ Override
142- public boolean setTarget ( final ImgPlus < T > img , final Map < String , Object > settings )
143- {
144- this .img = img ;
145- this .settings = settings ;
146- return checkSettings ( settings );
147- }
148-
149- @ Override
150- public String getErrorMessage ()
151- {
152- return errorMessage ;
153- }
154-
155- @ Override
156- public boolean marshall ( final Map < String , Object > settings , final Element element )
157- {
158- final StringBuilder errorHolder = new StringBuilder ();
159- boolean ok = writeTargetChannel ( settings , element , errorHolder );
160- ok = ok && writeAttribute ( settings , element , KEY_TOLERANCE , Double .class , errorHolder );
161- ok = ok && writeAttribute ( settings , element , KEY_CONNECTIVITY , Integer .class , errorHolder );
162- ok = ok && writeAttribute ( settings , element , KEY_SIMPLIFY_CONTOURS , Boolean .class , errorHolder );
163-
164- if ( !ok )
165- errorMessage = errorHolder .toString ();
166-
167- return ok ;
168- }
169-
170- @ Override
171- public boolean unmarshall ( final Element element , final Map < String , Object > settings )
172- {
173- settings .clear ();
174- final StringBuilder errorHolder = new StringBuilder ();
175- boolean ok = true ;
176- ok = ok && readIntegerAttribute ( element , settings , KEY_TARGET_CHANNEL , errorHolder );
177- ok = ok && readDoubleAttribute ( element , settings , KEY_TOLERANCE , errorHolder );
178- ok = ok && readIntegerAttribute ( element , settings , KEY_CONNECTIVITY , errorHolder );
179- ok = ok && readBooleanAttribute ( element , settings , KEY_SIMPLIFY_CONTOURS , errorHolder );
180-
181- if ( !ok )
182- {
183- errorMessage = errorHolder .toString ();
184- return false ;
185- }
186- return checkSettings ( settings );
187- }
188-
189112 @ Override
190113 public ConfigurationPanel getDetectorConfigurationPanel ( final Settings settings , final Model model )
191114 {
@@ -204,36 +127,21 @@ public Map< String, Object > getDefaultSettings()
204127 }
205128
206129 @ Override
207- public boolean checkSettings ( final Map < String , Object > settings )
130+ public String getInfoText ( )
208131 {
209- boolean ok = true ;
210- final StringBuilder errorHolder = new StringBuilder ();
211- ok = ok & checkParameter ( settings , KEY_TARGET_CHANNEL , Integer .class , errorHolder );
212- ok = ok & checkParameter ( settings , KEY_TOLERANCE , Double .class , errorHolder );
213- ok = ok & checkParameter ( settings , KEY_CONNECTIVITY , Integer .class , errorHolder );
214- ok = ok & checkParameter ( settings , KEY_SIMPLIFY_CONTOURS , Boolean .class , errorHolder );
215- final List < String > mandatoryKeys = new ArrayList <>();
216- mandatoryKeys .add ( KEY_TARGET_CHANNEL );
217- mandatoryKeys .add ( KEY_TOLERANCE );
218- mandatoryKeys .add ( KEY_CONNECTIVITY );
219- mandatoryKeys .add ( KEY_SIMPLIFY_CONTOURS );
220- ok = ok & checkMapKeys ( settings , mandatoryKeys , null , errorHolder );
221- if ( !ok )
222- errorMessage = errorHolder .toString ();
223-
224- return ok ;
132+ return INFO_TEXT ;
225133 }
226134
227135 @ Override
228- public String getInfoText ()
136+ public ImageIcon getIcon ()
229137 {
230- return INFO_TEXT ;
138+ return ICON ;
231139 }
232140
233141 @ Override
234- public ImageIcon getIcon ()
142+ public String getUrl ()
235143 {
236- return null ;
144+ return DOC_URL ;
237145 }
238146
239147 @ Override
@@ -253,10 +161,4 @@ public boolean has2Dsegmentation()
253161 {
254162 return true ;
255163 }
256-
257- @ Override
258- public MorphoLibJDetectorFactory < T > copy ()
259- {
260- return new MorphoLibJDetectorFactory <>();
261- }
262164}
0 commit comments