added CSV export of annotation rows to application.
[jalview.git] / src / jalview / gui / AnnotationExporter.java
index 41689c5..ab3f0d1 100755 (executable)
@@ -28,6 +28,13 @@ import javax.swing.*;
 import jalview.datamodel.*;\r
 import jalview.io.*;\r
 \r
+/**\r
+ * \r
+ * GUI dialog for exporting features or alignment annotations depending upon which method is called.\r
+ * \r
+ * @author AMW\r
+ *\r
+ */\r
 public class AnnotationExporter\r
     extends JPanel\r
 {\r
@@ -61,6 +68,7 @@ public class AnnotationExporter
   {\r
     this.ap = ap;\r
     features = true;\r
+    CSVFormat.setVisible(false);\r
     frame.setTitle("Export Features");\r
   }\r
 \r
@@ -72,6 +80,7 @@ public class AnnotationExporter
     this.ap = ap;\r
     features = false;\r
     GFFFormat.setVisible(false);\r
+    CSVFormat.setVisible(true);\r
     this.annotations = annotations;\r
     this.sequenceGroups = sequenceGroups;\r
     this.alignmentProperties = alProperties;\r
@@ -110,10 +119,15 @@ public class AnnotationExporter
       }\r
       else\r
       {\r
-        text = new AnnotationFile().printAnnotations(\r
+        if (CSVFormat.isSelected())\r
+        {\r
+          text = new AnnotationFile().printCSVAnnotations(annotations);\r
+        } else {\r
+          text = new AnnotationFile().printAnnotations(\r
             annotations,\r
             sequenceGroups,\r
             alignmentProperties);\r
+        }\r
       }\r
 \r
       try\r
@@ -153,10 +167,15 @@ public class AnnotationExporter
     }\r
     else if (!features)\r
     {\r
-      text = new AnnotationFile().printAnnotations(\r
+      if (CSVFormat.isSelected())\r
+      {\r
+        text = new AnnotationFile().printCSVAnnotations(annotations);\r
+      } else {\r
+        text = new AnnotationFile().printAnnotations(\r
           annotations,\r
           sequenceGroups,\r
           alignmentProperties);\r
+      }\r
     }\r
 \r
     CutAndPasteTransfer cap = new CutAndPasteTransfer();\r
@@ -214,6 +233,8 @@ public class AnnotationExporter
     jalviewFormat.setText("Jalview");\r
     GFFFormat.setOpaque(false);\r
     GFFFormat.setText("GFF");\r
+    CSVFormat.setOpaque(false);\r
+    CSVFormat.setText("CSV(Spreadsheet)");\r
     jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);\r
     jLabel1.setText("Format: ");\r
     this.setBackground(Color.white);\r
@@ -226,8 +247,10 @@ public class AnnotationExporter
     jPanel3.add(jLabel1);\r
     jPanel3.add(jalviewFormat);\r
     jPanel3.add(GFFFormat);\r
+    jPanel3.add(CSVFormat);\r
     buttonGroup.add(jalviewFormat);\r
     buttonGroup.add(GFFFormat);\r
+    buttonGroup.add(CSVFormat);\r
     this.add(jPanel3, null);\r
     this.add(jPanel1, null);\r
   }\r
@@ -239,6 +262,7 @@ public class AnnotationExporter
   ButtonGroup buttonGroup = new ButtonGroup();\r
   JRadioButton jalviewFormat = new JRadioButton();\r
   JRadioButton GFFFormat = new JRadioButton();\r
+  JRadioButton CSVFormat = new JRadioButton();\r
   JLabel jLabel1 = new JLabel();\r
   JPanel jPanel3 = new JPanel();\r
   FlowLayout flowLayout1 = new FlowLayout();\r