Merge branch 'JAL-1569_wuss_vienna_broke' into develop
[jalview.git] / src / jalview / gui / AlignFrame.java
index 6d8fe6d..8bea101 100644 (file)
@@ -53,6 +53,7 @@ import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.io.AlignmentProperties;
 import jalview.io.AnnotationFile;
+import jalview.io.BioJsHTMLOutput;
 import jalview.io.FeaturesFile;
 import jalview.io.FileLoader;
 import jalview.io.FormatAdapter;
@@ -279,7 +280,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   /**
-   * Make a new AlignFrame from exisiting alignmentPanels
+   * Make a new AlignFrame from existing alignmentPanels
    * 
    * @param ap
    *          AlignmentPanel
@@ -746,10 +747,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     scaleRight.setVisible(av.wrapAlignment);
     annotationPanelMenuItem.setState(av.showAnnotation);
     /*
-     * Show/hide all annotations only enabled if annotation panel is shown
+     * Show/hide annotations only enabled if annotation panel is shown
      */
-    showAllAnnotations.setEnabled(annotationPanelMenuItem.getState());
-    hideAllAnnotations.setEnabled(annotationPanelMenuItem.getState());
+    showAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
+    hideAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
+    showAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
+    hideAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
     viewBoxesMenuItem.setSelected(av.showBoxes);
     viewTextMenuItem.setSelected(av.showText);
     showNonconservedMenuItem.setSelected(av.getShowUnconserved());
@@ -1229,6 +1232,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
   }
 
+  @Override
+  public void bioJSMenuItem_actionPerformed(ActionEvent e)
+  {
+    new BioJsHTMLOutput(alignPanel,
+            alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
+  }
   public void createImageMap(File file, String image)
   {
     alignPanel.makePNGImageMap(file, image);
@@ -1258,6 +1267,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     alignPanel.makeEPS(f);
   }
 
+  public void createSVG(File f)
+  {
+    alignPanel.makeSVG(f);
+  }
   @Override
   public void pageSetup_actionPerformed(ActionEvent e)
   {
@@ -3100,8 +3113,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     final boolean setVisible = annotationPanelMenuItem.isSelected();
     viewport.setShowAnnotation(setVisible);
     alignPanel.setAnnotationVisible(setVisible);
-    this.showAllAnnotations.setEnabled(setVisible);
-    this.hideAllAnnotations.setEnabled(setVisible);
+    this.showAllSeqAnnotations.setEnabled(setVisible);
+    this.hideAllSeqAnnotations.setEnabled(setVisible);
+    this.showAllAlAnnotations.setEnabled(setVisible);
+    this.hideAllAlAnnotations.setEnabled(setVisible);
   }
 
   @Override
@@ -5767,19 +5782,42 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   /**
-   * Action on selection of menu option to Show or Hide all annotations.
+   * Action on selection of menu options to Show or Hide annotations.
    * 
-   * @param visibile
+   * @param visible
+   * @param forSequences
+   *          update sequence-related annotations
+   * @param forAlignment
+   *          update non-sequence-related annotations
    */
   @Override
-  protected void setAllAnnotationsVisibility(boolean visible)
+  protected void setAnnotationsVisibility(boolean visible,
+          boolean forSequences, boolean forAlignment)
   {
     for (AlignmentAnnotation aa : alignPanel.getAlignment()
             .getAlignmentAnnotation())
     {
-      aa.visible = visible;
+      boolean apply = (aa.sequenceRef == null && forAlignment)
+              || (aa.sequenceRef != null && forSequences);
+      if (apply)
+      {
+        aa.visible = visible;
+      }
     }
-    this.alignPanel.paintAlignment(true);
+    alignPanel.validateAnnotationDimensions(false);
+    alignPanel.alignmentChanged();
+  }
+
+  /**
+   * Store selected annotation sort order for the view and repaint.
+   */
+  @Override
+  protected void sortAnnotations_actionPerformed()
+  {
+    this.alignPanel.av.setSortAnnotationsBy(getAnnotationSortOrder());
+    this.alignPanel.av
+            .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
+    alignPanel.paintAlignment(true);
   }
 }