X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationLabels.java;h=3d809acfb49c7e333f5e47acf24050f2609510fb;hb=3609d4b908fa64cab35f2348401baab3347188fc;hp=de67c2390f0393f5488c26f6ed3929020d66e007;hpb=eda1adb8ef48c7c0da70635db7253a7489335603;p=jalview.git diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index de67c23..3d809ac 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -34,6 +34,7 @@ import jalview.io.FormatAdapter; import jalview.util.Comparison; import jalview.util.MessageManager; import jalview.util.Platform; +import jalview.workers.InformationThread; import java.awt.Color; import java.awt.Cursor; @@ -352,6 +353,10 @@ public class AnnotationLabels extends JPanel 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); @@ -399,7 +404,8 @@ public class AnnotationLabels extends JPanel 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) { @@ -407,7 +413,7 @@ public class AnnotationLabels extends JPanel 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); } @@ -420,11 +426,169 @@ public class AnnotationLabels extends JPanel 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) + { + if (!ann.groupRef.isUseInfoLetterHeight()) + { + ann.groupRef.setIgnoreBelowBackground(cbmi.getState()); + // todo and recompute group annotation + } + } + else if (!ap.av.isInfoLetterHeight()) + { + 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); + } + } + + /** * 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 @@ -925,7 +1089,6 @@ public class AnnotationLabels extends JPanel PaintRefresher.Refresh(ap, ap.av.getSequenceSetId()); ap.av.sendSelection(); } - } } return; @@ -997,7 +1160,6 @@ public class AnnotationLabels extends JPanel @Override public void paintComponent(Graphics g) { - int width = getWidth(); if (width == 0) { @@ -1012,7 +1174,6 @@ public class AnnotationLabels extends JPanel } drawComponent(g2, true, width); - } /**