X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPopupMenu.java;h=37082aabd69158d17f4478fbb31f0d658635a12c;hb=c9df5bd6e95c23c9b560c0a59003d1f4043f8055;hp=2aa8675637fbe0dbbca75f7d9f35e13884dd0570;hpb=6296524c4ccada42516aac9a85398170f5a3bc5d;p=jalview.git diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 2aa8675..37082aa 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -20,6 +20,27 @@ */ package jalview.gui; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.Collections; +import java.util.Hashtable; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.Vector; + +import javax.swing.ButtonGroup; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JColorChooser; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; +import javax.swing.JRadioButtonMenuItem; + import jalview.analysis.AAFrequency; import jalview.analysis.AlignmentAnnotationUtils; import jalview.analysis.AlignmentUtils; @@ -59,27 +80,6 @@ import jalview.util.GroupUrlLink.UrlStringTooLongException; import jalview.util.MessageManager; import jalview.util.UrlLink; -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Arrays; -import java.util.Collections; -import java.util.Hashtable; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.Vector; - -import javax.swing.ButtonGroup; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JColorChooser; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButtonMenuItem; - /** * DOCUMENT ME! * @@ -322,49 +322,54 @@ public class PopupMenu extends JPopupMenu makeReferenceSeq.setText("Mark as representative"); } - if (ap.av.getAlignment().isNucleotide() == false) + if (!ap.av.getAlignment().isNucleotide()) { remove(rnaStructureMenu); } - - if (ap.av.getAlignment().isNucleotide() == true) + else { - AlignmentAnnotation[] aa = ap.av.getAlignment() + /* + * add menu items to 2D-render any alignment or sequence secondary + * structure annotation + */ + AlignmentAnnotation[] aas = ap.av.getAlignment() .getAlignmentAnnotation(); - for (int i = 0; aa != null && i < aa.length; i++) + if (aas != null) { - if (aa[i].isValidStruc() && aa[i].sequenceRef == null) + for (final AlignmentAnnotation aa : aas) { - final String rnastruc = aa[i].getRNAStruc(); - final String structureLine = aa[i].label + " (alignment)"; - menuItem = new JMenuItem(); - menuItem.setText(MessageManager.formatMessage( - "label.2d_rna_structure_line", new Object[] - { structureLine })); - menuItem.addActionListener(new java.awt.event.ActionListener() + if (aa.isValidStruc() && aa.sequenceRef == null) { - @Override - public void actionPerformed(ActionEvent e) + /* + * valid alignment RNA secondary structure annotation + */ + menuItem = new JMenuItem(); + menuItem.setText(MessageManager.formatMessage( + "label.2d_rna_structure_line", new Object[] + { aa.label })); + menuItem.addActionListener(new java.awt.event.ActionListener() { - new AppVarna(structureLine, seq, seq.getSequenceAsString(), - rnastruc, seq.getName(), ap); - System.out.println("end"); - } - }); - rnaStructureMenu.add(menuItem); + @Override + public void actionPerformed(ActionEvent e) + { + new AppVarna(seq, aa, ap); + } + }); + rnaStructureMenu.add(menuItem); + } } } - if (seq.getAnnotation() != null) { - AlignmentAnnotation seqAnno[] = seq.getAnnotation(); - for (int i = 0; i < seqAnno.length; i++) + AlignmentAnnotation seqAnns[] = seq.getAnnotation(); + for (final AlignmentAnnotation aa : seqAnns) { - if (seqAnno[i].isValidStruc()) + if (aa.isValidStruc()) { - final String rnastruc = seqAnno[i].getRNAStruc(); - + /* + * valid sequence RNA secondary structure annotation + */ // TODO: make rnastrucF a bit more nice menuItem = new JMenuItem(); menuItem.setText(MessageManager.formatMessage( @@ -376,10 +381,7 @@ public class PopupMenu extends JPopupMenu public void actionPerformed(ActionEvent e) { // TODO: VARNA does'nt print gaps in the sequence - - new AppVarna(seq.getName() + " structure", seq, seq - .getSequenceAsString(), rnastruc, seq.getName(), - ap); + new AppVarna(seq, aa, ap); } }); rnaStructureMenu.add(menuItem);