Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
Adding a label functionality. Done by Nikhil.
authorlingutln <lingutln@localhost>
Mon, 14 Nov 2011 19:21:05 +0000 (19:21 +0000)
committerlingutln <lingutln@localhost>
Mon, 14 Nov 2011 19:21:05 +0000 (19:21 +0000)
svn path=/; revision=213

image_annotation/._build.xml [new file with mode: 0644]
image_annotation/.classpath [new file with mode: 0644]
image_annotation/.project [new file with mode: 0644]
image_annotation/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
image_annotation/lib/json.jar [new file with mode: 0644]
image_annotation/src/ie/dcu/apps/ist/AppWindow.java
image_annotation/src/ie/dcu/apps/ist/views/SegmentationView.java

diff --git a/image_annotation/._build.xml b/image_annotation/._build.xml
new file mode 100644 (file)
index 0000000..18adcdd
Binary files /dev/null and b/image_annotation/._build.xml differ
diff --git a/image_annotation/.classpath b/image_annotation/.classpath
new file mode 100644 (file)
index 0000000..6a5ba76
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="lib" path="lib/swt-gtk-64.jar"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="src" path="plugins1"/>
+       <classpathentry kind="lib" path="lib/istapi-src.jar"/>
+       <classpathentry kind="lib" path="lib/istapi.jar"/>
+       <classpathentry kind="lib" path="lib/jface.jar"/>
+       <classpathentry kind="lib" path="resources/ant/lib/ant-deb.jar"/>
+       <classpathentry kind="lib" path="resources/ant/lib/ant-gzip2.jar"/>
+       <classpathentry kind="lib" path="resources/ant/lib/ant-passwd-task.jar"/>
+       <classpathentry kind="lib" path="resources/ant/lib/ant-swt-identify.jar"/>
+       <classpathentry kind="lib" path="resources/ant/lib/jsmoothgen-ant.jar"/>
+       <classpathentry kind="lib" path="resources/ant/lib/standalone-compiler.jar"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry exported="true" kind="lib" path="lib/swt-gtk.jar"/>
+       <classpathentry kind="lib" path="lib/swt-win.jar"/>
+       <classpathentry kind="lib" path="/home/lingutln/workspace/image_annotation/lib/json.jar"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/image_annotation/.project b/image_annotation/.project
new file mode 100644 (file)
index 0000000..b767f9e
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>Segmentation</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+       <linkedResources>
+               <link>
+                       <name>plugins1</name>
+                       <type>2</type>
+                       <location>/home/lingutln/Downloads/ist-source/Interactive Segmentation App/plugins</location>
+               </link>
+       </linkedResources>
+</projectDescription>
diff --git a/image_annotation/.settings/org.eclipse.jdt.core.prefs b/image_annotation/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..b0ea1ab
--- /dev/null
@@ -0,0 +1,12 @@
+#Thu Mar 25 19:16:32 GMT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/image_annotation/lib/json.jar b/image_annotation/lib/json.jar
new file mode 100644 (file)
index 0000000..82ad5fb
Binary files /dev/null and b/image_annotation/lib/json.jar differ
index a047dbe9c91f0fb435d5cb92262f0f49334ca283..a07bbb0a917a6a301c42136df072c286dbe212e7 100644 (file)
@@ -336,7 +336,10 @@ public class AppWindow extends ApplicationWindow implements FileDropListener {
 
                help.add(actions.get(HelpAction.class));
                help.add(actions.get(AboutAction.class));
-                               
+               
+               MenuManager annotate = addMenu(bar, "&Annotate");
+               annotate.add(actions.get(HelpAction.class));
+               
                if (OsUtils.isMacOSX()) {
                        // Enhance the UI on the Mac
                        IAction aboutAction = actions.get(AboutAction.class);
index 14a1befb163af9eadb9c22c42dbd441419afa19a..b5b52eed1b5edd88d6550af97046df712fa39a40 100644 (file)
@@ -15,6 +15,8 @@ import java.lang.reflect.InvocationTargetException;
 import java.net.*;
 import java.util.Properties;
 import java.util.logging.*;
+import java.io.*;
+import org.json.*;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.action.*;
@@ -41,11 +43,11 @@ public class SegmentationView extends Composite {
        
        // View handling annotations
        private final AnnotatedImageControl view;
-               
        
-       // Left, center and right tool bar
-       private final ToolBar bar1, bar2, bar3;
        
+       // Left and right tool bar
+       private final ToolBar bar1, bar2, bar3;
+               
        
        // Control to change brush size
        private final BrushControl brushControl;
@@ -59,14 +61,14 @@ public class SegmentationView extends Composite {
        // algorithm, without crashing the application.
        private RobustSegmenterProxy segmenterProxy;
        
-       
        // Auto segment on update flag
        private boolean auto = true;
        
-       
        // Combo box housing the selectable views
-       private Combo combo;
+       private Combo combo, comboLabel;
        
+       // Button for assigning a label to the Segmented image
+       private Button assign;
        
        // Current segmentation tool
        private Segmenter segmenter;
@@ -97,6 +99,7 @@ public class SegmentationView extends Composite {
                SetPainter,
                SetLabel,
                SegmenterOptions;
+               
                private ToolAction action;
        };
        
@@ -106,9 +109,9 @@ public class SegmentationView extends Composite {
                this.props = props;
                
                painters = new PainterRegistry();
-               bar1 = new ToolBar(this, SWT.LEFT | SWT.FLAT);
+               bar1 = new ToolBar(this, SWT.RIGHT | SWT.FLAT);
                bar2 = new ToolBar(this, SWT.RIGHT | SWT.FLAT);
-               bar3 = new ToolBar(this, SWT.CENTER | SWT.FLAT);
+               bar3 = new ToolBar(this, SWT.RIGHT | SWT.FLAT);
                view = new AnnotatedImageControl(this, SWT.BORDER);
                brushControl = new BrushControl(getShell(), SWT.BORDER);
                eventHandler = new EventHandler();
@@ -170,7 +173,6 @@ public class SegmentationView extends Composite {
                m.add(getAction(Tool.AutoApply));
                m.add(getAction(Tool.Apply));
                m.add(getAction(Tool.SegmenterOptions));
-               m.add(new Separator());
                m.update(true);
        }
        
@@ -189,15 +191,25 @@ public class SegmentationView extends Composite {
        
        private void createToolbar3() {
                SwtUtils.addLabel(bar3, getAction(Tool.SetLabel).getText());
+               comboLabel = SwtUtils.addCombo(bar3, 130, SWT.SIMPLE);
+               comboLabel.setToolTipText( getAction(Tool.SetLabel).getToolTipText());
+               comboLabel.addKeyListener(new KeyListener() {
+                       @Override
+                       public void keyReleased(KeyEvent e) {
+                               comboLabel.remove(0,comboLabel.getItemCount()-1);
+                               setLabel(comboLabel.getText());
+                   }
+                       @Override
+                       public void keyPressed(KeyEvent arg0) {
+                               // TODO Auto-generated method stub
+                       }
+               });
                ToolItem item = new ToolItem(bar3, SWT.SEPARATOR);
-               Text text = new Text(bar3, SWT.SINGLE);
-               text.setToolTipText( getAction(Tool.SetLabel).getToolTipText());
-               text.setText("Enter a Label");
-               item.setWidth(100);
-               item.setControl(text);
-               text.pack();
+               assign = new Button(bar3, SWT.PUSH);
+               assign.setText("Assign");
+               item.setWidth(50);
+               item.setControl(assign);
                bar3.pack();
-               
        }
        
        
@@ -211,10 +223,8 @@ public class SegmentationView extends Composite {
                
                Point sz1 = bar1.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                Point sz2 = bar2.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-               Point sz3 = bar3.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                
-               int heightHintOfTwo = Math.max(sz1.y, sz2.y);
-               int heightHint = Math.max(heightHintOfTwo, sz3.y);
+               int heightHint = Math.max(sz1.y, sz2.y);
                
                // Layout toolbar 1
                GridData gd = new GridData();
@@ -229,15 +239,9 @@ public class SegmentationView extends Composite {
                gd.heightHint = heightHint;
                bar2.setLayoutData(gd);
                
-               // Layout toolbar 3
-               gd = new GridData();
-               gd.horizontalAlignment = SWT.FILL;
-               gd.heightHint = heightHint;
-               bar3.setLayoutData(gd);
-               
                // Layout view
                gd = new GridData();
-               gd.verticalIndent = 3;
+               gd.verticalIndent = 2;
                gd.horizontalSpan = 3;
                gd.grabExcessHorizontalSpace = true;
                gd.grabExcessVerticalSpace = true;
@@ -362,13 +366,6 @@ public class SegmentationView extends Composite {
        }
 
 
-       // For labeling the image
-       public void setLabel(SegmentationPainter painter) {
-               view.setPainter(painter);
-               combo.setText(painter.getName());
-       }
-       
-       
        public void setPainter(SegmentationPainter painter) {
                view.setPainter(painter);
                combo.setText(painter.getName());
@@ -758,8 +755,31 @@ public class SegmentationView extends Composite {
                SegmentationPainter painter = painters.get(combo.getText());
                setPainter(painter);
        }
-
-
+       
+       private void setLabel(String content) {
+               try
+           {
+                   URL terms = new URL("http://palea.cgrb.oregonstate.edu/paw/services/TermSearch_JSON.php?user=paw&field=name&type=autocomplete&ontology=po&qval="+content+"&format=json&max=20");
+                   URLConnection conn = terms.openConnection();
+               BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+               String inputLine;
+               JSONObject object = null;
+               while ((inputLine = in.readLine()) != null) 
+               {
+                   object = new JSONObject(inputLine);
+               }
+               JSONArray array = new JSONArray(object.getString("sfautocomplete"));
+               for(int i=0; i<array.length();i++)
+               {
+                       comboLabel.add(array.getJSONObject(i).getString("title"),i);
+               }
+               in.close();
+           }
+           catch(Exception ex)
+           {
+           }
+       }
+       
        private void apply() {
                performSegmentation(null, view.getContext());
        }