Add new feature from seqrch results
authoramwaterhouse <Andrew Waterhouse>
Thu, 16 Mar 2006 15:13:55 +0000 (15:13 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 16 Mar 2006 15:13:55 +0000 (15:13 +0000)
src/jalview/appletgui/Finder.java

index fb8c280..8905b52 100755 (executable)
@@ -84,20 +84,37 @@ public class Finder extends Panel implements ActionListener
   public void createNewGroup_actionPerformed()\r
   {\r
 \r
+    CutAndPasteTransfer cap = new CutAndPasteTransfer(true, null);\r
+    Dialog dialog = new Dialog(ap.alignFrame, "Enter New Feature Name", true);\r
+    dialog.add(cap);\r
+\r
+    cap.setText(textfield.getText());\r
+\r
+    dialog.setBounds( frame.getLocation().x+frame.getSize().width+5,\r
+                      frame.getLocation().y+20,300,100);\r
+    dialog.show();\r
+\r
+\r
+    String featureName = cap.getText().trim();\r
+    if(featureName.length()<1)\r
+      return;\r
+\r
+\r
     for (int i = 0; i < searchResults.getSize(); i ++ )\r
     {\r
         SequenceI seq = searchResults.getResultSequence(i);\r
 \r
-        SequenceFeature sf = new SequenceFeature(textfield.getText(),\r
-            "Search Results", null,\r
+        SequenceFeature sf = new SequenceFeature(featureName,\r
+            null, null,\r
             searchResults.getResultStart(i),\r
            searchResults.getResultEnd(i));\r
 \r
         ap.seqPanel.seqCanvas.getFeatureRenderer().addNewFeature(\r
-            textfield.getText(), new Color(60,160,115));\r
+            featureName, new Color(60,160,115));\r
         seq.addSequenceFeature(sf);\r
     }\r
 \r
+    ap.seqPanel.seqCanvas.getFeatureRenderer().findAllFeatures();\r
     ap.alignFrame.sequenceFeatures.setState(true);\r
     av.showSequenceFeatures(true);\r
     ap.highlightSearchResults(null);\r
@@ -155,6 +172,7 @@ public class Finder extends Panel implements ActionListener
 \r
     while (!found && seqIndex < end)\r
     {\r
+\r
       seq = (Sequence) av.alignment.getSequenceAt(seqIndex);\r
 \r
       if (selection != null && !selection.sequences.contains(seq))\r
@@ -172,7 +190,7 @@ public class Finder extends Panel implements ActionListener
       }\r
 \r
       ///Shall we ignore gaps????\r
-      StringBuffer noGaps = new StringBuffer();\r
+      StringBuffer noGapsSB = new StringBuffer();\r
       int insertCount = 0;\r
       Vector spaces = new Vector();\r
 \r
@@ -181,7 +199,7 @@ public class Finder extends Panel implements ActionListener
 \r
         if (!jalview.util.Comparison.isGap(item.charAt(j)))\r
         {\r
-          noGaps.append(item.charAt(j));\r
+          noGapsSB.append(item.charAt(j));\r
           spaces.addElement(new Integer(insertCount));\r
         }\r
         else\r
@@ -190,10 +208,12 @@ public class Finder extends Panel implements ActionListener
         }\r
       }\r
 \r
+      String noGaps = noGapsSB.toString();\r
+\r
       for (int r = resIndex; r < noGaps.length(); r++)\r
       {\r
 \r
-        if (regex.searchFrom(noGaps.toString(), r))\r
+        if (regex.searchFrom(noGaps, r))\r
         {\r
           resIndex = regex.matchedFrom();\r
           if (selection != null &&\r
@@ -264,8 +284,8 @@ public class Finder extends Panel implements ActionListener
 \r
     if (findAll)\r
     {\r
-      String message = (searchResults.getSize()) + " matches found.";\r
-      System.out.println(message);\r
+      String message = (searchResults==null?0 : searchResults.getSize()) + " matches found.";\r
+      ap.alignFrame.statusBar.setText("Search results: "+searchString+" : "+message);\r
     }\r
 \r
   }\r