import jalview.util.Comparison;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.workers.InformationThread;
import java.awt.Color;
import java.awt.Cursor;
pop.show(this, evt.getX(), evt.getY());
return;
}
+
+ final AlignmentAnnotation ann = aa[selectedRow];
+ final boolean isSequenceAnnotation = ann.sequenceRef != null;
+
item = new JMenuItem(EDITNAME);
item.addActionListener(this);
pop.add(item);
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);
}
});
if (selectedRow < aa.length)
{
final String label = aa[selectedRow].label;
- if (!aa[selectedRow].autoCalculated)
+ if (!(aa[selectedRow].autoCalculated)
+ && !(InformationThread.HMM_CALC_ID.equals(ann.getCalcId())))
{
if (aa[selectedRow].graph == AlignmentAnnotation.NO_GRAPH)
{
pop.addSeparator();
// av and sequencegroup need to implement same interface for
item = new JCheckBoxMenuItem(TOGGLE_LABELSCALE,
- aa[selectedRow].scaleColLabel);
+ aa[selectedRow].scaleColLabel);
item.addActionListener(this);
pop.add(item);
}
}
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()
+ addConsensusMenuOptions(ap, aa[selectedRow], pop);
+
+ final JMenuItem consclipbrd = new JMenuItem(COPYCONS_SEQ);
+ consclipbrd.addActionListener(this);
+ pop.add(consclipbrd);
+ }
+ else if (InformationThread.HMM_CALC_ID.equals(ann.getCalcId()))
+ {
+ addHmmerMenu(pop, ann);
+ }
+ }
+ pop.show(this, evt.getX(), evt.getY());
+ }
+
+ /**
+ * Adds context menu options for (alignment or group) Hmmer annotation
+ *
+ * @param pop
+ * @param ann
+ */
+ protected void addHmmerMenu(JPopupMenu pop, final AlignmentAnnotation ann)
+ {
+ final boolean isGroupAnnotation = ann.groupRef != null;
+ pop.addSeparator();
+ final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(
+ MessageManager.getString(
+ "label.ignore_below_background_frequency"),
+ isGroupAnnotation
+ ? ann.groupRef
+ .isIgnoreBelowBackground()
+ : ap.av.isIgnoreBelowBackground());
+ cbmi.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ if (isGroupAnnotation)
{
- @Override
- public void actionPerformed(ActionEvent e)
+ if (!ann.groupRef.isUseInfoLetterHeight())
{
- 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();
+ ann.groupRef.setIgnoreBelowBackground(cbmi.getState());
+ // todo and recompute group annotation
}
- });
- pop.add(cbmi);
- // av and sequencegroup need to implement same interface for
- if (aaa.groupRef != null)
+ }
+ else if (!ap.av.isInfoLetterHeight())
{
- 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)
- {
+ ap.av.setIgnoreBelowBackground(cbmi.getState(), ap);
+ // todo and recompute annotation
+ }
+ ap.alignmentChanged(); // todo not like this
+ }
+ });
+ pop.add(cbmi);
+ final JCheckBoxMenuItem letterHeight = new JCheckBoxMenuItem(
+ MessageManager.getString("label.use_info_for_height"),
+ isGroupAnnotation ? ann.groupRef.isUseInfoLetterHeight()
+ : ap.av.isInfoLetterHeight());
+ letterHeight.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ if (isGroupAnnotation)
+ {
+ ann.groupRef.setInfoLetterHeight((letterHeight.getState()));
+ ann.groupRef.setIgnoreBelowBackground(true);
+ // todo and recompute group annotation
+ }
+ else
+ {
+ ap.av.setInfoLetterHeight(letterHeight.getState(), ap);
+ ap.av.setIgnoreBelowBackground(true, ap);
+ // todo and recompute annotation
+ }
+ ap.alignmentChanged();
+ }
+ });
+ pop.add(letterHeight);
+ if (isGroupAnnotation)
+ {
+ final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_group_histogram"),
+ ann.groupRef.isShowInformationHistogram());
+ chist.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ ann.groupRef.setShowInformationHistogram(chist.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(chist);
+ final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_group_logo"),
+ ann.groupRef.isShowHMMSequenceLogo());
+ cprofl.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ ann.groupRef.setShowHMMSequenceLogo(cprofl.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(cprofl);
+ final JCheckBoxMenuItem cproflnorm = new JCheckBoxMenuItem(
+ MessageManager.getString("label.normalise_group_logo"),
+ ann.groupRef.isNormaliseHMMSequenceLogo());
+ cproflnorm.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ ann.groupRef
+ .setNormaliseHMMSequenceLogo(cproflnorm.getState());
+ // automatically enable logo display if we're clicked
+ ann.groupRef.setShowHMMSequenceLogo(true);
+ ap.repaint();
+ }
+ });
+ pop.add(cproflnorm);
+ }
+ else
+ {
+ final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_histogram"),
+ av.isShowInformationHistogram());
+ chist.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.setShowInformationHistogram(chist.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(chist);
+ final JCheckBoxMenuItem cprof = new JCheckBoxMenuItem(
+ MessageManager.getString("label.show_logo"),
+ av.isShowHMMSequenceLogo());
+ cprof.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.setShowHMMSequenceLogo(cprof.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(cprof);
+ final JCheckBoxMenuItem cprofnorm = new JCheckBoxMenuItem(
+ MessageManager.getString("label.normalise_logo"),
+ av.isNormaliseHMMSequenceLogo());
+ cprofnorm.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ av.setShowHMMSequenceLogo(true);
+ av.setNormaliseHMMSequenceLogo(cprofnorm.getState());
+ ap.repaint();
+ }
+ });
+ pop.add(cprofnorm);
+ }
+ }
- // 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);
+ /**
+ * 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)
+ {
+ 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());
}
/**
if (selectedRow > -1 && ap.av.getAlignment()
.getAlignmentAnnotation().length > selectedRow)
{
- AlignmentAnnotation aa = ap.av.getAlignment()
- .getAlignmentAnnotation()[selectedRow];
+ AlignmentAnnotation[] anns = ap.av.getAlignment()
+ .getAlignmentAnnotation();
+ AlignmentAnnotation aa = anns[selectedRow];
String desc = getTooltip(aa);
this.setToolTipText(desc);
+ String msg = getStatusMessage(aa, anns);
+ ap.alignFrame.setStatus(msg);
+ }
+ }
+
+ /**
+ * Constructs suitable text to show in the status bar when over an annotation
+ * label, containing the associated sequence name (if any), and the annotation
+ * labels (or all labels for a graph group annotation)
+ *
+ * @param aa
+ * @param anns
+ * @return
+ */
+ static String getStatusMessage(AlignmentAnnotation aa,
+ AlignmentAnnotation[] anns)
+ {
+ if (aa == null)
+ {
+ return null;
}
+
+ StringBuilder msg = new StringBuilder(32);
+ if (aa.sequenceRef != null)
+ {
+ msg.append(aa.sequenceRef.getName()).append(" : ");
+ }
+
+ if (aa.graphGroup == -1)
+ {
+ msg.append(aa.label);
+ }
+ else if (anns != null)
+ {
+ boolean first = true;
+ for (int i = anns.length - 1; i >= 0; i--)
+ {
+ if (anns[i].graphGroup == aa.graphGroup)
+ {
+ if (!first)
+ {
+ msg.append(", ");
+ }
+ msg.append(anns[i].label);
+ first = false;
+ }
+ }
+ }
+
+ return msg.toString();
}
/**
PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
ap.av.sendSelection();
}
-
}
}
return;
@Override
public void paintComponent(Graphics g)
{
-
int width = getWidth();
if (width == 0)
{
}
drawComponent(g2, true, width);
-
}
/**