Merge branch 'develop' into features/mchmmer
[jalview.git] / src / jalview / gui / AnnotationLabels.java
index 4e181b3..067acd7 100755 (executable)
@@ -443,7 +443,8 @@ public class AnnotationLabels extends JPanel
     if (selectedRow < aa.length)
     {
       final String label = aa[selectedRow].label;
-      if (!aa[selectedRow].autoCalculated)
+      if (!(aa[selectedRow].autoCalculated)
+              && !("HMM".equals(aa[selectedRow].getCalcId())))
       {
         if (aa[selectedRow].graph == AlignmentAnnotation.NO_GRAPH)
         {
@@ -458,8 +459,11 @@ public class AnnotationLabels extends JPanel
       }
       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)
@@ -570,7 +574,6 @@ public class AnnotationLabels extends JPanel
               // can be
               // updated.
               av.setShowConsensusHistogram(chist.getState());
-              ap.alignFrame.setMenusForViewport();
               ap.repaint();
               // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
             }
@@ -591,7 +594,6 @@ public class AnnotationLabels extends JPanel
               // can be
               // updated.
               av.setShowSequenceLogo(cprof.getState());
-              ap.alignFrame.setMenusForViewport();
               ap.repaint();
               // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
             }
@@ -613,7 +615,6 @@ public class AnnotationLabels extends JPanel
               // updated.
               av.setShowSequenceLogo(true);
               av.setNormaliseSequenceLogo(cprofnorm.getState());
-              ap.alignFrame.setMenusForViewport();
               ap.repaint();
               // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
             }
@@ -624,6 +625,212 @@ public class AnnotationLabels extends JPanel
         consclipbrd.addActionListener(this);
         pop.add(consclipbrd);
       }
+      else if ("HMM".equals(aa[selectedRow].getCalcId())) // TODO create labels
+                                                          // in message resource
+                                                          // for these
+      {
+        pop.addSeparator();
+        final AlignmentAnnotation aaa = aa[selectedRow];
+
+        final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(
+                MessageManager.getString(
+                        "label.ignore_below_background_frequency"),
+                (aa[selectedRow].groupRef != null)
+                        ? aa[selectedRow].groupRef
+                                .getIgnoreBelowBackground()
+                        : ap.av.isIgnoreBelowBackground());
+
+        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.
+              if (aaa.groupRef.getInfoLetterHeight() == false)
+              {
+                aaa.groupRef.setIgnoreBelowBackground(cbmi.getState());
+                ap.getAnnotationPanel()
+                        .paint(ap.getAnnotationPanel().getGraphics());
+              }
+            }
+            else if (ap.av.isInfoLetterHeight() == false)
+            {
+              ap.av.setIgnoreBelowBackground(cbmi.getState(), ap);
+            }
+            ap.alignmentChanged();
+          }
+        });
+        pop.add(cbmi);
+        final JCheckBoxMenuItem letteHeight = new JCheckBoxMenuItem(
+                MessageManager.getString("label.use_info_for_height"),
+                (aa[selectedRow].groupRef != null)
+                        ? aa[selectedRow].groupRef.getInfoLetterHeight()
+                        : ap.av.isInfoLetterHeight());
+
+        letteHeight.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.setInfoLetterHeight((letteHeight.getState()));
+              if (aaa.groupRef.getIgnoreBelowBackground() == false)
+              {
+                aaa.groupRef.setIgnoreBelowBackground(true);
+              }
+              ap.getAnnotationPanel()
+                      .paint(ap.getAnnotationPanel().getGraphics());
+            }
+            else
+            {
+              ap.av.setInfoLetterHeight(letteHeight.getState(), ap);
+              if (ap.av.isIgnoreBelowBackground() == false)
+              {
+                ap.av.setIgnoreBelowBackground(true, ap);
+              }
+            }
+            ap.alignmentChanged();
+          }
+        });
+        pop.add(letteHeight);
+        if (aaa.groupRef != null)
+        {
+          final JCheckBoxMenuItem chist = new JCheckBoxMenuItem(
+                  MessageManager.getString("label.show_group_histogram"),
+                  aa[selectedRow].groupRef.isShowInformationHistogram());
+          chist.addActionListener(new ActionListener()
+          {
+            @Override
+            public void actionPerformed(ActionEvent e)
+            {
+              // TODO: pass on reference
+              // to ap
+              // so the
+              // view
+              // can be
+              // updated.
+              aaa.groupRef.setShowInformationHistogram(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.isShowHMMSequenceLogo());
+          cprofl.addActionListener(new ActionListener()
+          {
+            @Override
+            public void actionPerformed(ActionEvent e)
+            {
+              // TODO: pass on reference
+              // to ap
+              // so the
+              // view
+              // can be
+              // updated.
+              aaa.groupRef.setshowHMMSequenceLogo(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.isNormaliseHMMSequenceLogo());
+          cproflnorm.addActionListener(new ActionListener()
+          {
+            @Override
+            public void actionPerformed(ActionEvent e)
+            {
+
+              // TODO: pass on reference
+              // to ap
+              // so the
+              // view
+              // can be
+              // updated.
+              aaa.groupRef
+                      .setNormaliseHMMSequenceLogo(cproflnorm.getState());
+              // automatically enable logo display if we're clicked
+              aaa.groupRef.setshowHMMSequenceLogo(true);
+              ap.repaint();
+              // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+            }
+          });
+          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)
+            {
+              // TODO: pass on reference
+              // to ap
+              // so the
+              // view
+              // can be
+              // updated.
+              av.setShowInformationHistogram(chist.getState());
+              ap.repaint();
+              // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+            }
+          });
+          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)
+            {
+              // TODO: pass on reference
+              // to ap
+              // so the
+              // view
+              // can be
+              // updated.
+              av.updateInformation(ap);
+              av.setShowHMMSequenceLogo(cprof.getState());
+              ap.repaint();
+              // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+            }
+          });
+          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)
+            {
+              // TODO: pass on reference
+              // to ap
+              // so the
+              // view
+              // can be
+              // updated.
+              av.setShowHMMSequenceLogo(true);
+              av.setNormaliseHMMSequenceLogo(cprofnorm.getState());
+              ap.repaint();
+              // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+            }
+          });
+          pop.add(cprofnorm);
+        }
+      }
     }
     pop.show(this, evt.getX(), evt.getY());
   }
@@ -989,8 +1196,10 @@ public class AnnotationLabels extends JPanel
 
     if (av.hasHiddenColumns())
     {
+
       hiddenColumns = av.getAlignment().getHiddenColumns()
               .getHiddenColumnsCopy();
+
     }
 
     Desktop.jalviewClipboard = new Object[] { seqs, ds, // what is the dataset