From dedbb25d7f54f28aaa36592be27c80487090e10d Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 16 Mar 2006 15:13:55 +0000 Subject: [PATCH] Add new feature from seqrch results --- src/jalview/appletgui/Finder.java | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/jalview/appletgui/Finder.java b/src/jalview/appletgui/Finder.java index fb8c280..8905b52 100755 --- a/src/jalview/appletgui/Finder.java +++ b/src/jalview/appletgui/Finder.java @@ -84,20 +84,37 @@ public class Finder extends Panel implements ActionListener public void createNewGroup_actionPerformed() { + CutAndPasteTransfer cap = new CutAndPasteTransfer(true, null); + Dialog dialog = new Dialog(ap.alignFrame, "Enter New Feature Name", true); + dialog.add(cap); + + cap.setText(textfield.getText()); + + dialog.setBounds( frame.getLocation().x+frame.getSize().width+5, + frame.getLocation().y+20,300,100); + dialog.show(); + + + String featureName = cap.getText().trim(); + if(featureName.length()<1) + return; + + for (int i = 0; i < searchResults.getSize(); i ++ ) { SequenceI seq = searchResults.getResultSequence(i); - SequenceFeature sf = new SequenceFeature(textfield.getText(), - "Search Results", null, + SequenceFeature sf = new SequenceFeature(featureName, + null, null, searchResults.getResultStart(i), searchResults.getResultEnd(i)); ap.seqPanel.seqCanvas.getFeatureRenderer().addNewFeature( - textfield.getText(), new Color(60,160,115)); + featureName, new Color(60,160,115)); seq.addSequenceFeature(sf); } + ap.seqPanel.seqCanvas.getFeatureRenderer().findAllFeatures(); ap.alignFrame.sequenceFeatures.setState(true); av.showSequenceFeatures(true); ap.highlightSearchResults(null); @@ -155,6 +172,7 @@ public class Finder extends Panel implements ActionListener while (!found && seqIndex < end) { + seq = (Sequence) av.alignment.getSequenceAt(seqIndex); if (selection != null && !selection.sequences.contains(seq)) @@ -172,7 +190,7 @@ public class Finder extends Panel implements ActionListener } ///Shall we ignore gaps???? - StringBuffer noGaps = new StringBuffer(); + StringBuffer noGapsSB = new StringBuffer(); int insertCount = 0; Vector spaces = new Vector(); @@ -181,7 +199,7 @@ public class Finder extends Panel implements ActionListener if (!jalview.util.Comparison.isGap(item.charAt(j))) { - noGaps.append(item.charAt(j)); + noGapsSB.append(item.charAt(j)); spaces.addElement(new Integer(insertCount)); } else @@ -190,10 +208,12 @@ public class Finder extends Panel implements ActionListener } } + String noGaps = noGapsSB.toString(); + for (int r = resIndex; r < noGaps.length(); r++) { - if (regex.searchFrom(noGaps.toString(), r)) + if (regex.searchFrom(noGaps, r)) { resIndex = regex.matchedFrom(); if (selection != null && @@ -264,8 +284,8 @@ public class Finder extends Panel implements ActionListener if (findAll) { - String message = (searchResults.getSize()) + " matches found."; - System.out.println(message); + String message = (searchResults==null?0 : searchResults.getSize()) + " matches found."; + ap.alignFrame.statusBar.setText("Search results: "+searchString+" : "+message); } } -- 1.7.10.2