AlignmentUtils.showOrHideSequenceAnnotations(
ap.av.getAlignment(), Collections.singleton(label),
null, false, false);
- // for (AlignmentAnnotation ann : ap.av.getAlignment()
- // .getAlignmentAnnotation())
- // {
- // if (ann.sequenceRef != null && ann.label != null
- // && ann.label.equals(label))
- // {
- // ann.visible = false;
- // }
- // }
ap.refresh(true);
}
});
}
else if (label.indexOf("Consensus") > -1)
{
- pop.addSeparator();
- // av and sequencegroup need to implement same interface for
- final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(
- MessageManager.getString("label.ignore_gaps_consensus"),
- (aa[selectedRow].groupRef != null)
- ? aa[selectedRow].groupRef.getIgnoreGapsConsensus()
- : ap.av.isIgnoreGapsConsensus());
- final AlignmentAnnotation aaa = aa[selectedRow];
- cbmi.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if (aaa.groupRef != null)
- {
- // TODO: pass on reference to ap so the view can be updated.
- aaa.groupRef.setIgnoreGapsConsensus(cbmi.getState());
- ap.getAnnotationPanel()
- .paint(ap.getAnnotationPanel().getGraphics());
- }
- else
- {
- ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap);
- }
- ap.alignmentChanged();
- }
- });
- pop.add(cbmi);
- // av and sequencegroup need to implement same interface for
+ addConsensusMenuOptions(ap, aa[selectedRow], pop);
+
+ final JMenuItem consclipbrd = new JMenuItem(COPYCONS_SEQ);
+ consclipbrd.addActionListener(this);
+ pop.add(consclipbrd);
+ }
+ }
+ pop.show(this, evt.getX(), evt.getY());
+ }
+
+ /**
+ * A helper method that adds menu options for calculation and visualisation of
+ * group and/or alignment consensus annotation to a popup menu. This is
+ * designed to be reusable for either unwrapped mode (popup menu is shown on
+ * component AnnotationLabels), or wrapped mode (popup menu is shown on
+ * IdPanel when the mouse is over an annotation label).
+ *
+ * @param ap
+ * @param ann
+ * @param pop
+ */
+ static void addConsensusMenuOptions(AlignmentPanel ap,
+ AlignmentAnnotation ann,
+ JPopupMenu pop)
+ {
+ pop.addSeparator();
+
+ final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(
+ MessageManager.getString("label.ignore_gaps_consensus"),
+ (ann.groupRef != null) ? ann.groupRef.getIgnoreGapsConsensus()
+ : ap.av.isIgnoreGapsConsensus());
+ final AlignmentAnnotation aaa = ann;
+ cbmi.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
if (aaa.groupRef != null)
{
- final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
- MessageManager.getString("label.show_group_histogram"),
- aa[selectedRow].groupRef.isShowConsensusHistogram());
- chist.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent 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());
- }
- });
- pop.add(chist);
- final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem(
- MessageManager.getString("label.show_group_logo"),
- aa[selectedRow].groupRef.isShowSequenceLogo());
- cprofl.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent 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());
- }
- });
- pop.add(cprofl);
- final JCheckBoxMenuItem cproflnorm = new JCheckBoxMenuItem(
- MessageManager.getString("label.normalise_group_logo"),
- aa[selectedRow].groupRef.isNormaliseSequenceLogo());
- cproflnorm.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
-
- // TODO: pass on reference
- // to ap
- // so the
- // view
- // can be
- // updated.
- aaa.groupRef.setNormaliseSequenceLogo(cproflnorm.getState());
- // automatically enable logo display if we're clicked
- aaa.groupRef.setshowSequenceLogo(true);
- ap.repaint();
- // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
- }
- });
- pop.add(cproflnorm);
+ aaa.groupRef.setIgnoreGapsConsensus(cbmi.getState());
+ ap.getAnnotationPanel()
+ .paint(ap.getAnnotationPanel().getGraphics());
}
else
{
- final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
- MessageManager.getString("label.show_histogram"),
- av.isShowConsensusHistogram());
- chist.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- // TODO: pass on reference
- // to ap
- // so the
- // view
- // can be
- // updated.
- av.setShowConsensusHistogram(chist.getState());
- ap.alignFrame.setMenusForViewport();
- ap.repaint();
- // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
- }
- });
- pop.add(chist);
- final JCheckBoxMenuItem cprof = new JCheckBoxMenuItem(
- MessageManager.getString("label.show_logo"),
- av.isShowSequenceLogo());
- cprof.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- // TODO: pass on reference
- // to ap
- // so the
- // view
- // can be
- // updated.
- av.setShowSequenceLogo(cprof.getState());
- ap.alignFrame.setMenusForViewport();
- ap.repaint();
- // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
- }
- });
- pop.add(cprof);
- final JCheckBoxMenuItem cprofnorm = new JCheckBoxMenuItem(
- MessageManager.getString("label.normalise_logo"),
- av.isNormaliseSequenceLogo());
- cprofnorm.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- // TODO: pass on reference
- // to ap
- // so the
- // view
- // can be
- // updated.
- av.setShowSequenceLogo(true);
- av.setNormaliseSequenceLogo(cprofnorm.getState());
- ap.alignFrame.setMenusForViewport();
- ap.repaint();
- // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
- }
- });
- pop.add(cprofnorm);
+ ap.av.setIgnoreGapsConsensus(cbmi.getState(), ap);
}
- final JMenuItem consclipbrd = new JMenuItem(COPYCONS_SEQ);
- consclipbrd.addActionListener(this);
- pop.add(consclipbrd);
+ ap.alignmentChanged();
}
+ });
+ pop.add(cbmi);
+
+ if (aaa.groupRef != null)
+ {
+ /*
+ * group consensus options
+ */
+ final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_group_histogram"),
+ ann.groupRef.isShowConsensusHistogram());
+ chist.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ aaa.groupRef.setShowConsensusHistogram(chist.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(chist);
+ final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_group_logo"),
+ ann.groupRef.isShowSequenceLogo());
+ cprofl.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ aaa.groupRef.setshowSequenceLogo(cprofl.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(cprofl);
+ final JCheckBoxMenuItem cproflnorm = new JCheckBoxMenuItem(
+ MessageManager.getString("label.normalise_group_logo"),
+ ann.groupRef.isNormaliseSequenceLogo());
+ cproflnorm.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ aaa.groupRef.setNormaliseSequenceLogo(cproflnorm.getState());
+ // automatically enable logo display if we're clicked
+ aaa.groupRef.setshowSequenceLogo(true);
+ ap.repaint();
+ }
+ });
+ pop.add(cproflnorm);
+ }
+ else
+ {
+ /*
+ * alignment consensus options
+ */
+ final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_histogram"),
+ ap.av.isShowConsensusHistogram());
+ chist.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ ap.av.setShowConsensusHistogram(chist.getState());
+ ap.alignFrame.setMenusForViewport();
+ ap.repaint();
+ }
+ });
+ pop.add(chist);
+ final JCheckBoxMenuItem cprof = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_logo"),
+ ap.av.isShowSequenceLogo());
+ cprof.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ ap.av.setShowSequenceLogo(cprof.getState());
+ ap.alignFrame.setMenusForViewport();
+ ap.repaint();
+ }
+ });
+ pop.add(cprof);
+ final JCheckBoxMenuItem cprofnorm = new JCheckBoxMenuItem(
+ MessageManager.getString("label.normalise_logo"),
+ ap.av.isNormaliseSequenceLogo());
+ cprofnorm.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ ap.av.setShowSequenceLogo(true);
+ ap.av.setNormaliseSequenceLogo(cprofnorm.getState());
+ ap.alignFrame.setMenusForViewport();
+ ap.repaint();
+ }
+ });
+ pop.add(cprofnorm);
}
- pop.show(this, evt.getX(), evt.getY());
}
/**
import java.util.List;
import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
}
MousePos pos = alignPanel.getSeqPanel().findMousePosition(e);
- if (pos.isOverAnnotation())
- {
- // mouse is over an annotation label in wrapped mode
- return;
- }
if (e.isPopupTrigger()) // Mac reports this in mousePressed
{
*/
void showPopupMenu(MouseEvent e, MousePos pos)
{
+ if (pos.isOverAnnotation())
+ {
+ showAnnotationMenu(e, pos);
+ return;
+ }
+
Sequence sq = (Sequence) av.getAlignment().getSequenceAt(pos.seqIndex);
/*
}
/**
+ * On right mouse click on a Consensus annotation label, shows a limited popup
+ * menu, with options to configure the consensus calculation and rendering.
+ *
+ * @param e
+ * @param pos
+ * @see AnnotationLabels#showPopupMenu(MouseEvent)
+ */
+ void showAnnotationMenu(MouseEvent e, MousePos pos)
+ {
+ if (pos.annotationIndex == -1)
+ {
+ return;
+ }
+ AlignmentAnnotation[] anns = this.av.getAlignment()
+ .getAlignmentAnnotation();
+ if (anns == null || pos.annotationIndex >= anns.length)
+ {
+ return;
+ }
+ AlignmentAnnotation ann = anns[pos.annotationIndex];
+ if (!ann.label.contains("Consensus"))
+ {
+ return;
+ }
+
+ JPopupMenu pop = new JPopupMenu(
+ MessageManager.getString("label.annotations"));
+ AnnotationLabels.addConsensusMenuOptions(this.alignPanel, ann, pop);
+ pop.show(this, e.getX(), e.getY());
+ }
+
+ /**
* Toggle whether the sequence is part of the current selection group.
*
* @param seq
scrollThread.running = false;
}
MousePos pos = alignPanel.getSeqPanel().findMousePosition(e);
- if (pos.isOverAnnotation())
- {
- // mouse is over an annotation label in wrapped mode
- return;
- }
mouseDragging = false;
PaintRefresher.Refresh(this, av.getSequenceSetId());