Skip to content

Commit

Permalink
Added show mask button
Browse files Browse the repository at this point in the history
  • Loading branch information
CellDynamics committed Jan 11, 2018
1 parent aa4a9ad commit f6c7adf
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
Expand Up @@ -136,6 +136,7 @@ public RandomWalkSegmentationPlugin_() {
view.addFgController(new FgController());
view.addCloneController(new CloneController());
view.addLoadQconfController(new LoadQconfController());
view.addQconfShowSeedImageController(new QconfShowSeedImageController());
view.addRunActiveController(new RunActiveBtnController());
view.addHelpController(new HelpBtnController());
view.addSeedRoiController(new SeedRoiController());
Expand Down Expand Up @@ -673,20 +674,38 @@ public void actionPerformed(ActionEvent arg0) {
RandomWalkModel model = (RandomWalkModel) options;
model.qconfFile = Paths.get(directory, filename).toString();
view.setLqconfFile(filename);
}
}

/**
* Handle show loaded qconf file mask button.
*
* @author p.baniukiewicz
*
*/
public class QconfShowSeedImageController implements ActionListener {

@Override
public void actionPerformed(ActionEvent arg0) {
RandomWalkModel model = (RandomWalkModel) options;
if (model.qconfFile == null || model.qconfFile.isEmpty()
|| Paths.get(model.qconfFile).getFileName() == null) {
return;
}
try {
// TODO add checkbox in UI to show (in QCONFfile dynamic region, first line)
ImagePlus seedImage;
// temporary load, it is repeated in runPlugin
seedImage = new GenerateMask_("opts={paramFile:(" + model.qconfFile + "),binary:false}")
.getRes();
seedImage.setTitle("Mask-" + Paths.get(model.qconfFile).getFileName().toString() + ".tif");
new ContrastEnhancer().stretchHistogram(seedImage, 0.35);
seedImage.show();

} catch (QuimpPluginException e) {
LOGGER.debug("Can not load QCONF"); // not important, error handled in runPlugin
}

}

}

/**
Expand Down
Expand Up @@ -260,6 +260,7 @@ public void setCbMaskSeedImage(String[] item, String sel) {
}

private JButton bnQconfSeedImage;
private JButton bnQconfShowSeedImage;

private JButton bnClone;
private JButton bnSeedRoi;
Expand Down Expand Up @@ -873,7 +874,8 @@ public RandomWalkView() {
cbCreatedSeedImage = new JComboBox<String>();
cbRgbSeedImage = new JComboBox<String>();
cbMaskSeedImage = new JComboBox<String>();
bnQconfSeedImage = new JButton("Open");
bnQconfSeedImage = new JButton("Load");
bnQconfShowSeedImage = new JButton("Show");
bnClone = new JButton("Clone");
UiTools.setToolTip(bnClone, "Clone selected original image.");
bnSeedRoi = new JButton("Seed");
Expand Down Expand Up @@ -1140,6 +1142,7 @@ public void enableUI(boolean status) {
cbSeedSource.setEnabled(status);
cbMaskSeedImage.setEnabled(status);
bnQconfSeedImage.setEnabled(status);
bnQconfShowSeedImage.setEnabled(status);
bnClone.setEnabled(status);
bnSeedRoi.setEnabled(status);
bnFore.setEnabled(status);
Expand Down Expand Up @@ -1383,8 +1386,25 @@ private JPanel getQconfImage() {
.createTitledBorder(BorderFactory.createLineBorder(Color.ORANGE), "Seed from QCONF"));
dynPanel.setLayout(new GridLayout(2, 1, 2, 2));

dynPanel.add(bnQconfSeedImage);
JPanel upperrow = new JPanel();
upperrow.setLayout(new GridBagLayout());
GridBagConstraints constrProc = new GridBagConstraints();
constrProc.gridx = 0;
constrProc.gridy = 0;
constrProc.weightx = 1;
constrProc.weighty = 1;
constrProc.fill = GridBagConstraints.HORIZONTAL;
upperrow.add(bnQconfSeedImage, constrProc);
constrProc.gridx = 1;
constrProc.gridy = 0;
constrProc.weightx = 1;
constrProc.weighty = 1;
constrProc.fill = GridBagConstraints.HORIZONTAL;
upperrow.add(bnQconfShowSeedImage, constrProc);
dynPanel.add(upperrow);
dynPanel.add(lbQconfFile);
UiTools.setToolTip(bnQconfShowSeedImage, "Show mask generated from loaded QCONF file.");
UiTools.setToolTip(bnQconfSeedImage, "Load mask from QCONF file.");

return dynPanel;
}
Expand Down Expand Up @@ -1633,6 +1653,15 @@ public void addLoadQconfController(ActionListener list) {
bnQconfSeedImage.addActionListener(list);
}

/**
* Assign listener to Show loaded Qconfbutton.
*
* @param list listener
*/
public void addQconfShowSeedImageController(ActionListener list) {
bnQconfShowSeedImage.addActionListener(list);
}

/**
* Assign listener to original image selector.
*
Expand Down

0 comments on commit f6c7adf

Please sign in to comment.