import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.List;
import java.util.Vector;
import javax.swing.ButtonGroup;
JMenu outputMenu = new JMenu();
+ JMenu showAnnotationsMenu = new JMenu();
+
+ JMenu hideAnnotationsMenu = new JMenu();
+
JMenuItem sequenceFeature = new JMenuItem();
JMenuItem textColour = new JMenuItem();
outputMenu.add(item);
}
+ buildAnnotationTypesMenu();
+
try
{
jbInit();
}
}
+ /**
+ * Find which sequence-specific annotation types are associated with the
+ * current selection, and add these as menu items (for show / hide annotation
+ * types).
+ */
+ protected void buildAnnotationTypesMenu()
+ {
+ List<String> found = new ArrayList<String>();
+ for (AlignmentAnnotation aa : ap.getAlignment()
+ .getAlignmentAnnotation())
+ {
+ if (aa.sequenceRef != null)
+ {
+ if (ap.av.getSelectionGroup().getSequences()
+ .contains(aa.sequenceRef))
+ {
+ final String label = aa.label;
+ if (!found.contains(label))
+ {
+ found.add(label);
+ final JMenuItem showitem = new JMenuItem(label);
+ showitem.addActionListener(new java.awt.event.ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ showHideAnnotation_actionPerformed(label, true);
+ }
+ });
+ showAnnotationsMenu.add(showitem);
+ final JMenuItem hideitem = new JMenuItem(label);
+ hideitem.addActionListener(new java.awt.event.ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ showHideAnnotation_actionPerformed(label, false);
+ }
+ });
+ hideAnnotationsMenu.add(hideitem);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Action on selecting an annotation type to show or hide for the selection.
+ *
+ * @param type
+ * @param doShow
+ */
+ protected void showHideAnnotation_actionPerformed(String type,
+ boolean doShow)
+ {
+ for (AlignmentAnnotation aa : ap.getAlignment()
+ .getAlignmentAnnotation())
+ {
+ if (aa.sequenceRef != null && type.equals(aa.label))
+ {
+ if (ap.av.getSelectionGroup().getSequences()
+ .contains(aa.sequenceRef))
+ {
+ aa.visible = doShow;
+ }
+ }
+ }
+ refresh();
+ }
+
private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
{
});
outputMenu.setText(MessageManager.getString("label.out_to_textbox")
+ "...");
+ showAnnotationsMenu.setText(MessageManager
+ .getString("label.show_annotations"));
+ hideAnnotationsMenu.setText(MessageManager
+ .getString("label.hide_annotations"));
sequenceFeature.setText(MessageManager
.getString("label.create_sequence_feature"));
sequenceFeature.addActionListener(new ActionListener()
add(sequenceMenu);
this.add(structureMenu);
groupMenu.add(chooseAnnotations);
+ groupMenu.add(showAnnotationsMenu);
+ groupMenu.add(hideAnnotationsMenu);
groupMenu.add(editMenu);
groupMenu.add(outputMenu);
groupMenu.add(sequenceFeature);