Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
Added auto-enable/disable functionality to the annotation combo and assign button...
authorlingutln <lingutln@localhost>
Mon, 12 Dec 2011 21:33:45 +0000 (21:33 +0000)
committerlingutln <lingutln@localhost>
Mon, 12 Dec 2011 21:33:45 +0000 (21:33 +0000)
svn path=/; revision=220

image_annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java
image_annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java
image_annotation/src/ie/dcu/apps/ist/export/imagemap/MapArea.java
image_annotation/src/ie/dcu/apps/ist/views/SegmentationView.java

index 54c78f752da5876901ff56437a0f4f546c0fb3f9..3efe02085092e40a043b3cdf93633ed2aa02f9a2 100644 (file)
@@ -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");
index 1ac92c8708621750cc35667681acb8284c95cb97..09fafa15bef2e7244ecf597954ededd9ffeec5b8 100644 (file)
@@ -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);
index 8bef6da2f281c1add6d8bc4d48a4e2edb89eb4e1..2bc22b38c1de09caf5c1bcb0c852dd6168fb622d 100644 (file)
@@ -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<String, String> attrs;
@@ -23,7 +22,6 @@ public class MapArea {
        public MapArea() {
                href = "";
                alt = "";
-               title = "";
                shape = AreaShape.Polygon;
                coords = new int[0];
                attrs = new HashMap<String, String>();
@@ -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());
                
index b5287c400ed9aff4a1478548d7b8afcb5042a935..df089946c79f1fb9e77843e4f4369b94fd068000 100644 (file)
@@ -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() {