X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAPopupMenu.java;h=a56f76dcb2e437a13a9d459cc0bb2a0db2b01ea7;hb=d438fa16745a7998c9c1d92ff9ae4d47000f8784;hp=2bacd7056c5cde03907324d37564a6ccaa68dee7;hpb=b57fe83e78a9fb160a4765099880827b82222c53;p=jalview.git diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 2bacd70..a56f76d 100755 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) + * Copyright (C) 2010 J Procter, AM Waterhouse, 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 file is part of Jalview. * - * 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. + * Jalview 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 3 of the License, or (at your option) any later version. * - * 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 + * Jalview 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 Jalview. If not, see . */ package jalview.appletgui; @@ -113,6 +112,11 @@ public class APopupMenu extends java.awt.PopupMenu implements MenuItem revealAll = new MenuItem(); + MenuItem revealSeq = new MenuItem(); + /** + * index of sequence to be revealed + */ + int revealSeq_index=-1; Menu menu1 = new Menu(); public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links) @@ -152,7 +156,7 @@ public class APopupMenu extends java.awt.PopupMenu implements showText.setState(sg.getDisplayText()); showColourText.setState(sg.getColourText()); showBoxes.setState(sg.getDisplayBoxes()); - displayNonconserved.setState(sg.getShowunconserved()); + displayNonconserved.setState(sg.getShowNonconserved()); if (!ap.av.alignment.getGroups().contains(sg)) { groupMenu.remove(unGroupMenuItem); @@ -179,19 +183,19 @@ public class APopupMenu extends java.awt.PopupMenu implements continue; } final String target = urlLink.getTarget(); // link.substring(0, - // link.indexOf("|")); + // link.indexOf("|")); final String label = urlLink.getLabel(); if (urlLink.isDynamic()) { // collect matching db-refs - DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq - .getDBRef(), new String[] - { target }); + DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs( + seq.getDBRef(), new String[] + { target }); // collect id string too String id = seq.getName(); String descr = seq.getDescription(); - if (descr!=null && descr.length()<1) + if (descr != null && descr.length() < 1) { descr = null; } @@ -230,8 +234,9 @@ public class APopupMenu extends java.awt.PopupMenu implements } // addshowLink(linkMenu, target, url_pref + id + url_suff); } - // Now construct URLs from description but only try to do it for regex URL links - if (descr != null && urlLink.getRegexReplace()!=null) + // Now construct URLs from description but only try to do it for regex + // URL links + if (descr != null && urlLink.getRegexReplace() != null) { // create link for this URL from description only if regex matches String[] urls = urlLink.makeUrls(descr, true); @@ -252,11 +257,12 @@ public class APopupMenu extends java.awt.PopupMenu implements * final String url; * * if (link.indexOf("$SEQUENCE_ID$") > -1) { // Substitute SEQUENCE_ID - * string and any matching database reference accessions String url_pref = - * link.substring(link.indexOf("|") + 1, link.indexOf("$SEQUENCE_ID$")); + * string and any matching database reference accessions String url_pref + * = link.substring(link.indexOf("|") + 1, + * link.indexOf("$SEQUENCE_ID$")); * * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13); - * // collect matching db-refs DBRefEntry[] dbr = + * // collect matching db-refs DBRefEntry[] dbr = * jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new * String[]{target}); // collect id string too String id = * seq.getName(); if (id.indexOf("|") > -1) { id = @@ -271,16 +277,19 @@ public class APopupMenu extends java.awt.PopupMenu implements * link.substring(link.lastIndexOf("|")+1)); } */ } - - if (seq != null) - { - seqMenu.add(linkMenu); - } - else + if (linkMenu.getItemCount() > 0) { - add(linkMenu); + if (seq != null) + { + seqMenu.add(linkMenu); + } + else + { + add(linkMenu); + } } } + // TODO: add group link menu entry here if (seq != null) { seqMenu.setLabel(seq.getName()); @@ -294,6 +303,17 @@ public class APopupMenu extends java.awt.PopupMenu implements if (!ap.av.hasHiddenRows) { remove(revealAll); + remove(revealSeq); + } else { + final int index = ap.av.alignment.findIndex(seq); + + if (ap.av.adjustForHiddenSeqs(index) + - ap.av.adjustForHiddenSeqs(index - 1) > 1) + { + revealSeq_index=index; + } else { + remove(revealSeq); + } } } @@ -301,10 +321,10 @@ public class APopupMenu extends java.awt.PopupMenu implements * add a show URL menu item to the given linkMenu * * @param linkMenu - * @param target - - * menu label string - * @param url - - * url to open + * @param target + * - menu label string + * @param url + * - url to open */ private void addshowLink(Menu linkMenu, final String target, final String url) @@ -316,12 +336,12 @@ public class APopupMenu extends java.awt.PopupMenu implements * add a show URL menu item to the given linkMenu * * @param linkMenu - * @param target - - * URL target window - * @param label - - * menu label string - * @param url - - * url to open + * @param target + * - URL target window + * @param label + * - menu label string + * @param url + * - url to open */ private void addshowLink(Menu linkMenu, final String target, final String label, final String url) @@ -442,6 +462,10 @@ public class APopupMenu extends java.awt.PopupMenu implements { hideSequences(true); } + else if (source == revealSeq) + { + ap.av.showSequence(revealSeq_index); + } else if (source == revealAll) { ap.av.showAllHiddenSeqs(); @@ -488,8 +512,8 @@ public class APopupMenu extends java.awt.PopupMenu implements { EditCommand editCommand = new EditCommand("Edit Sequences", EditCommand.REPLACE, dialog.getName().replace(' ', - ap.av.getGapCharacter()), sg - .getSequencesAsArray(ap.av.hiddenRepSequences), + ap.av.getGapCharacter()), + sg.getSequencesAsArray(ap.av.hiddenRepSequences), sg.getStartRes(), sg.getEndRes() + 1, ap.av.alignment); ap.alignFrame.addHistoryItem(editCommand); @@ -582,18 +606,28 @@ public class APopupMenu extends java.awt.PopupMenu implements return; } - int gSize = sg.getSize(); - SequenceI[] seqs = new SequenceI[gSize]; - SequenceFeature[] features = new SequenceFeature[gSize]; + int rsize = 0, gSize = sg.getSize(); + SequenceI[] rseqs, seqs = new SequenceI[gSize]; + SequenceFeature[] tfeatures, features = new SequenceFeature[gSize]; for (int i = 0; i < gSize; i++) { - seqs[i] = sg.getSequenceAt(i); int start = sg.getSequenceAt(i).findPosition(sg.getStartRes()); int end = sg.findEndRes(sg.getSequenceAt(i)); - features[i] = new SequenceFeature(null, null, null, start, end, - "Jalview"); + if (start <= end) + { + seqs[rsize] = sg.getSequenceAt(i); + features[rsize] = new SequenceFeature(null, null, null, start, + end, "Jalview"); + rsize++; + } } + rseqs = new SequenceI[rsize]; + tfeatures = new SequenceFeature[rsize]; + System.arraycopy(seqs, 0, rseqs, 0, rsize); + System.arraycopy(features, 0, tfeatures, 0, rsize); + features = tfeatures; + seqs = rseqs; if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs, features, true, ap)) @@ -616,19 +650,20 @@ public class APopupMenu extends java.awt.PopupMenu implements Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "Selection output - " - + e.getActionCommand(), 600, 500); + jalview.bin.JalviewLite.addFrame(frame, + "Selection output - " + e.getActionCommand(), 600, 500); - cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(e - .getActionCommand(), new Alignment(ap.av - .getSelectionAsNewSequence()), ap.av.showJVSuffix)); + cap.setText(new jalview.io.AppletFormatAdapter().formatSequences( + e.getActionCommand(), + new Alignment(ap.av.getSelectionAsNewSequence()), + ap.av.showJVSuffix)); } void editName() { - EditNameDialog dialog = new EditNameDialog(seq.getName(), seq - .getDescription(), " Sequence Name", + EditNameDialog dialog = new EditNameDialog(seq.getName(), + seq.getDescription(), " Sequence Name", "Sequence Description", ap.alignFrame, "Edit Sequence Name / Description", 500, 100, true); @@ -697,10 +732,12 @@ public class APopupMenu extends java.awt.PopupMenu implements hideSeqs.setLabel("Hide Sequences"); repGroup.setLabel("Represent Group with"); revealAll.setLabel("Reveal All"); + revealSeq.setLabel("Reveal Sequences"); menu1.setLabel("Group"); add(groupMenu); this.add(seqMenu); this.add(hideSeqs); + this.add(revealSeq); this.add(revealAll); groupMenu.add(editGroupName); groupMenu.add(editMenu); @@ -781,6 +818,7 @@ public class APopupMenu extends java.awt.PopupMenu implements hideSeqs.addActionListener(this); repGroup.addActionListener(this); revealAll.addActionListener(this); + revealSeq.addActionListener(this); } void refresh() @@ -791,9 +829,9 @@ public class APopupMenu extends java.awt.PopupMenu implements protected void clustalColour_actionPerformed() { SequenceGroup sg = getGroup(); - sg.cs = new ClustalxColourScheme(sg - .getSequences(ap.av.hiddenRepSequences), ap.av.alignment - .getWidth()); + sg.cs = new ClustalxColourScheme( + sg.getSequences(ap.av.hiddenRepSequences), + ap.av.alignment.getWidth()); refresh(); } @@ -855,9 +893,9 @@ public class APopupMenu extends java.awt.PopupMenu implements if (abovePIDColour.getState()) { - sg.cs.setConsensus(AAFrequency.calculate(sg - .getSequences(ap.av.hiddenRepSequences), 0, ap.av.alignment - .getWidth())); + sg.cs.setConsensus(AAFrequency.calculate( + sg.getSequences(ap.av.hiddenRepSequences), 0, + ap.av.alignment.getWidth())); int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup() .getName()); @@ -885,9 +923,9 @@ public class APopupMenu extends java.awt.PopupMenu implements { SequenceGroup sg = getGroup(); sg.cs = new PIDColourScheme(); - sg.cs.setConsensus(AAFrequency.calculate(sg - .getSequences(ap.av.hiddenRepSequences), 0, ap.av.alignment - .getWidth())); + sg.cs.setConsensus(AAFrequency.calculate( + sg.getSequences(ap.av.hiddenRepSequences), 0, + ap.av.alignment.getWidth())); refresh(); } @@ -897,9 +935,9 @@ public class APopupMenu extends java.awt.PopupMenu implements sg.cs = new Blosum62ColourScheme(); - sg.cs.setConsensus(AAFrequency.calculate(sg - .getSequences(ap.av.hiddenRepSequences), 0, ap.av.alignment - .getWidth())); + sg.cs.setConsensus(AAFrequency.calculate( + sg.getSequences(ap.av.hiddenRepSequences), 0, + ap.av.alignment.getWidth())); refresh(); } @@ -922,8 +960,8 @@ public class APopupMenu extends java.awt.PopupMenu implements { Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, sg - .getSequences(ap.av.hiddenRepSequences), 0, + ResidueProperties.propHash, 3, + sg.getSequences(ap.av.hiddenRepSequences), 0, ap.av.alignment.getWidth()); c.calculate(); @@ -978,7 +1016,7 @@ public class APopupMenu extends java.awt.PopupMenu implements public void showNonconserved_itemStateChanged() { - getGroup().setShowunconserved(this.displayNonconserved.getState()); + getGroup().setShowNonconserved(this.displayNonconserved.getState()); refresh(); } @@ -1019,6 +1057,7 @@ public class APopupMenu extends java.awt.PopupMenu implements } ap.av.hideSequence(hseqs); + ap.av.sendSelection(); } }