@@ -54,10 +54,10 @@ public abstract class AbstractSpotDetectorOp extends AbstractUnaryHybridCF< List
5454{
5555
5656 @ Parameter ( type = ItemIO .INPUT )
57- private Map < String , Object > settings ;
57+ protected Map < String , Object > settings ;
5858
5959 @ Parameter ( type = ItemIO .INPUT )
60- private SpatioTemporalIndex < Spot > sti ;
60+ protected SpatioTemporalIndex < Spot > sti ;
6161
6262 @ Parameter ( type = ItemIO .BOTH , required = false )
6363 protected DetectionQualityFeature qualityFeature ;
@@ -69,18 +69,33 @@ public abstract class AbstractSpotDetectorOp extends AbstractUnaryHybridCF< List
6969 protected boolean ok ;
7070
7171 @ Parameter
72- private ThreadService threadService ;
72+ protected ThreadService threadService ;
7373
7474 @ Parameter ( required = false )
75- private StatusService statusService ;
75+ protected StatusService statusService ;
7676
7777 @ Parameter ( required = false )
78- private Logger log ;
78+ protected Logger log ;
7979
80- private long processingTime ;
80+ protected long processingTime ;
8181
8282 protected DetectorOp detector ;
8383
84+ /**
85+ * Default execution routine for a Mamut spot detector.
86+ * <p>
87+ * Calling this method will run the {@link DetectorOp} specified by its
88+ * class (3rd input) on the specified sources (1st input). The positions
89+ * found by the detector op will be then converted to {@link Spot}s and
90+ * added to the specified {@link ModelGraph} (2nd input).
91+ *
92+ * @param sources
93+ * the souces to operate on.
94+ * @param graph
95+ * the {@link ModelGraph} to add the spots to.
96+ * @param cl
97+ * the {@link DetectorOp} to run.
98+ */
8499 protected void exec ( final List < SourceAndConverter < ? > > sources , final ModelGraph graph , final Class < ? extends DetectorOp > cl )
85100 {
86101 ok = false ;
@@ -89,29 +104,8 @@ protected void exec( final List< SourceAndConverter< ? > > sources, final ModelG
89104 if ( null == qualityFeature )
90105 qualityFeature = new DetectionQualityFeature ( graph .vertices ().getRefPool () );
91106
92- /*
93- * Resolve add detection behavior.
94- */
95- final DetectionCreatorFactory detectionCreator ;
96- if ( null == sti )
97- {
98- detectionCreator = MamutDetectionCreatorFactories .getAddDetectionCreatorFactory ( graph , qualityFeature );
99- }
100- else
101- {
102- DetectionBehavior detectionBehavior = DetectionBehavior .ADD ;
103- final String addBehavior = ( String ) settings .get ( KEY_ADD_BEHAVIOR );
104- if ( null != addBehavior )
105- {
106- try
107- {
108- detectionBehavior = MamutDetectionCreatorFactories .DetectionBehavior .valueOf ( addBehavior );
109- }
110- catch ( final IllegalArgumentException e )
111- {}
112- }
113- detectionCreator = detectionBehavior .getFactory ( graph , qualityFeature , sti );
114- }
107+ // Resolve add detection behavior.
108+ final DetectionCreatorFactory detectionCreator = getDetectorFactory ( graph );
115109
116110 this .detector = ( DetectorOp ) Inplaces .binary1 ( ops (), cl ,
117111 detectionCreator , sources , settings );
@@ -138,6 +132,47 @@ protected void exec( final List< SourceAndConverter< ? > > sources, final ModelG
138132 }
139133 }
140134
135+ /**
136+ * Instantiates a default {@link DetectionCreatorFactory} configured to add
137+ * spots to the specified {@link ModelGraph}.
138+ * <p>
139+ * If a setting key 'ADD_BEHAVIOR' exists in the {@link #settings} field,
140+ * the corresponding factory will be returned. Otherwise, the factory
141+ * created adds spots to the graph, regardless of possibly pre-existing
142+ * spots.
143+ *
144+ * @param graph
145+ * the {@link ModelGraph}.
146+ * @return a new {@link DetectionCreatorFactory}.
147+ */
148+ protected DetectionCreatorFactory getDetectorFactory ( final ModelGraph graph )
149+ {
150+ /*
151+ * Resolve add detection behavior.
152+ */
153+ final DetectionCreatorFactory detectionCreator ;
154+ if ( null == sti )
155+ {
156+ detectionCreator = MamutDetectionCreatorFactories .getAddDetectionCreatorFactory ( graph , qualityFeature );
157+ }
158+ else
159+ {
160+ DetectionBehavior detectionBehavior = DetectionBehavior .ADD ;
161+ final String addBehavior = ( String ) settings .get ( KEY_ADD_BEHAVIOR );
162+ if ( null != addBehavior )
163+ {
164+ try
165+ {
166+ detectionBehavior = MamutDetectionCreatorFactories .DetectionBehavior .valueOf ( addBehavior );
167+ }
168+ catch ( final IllegalArgumentException e )
169+ {}
170+ }
171+ detectionCreator = detectionBehavior .getFactory ( graph , qualityFeature , sti );
172+ }
173+ return detectionCreator ;
174+ }
175+
141176 @ Override
142177 public long getProcessingTime ()
143178 {
0 commit comments