// Auto segment on update flag
private boolean auto = true;
+
+ // Inorder to toggle between segmentation and Labelling mode. Initially under Segmentation Mode
+ private boolean labelMode = false;
// Combo box housing the selectable views
private Combo combo;
private void addListeners() {
brushControl.addSelectionListener(eventHandler);
- view.addContextChangeListener(eventHandler);
+ if(!labelMode)
+ {
+ view.addContextChangeListener(eventHandler);
+ }
view.addZoomListener(eventHandler);
addDisposeListener(eventHandler);
}
*/
private void createToolbar3() {
SwtUtils.addLabel(bar3, getAction(Tool.SetLabel).getText());
- comboLabel = SwtUtils.addCombo(bar3, 130, SWT.SIMPLE);
+ comboLabel = SwtUtils.addCombo(bar3, 150, SWT.SIMPLE);
comboLabel.setToolTipText( getAction(Tool.SetLabel).getToolTipText());
comboLabel.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
+ /*
+ * For the down arrow functionality
+ */
if(e.keyCode == 16777218)
{
comboLabel.setListVisible(true);
}
- public void setAnnotationType(AnnotationType type) {
- view.setAnnotationType(type);
+ public void setAnnotationType(AnnotationType type, boolean isLabelling) {
+ view.setAnnotationType(type, isLabelling);
}
this.auto = checked;
}
+ public void setLabellingMode(boolean checked) {
+ if (!this.labelMode && checked) {
+ // Toggling between Segmentation and labelling
+ Tool.Foreground.action.setEnabled(false);
+ Tool.Background.action.setEnabled(false);
+ setAnnotationType(AnnotationType.Background, true);
+ view.removeContextChangeListener(eventHandler);
+ if(!(view.getTool() == null))
+ {
+ view.getTool().detach();
+ }
+ }
+ else
+ {
+ view.addContextChangeListener(eventHandler);
+ view.getTool().attach(view.getImageControl());
+ }
+ this.labelMode = checked;
+ updateToolStates();
+ }
public boolean isAutoApply() {
return this.auto;
switch (a) {
case Foreground:
case Background:
+ case OperatingMode:
case AutoApply:
return Action.AS_CHECK_BOX;
case SetBrushSize:
private void execute(Tool a, Event e) {
switch (a) {
case Foreground:
- setAnnotationType(AnnotationType.Foreground);
+ setAnnotationType(AnnotationType.Foreground, false);
break;
case Background:
- setAnnotationType(AnnotationType.Background);
+ setAnnotationType(AnnotationType.Background, false);
+ break;
+ case OperatingMode:
+ setLabellingMode(a.action.isChecked());
break;
case ZoomIn:
zoomIn();
assign.setEnabled(canZoomBestFit() & !(comboLabel.getText().isEmpty()));
Tool.Foreground.action.setChecked(isAnnotatingForeground());
Tool.Background.action.setChecked(isAnnotatingBackground());
+ Tool.OperatingMode.action.setChecked(labelMode);
Tool.Clear.action.setEnabled(canClear());
Tool.AutoApply.action.setChecked(auto);
Tool.SegmenterOptions.action.setEnabled(canShowOptions());
+ Tool.Foreground.action.setEnabled(!labelMode && canZoomIn());
+ Tool.Background.action.setEnabled(!labelMode && canZoomIn());
+ Tool.OperatingMode.action.setEnabled(canZoomIn());
// Always enabled if view enabled
Tool.SetBrushSize.action.setEnabled(true);
Tool.SegmenterOptions.action.setEnabled(true);
Tool.SetPainter.action.setEnabled(true);
Tool.Repaint.action.setEnabled(true);
- Tool.Foreground.action.setEnabled(true);
- Tool.Background.action.setEnabled(true);
Tool.AutoApply.action.setEnabled(true);
} else {
// Detach old tool
int lineWidth = 1;
- if (tool != null) {
- lineWidth = tool.getLineWidth();
- tool.detach();
- tool = null;
+ if (getTool() != null) {
+ lineWidth = getTool().getLineWidth();
+ getTool().detach();
+ setTool(null);
}
// Detach old annotation listener
annotations.addAnnotationListener(listener);
// Attach a new annotation tool
- tool = new AnnotationTool(annotations, view);
- tool.setLineWidth(lineWidth);
+ setTool(new AnnotationTool(annotations, view));
+ getTool().setLineWidth(lineWidth);
}
// Create the initial image
public int getLineWidth() {
- if (tool != null) {
- return tool.getLineWidth();
+ if (getTool() != null) {
+ return getTool().getLineWidth();
}
return 1;
}
public void setLineWidth(int width) {
- if (tool != null) {
- tool.setLineWidth(width);
+ if (getTool() != null) {
+ getTool().setLineWidth(width);
}
}
public AnnotationType getAnnotationType() {
- if (tool != null) {
- return tool.getType();
+ if (getTool() != null) {
+ return getTool().getType();
}
return AnnotationType.Foreground;
}
- public void setAnnotationType(AnnotationType type) {
- if (tool != null) {
- tool.setType(type);
+ public void setAnnotationType(AnnotationType type, boolean isLabelling) {
+ if (getTool() != null) {
+ getTool().setType(type, isLabelling);
}
}
}
+ public AnnotationTool getTool() {
+ return tool;
+ }
+
+
+ public void setTool(AnnotationTool tool) {
+ this.tool = tool;
+ }
+
+
private final DisposeListener disposeListener = new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (cursor != null) {