From: amwaterhouse Date: Thu, 16 Mar 2006 15:28:30 +0000 (+0000) Subject: Hide Sequences X-Git-Tag: Root_VamJalview_2_07b+~44 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3fb85e9272c55b49583d558ca9c44babcf1b3a0b;p=jalview.git Hide Sequences --- diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 3114211..ba178ab 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -111,28 +111,58 @@ public class PopupMenu extends JPopupMenu } - if ((seq != null) - && seq.getDatasetSequence().getPDBId() != null) + if (seq != null) { - java.util.Enumeration e = seq.getDatasetSequence().getPDBId().elements(); - while(e.hasMoreElements()) + JMenuItem menuItem; + if( seq.getDatasetSequence().getPDBId() != null) { - final PDBEntry pdb = (PDBEntry)e.nextElement(); - - JMenuItem pdbMenuItem = new JMenuItem(); - pdbMenuItem.setText("View PDB entry: "+pdb.getId()); - pdbMenuItem.addActionListener(new java.awt.event.ActionListener() + java.util.Enumeration e = seq.getDatasetSequence().getPDBId(). + elements(); + while (e.hasMoreElements()) { + final PDBEntry pdb = (PDBEntry) e.nextElement(); + + menuItem = new JMenuItem(); + menuItem.setText("View PDB entry: " + pdb.getId()); + menuItem.addActionListener(new java.awt.event.ActionListener() + { public void actionPerformed(ActionEvent e) { new PDBViewer(pdb, sequence, ap.seqPanel.seqCanvas); } + }); + sequenceMenu.add(menuItem); + } + } + + menuItem = new JMenuItem("Hide Sequences"); + menuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + hideSequences(false); + } + }); + sequenceMenu.add(menuItem); + + if(ap.av.getSelectionGroup() !=null && ap.av.getSelectionGroup().getSize()>1) + { + menuItem = new JMenuItem("Represent Group with " + seq.getName()); + menuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + hideSequences(true); + } }); - sequenceMenu.add(pdbMenuItem); + sequenceMenu.add(menuItem); } + } + + SequenceGroup sg = ap.av.getSelectionGroup(); if (sg != null) @@ -245,6 +275,7 @@ public class PopupMenu extends JPopupMenu } } + /** * DOCUMENT ME! * @@ -928,4 +959,33 @@ public class PopupMenu extends JPopupMenu ex.printStackTrace(); } } + + void hideSequences(boolean representGroup) + { + SequenceGroup sg = ap.av.getSelectionGroup(); + if(sg==null || sg.getSize()<1) + { + ap.av.hideSequence(sequence); + return; + } + + int index = 0; + while(index < sg.sequences.size()) + { + if(representGroup && sg.getSequenceAt(index)!=sequence) + { + sequence.addHiddenSequence(sg.getSequenceAt(index)); + ap.av.hideSequence(sg.getSequenceAt(index)); + } + else if(!representGroup) + { + ap.av.hideSequence(sg.getSequenceAt(index)); + } + index ++; + } + + ap.av.setSelectionGroup(null); + refresh(); + } + }