Skip to content

Commit 368116d

Browse files
committed
fix: batchMode
1 parent 5a558a9 commit 368116d

4 files changed

Lines changed: 41 additions & 47 deletions

File tree

src/main/java/com/berdal84/mageek/MColorPreset.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ final MColor getMetaColorAt(int _index)
103103
{
104104
return colors[_index];
105105
}
106+
107+
final void setMetaColorAt(int _index, MColor _color)
108+
{
109+
colors[_index] = _color;
110+
}
111+
106112

107113
final String getIJColorStringAt(int _index)
108114
{

src/main/java/com/berdal84/mageek/Mageek.java

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,13 @@ public void run()
197197
gui.setAvailableZProjection(ZProjector.METHODS);
198198
gui.setZProjection(ZProjector.METHODS[ZProjector.AVG_METHOD]);
199199
gui.setVisible(true);
200-
gui.setAlwaysOnTop(false);
200+
gui.setAlwaysOnTop(false);
201+
gui.setBatchMode(batchMode);
201202

202203
gui.addBrowseBtnListener((ActionEvent evt)->
203204
{
204205
gui.setStatus("Browsing folder ...");
205-
206+
gui.setProgress(0);
206207
askSourceDirectoryToUser();
207208

208209
if (sourceFolder != null)
@@ -213,8 +214,6 @@ public void run()
213214
sourceFolder.toString()
214215
)
215216
);
216-
gui.setProgress(10);
217-
218217
gui.setSourceDirectory(sourceFolder.toString());
219218

220219
scannedFiles = FileHelper.getFiles(sourceFolder, true);
@@ -226,7 +225,6 @@ public void run()
226225
else
227226
{
228227
gui.setStatus("Browsing aborted.");
229-
gui.setProgress(0);
230228
gui.clearFileList();
231229
}
232230
});
@@ -335,7 +333,15 @@ public void windowDeactivated(WindowEvent e)
335333

336334
if ( !presetName.equals("Custom") )
337335
{
338-
gui.setColorPreset( colorPresets.get(presetName), true);
336+
MColorPreset presetSelected = colorPresets.get(presetName);
337+
gui.setColorPreset( presetSelected, true);
338+
339+
// We choose a unique event for color item selection changed
340+
// We need to update the selectedColorPreset entirely
341+
for( int i=0; i < 4; i++ )
342+
{
343+
selectedColors.setMetaColorAt(i, presetSelected.getMetaColorAt(i) );
344+
}
339345
}
340346
});
341347

@@ -418,6 +424,10 @@ private void processFiles()
418424
int channel = 0;
419425
for (ImagePlus channelImg : allChannels)
420426
{
427+
if( !batchMode )
428+
{
429+
channelImg.show();
430+
}
421431

422432
if ( channelImg.getNSlices() > 1 )
423433
{
@@ -440,9 +450,23 @@ private void processFiles()
440450
);
441451

442452
ImagePlus out = new ImagePlus("out", p.createImage());
453+
454+
if( !batchMode )
455+
{
456+
channelImg.close();
457+
out.show();
458+
}
459+
443460
FileSaver saver = new FileSaver(out);
444461
saver.saveAsTiff(outputPath);
445462
channel++;
463+
464+
465+
if( !batchMode )
466+
{
467+
out.close();
468+
469+
}
446470
}
447471
serie++;
448472
}
@@ -462,31 +486,6 @@ private void processFiles()
462486
}
463487

464488
gui.setStatus("Processing DONE");
465-
466-
if ( !batchMode && !allImages.isEmpty() )
467-
{
468-
DialogPrompt.Result response =
469-
ui.showDialog(
470-
"Would you like to open the images?",
471-
MessageType.QUESTION_MESSAGE,
472-
OptionType.YES_NO_OPTION
473-
);
474-
475-
if( response.equals( DialogPrompt.Result.YES_OPTION ) )
476-
{
477-
allImages.forEach( (ImagePlus[] imgs )->
478-
{
479-
for(ImagePlus img : imgs )
480-
{
481-
img.show();
482-
}
483-
});
484-
}
485-
}
486-
else
487-
{
488-
gui.setStatus("No images were loaded :(");
489-
}
490489
}
491490
else
492491
{

src/main/java/com/berdal84/mageek/MageekFrame.form

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,9 @@
493493
</Component>
494494
<Component class="javax.swing.JCheckBox" name="batchCheckBox">
495495
<Properties>
496-
<Property name="selected" type="boolean" value="true"/>
497496
<Property name="text" type="java.lang.String" value="Batch Mode"/>
498497
<Property name="toolTipText" type="java.lang.String" value="Enable by default, will process the images in background (faster)."/>
499498
</Properties>
500-
<Events>
501-
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="batchCheckBoxActionPerformed"/>
502-
</Events>
503499
</Component>
504500
</SubComponents>
505501
</Container>

src/main/java/com/berdal84/mageek/MageekFrame.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,8 @@ public void valueChanged(javax.swing.event.ListSelectionEvent evt)
226226
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
227227
jLabel9.setText("Channel 4");
228228

229-
batchCheckBox.setSelected(true);
230229
batchCheckBox.setText("Batch Mode");
231230
batchCheckBox.setToolTipText("Enable by default, will process the images in background (faster).");
232-
batchCheckBox.addActionListener(new java.awt.event.ActionListener()
233-
{
234-
public void actionPerformed(java.awt.event.ActionEvent evt)
235-
{
236-
batchCheckBoxActionPerformed(evt);
237-
}
238-
});
239231

240232
javax.swing.GroupLayout colorPanelLayout = new javax.swing.GroupLayout(colorPanel);
241233
colorPanel.setLayout(colorPanelLayout);
@@ -354,10 +346,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
354346
pack();
355347
}// </editor-fold>//GEN-END:initComponents
356348

357-
private void batchCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_batchCheckBoxActionPerformed
358-
// TODO add your handling code here:
359-
}//GEN-LAST:event_batchCheckBoxActionPerformed
360-
361349
private void extensionListValueChanged(javax.swing.event.ListSelectionEvent evt)//GEN-FIRST:event_extensionListValueChanged
362350
{//GEN-HEADEREND:event_extensionListValueChanged
363351

@@ -616,5 +604,10 @@ String getSelectedIJColorStringAt(int i)
616604
{
617605
return (String) colorComboBoxes.get(i).getSelectedItem();
618606
}
607+
608+
void setBatchMode(boolean batchMode)
609+
{
610+
batchCheckBox.setSelected(batchMode);
611+
}
619612

620613
};

0 commit comments

Comments
 (0)