add partial button fix to annotation and statistics output
[jalview.git] / src / jalview / gui / AnnotationLabels.java
index 3e4ec98..445ee11 100755 (executable)
@@ -74,6 +74,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
   private static final Pattern LEFT_ANGLE_BRACKET_PATTERN = Pattern
           .compile("<");
 
+
   String TOGGLE_LABELSCALE = MessageManager
           .getString("label.scale_label_to_column");
 
@@ -421,7 +422,8 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     if (selectedRow < aa.length)
     {
       final String label = aa[selectedRow].label;
-      if (!aa[selectedRow].autoCalculated)
+      if (!(aa[selectedRow].autoCalculated
+              || label.indexOf("Information Content") > -1))
       {
         if (aa[selectedRow].graph == AlignmentAnnotation.NO_GRAPH)
         {
@@ -436,14 +438,18 @@ public class AnnotationLabels extends JPanel implements MouseListener,
       }
       else if (label.indexOf("Consensus") > -1)
       {
+
+
         pop.addSeparator();
         // av and sequencegroup need to implement same interface for
+        final AlignmentAnnotation aaa = aa[selectedRow];
+
         final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(
-                MessageManager.getString("label.ignore_gaps_consensus"),
+                  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
@@ -602,6 +608,178 @@ public class AnnotationLabels extends JPanel implements MouseListener,
         consclipbrd.addActionListener(this);
         pop.add(consclipbrd);
       }
+      else if (label.indexOf("Information Content") > -1) // TODO create labels
+                                                          // in message resource
+                                                          // for these
+      {
+        pop.addSeparator();
+        final AlignmentAnnotation aaa = aa[selectedRow];
+
+        final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(
+                "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.
+              aaa.groupRef.setIgnoreBelowBackground(cbmi.getState());
+              ap.getAnnotationPanel()
+                      .paint(ap.getAnnotationPanel().getGraphics());
+            }
+            else
+            {
+              ap.av.setIgnoreBelowBackground(cbmi.getState(), ap);
+            }
+            ap.alignmentChanged();
+          }
+        });
+        pop.add(cbmi);
+        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.alignFrame.setMenusForViewport();
+              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.setShowHMMSequenceLogo(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.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.alignFrame.setMenusForViewport();
+              ap.repaint();
+              // ap.annotationPanel.paint(ap.annotationPanel.getGraphics());
+            }
+          });
+          pop.add(cprofnorm);
+        }
+        final JMenuItem consclipbrd = new JMenuItem(COPYCONS_SEQ);
+        consclipbrd.addActionListener(this);
+        pop.add(consclipbrd);
+      }
     }
     pop.show(this, evt.getX(), evt.getY());
   }
@@ -954,7 +1132,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
 
     int[] alignmentStartEnd = new int[] { 0, ds.getWidth() - 1 };
     List<int[]> hiddenCols = av.getAlignment().getHiddenColumns()
-            .getListOfCols();
+            .getHiddenRegions();
     if (hiddenCols != null)
     {
       alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex(
@@ -969,9 +1147,9 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     ArrayList<int[]> hiddenColumns = null;
     if (av.hasHiddenColumns())
     {
-      hiddenColumns = new ArrayList<int[]>();
+      hiddenColumns = new ArrayList<>();
       for (int[] region : av.getAlignment().getHiddenColumns()
-              .getListOfCols())
+              .getHiddenRegions())
       {
         hiddenColumns.add(new int[] { region[0], region[1] });
       }