Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
Implemented functionality of toggling between Segmentation mode and labelling mode...
authorlingutln <lingutln@localhost>
Mon, 26 Dec 2011 03:18:08 +0000 (03:18 +0000)
committerlingutln <lingutln@localhost>
Mon, 26 Dec 2011 03:18:08 +0000 (03:18 +0000)
svn path=/; revision=237

Annotation/library/commons-lang3-3.1.jar [new file with mode: 0644]
Annotation/src/ie/dcu/apps/ist/controllers/AnnotationTool.java
Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java
Annotation/src/ie/dcu/apps/ist/widgets/AnnotatedImageControl.java

diff --git a/Annotation/library/commons-lang3-3.1.jar b/Annotation/library/commons-lang3-3.1.jar
new file mode 100644 (file)
index 0000000..a85e539
Binary files /dev/null and b/Annotation/library/commons-lang3-3.1.jar differ
index eb89bb0a1912e7320ecf6d017355c94f451b792e..e02fecfdf5998edc2997d187bd1a55bd9243b52a 100644 (file)
@@ -38,7 +38,6 @@ public class AnnotationTool extends MouseMotionAdapter {
                this.current = null;
                this.lineWidth = 1;
                this.type = AnnotationType.Foreground;
-               
                attach(view);
        }
 
@@ -48,9 +47,9 @@ public class AnnotationTool extends MouseMotionAdapter {
         * @param view
         */
        public void attach(ImageControl view) {
+               
                detach();
-       
-               if (view != null) {
+           if (view != null) {
                        this.view = view;
                        canvas = view.getCanvas();
                        canvas.addMouseListener(this);
@@ -107,7 +106,7 @@ public class AnnotationTool extends MouseMotionAdapter {
        /**
         * @param type the annotation type to set
         */
-       public void setType(AnnotationType type) {
+       public void setType(AnnotationType type, boolean isLabelling) {
                assert (type != null);
                this.type = type;
        }
index 56669a48bd3c10eff43995042bfcaf59396788e7..c13f1a998d42fb62a6913fc2b3e22c5be3e9fbb2 100644 (file)
@@ -68,6 +68,9 @@ public class SegmentationView extends Composite {
        
        // 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;
@@ -154,7 +157,10 @@ public class SegmentationView extends Composite {
 
        private void addListeners() {
                brushControl.addSelectionListener(eventHandler);
-               view.addContextChangeListener(eventHandler);
+               if(!labelMode)
+               {
+                       view.addContextChangeListener(eventHandler);
+               }
                view.addZoomListener(eventHandler);
                addDisposeListener(eventHandler);
        }
@@ -201,11 +207,14 @@ public class SegmentationView extends Composite {
         */
        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);
@@ -342,8 +351,8 @@ public class SegmentationView extends Composite {
        }
        
 
-       public void setAnnotationType(AnnotationType type) {
-               view.setAnnotationType(type);
+       public void setAnnotationType(AnnotationType type, boolean isLabelling) {
+               view.setAnnotationType(type, isLabelling);
        }
        
        
@@ -421,6 +430,26 @@ public class SegmentationView extends Composite {
                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;
@@ -689,6 +718,7 @@ public class SegmentationView extends Composite {
                switch (a) {
                case Foreground:
                case Background:
+               case OperatingMode:
                case AutoApply:
                        return Action.AS_CHECK_BOX;
                case SetBrushSize:
@@ -703,10 +733,13 @@ public class SegmentationView extends Composite {
        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();
@@ -769,17 +802,19 @@ public class SegmentationView extends Composite {
                        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 {
index ed1c4b164063381cb5fa8867ddee9e2bf62761cd..f023313d55715240f4d80a9d83e689649b1f9302 100644 (file)
@@ -72,10 +72,10 @@ public class AnnotatedImageControl extends Composite {
                
                // 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
@@ -92,8 +92,8 @@ public class AnnotatedImageControl extends Composite {
                        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
@@ -105,31 +105,31 @@ public class AnnotatedImageControl extends Composite {
        
 
        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);
                }
        }
        
@@ -351,6 +351,16 @@ public class AnnotatedImageControl extends Composite {
        }
        
        
+       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) {