--- /dev/null
+<?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>
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.*;
// 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;
// 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;
SetPainter,
SetLabel,
SegmenterOptions;
+
private ToolAction action;
};
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();
m.add(getAction(Tool.AutoApply));
m.add(getAction(Tool.Apply));
m.add(getAction(Tool.SegmenterOptions));
- m.add(new Separator());
m.update(true);
}
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();
-
}
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();
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;
}
- // 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());
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());
}