+ }
+ // add the rest if there are actually rows to show
+ item = new MenuItem(EDITNAME);
+ item.addActionListener(this);
+ popup.add(item);
+ item = new MenuItem(HIDE);
+ item.addActionListener(this);
+ popup.add(item);
+
+ /*
+ * Hide all <label>:
+ */
+ if (selectedRow < aa.length)
+ {
+ if (aa[selectedRow].sequenceRef != null)
+ {
+ final String label = aa[selectedRow].label;
+ MenuItem hideType = new MenuItem(
+ MessageManager.getString("label.hide_all") + " " + label);
+ hideType.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ AlignmentUtils.showOrHideSequenceAnnotations(
+ ap.av.getAlignment(), Collections.singleton(label),
+ null, false, false);
+ refresh();
+ }
+ });
+ popup.add(hideType);
+ }
+ }
+
+ if (hasHiddenRows)
+ {
+ item = new MenuItem(SHOWALL);
+ item.addActionListener(this);
+ popup.add(item);
+ }
+ this.add(popup);
+ item = new MenuItem(OUTPUT_TEXT);
+ item.addActionListener(this);
+ popup.add(item);
+ if (selectedRow < aa.length)
+ {
+ if (aa[selectedRow].autoCalculated)
+ {
+ if (aa[selectedRow].label.indexOf("Consensus") > -1)
+ {
+ popup.addSeparator();
+ final CheckboxMenuItem cbmi = new CheckboxMenuItem(
+ MessageManager.getString("label.ignore_gaps_consensus"),
+ (aa[selectedRow].groupRef != null)
+ ? aa[selectedRow].groupRef
+ .getIgnoreGapsConsensus()
+ : ap.av.isIgnoreGapsConsensus());
+ final AlignmentAnnotation aaa = aa[selectedRow];
+ cbmi.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ if (aaa.groupRef != null)
+ {
+ // TODO: pass on reference to ap so the view can be updated.
+ aaa.groupRef.setIgnoreGapsConsensus(cbmi.getState());
+ }
+ else
+ {
+ ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap);
+ }
+ ap.paintAlignment(true, true);
+ }
+ });
+ popup.add(cbmi);
+ if (aaa.groupRef != null)
+ {
+ final CheckboxMenuItem chist = new CheckboxMenuItem(
+ MessageManager
+ .getString("label.show_group_histogram"),
+ aa[selectedRow].groupRef.isShowConsensusHistogram());
+ chist.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ // TODO: pass on reference
+ // to ap
+ // so the
+ // view
+ // can be
+ // updated.
+ aaa.groupRef.setShowConsensusHistogram(chist.getState());
+ ap.repaint();
+ // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+ }
+ });
+ popup.add(chist);
+ final CheckboxMenuItem cprofl = new CheckboxMenuItem(
+ MessageManager.getString("label.show_group_logo"),
+ aa[selectedRow].groupRef.isShowSequenceLogo());
+ cprofl.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ // TODO: pass on reference
+ // to ap
+ // so the
+ // view
+ // can be
+ // updated.
+ aaa.groupRef.setshowSequenceLogo(cprofl.getState());
+ ap.repaint();
+ // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+ }
+ });
+
+ popup.add(cprofl);
+ final CheckboxMenuItem cprofn = new CheckboxMenuItem(
+ MessageManager
+ .getString("label.normalise_group_logo"),
+ aa[selectedRow].groupRef.isNormaliseSequenceLogo());
+ cprofn.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ // TODO: pass on reference
+ // to ap
+ // so the
+ // view
+ // can be
+ // updated.
+ aaa.groupRef.setshowSequenceLogo(true);
+ aaa.groupRef.setNormaliseSequenceLogo(cprofn.getState());
+ ap.repaint();
+ // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+ }
+ });
+ popup.add(cprofn);
+ }
+ else
+ {
+ final CheckboxMenuItem chist = new CheckboxMenuItem(
+ MessageManager.getString("label.show_histogram"),
+ av.isShowConsensusHistogram());
+ chist.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ // TODO: pass on reference
+ // to ap
+ // so the
+ // view
+ // can be
+ // updated.
+ av.setShowConsensusHistogram(chist.getState());
+ ap.alignFrame.showConsensusHistogram
+ .setState(chist.getState()); // TODO: implement
+ // ap.updateGUI()/alignFrame.updateGUI
+ // for applet
+ ap.repaint();
+ // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+ }
+ });
+ popup.add(chist);
+ final CheckboxMenuItem cprof = new CheckboxMenuItem(
+ MessageManager.getString("label.show_logo"),
+ av.isShowSequenceLogo());
+ cprof.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ // TODO: pass on reference
+ // to ap
+ // so the
+ // view
+ // can be
+ // updated.
+ av.setShowSequenceLogo(cprof.getState());
+ ap.alignFrame.showSequenceLogo.setState(cprof.getState()); // TODO:
+ // implement
+ // ap.updateGUI()/alignFrame.updateGUI
+ // for
+ // applet
+ ap.repaint();
+ // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+ }
+ });
+ popup.add(cprof);
+ final CheckboxMenuItem cprofn = new CheckboxMenuItem(
+ MessageManager.getString("label.normalise_logo"),
+ av.isNormaliseSequenceLogo());
+ cprofn.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ // TODO: pass on reference
+ // to ap
+ // so the
+ // view
+ // can be
+ // updated.
+ av.setShowSequenceLogo(true);
+ ap.alignFrame.normSequenceLogo
+ .setState(cprofn.getState()); // TODO:
+ // implement
+ // ap.updateGUI()/alignFrame.updateGUI
+ // for
+ // applet
+ av.setNormaliseSequenceLogo(cprofn.getState());
+ ap.repaint();
+ // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+ }
+ });
+ popup.add(cprofn);
+ }
+
+ item = new MenuItem(COPYCONS_SEQ);
+ item.addActionListener(this);
+ popup.add(item);
+ }
+ }
+ }
+ popup.show(this, evt.getX(), evt.getY());
+ }
+ else
+ {
+ // selection action.
+ if (selectedRow > -1 && selectedRow < aa.length)
+ {
+ if (aa[selectedRow].groupRef != null)
+ {
+ if (evt.getClickCount() >= 2)
+ {
+ // todo: make the ap scroll to the selection - not necessary, first
+ // click highlights/scrolls, second selects
+ ap.seqPanel.ap.idPanel.highlightSearchResults(null);
+ // process modifiers
+ SequenceGroup sg = ap.av.getSelectionGroup();
+ if (sg == null || sg == aa[selectedRow].groupRef
+ || !(jalview.util.Platform.isControlDown(evt)
+ || evt.isShiftDown()))
+ {
+ if (jalview.util.Platform.isControlDown(evt)
+ || evt.isShiftDown())
+ {
+ // clone a new selection group from the associated group
+ ap.av.setSelectionGroup(
+ new SequenceGroup(aa[selectedRow].groupRef));
+ }
+ else
+ {
+ // set selection to the associated group so it can be edited
+ ap.av.setSelectionGroup(aa[selectedRow].groupRef);
+ }
+ }
+ else
+ {
+ // modify current selection with associated group
+ int remainToAdd = aa[selectedRow].groupRef.getSize();
+ for (SequenceI sgs : aa[selectedRow].groupRef.getSequences())
+ {
+ if (jalview.util.Platform.isControlDown(evt))
+ {
+ sg.addOrRemove(sgs, --remainToAdd == 0);
+ }
+ else
+ {
+ // notionally, we should also add intermediate sequences from
+ // last added sequence ?
+ sg.addSequence(sgs, --remainToAdd == 0);
+ }
+ }
+ }
+ ap.paintAlignment(false, false);
+ PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
+ ap.av.sendSelection();
+ }
+ else
+ {
+ ap.seqPanel.ap.idPanel.highlightSearchResults(
+ aa[selectedRow].groupRef.getSequences(null));
+ }
+ return;
+ }
+ else if (aa[selectedRow].sequenceRef != null)