From: lingutln Date: Mon, 14 Nov 2011 19:21:05 +0000 (+0000) Subject: Adding a label functionality. Done by Nikhil. X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=46a5f3eaa9c0a67cf0fb6f4d39bbd54461fcdbcd;p=old-jaiswallab-svn%2F.git Adding a label functionality. Done by Nikhil. svn path=/; revision=213 --- diff --git a/image_annotation/._build.xml b/image_annotation/._build.xml new file mode 100644 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 index 0000000..6a5ba76 --- /dev/null +++ b/image_annotation/.classpath @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/image_annotation/.project b/image_annotation/.project new file mode 100644 index 0000000..b767f9e --- /dev/null +++ b/image_annotation/.project @@ -0,0 +1,24 @@ + + + Segmentation + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + plugins1 + 2 + /home/lingutln/Downloads/ist-source/Interactive Segmentation App/plugins + + + diff --git a/image_annotation/.settings/org.eclipse.jdt.core.prefs b/image_annotation/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b0ea1ab --- /dev/null +++ b/image_annotation/.settings/org.eclipse.jdt.core.prefs @@ -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 index 0000000..82ad5fb Binary files /dev/null and b/image_annotation/lib/json.jar differ diff --git a/image_annotation/src/ie/dcu/apps/ist/AppWindow.java b/image_annotation/src/ie/dcu/apps/ist/AppWindow.java index a047dbe..a07bbb0 100644 --- a/image_annotation/src/ie/dcu/apps/ist/AppWindow.java +++ b/image_annotation/src/ie/dcu/apps/ist/AppWindow.java @@ -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); diff --git a/image_annotation/src/ie/dcu/apps/ist/views/SegmentationView.java b/image_annotation/src/ie/dcu/apps/ist/views/SegmentationView.java index 14a1bef..b5b52ee 100644 --- a/image_annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/image_annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -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