merge from 2_4_Release branch
[jalview.git] / src / jalview / gui / Finder.java
index 5668b42..cad734b 100755 (executable)
@@ -1,17 +1,17 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- *
+ * 
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
+ * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
@@ -29,27 +29,33 @@ import jalview.jbgui.*;
 
 /**
  * DOCUMENT ME!
- *
+ * 
  * @author $author$
  * @version $Revision$
  */
-public class Finder
-    extends GFinder
+public class Finder extends GFinder
 {
   AlignViewport av;
+
   AlignmentPanel ap;
+
   JInternalFrame frame;
+
   int seqIndex = 0;
+
   int resIndex = 0;
 
   SearchResults searchResults;
 
   /**
    * Creates a new Finder object.
-   *
-   * @param av DOCUMENT ME!
-   * @param ap DOCUMENT ME!
-   * @param f DOCUMENT ME!
+   * 
+   * @param av
+   *                DOCUMENT ME!
+   * @param ap
+   *                DOCUMENT ME!
+   * @param f
+   *                DOCUMENT ME!
    */
   public Finder()
   {
@@ -63,8 +69,9 @@ public class Finder
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *                DOCUMENT ME!
    */
   public void findNext_actionPerformed(ActionEvent e)
   {
@@ -76,8 +83,9 @@ public class Finder
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *                DOCUMENT ME!
    */
   public void findAll_actionPerformed(ActionEvent e)
   {
@@ -95,8 +103,8 @@ public class Finder
 
     if (frame != null && frame instanceof AlignFrame)
     {
-      av = ( (AlignFrame) frame).viewport;
-      ap = ( (AlignFrame) frame).alignPanel;
+      av = ((AlignFrame) frame).viewport;
+      ap = ((AlignFrame) frame).alignPanel;
       return true;
     }
     return false;
@@ -104,27 +112,27 @@ public class Finder
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *                DOCUMENT ME!
    */
   public void createNewGroup_actionPerformed(ActionEvent e)
   {
     SequenceI[] seqs = new SequenceI[searchResults.getSize()];
-    SequenceFeature[] features = new SequenceFeature[searchResults.getSize()];
+    SequenceFeature[] features = new SequenceFeature[searchResults
+            .getSize()];
 
     for (int i = 0; i < searchResults.getSize(); i++)
     {
       seqs[i] = searchResults.getResultSequence(i).getDatasetSequence();
 
       features[i] = new SequenceFeature(textfield.getText().trim(),
-                                        "Search Results", null,
-                                        searchResults.getResultStart(i),
-                                        searchResults.getResultEnd(i),
-                                        "Search Results");
+              "Search Results", null, searchResults.getResultStart(i),
+              searchResults.getResultEnd(i), "Search Results");
     }
 
-    if (ap.seqPanel.seqCanvas.getFeatureRenderer()
-        .amendFeatures(seqs, features, true, ap))
+    if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
+            features, true, ap))
     {
       ap.alignFrame.showSeqFeatures.setSelected(true);
       av.setShowSequenceFeatures(true);
@@ -134,8 +142,9 @@ public class Finder
 
   /**
    * DOCUMENT ME!
-   *
-   * @param findAll DOCUMENT ME!
+   * 
+   * @param findAll
+   *                DOCUMENT ME!
    */
   void doSearch(boolean findAll)
   {
@@ -147,10 +156,12 @@ public class Finder
     {
       return;
     }
-    // TODO: extend finder to match descriptions, features and annotation, and other stuff
-    // TODO: add switches to control what is searched - sequences, IDS, descriptions, features
-    jalview.analysis.Finder finder = new jalview.analysis.Finder(av.alignment,
-        av.getSelectionGroup(), seqIndex, resIndex);
+    // TODO: extend finder to match descriptions, features and annotation, and
+    // other stuff
+    // TODO: add switches to control what is searched - sequences, IDS,
+    // descriptions, features
+    jalview.analysis.Finder finder = new jalview.analysis.Finder(
+            av.alignment, av.getSelectionGroup(), seqIndex, resIndex);
     finder.setCaseSensitive(caseSensitive.isSelected());
     finder.setFindAll(findAll);
 
@@ -159,10 +170,11 @@ public class Finder
     seqIndex = finder.getSeqIndex();
     resIndex = finder.getResIndex();
 
-    searchResults = finder.getSearchResults(); // find(regex, caseSensitive.isSelected(), )
+    searchResults = finder.getSearchResults(); // find(regex,
+                                                // caseSensitive.isSelected(), )
     Vector idMatch = finder.getIdMatch();
     // set or reset the GUI
-    if ( (searchResults.getSize() == 0) && (idMatch.size() > 0))
+    if ((searchResults.getSize() == 0) && (idMatch.size() > 0))
     {
       ap.idPanel.highlightSearchResults(idMatch);
     }
@@ -178,14 +190,15 @@ public class Finder
       searchResults = null;
     }
 
-    // if allResults is null, this effectively switches displaySearch flag in seqCanvas
+    // if allResults is null, this effectively switches displaySearch flag in
+    // seqCanvas
     ap.highlightSearchResults(searchResults);
-    // TODO: add enablers for 'SelectSequences' or 'SelectColumns' or 'SelectRegion' selection
+    // TODO: add enablers for 'SelectSequences' or 'SelectColumns' or
+    // 'SelectRegion' selection
     if (!findAll && resultSize == 0)
     {
       JOptionPane.showInternalMessageDialog(this, "Finished searching",
-                                            null,
-                                            JOptionPane.INFORMATION_MESSAGE);
+              null, JOptionPane.INFORMATION_MESSAGE);
       resIndex = 0;
       seqIndex = 0;
     }
@@ -194,7 +207,7 @@ public class Finder
     {
       String message = resultSize + " matches found.";
       JOptionPane.showInternalMessageDialog(this, message, null,
-                                            JOptionPane.INFORMATION_MESSAGE);
+              JOptionPane.INFORMATION_MESSAGE);
     }
 
   }