group associated annotation and logos JAL-516 JAL-759
[jalview.git] / src / jalview / appletgui / AlignFrame.java
index bad7848..2e9b7ea 100755 (executable)
@@ -70,6 +70,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     annotationPanelMenuItem.setState(viewport.showAnnotation);
     displayNonconservedMenuItem.setState(viewport.getShowunconserved());
     followMouseOverFlag.setState(viewport.getFollowHighlight());
+    showGroupConsensus.setState(viewport.showGroupConsensus);
+    showGroupConservation.setState(viewport.showGroupConservation);
+    showConsensusHistogram.setState(viewport.showConsensusHistogram);
+    showSequenceLogo.setState(viewport.showSequenceLogo);
 
     seqLimits.setState(viewport.showJVSuffix);
 
@@ -597,7 +601,26 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {
       mouseOverFlag_stateChanged();
     }
-
+    else if (evt.getSource() == showGroupConsensus)
+    {
+      showGroupConsensus_actionPerformed();
+    }
+    else if (evt.getSource() == showGroupConservation)
+    {
+      showGroupConservation_actionPerformed();
+    }
+    else if (evt.getSource() == showSequenceLogo)
+    {
+      showSequenceLogo_actionPerformed();
+    }
+    else if (evt.getSource() == showConsensusHistogram)
+    {
+      showConsensusHistogram_actionPerformed();
+    }
+    else if (evt.getSource() == applyAutoAnnotationSettings)
+    {
+      applyAutoAnnotationSettings_actionPerformed();
+    }
     alignPanel.paintAlignment(true);
   }
 
@@ -787,6 +810,26 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       viewport.showAllHiddenSeqs();
       alignPanel.paintAlignment(true);
     }
+    else if (source == showGroupConsensus)
+    {
+      showGroupConsensus_actionPerformed();
+    }
+    else if (source == showGroupConservation)
+    {
+      showGroupConservation_actionPerformed();
+    }
+    else if (source == showSequenceLogo)
+    {
+      showSequenceLogo_actionPerformed();
+    }
+    else if (source == showConsensusHistogram)
+    {
+      showConsensusHistogram_actionPerformed();
+    }
+    else if (source == applyAutoAnnotationSettings)
+    {
+      applyAutoAnnotationSettings_actionPerformed();
+    }
     else if (source == featureSettings)
     {
       new FeatureSettings(alignPanel);
@@ -1641,6 +1684,56 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     viewport.sendSelection();
   }
 
+  /**
+   * group consensus toggled
+   * 
+   */
+  protected void showGroupConsensus_actionPerformed()
+  {
+    viewport.setShowGroupConsensus(showGroupConsensus.getState());
+    alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+
+  }
+
+  /**
+   * group conservation toggled.
+   */
+  protected void showGroupConservation_actionPerformed()
+  {
+    viewport.setShowGroupConservation(showGroupConservation.getState());
+    alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
+   * .event.ActionEvent)
+   */
+  protected void showConsensusHistogram_actionPerformed()
+  {
+    viewport.setShowConsensusHistogram(showConsensusHistogram.getState());
+    alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+  }
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
+   * .event.ActionEvent)
+   */
+  protected void showSequenceLogo_actionPerformed()
+  {
+    viewport.setShowSequenceLogo(showSequenceLogo.getState());
+    alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+  }
+
+  protected void applyAutoAnnotationSettings_actionPerformed()
+  {
+    alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+  }
+
   protected void makeGrpsFromSelection_actionPerformed()
   {
     if (viewport.getSelectionGroup() != null)
@@ -1668,7 +1761,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
           ;
       }
       PaintRefresher.Refresh(this, viewport.getSequenceSetId());
-      // alignPanel.updateAnnotation();
+      alignPanel.updateAnnotation();
       alignPanel.paintAlignment(true);
     }
   }
@@ -2371,7 +2464,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
             || (viewport.getSelectionGroup() == null && viewport.alignment
                     .getHeight() > 1))
     {
-      final TreePanel tp = new TreePanel(viewport, type, pwType);
+      final TreePanel tp = new TreePanel(alignPanel, type, pwType);
 
       addTreeMenuItem(tp, title);
 
@@ -2391,7 +2484,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   public void loadTree(jalview.io.NewickFile tree, String treeFile)
   {
-    TreePanel tp = new TreePanel(viewport, treeFile, "From File - ", tree);
+    TreePanel tp = new TreePanel(alignPanel, treeFile, "From File - ", tree);
     jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
     addTreeMenuItem(tp, treeFile);
   }
@@ -2756,8 +2849,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   CheckboxMenuItem seqLimits = new CheckboxMenuItem();
 
   CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem();
-
+  
   CheckboxMenuItem followMouseOverFlag = new CheckboxMenuItem();
+  Menu autoAnnMenu=new Menu();
+  CheckboxMenuItem showSequenceLogo= new CheckboxMenuItem();
+  CheckboxMenuItem applyAutoAnnotationSettings = new CheckboxMenuItem();
+  CheckboxMenuItem showConsensusHistogram = new CheckboxMenuItem();
+  CheckboxMenuItem showGroupConsensus = new CheckboxMenuItem();
+  CheckboxMenuItem showGroupConservation = new CheckboxMenuItem();
 
   private void jbInit() throws Exception
   {
@@ -2961,6 +3060,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     hideAllButSelection.setLabel("All but Selected Region (Shift+Ctrl+H)");
     hideAllSelection.setLabel("Selected Region");
     showAllHidden.setLabel("All Sequences and Columns");
+    showGroupConsensus.setLabel("Group Consensus");
+    showGroupConservation.setLabel("Group Conservation");
+    showConsensusHistogram.setLabel("Show Consensus Histogram");
+    showSequenceLogo.setLabel("Show Consensus Logo");
+    applyAutoAnnotationSettings.setLabel("Apply to all groups");
+    applyAutoAnnotationSettings.setState(true);
+    autoAnnMenu.setLabel("Autocalculated Annotation");
+    
     invertColSel.addActionListener(this);
     showColumns.addActionListener(this);
     showSeqs.addActionListener(this);
@@ -2969,6 +3076,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     hideAllButSelection.addActionListener(this);
     hideAllSelection.addActionListener(this);
     showAllHidden.addActionListener(this);
+    showGroupConsensus.addItemListener(this);
+    showGroupConservation.addItemListener(this);
+    showConsensusHistogram.addItemListener(this);
+    showSequenceLogo.addItemListener(this);
+    applyAutoAnnotationSettings.addItemListener(this);
     formatMenu.setLabel("Format");
     selectMenu.setLabel("Select");
     newView.setLabel("New View");
@@ -3018,6 +3130,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     viewMenu.addSeparator();
     viewMenu.add(followMouseOverFlag);
     viewMenu.add(annotationPanelMenuItem);
+    autoAnnMenu.add(applyAutoAnnotationSettings);
+    autoAnnMenu.add(showConsensusHistogram);
+    autoAnnMenu.add(showSequenceLogo);
+    autoAnnMenu.addSeparator();
+    autoAnnMenu.add(showGroupConservation);
+    autoAnnMenu.add(showGroupConsensus);
+    viewMenu.add(autoAnnMenu);
     viewMenu.addSeparator();
     viewMenu.add(sequenceFeatures);
     viewMenu.add(featureSettings);