Skip to content

Commit

Permalink
Removed references to obsolete image segmentation operator interface …
Browse files Browse the repository at this point in the history
…class in MiToBo.
  • Loading branch information
bimoelle committed May 15, 2020
1 parent 8f67a67 commit c3e9388
Showing 1 changed file with 0 additions and 244 deletions.
244 changes: 0 additions & 244 deletions src/main/java/de/unihalle/informatik/rhizoTrak/display/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ as published by the Free Software Foundation (http://www.gnu.org/licenses/gpl.tx
import de.unihalle.informatik.Alida.operator.events.ALDOperatorCollectionEvent;
import de.unihalle.informatik.Alida.operator.events.ALDOperatorCollectionEvent.ALDOperatorCollectionEventType;
import de.unihalle.informatik.Alida.operator.events.ALDOperatorCollectionEventListener;
import de.unihalle.informatik.MiToBo.apps.minirhizotron.segmentation.RootSegmentationOperator;
import de.unihalle.informatik.MiToBo.core.datatypes.images.MTBImage;
import de.unihalle.informatik.MiToBo.core.operator.MTBOperatorCollection;
import de.unihalle.informatik.rhizoTrak.ControlWindow;
Expand Down Expand Up @@ -335,8 +334,6 @@ public final class Display extends DBObject implements ActionListener, IJEventLi
*/
private JList<String> list;

private MTBOperatorCollection<RootSegmentationOperator> operatorCollection;

private ALDOperatorCollectionElement operator;

private JButton runButton;
Expand Down Expand Up @@ -6759,13 +6756,6 @@ else if(command.equals("Delete treelines")){
else if(command.equals("Load images")){
Display.getFront().getProject().getRhizoMain().getRhizoImages().createImageLoaderFrame();
}
else if(command.equals("configureOperator")){
configureOperator();
}
else if(command.equals("runOperator")) {
runButton.setEnabled(false);
runOperator();
}
else if(command.equals("preferences")){
Display.getFront().getProject().getRhizoMain().getRhizoColVis().createPreferencesFrame();;
}
Expand Down Expand Up @@ -6860,62 +6850,6 @@ else if(command.equals("aboutRhizo")){
}});
}

// Opens the configuration window of the selected operator
private void configureOperator() {
String selectedOperatorName = list.getSelectedValue();
if ( selectedOperatorName != null )
{
// Checks if the window is already open
boolean isConfigFrameOpen = false;
for ( Display display : Display.getDisplays() )
{
JFrame frame = display.getFrame();
if ( frame.getTitle().contains("ALDOperatorConfigurationFrame:") && frame.isShowing() )
{
isConfigFrameOpen = true;
}
}
if ( !isConfigFrameOpen )
{
operatorCollection.openOperatorConfigWindow(selectedOperatorName);
}
}
else
{
JOptionPane.showMessageDialog(null, "Please choose an operator to configure.",
"Choose operator", JOptionPane.ERROR_MESSAGE);
}
}

// Runs the selected operator
private void runOperator()
{
// Gets the current image
Layer l = Display.getFrontLayer();
ImagePlus img = l.getPatches(true).get(0).getImagePlus();

operator = operatorCollection.getOperator(list.getSelectedValue());
if( operator != null )
{
runButton.setEnabled(false);
// Add method of RootSegmentationOperator to set image
if ( operator instanceof RootSegmentationOperator)
{
((RootSegmentationOperator) operator).setImage(img);
}

LinkedList<String> operatorList = new LinkedList<String>();
// only one operator can be selected
operatorList.add(list.getSelectedValue());
operatorCollection.runOperators(operatorList);
}
else
{
JOptionPane.showMessageDialog(null, "Please choose an operator to run.",
"Choose operator", JOptionPane.ERROR_MESSAGE);
}
}

private static String[] getReleaseInfosFromJar() {

InputStream is= null;
Expand Down Expand Up @@ -7714,15 +7648,11 @@ private JPanel createExtendedOptionPanel(RhizoMain rm)
JPanel group21 = new JPanel(new GridLayout(0, 2, 5, 1)); // Read and write operations
JPanel group3 = new JPanel(new GridLayout(0, 2, 5, 1)); // Connector related operations
JPanel group4 = new JPanel(new GridLayout(0, 2, 5, 1)); // Image related operations
JPanel group5 = new JPanel(new GridLayout(0, 1, 5, 1)); // Label for operators
JPanel group51 = new JPanel(new GridLayout(0, 1, 5, 1)); // Choose operator from list
JPanel group52 = new JPanel(new GridLayout(0, 2, 5, 1)); // Configure and run chosen operator
JPanel group6 = new JPanel(new GridLayout(0, 2, 5, 1)); // RhizoTrak miscellaneous
group11.setBorder(new EmptyBorder(5, 5, 5, 5));
group21.setBorder(new EmptyBorder(5, 5, 5, 5));
group3.setBorder(new EmptyBorder(5, 5, 5, 5));
group4.setBorder(new EmptyBorder(5, 5, 5, 5));
group52.setBorder(new EmptyBorder(5, 5, 5, 5));
group6.setBorder(new EmptyBorder(5, 5, 5, 5));

JLabel labelTreeline = new JLabel("Treelines:", JLabel.LEFT);
Expand Down Expand Up @@ -7798,31 +7728,6 @@ private JPanel createExtendedOptionPanel(RhizoMain rm)
loadImagesButton.addActionListener(this);
group4.add(loadImagesButton);

// Get available operators
JScrollPane scrollPane = getScrollableOperatorList();
boolean isOperatorAvailable = false;
if ( list.getModel().getSize() > 0 )
{
isOperatorAvailable = true;
}

JLabel labelOperators = new JLabel("Available Operators:", JLabel.LEFT);
group5.add(labelOperators);

group51.add(scrollPane);

runButton = new JButton("Run");
runButton.setToolTipText("Runs the selected operator.");
runButton.setActionCommand("runOperator");
runButton.addActionListener(this);
group52.add(runButton);

JButton configureButton = new JButton("Configure");
configureButton.setToolTipText("Opens a new window to configure the selected operator.");
configureButton.setActionCommand("configureOperator");
configureButton.addActionListener(this);
group52.add(configureButton);

JButton preferencesButton = new JButton("Preferences");
preferencesButton.setToolTipText("Edit treelines display options and other user settings.");
preferencesButton.setActionCommand("preferences");
Expand Down Expand Up @@ -7865,161 +7770,12 @@ private JPanel createExtendedOptionPanel(RhizoMain rm)
panel.add(group4);
panel.add(Box.createRigidArea(new Dimension(0, VGAP)));
panel.add(new JSeparator(JSeparator.HORIZONTAL));
// Only display panel if there is at least one available operator
if ( isOperatorAvailable )
{
panel.add(Box.createRigidArea(new Dimension(0, VGAP)));
panel.add(group5);
panel.add(group51);
panel.add(group52);
panel.add(Box.createRigidArea(new Dimension(0, VGAP)));
panel.add(new JSeparator(JSeparator.HORIZONTAL));
}
panel.add(Box.createRigidArea(new Dimension(0, VGAP)));
panel.add(group6);

return panel;
}

// Gets all available operators in a scrollable list
protected JScrollPane getScrollableOperatorList()
{
Vector<String> detectorList = new Vector<String>();

try
{
operatorCollection = new MTBOperatorCollection<RootSegmentationOperator>(RootSegmentationOperator.class);
// allows to restart the operator with the same parameter values
operatorCollection.setRerunFlags(true);
operatorCollection.addALDOperatorCollectionEventListener(new ALDOperatorCollectionEventListener()
{
// Event Listener for operator
@Override
public void handleALDOperatorCollectionEvent(ALDOperatorCollectionEvent event)
{
if ( event.getEventType() == ALDOperatorCollectionEventType.RESULTS_AVAILABLE )
{
runButton.setEnabled(true);

// Get results from operator
try
{
MTBImage image = (MTBImage) operator.getParameter("resultImage");
image.show();
}
catch (ALDOperatorException e)
{
IJError.print(e);
}

Map<Integer, Map<Integer, de.unihalle.informatik.MiToBo.apps.minirhizotron.segmentation.Node>> resultLineMap = null;

int sizeStatusLabel = getProject().getRhizoMain().getProjectConfig().sizeStatusLabelMapping();
String[] fullNames = new String[sizeStatusLabel+1];
for ( int i = 0; i < sizeStatusLabel; i++)
{
fullNames[i] = getProject().getRhizoMain().getProjectConfig().getStatusLabel(i).getName();
}
fullNames[sizeStatusLabel] = "STATUS_UNDEFINED";

final String status = (String) JOptionPane.showInputDialog(null,
"Which status should the treeline nodes have?\n"
+ "If you then press \'OK\', "
+ "the treelines will be imported in the image.",
"Choose status", JOptionPane.PLAIN_MESSAGE,
null, fullNames, fullNames[0]);
if( status != null )
{
if(operator instanceof RootSegmentationOperator)
{
resultLineMap = ((RootSegmentationOperator) operator).getMap();
}

/*
* starts two threads: first one to transfer the polylines to treelines, second on to freeze the GUI through
* a modal window. The window is then closed by the first thread if the transfer has been finished.
*/
final Map<Integer, Map<Integer, de.unihalle.informatik.MiToBo.apps.minirhizotron.segmentation.Node>> rLM = resultLineMap;
JDialog d = new JDialog();

// transfer the result polylines to treelines
Thread transferTreeline = new Thread()
{
public void run()
{
RhizoLineMapToTreeline lineMapToTree = new RhizoLineMapToTreeline(new RhizoMain(Display.getFront().getProject()));
lineMapToTree.convertLineMapToTreeLine(rLM, status);
d.setVisible(false);
}
};

// modal window to freeze the GUI
Thread showDialog = new Thread()
{
public void run()
{
JLabel l = new JLabel("Transfer of polylines to treelines in progress ... please wait!", JLabel.CENTER);
l.setVerticalAlignment(JLabel.CENTER);
d.add(l);
d.setTitle("Transfer to treelines");
d.setSize(600,200);
d.setModal(true);
d.setVisible(true);
}
};

// start both threads
showDialog.start();
transferTreeline.start();
}
}
else if ( event.getEventType() == ALDOperatorCollectionEventType.OP_NOT_CONFIGURED )
{
JOptionPane.showMessageDialog(null,
"Operator not completely configured.",
"Configure operator", JOptionPane.ERROR_MESSAGE);
}
else if ( event.getEventType() == ALDOperatorCollectionEventType.RUN_FAILURE )
{
JOptionPane.showMessageDialog(null,
"Something went wrong during execution of the operator.",
"Run failure", JOptionPane.ERROR_MESSAGE);
}
else if ( event.getEventType() == ALDOperatorCollectionEventType.INIT_FAILURE )
{
JOptionPane.showMessageDialog(null,
"Operator is not well initialized.",
"Initialization failure", JOptionPane.ERROR_MESSAGE);
}
else // ALDOperatorCollectionEventType.UNKNOWN
{
// do nothing
}
}
});
Collection<String> uniqueClassIDs = operatorCollection.getUniqueClassIDs();
detectorList.addAll(uniqueClassIDs);
}
catch (Exception e)
{
IJError.print(e);
}

Collections.sort(detectorList);
list = new JList<String>(detectorList);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// first operator selected as default
list.setSelectedIndex(0);
// only as high as needed for all found operators
list.setVisibleRowCount(detectorList.size());

JScrollPane scroll = new JScrollPane(list);
scroll.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

return scroll;
}

protected Image applyFilters(final Image img) {
if (!filter_enabled) return img;
return applyFilters(new ImagePlus("filtered", img)).getProcessor().createImage();
Expand Down

0 comments on commit c3e9388

Please sign in to comment.