From: lingutln Date: Mon, 12 Dec 2011 21:33:45 +0000 (+0000) Subject: Added auto-enable/disable functionality to the annotation combo and assign button... X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=d5f290509a73195fe7e6d8392515361566003ee3;p=old-jaiswallab-svn%2F.git Added auto-enable/disable functionality to the annotation combo and assign button. Done by Nikhil. svn path=/; revision=220 --- diff --git a/image_annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java b/image_annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java index 54c78f7..3efe020 100644 --- a/image_annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java +++ b/image_annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java @@ -2,6 +2,7 @@ package ie.dcu.apps.ist.actions; import ie.dcu.apps.ist.dialogs.ExportDialog; import ie.dcu.apps.ist.export.imagemap.*; +import ie.dcu.apps.ist.views.*; import ie.dcu.segment.*; import ie.dcu.swt.ImageConverter; @@ -16,7 +17,7 @@ import org.eclipse.swt.program.Program; * * @author Kevin McGuinness */ -public class ExportImageMapAction extends AppAction { +public class ExportImageMapAction extends AppAction{ public ExportImageMapAction(ActionManager m) { super(m); @@ -46,6 +47,12 @@ public class ExportImageMapAction extends AppAction { exporter.setObjectLink(result.link); exporter.setExportShape(result.shape); exporter.setObjectDescription(result.description); + String label = SegmentationView.comboLabel.getText(); + if(label.indexOf('{') != -1) + { + label = label.substring(0,label.indexOf('{')-1); + } + exporter.setTitle(label); // Export try { @@ -57,7 +64,7 @@ public class ExportImageMapAction extends AppAction { handleError(e); return; } - + // for opening the image after saving as ImageMap if (result.open) { File file = new File(result.folder, result.html); Program program = Program.findProgram(".html"); diff --git a/image_annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java b/image_annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java index 1ac92c8..09fafa1 100644 --- a/image_annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java +++ b/image_annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java @@ -26,6 +26,7 @@ public class Exporter { private String imageName = "image"; private String objectDescription = ""; private String objectLink = ""; + private String title = ""; private AreaShape exportShape = AreaShape.Polygon; public Exporter(BufferedImage image, SegmentationMask mask) { @@ -65,6 +66,14 @@ public class Exporter { this.imageName = imageName; } + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + public String getObjectDescription() { return objectDescription; } @@ -153,6 +162,7 @@ public class Exporter { imageName, idx++)); area.addAttr("onmouseout", String.format("rollover(document.%s, image0)", imageName)); + area.addAttr("title",getTitle()); } map.addArea(area); diff --git a/image_annotation/src/ie/dcu/apps/ist/export/imagemap/MapArea.java b/image_annotation/src/ie/dcu/apps/ist/export/imagemap/MapArea.java index 8bef6da..2bc22b3 100644 --- a/image_annotation/src/ie/dcu/apps/ist/export/imagemap/MapArea.java +++ b/image_annotation/src/ie/dcu/apps/ist/export/imagemap/MapArea.java @@ -15,7 +15,6 @@ public class MapArea { private String href; private String alt; - private String title; private AreaShape shape; private int[] coords; private final Map attrs; @@ -23,7 +22,6 @@ public class MapArea { public MapArea() { href = ""; alt = ""; - title = ""; shape = AreaShape.Polygon; coords = new int[0]; attrs = new HashMap(); @@ -45,14 +43,6 @@ public class MapArea { return alt; } - public void setTitle(String alt) { - this.title = title == null ? "" : title; - } - - public String getTitle() { - return title; - } - public void setAlt(String alt) { this.alt = alt == null ? "" : alt; } @@ -118,7 +108,6 @@ public class MapArea { tag .attr("href", encodedHREF) .attr("alt", alt) - .attr("title", getTitle()) .attr("shape", shape.toString()) .attr("coords", getCoordsString()); 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 b5287c4..df08994 100644 --- a/image_annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/image_annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -68,7 +68,9 @@ public class SegmentationView extends Composite { private boolean auto = true; // Combo box housing the selectable views - private Combo combo, comboLabel; + private Combo combo; + + public static Combo comboLabel; // Current segmentation tool private Segmenter segmenter; @@ -201,7 +203,7 @@ public class SegmentationView extends Composite { public void keyReleased(KeyEvent e) { comboLabel.remove(0,comboLabel.getItemCount()-1); setLabel(comboLabel.getText()); - Display.getCurrent().asyncExec(new Runnable() { + Display.getCurrent().asyncExec(new Runnable() { public void run() { comboLabel.setText(comboLabel.getText()); comboLabel.forceFocus(); @@ -219,9 +221,17 @@ public class SegmentationView extends Composite { item.setControl(assign); assign.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { - System.out.println("selected"+comboLabel.getText()); + String lab = null; + if(comboLabel.getText().indexOf('{') != -1) + { + lab = comboLabel.getText().substring(0,comboLabel.getText().indexOf('{')-1); + } + else + { + lab = comboLabel.getText(); + } + System.out.println("selected"+lab); } - @Override public void widgetDefaultSelected(SelectionEvent arg0) { // TODO Auto-generated method stub @@ -744,6 +754,8 @@ public class SegmentationView extends Composite { Tool.ZoomOut.action.setEnabled(canZoomOut()); Tool.ZoomOriginal.action.setEnabled(canZoomOriginal()); Tool.ZoomBestFit.action.setEnabled(canZoomBestFit()); + comboLabel.setEnabled(canZoomBestFit()); + assign.setEnabled(canZoomBestFit() & !(comboLabel.getText().isEmpty())); Tool.Foreground.action.setChecked(isAnnotatingForeground()); Tool.Background.action.setChecked(isAnnotatingBackground()); Tool.Clear.action.setEnabled(canClear()); @@ -768,7 +780,6 @@ public class SegmentationView extends Composite { } - private void setPainter() { SegmentationPainter painter = painters.get(combo.getText()); setPainter(painter); @@ -777,18 +788,17 @@ public class SegmentationView extends Composite { private void setLabel(String content) { try { - System.out.println("Content coming as"+content); - URL url = new URL("http://palea.cgrb.oregonstate.edu/services/PO_web_service.php?request_type=term_search&search_value="+content+"&inc_synonyms&branch_filter=plant_anatomy&max=20"); + String content1 = URLEncoder.encode(content.toString(),"UTF-8"); + URL url = new URL("http://palea.cgrb.oregonstate.edu/services/PO_web_service.php?request_type=term_search&search_value="+content1+"&inc_synonyms&branch_filter=plant_anatomy&max=20"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); if(connection.getResponseCode() == 200) { String inputLine; JSONObject object = null; while ((inputLine = in.readLine()) != null) { - System.out.println("Response coming as"+inputLine); - object = new JSONObject(inputLine); + object = new JSONObject(inputLine); } JSONArray array = new JSONArray(object.getString("PO_term_search_response")); String listElement; @@ -816,6 +826,7 @@ public class SegmentationView extends Composite { catch(Exception ex) { } + assign.setEnabled(!(comboLabel.getText().isEmpty())); } private void apply() {