Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
Save functionality. Done by Nikhil.
authorlingutln <lingutln@localhost>
Wed, 23 Nov 2011 21:02:47 +0000 (21:02 +0000)
committerlingutln <lingutln@localhost>
Wed, 23 Nov 2011 21:02:47 +0000 (21:02 +0000)
svn path=/; revision=219

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

index 2dc7003cdb62a7a98ff3428dbb598dd61626778b..8bef6da2f281c1add6d8bc4d48a4e2edb89eb4e1 100644 (file)
@@ -15,6 +15,7 @@ public class MapArea {
        
        private String href;
        private String alt;
+       private String title;
        private AreaShape shape;
        private int[] coords;
        private final Map<String, String> attrs;
@@ -22,6 +23,7 @@ public class MapArea {
        public MapArea() {
                href = "";
                alt = "";
+               title = "";
                shape = AreaShape.Polygon;
                coords = new int[0];
                attrs = new HashMap<String, String>();
@@ -43,10 +45,18 @@ 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;
        }
-
+       
        public AreaShape getShape() {
                return shape;
        }
@@ -108,7 +118,7 @@ public class MapArea {
                tag
                  .attr("href", encodedHREF)
                  .attr("alt", alt)
-                 .attr("title", alt)
+                 .attr("title", getTitle())
                  .attr("shape", shape.toString())
                  .attr("coords", getCoordsString());
                
index 61077258525fb58d6b5645a024f7f4ad9486e371..b5287c400ed9aff4a1478548d7b8afcb5042a935 100644 (file)
@@ -47,7 +47,10 @@ public class SegmentationView extends Composite {
        
        // Left and right tool bar
        private final ToolBar bar1, bar2, bar3;
-               
+       
+       private final Button assign;
+       
+       //private final StyledText text;                
        
        // Control to change brush size
        private final BrushControl brushControl;
@@ -109,6 +112,7 @@ public class SegmentationView extends Composite {
                bar1 = new ToolBar(this, SWT.RIGHT | SWT.FLAT);
                bar2 = new ToolBar(this, SWT.RIGHT | SWT.FLAT);
                bar3 = new ToolBar(this, SWT.RIGHT | SWT.FLAT);
+               assign = new Button(bar3, SWT.PUSH);
                view = new AnnotatedImageControl(this, SWT.BORDER);
                brushControl = new BrushControl(getShell(), SWT.BORDER);
                eventHandler = new EventHandler();
@@ -186,7 +190,7 @@ public class SegmentationView extends Composite {
                bar2.pack();
        }
        /**
-        * Third tool bar for holding the Annotate combo
+        * Third tool bar for holding the Annotate Combo box
         */
        private void createToolbar3() {
                SwtUtils.addLabel(bar3, getAction(Tool.SetLabel).getText());
@@ -199,9 +203,9 @@ public class SegmentationView extends Composite {
                                setLabel(comboLabel.getText());
                            Display.getCurrent().asyncExec(new Runnable() {
                                public void run() {
-                                       comboLabel.setFocus();
                                        comboLabel.setText(comboLabel.getText());
-                               }
+                                       comboLabel.forceFocus();
+                                       }
                                });
                        }
                        @Override
@@ -209,12 +213,21 @@ public class SegmentationView extends Composite {
                                // TODO Auto-generated method stub
                        }
                });
-               /*ToolItem item = new ToolItem(bar3, SWT.SEPARATOR);
-               assign = new Button(bar3, SWT.PUSH);
+               ToolItem item = new ToolItem(bar3, SWT.SEPARATOR);
                assign.setText("Assign");
                item.setWidth(50);
                item.setControl(assign);
-               bar3.pack();*/
+               assign.addSelectionListener(new SelectionListener() {
+        public void widgetSelected(SelectionEvent arg0) {
+               System.out.println("selected"+comboLabel.getText());
+                   }
+
+               @Override
+               public void widgetDefaultSelected(SelectionEvent arg0) {
+                       // TODO Auto-generated method stub
+               }
+               });
+               bar3.pack();
        }
        
        
@@ -764,22 +777,41 @@ public class SegmentationView extends Composite {
        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) 
+                       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");
+                       HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+               BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+               if(connection.getResponseCode() == 200)
                {
-                   object = new JSONObject(inputLine);
-               }
-               JSONArray array = new JSONArray(object.getString("sfautocomplete"));
-               for(int i=0; i<array.length();i++)
+                       String inputLine;
+                       JSONObject object = null;
+                       while ((inputLine = in.readLine()) != null) 
+                       {
+                               System.out.println("Response coming as"+inputLine);
+                           object = new JSONObject(inputLine);
+                       }
+                       JSONArray array = new JSONArray(object.getString("PO_term_search_response"));
+                       String listElement;
+                       for(int i=0; i<array.length();i++)
+                       {
+                               if(array.getJSONObject(i).getString("match_type").trim().equals("synonym"))
+                               {
+                                       listElement = (array.getJSONObject(i).getString("match")+" {"+array.getJSONObject(i).getString("is_synonym_of")+"}");
+                                       comboLabel.add(listElement,i);
+                               }
+                               else if(array.getJSONObject(i).getString("match_type").equals("term"))
+                               {
+                                       listElement = array.getJSONObject(i).getString("match");
+                                       comboLabel.add(listElement,i);
+                               }
+                       }
+                       //comboLabel.setListVisible(true);
+                   in.close();
+               }
+               else
                {
-                       comboLabel.add(array.getJSONObject(i).getString("title"),i);
-                       comboLabel.setListVisible(true);
+                       System.out.println("Response error");
                }
-               in.close();
            }
            catch(Exception ex)
            {