+ * Adds menu items for the Autocalculated Annotation sub-menu
+ *
+ * @param av
+ */
+ void buildAutoAnnotationMenu(AlignViewport av)
+ {
+ autoAnnMenu.removeAll();
+ autoAnnMenu.add(showAutoFirst);
+ autoAnnMenu.add(showAutoLast);
+ autoAnnMenu.addSeparator();
+ autoAnnMenu.add(applyAutoAnnotationSettings);
+ autoAnnMenu.add(showConsensusHistogram);
+ autoAnnMenu.add(showSequenceLogo);
+ autoAnnMenu.add(normaliseSequenceLogo);
+ autoAnnMenu.addSeparator();
+
+ /*
+ * add options to reinstate any deleted auto-calculated annotations
+ */
+ boolean hasConservation = false;
+ boolean hasQuality = false;
+ boolean hasConsensus = false;
+ boolean hasOccupancy = false;
+ boolean hasRnaStruct = false;
+ AlignmentAnnotation[] anns = av.getAlignment().getAlignmentAnnotation();
+ if (anns == null)
+ {
+ return;
+ }
+ for (int i = 0; i < anns.length; i++)
+ {
+ if (anns[i].autoCalculated)
+ {
+ // TODO JAL-3485 should let these strings be constants instead
+ if ("Conservation".equals(anns[i].label))
+ {
+ hasConservation = true;
+ }
+ else if ("Quality".equals(anns[i].label))
+ {
+ hasQuality = true;
+ }
+ else if ("Consensus".equals(anns[i].label))
+ {
+ hasConsensus = true;
+ }
+ else if ("Occupancy".equals(anns[i].label))
+ {
+ hasOccupancy = true;
+ }
+ else if ("StrucConsensus".equals(anns[i].label))
+ {
+ hasRnaStruct = true;
+ }
+ }
+ }
+ boolean added = false;
+
+ /*
+ * a shareable action to refresh stuff; NB action listeners
+ * get run in reverse order to that in which they are added!
+ */
+ ActionListener refresher = new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ alignPanel.adjustAnnotationHeight();
+ av.alignmentChanged(alignPanel);
+ buildAutoAnnotationMenu(av);
+ }
+ };
+
+ if (!av.isNucleotide())
+ {
+ if (!hasConservation)
+ {
+ JMenuItem mi = new JMenuItem("Conservation");
+ mi.addActionListener(refresher);
+ mi.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.initConservation();
+ }
+ });
+ autoAnnMenu.add(mi);
+ added = true;
+ }
+ if (!hasQuality)
+ {
+ JMenuItem mi = new JMenuItem("Quality");
+ mi.addActionListener(refresher);
+ mi.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.initQuality();
+ }
+ });
+ autoAnnMenu.add(mi);
+ added = true;
+ }
+ }
+ if (!hasConsensus)
+ {
+ JMenuItem mi = new JMenuItem("Consensus");
+ mi.addActionListener(refresher);
+ mi.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.initConsensus();
+ }
+ });
+ autoAnnMenu.add(mi);
+ added = true;
+ }
+ if (!hasOccupancy)
+ {
+ JMenuItem mi = new JMenuItem("Occupancy");
+ mi.addActionListener(refresher);
+ mi.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.initOccupancy();
+ }
+ });
+ autoAnnMenu.add(mi);
+ added = true;
+ }
+ if (!hasRnaStruct && av.isNucleotide()
+ && av.getAlignment().hasRNAStructure())
+ {
+ JMenuItem mi = new JMenuItem("Structure Consensus");
+ mi.addActionListener(refresher);
+ mi.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.initRNAStructure();
+ }
+ });
+ autoAnnMenu.add(mi);
+ added = true;
+ }
+
+ if (added)
+ {
+ autoAnnMenu.addSeparator();
+ }
+ autoAnnMenu.add(showGroupConservation);
+ autoAnnMenu.add(showGroupConsensus);
+ }
+
+ /**