JAL-1628 drop getShowAnnotation accessor in favour of isShowAnnotation in AlignViewpo...
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 23 Jan 2015 08:59:19 +0000 (08:59 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Fri, 23 Jan 2015 09:03:03 +0000 (09:03 +0000)
14 files changed:
src/jalview/api/AlignViewportI.java
src/jalview/appletgui/AlignFrame.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/AnnotationExporter.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/Jalview2XML.java
src/jalview/io/AnnotationFile.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/ws/rest/params/AnnotationFile.java
test/jalview/ws/jabaws/DisorderAnnotExportImport.java
test/jalview/ws/jabaws/JpredJabaStructExportImport.java
test/jalview/ws/jabaws/RNAStructExportImport.java

index 1c9d112..760f52d 100644 (file)
@@ -231,4 +231,18 @@ public interface AlignViewportI
 
   void setShowSequenceFeatures(boolean b);
 
+  /**
+   * 
+   * @param flag
+   *          indicating if annotation panel shown below alignment
+   * 
+   */
+  void setShowAnnotation(boolean b);
+
+  /**
+   * flag indicating if annotation panel shown below alignment
+   * 
+   * @return
+   */
+  boolean isShowAnnotation();
 }
index 9fb91ed..2a80e1e 100644 (file)
@@ -1200,11 +1200,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   public String outputAnnotations(boolean displayTextbox)
   {
-    String annotation = new AnnotationFile().printAnnotations(
-            viewport.showAnnotation ? viewport.getAlignment()
-                    .getAlignmentAnnotation() : null, viewport
-                    .getAlignment().getGroups(), ((Alignment) viewport
-                    .getAlignment()).alignmentProperties);
+    String annotation = new AnnotationFile()
+            .printAnnotationsForView(viewport);
 
     if (displayTextbox)
     {
index 0206c46..b19e54f 100644 (file)
@@ -1305,11 +1305,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void exportAnnotations_actionPerformed(ActionEvent e)
   {
-    new AnnotationExporter().exportAnnotations(alignPanel,
-            viewport.isShowAnnotation() ? viewport.getAlignment()
-                    .getAlignmentAnnotation() : null, viewport
-                    .getAlignment().getGroups(), ((Alignment) viewport
-                    .getAlignment()).alignmentProperties);
+    new AnnotationExporter().exportAnnotations(alignPanel);
   }
 
   @Override
index b8f575f..4df9a62 100644 (file)
@@ -138,7 +138,6 @@ public class AlignViewport extends AlignmentViewport implements
   Color textColour = Color.black;
 
   Color textColour2 = Color.white;
-  private boolean rightAlignIds = false;
 
   private AnnotationColumnChooser annotationColumnSelectionState;
   /**
@@ -1235,22 +1234,6 @@ public class AlignViewport extends AlignmentViewport implements
     this.showAutocalculatedAbove = showAutocalculatedAbove;
   }
 
-
-  public boolean isShowAnnotation()
-  {
-    return super.isShowAnnotation();
-  }
-
-  public boolean isRightAlignIds()
-  {
-    return rightAlignIds;
-  }
-
-  public void setRightAlignIds(boolean rightAlignIds)
-  {
-    this.rightAlignIds = rightAlignIds;
-  }
-
   public AnnotationColumnChooser getAnnotationColumnSelectionState()
   {
     return annotationColumnSelectionState;
index e859fb1..6517e70 100644 (file)
@@ -122,7 +122,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     setScrollValues(0, 0);
 
-    setAnnotationVisible(av.getShowAnnotation());
+    setAnnotationVisible(av.isShowAnnotation());
 
     hscroll.addAdjustmentListener(this);
     vscroll.addAdjustmentListener(this);
@@ -729,7 +729,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
         getSeqPanel().seqCanvas.fastPaint(scrollX, scrollY);
         getScalePanel().repaint();
 
-        if (av.getShowAnnotation() && scrollX != 0)
+        if (av.isShowAnnotation() && scrollX != 0)
         {
           getAnnotationPanel().fastPaint(scrollX);
         }
@@ -1249,7 +1249,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       }
 
     }
-    else if (av.getShowAnnotation())
+    else if (av.isShowAnnotation())
     {
       height += getAnnotationPanel().adjustPanelHeight() + 3;
     }
index e43c06b..df6f9eb 100644 (file)
@@ -21,7 +21,6 @@
 package jalview.gui;
 
 import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.SequenceGroup;
 import jalview.io.AnnotationFile;
 import jalview.io.FeaturesFile;
 import jalview.io.JalviewFileChooser;
@@ -33,8 +32,6 @@ import java.awt.Color;
 import java.awt.FlowLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.util.Hashtable;
-import java.util.List;
 
 import javax.swing.BorderFactory;
 import javax.swing.ButtonGroup;
@@ -62,11 +59,9 @@ public class AnnotationExporter extends JPanel
 
   boolean features = true;
 
-  AlignmentAnnotation[] annotations;
+  private AlignmentAnnotation[] annotations;
 
-  List<SequenceGroup> sequenceGroups;
-
-  Hashtable alignmentProperties;
+  private boolean wholeView;
 
   public AnnotationExporter()
   {
@@ -93,17 +88,29 @@ public class AnnotationExporter extends JPanel
     frame.setTitle(MessageManager.getString("label.export_features"));
   }
 
-  public void exportAnnotations(AlignmentPanel ap,
-          AlignmentAnnotation[] annotations, List<SequenceGroup> list,
-          Hashtable alProperties)
+  public void exportAnnotations(AlignmentPanel ap)
   {
     this.ap = ap;
+    annotations = ap.av.isShowAnnotation() ? null : ap.av.getAlignment()
+            .getAlignmentAnnotation();
+    wholeView = true;
+    startExportAnnotation();
+  }
+
+  public void exportAnnotations(AlignmentPanel alp,
+          AlignmentAnnotation[] toExport)
+  {
+    ap = alp;
+    annotations = toExport;
+    wholeView = false;
+    startExportAnnotation();
+  }
+
+  private void startExportAnnotation()
+  {
     features = false;
     GFFFormat.setVisible(false);
     CSVFormat.setVisible(true);
-    this.annotations = annotations;
-    this.sequenceGroups = list;
-    this.alignmentProperties = alProperties;
     frame.setTitle(MessageManager.getString("label.export_annotations"));
   }
 
@@ -121,36 +128,7 @@ public class AnnotationExporter extends JPanel
 
     if (value == JalviewFileChooser.APPROVE_OPTION)
     {
-      String text = MessageManager.getString("label.no_features_on_alignment");
-      if (features)
-      {
-        if (GFFFormat.isSelected())
-        {
-          text = new FeaturesFile().printGFFFormat(ap.av.getAlignment()
-                  .getDataset().getSequencesArray(), ap
-                  .getFeatureRenderer().getDisplayedFeatureCols(), true,
-                  ap.av.isShowNpFeats());// ap.av.featuresDisplayed//);
-        }
-        else
-        {
-          text = new FeaturesFile().printJalviewFormat(ap.av.getAlignment()
-                  .getDataset().getSequencesArray(), ap
-                  .getFeatureRenderer().getDisplayedFeatureCols(), true,
-                  ap.av.isShowNpFeats()); // ap.av.featuresDisplayed);
-        }
-      }
-      else
-      {
-        if (CSVFormat.isSelected())
-        {
-          text = new AnnotationFile().printCSVAnnotations(annotations);
-        }
-        else
-        {
-          text = new AnnotationFile().printAnnotations(annotations,
-                  sequenceGroups, alignmentProperties);
-        }
-      }
+      String text = getFileContents();
 
       try
       {
@@ -168,25 +146,26 @@ public class AnnotationExporter extends JPanel
     close_actionPerformed(null);
   }
 
-  public void toTextbox_actionPerformed(ActionEvent e)
+  private String getFileContents()
   {
-    String text = MessageManager.getString("label.no_features_on_alignment");
+    String text = MessageManager
+            .getString("label.no_features_on_alignment");
     if (features)
     {
       if (GFFFormat.isSelected())
       {
         text = new FeaturesFile().printGFFFormat(ap.av.getAlignment()
                 .getDataset().getSequencesArray(), ap.getFeatureRenderer()
-                .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());
+                .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());// ap.av.featuresDisplayed//);
       }
       else
       {
         text = new FeaturesFile().printJalviewFormat(ap.av.getAlignment()
                 .getDataset().getSequencesArray(), ap.getFeatureRenderer()
-                .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());
+                .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); // ap.av.featuresDisplayed);
       }
     }
-    else if (!features)
+    else
     {
       if (CSVFormat.isSelected())
       {
@@ -194,14 +173,26 @@ public class AnnotationExporter extends JPanel
       }
       else
       {
-        text = new AnnotationFile().printAnnotations(annotations,
-                sequenceGroups, alignmentProperties);
+        if (wholeView)
+        {
+          text = new AnnotationFile().printAnnotationsForView(ap.av);
+        }
+        else
+        {
+          text = new AnnotationFile().printAnnotations(annotations, null,
+                  null);
+        }
       }
     }
-
+    return text;
+  }
+  public void toTextbox_actionPerformed(ActionEvent e)
+  {
     CutAndPasteTransfer cap = new CutAndPasteTransfer();
+
     try
     {
+      String text = getFileContents();
       cap.setText(text);
       Desktop.addInternalFrame(
               cap,
@@ -309,5 +300,4 @@ public class AnnotationExporter extends JPanel
   JPanel jPanel3 = new JPanel();
 
   FlowLayout flowLayout1 = new FlowLayout();
-
 }
index 501df8a..97499c9 100755 (executable)
@@ -249,7 +249,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     {
       new AnnotationExporter().exportAnnotations(ap,
               new AlignmentAnnotation[]
-              { aa[selectedRow] }, null, null);
+      { aa[selectedRow] });
     }
     else if (evt.getActionCommand().equals(COPYCONS_SEQ))
     {
index 5d11901..c96b717 100644 (file)
@@ -1125,7 +1125,7 @@ public class Jalview2XML
       view.setFontSize(av.font.getSize());
       view.setFontStyle(av.font.getStyle());
       view.setRenderGaps(av.renderGaps);
-      view.setShowAnnotation(av.getShowAnnotation());
+      view.setShowAnnotation(av.isShowAnnotation());
       view.setShowBoxes(av.getShowBoxes());
       view.setShowColourText(av.getColourText());
       view.setShowFullId(av.getShowJVSuffix());
index c25d7af..6834e76 100755 (executable)
@@ -1691,4 +1691,18 @@ public class AnnotationFile
     }
     return sp.toString();
   }
+
+  public String printAnnotationsForView(AlignViewportI viewport)
+  {
+    return printAnnotations(viewport.isShowAnnotation() ? viewport
+            .getAlignment().getAlignmentAnnotation() : null, viewport
+            .getAlignment().getGroups(), viewport.getAlignment()
+            .getProperties());
+  }
+
+  public String printAnnotationsForAlignment(AlignmentI al)
+  {
+    return printAnnotations(al.getAlignmentAnnotation(), al.getGroups(),
+            al.getProperties());
+  }
 }
index 98b8d64..daea70d 100644 (file)
@@ -1751,37 +1751,26 @@ public abstract class AlignmentViewport implements AlignViewportI
 
   private boolean rightAlignIds = false;
 
-  /**
-   * DOCUMENT ME!
-   * 
-   * @return DOCUMENT ME!
-   */
-  public boolean getShowAnnotation()
-  {
-    return isShowAnnotation();
-  }
 
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param b
-   *          DOCUMENT ME!
-   */
+  @Override
   public void setShowAnnotation(boolean b)
   {
     showAnnotation = b;
   }
 
+  @Override
   public boolean isShowAnnotation()
   {
     return showAnnotation;
   }
 
+  @Override
   public boolean isRightAlignIds()
   {
     return rightAlignIds;
   }
 
+  @Override
   public void setRightAlignIds(boolean rightAlignIds)
   {
     this.rightAlignIds = rightAlignIds;
index 0268c35..1820182 100644 (file)
@@ -73,9 +73,8 @@ public class AnnotationFile extends InputType
     if (format.equals(JVANNOT))
     {
       return new StringBody(
-              new jalview.io.AnnotationFile().printAnnotations(
-                      al.getAlignmentAnnotation(), al.getGroups(),
-                      al.getProperties()));
+              new jalview.io.AnnotationFile()
+                      .printAnnotationsForAlignment(al));
     }
     else
     {
index db7d505..1e47800 100644 (file)
  */
 package jalview.ws.jabaws;
 
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.io.AnnotationFile;
@@ -34,6 +32,9 @@ import jalview.ws.jws2.AADisorderClient;
 import jalview.ws.jws2.Jws2Discoverer;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -124,9 +125,8 @@ public class DisorderAnnotExportImport
     {
       String aligfileout = new FormatAdapter().formatSequences("PFAM",
               al.getSequencesArray());
-      String anfileout = new AnnotationFile().printAnnotations(
-              al.getAlignmentAnnotation(), al.getGroups(),
-              al.getProperties());
+      String anfileout = new AnnotationFile()
+              .printAnnotationsForAlignment(al);
       assertTrue(
               "Test "
                       + testname
index f0b8f99..1e920e0 100644 (file)
@@ -186,9 +186,8 @@ public class JpredJabaStructExportImport
       String aligfileout = new FormatAdapter().formatSequences("PFAM",
               al.getSequencesArray());
 
-      String anfileout = new AnnotationFile().printAnnotations(
-              al.getAlignmentAnnotation(), al.getGroups(),
-              al.getProperties());
+      String anfileout = new AnnotationFile()
+              .printAnnotationsForAlignment(al);
       assertTrue(
               "Test "
                       + testname
index 9a723ca..cf86d18 100644 (file)
@@ -137,9 +137,8 @@ public class RNAStructExportImport
       String aligfileout = new FormatAdapter().formatSequences("PFAM",
               al.getSequencesArray());
 
-      String anfileout = new AnnotationFile().printAnnotations(
-              al.getAlignmentAnnotation(), al.getGroups(),
-              al.getProperties());
+      String anfileout = new AnnotationFile()
+              .printAnnotationsForAlignment(al);
       assertTrue(
               "Test "
                       + testname