Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
svn path=/; revision=465
authorlingutln <lingutln@localhost>
Wed, 10 Apr 2013 23:14:31 +0000 (23:14 +0000)
committerlingutln <lingutln@localhost>
Wed, 10 Apr 2013 23:14:31 +0000 (23:14 +0000)
Annotation/src/ie/dcu/apps/ist/labelling/Labels.java
Annotation/src/ie/dcu/apps/ist/labelling/OntologyTerm.java
Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java
Annotation/src/ie/dcu/apps/ist/widgets/AnnotatedImageControl.java

index 0eafac8b14552954eaafa45d13ed07408b7673f1..db3cb68ace0ca8eae9ad847997d6e36857c7384a 100644 (file)
@@ -9,6 +9,9 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLEncoder;
 import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import javax.xml.bind.DatatypeConverter;
 
 import javax.xml.parsers.*;
@@ -58,7 +61,7 @@ public class Labels
                        {
                                OntologyTerm term = new OntologyTerm();
                                term.setAccessionId(array.getJSONObject(i).getString("accession_id"));
-                               term.setName(array.getJSONObject(i).getString("match"));
+                               term.setName(formatizeToUnescapeHTML(array.getJSONObject(i).getString("match")));
                                terms.add(term);
                        }
                        in.close();
@@ -74,6 +77,19 @@ public class Labels
            return terms;
        }
        
+       public static String formatizeToUnescapeHTML(String term)
+       {
+               Pattern pattern = Pattern.compile("&#[0-9]+");
+           Matcher matcher = pattern.matcher(term);
+           StringBuffer formattedTerm = new StringBuffer();
+           while (matcher.find()) {
+               String matchedText = matcher.group();
+               matcher.appendReplacement(formattedTerm, matchedText + ";");
+           }
+           matcher.appendTail(formattedTerm);
+           return formattedTerm.toString();
+       }
+       
        
        
        
index 76b22abac52991f045fdb209782aaf87cf3e9e2c..39d30f7279963dbbc4bb6d5db431275c07c5f53d 100644 (file)
@@ -4,6 +4,8 @@
 package ie.dcu.apps.ist.labelling;
 
 import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.commons.lang3.StringEscapeUtils;
 
@@ -66,5 +68,4 @@ public class OntologyTerm {
        public OntologyTerm() {
                this.synonyms = new ArrayList<String>();
        }
-       
 }
index 246f4b421a1e08132911ecfe242d84562ad0fb72..aee4863a70421a0010686eef7f827a1007d0d294 100644 (file)
@@ -21,10 +21,11 @@ import java.net.*;
 import java.util.ArrayList;
 import java.util.Properties;
 import java.util.logging.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.action.*;
-import org.eclipse.jface.action.Action;
 import org.eclipse.jface.operation.*;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.swt.SWT;
@@ -304,7 +305,7 @@ public class SegmentationView extends Composite {
                if(view.getContext().isEnabled())
                {
                        OntologyTerm term = new OntologyTerm();
-                       term.setName((String)comboLabel.getData(comboLabel.getText()));
+                       term.setName((String)comboLabel.getData(formatizeToUnescapeHTML(comboLabel.getText())));
                        term.setAccessionId(parseAccessionIdFromComboLabel(comboLabel));
                        view.getContext().getEnabledMask().ontologyTerm = term;
                }
@@ -313,6 +314,19 @@ public class SegmentationView extends Composite {
                });
        }
        
+       public static String formatizeToUnescapeHTML(String term)
+       {
+               Pattern pattern = Pattern.compile("&#[0-9]+");
+           Matcher matcher = pattern.matcher(term);
+           StringBuffer formattedTerm = new StringBuffer();
+           while (matcher.find()) {
+               String matchedText = matcher.group();
+               matcher.appendReplacement(formattedTerm, matchedText + ";");
+           }
+           matcher.appendTail(formattedTerm);
+           return formattedTerm.toString();
+       }
+       
        /**
         * For dropping down the labels on pressing the down arrow key just like "Google suggests" functionality.
         * @param e
@@ -414,7 +428,7 @@ public class SegmentationView extends Composite {
                        
                                for (int j=0; j<synArray.length(); j++) {
                                TableItem item = new TableItem (termSynonymTable, SWT.NONE);
-                                       item.setText(0,synArray.getString(j));
+                                       item.setText(0,formatizeToUnescapeHTML(synArray.getString(j)));
                                }
                        termSynonymTable.getColumn(0).pack();
                                termSynonymTable.pack();
@@ -482,7 +496,7 @@ public class SegmentationView extends Composite {
                termDetailTable.pack();
        }
 
-       public void clearTermDetailTable() {
+       public static void clearTermDetailTable() {
                TableItem[] items = termDetailTable.getItems();
         for(int i=0; i<items.length; i++)
         {
@@ -493,7 +507,7 @@ public class SegmentationView extends Composite {
         }
        }
 
-       public void clearTermSynonymTable() {
+       public static void clearTermSynonymTable() {
                TableItem[] items = termSynonymTable.getItems();
         for(TableItem item : items)
         {
@@ -787,6 +801,11 @@ public class SegmentationView extends Composite {
                        {
                                view.getTool().detach();
                        }
+                       
+                       String segmentName = view.getContext().getEnabledMask().ontologyTerm.getName();
+                       if (segmentName.equals("")) {
+                               clearCurrentSegmentAnnotation();
+                       }
                }
                else
                {
@@ -798,6 +817,16 @@ public class SegmentationView extends Composite {
                updateToolStates();
        }
        
+       /**
+        * Clears annotation details of currently highlighted segment
+       */
+       
+       public static void clearCurrentSegmentAnnotation() {
+               SegmentationView.comboLabel.removeAll();
+               SegmentationView.clearTermDetailTable();
+               SegmentationView.clearTermSynonymTable();
+       }
+       
        /**
         * Forms a segmentation object based on the current view skipping previous segmentation objects.
        */
@@ -807,16 +836,7 @@ public class SegmentationView extends Composite {
                view.getContext().formSegmentationObject();
                updateToolStates();
        }
-       
-       /**
-        * Predicts the segments in the image using active learning.
-       */
-       /*public void predictSegments() {
-               SIFTDescriptor sift = new SIFTDescriptor();
-               sift.calculateDescriptors(view.getContext().getImage());
-               updateToolStates();
-       }*/     
-       
+
        public boolean isAutoApply() {
                return this.auto;
        }
index 8d2831437b87a09b5d5374781bcd78385fcf4b8a..4880b63bf18000af19342fed620b123312d6fefd 100644 (file)
@@ -411,28 +411,7 @@ public class AnnotatedImageControl extends Composite {
 
                public void mouseUp(MouseEvent event) {
                        Point mouseClickedPoint = new Point(event.x,event.y);
-                       // For the right click
-                       if(event.button == 3)
-                       { /* // JP - don't want this functionality right now
-                               PopUpLabelDialog dialog = new PopUpLabelDialog(getShell());
-                               PopUpLabelDialog.Result result = dialog.open();
-                               if (result != null) 
-                               {
-                                       String lab = null;
-                                       if(result.comboText.indexOf('{') != -1)
-                               {
-                                               lab = result.comboText.substring(0,result.comboText.indexOf('{')-1);
-                               }
-                               else
-                               {
-                                       lab = result.comboText;
-                               }
-                               System.out.println("selected"+lab);
-                                       //comboLabel.setText(result.comboText);
-                                       //execute(Tool.AssignButton, null);
-                               }*/
-                       }
-                       else if(event.button == 1)
+                       if(event.button == 1)
                        {
                                if(view.imageContains(mouseClickedPoint))
                                {
@@ -440,8 +419,13 @@ public class AnnotatedImageControl extends Composite {
                                        // For setting the comboLabel value and tooltip on clicking a segment
                                        String segmentName = ctx.getEnabledMask().ontologyTerm.getName();
                                        getCanvas().setToolTipText(segmentName);
-                                       SegmentationView.comboLabel.setText(segmentName);
-                                       SegmentationView.termDetailLookup(ctx.getEnabledMask().ontologyTerm.getAccessionId());
+                                       if (segmentName.equals("")) {
+                                               SegmentationView.clearCurrentSegmentAnnotation();
+                                       }
+                                       else {
+                                               SegmentationView.comboLabel.setText(segmentName);
+                                               SegmentationView.termDetailLookup(ctx.getEnabledMask().ontologyTerm.getAccessionId());
+                                       }
                                }
                                repaint();
                        }