X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationExporter.java;h=41689c566a8004d98c270efe34489e887f90c764;hb=29f633ca27df2db2790b81b1ca346d6692d4936c;hp=d4975a6c6196b44a9f8e6eacb1a99c2b21caa3b7;hpb=9922c9eec14599f6b141a8db8a3859cab7227ce0;p=jalview.git diff --git a/src/jalview/gui/AnnotationExporter.java b/src/jalview/gui/AnnotationExporter.java index d4975a6..41689c5 100755 --- a/src/jalview/gui/AnnotationExporter.java +++ b/src/jalview/gui/AnnotationExporter.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -19,17 +19,14 @@ package jalview.gui; +import java.util.*; + +import java.awt.*; +import java.awt.event.*; import javax.swing.*; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; +import jalview.datamodel.*; import jalview.io.*; -import jalview.datamodel.AlignmentAnnotation; - -import java.awt.Color; -import java.awt.FlowLayout; -import javax.swing.BorderFactory; - public class AnnotationExporter extends JPanel @@ -37,7 +34,9 @@ public class AnnotationExporter JInternalFrame frame; AlignmentPanel ap; boolean features = true; - AlignmentAnnotation [] annotations; + AlignmentAnnotation[] annotations; + Vector sequenceGroups; + Hashtable alignmentProperties; public AnnotationExporter() { @@ -66,102 +65,122 @@ public class AnnotationExporter } public void exportAnnotations(AlignmentPanel ap, - AlignmentAnnotation [] annotations) + AlignmentAnnotation[] annotations, + Vector sequenceGroups, + Hashtable alProperties) { this.ap = ap; features = false; GFFFormat.setVisible(false); this.annotations = annotations; + this.sequenceGroups = sequenceGroups; + this.alignmentProperties = alProperties; frame.setTitle("Export Annotations"); } public void toFile_actionPerformed(ActionEvent e) { - JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty( "LAST_DIRECTORY")); + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY")); - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle( - features ? "Save Features to File" : "Save Annotation to File"); - chooser.setToolTipText("Save"); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle( + features ? "Save Features to File" : "Save Annotation to File"); + chooser.setToolTipText("Save"); - int value = chooser.showSaveDialog(this); + int value = chooser.showSaveDialog(this); - if (value == JalviewFileChooser.APPROVE_OPTION) + if (value == JalviewFileChooser.APPROVE_OPTION) + { + String text = "No features found on alignment"; + if (features) { - String text = "No features found on alignment"; - if (features) + if (GFFFormat.isSelected()) { - if (GFFFormat.isSelected()) - text = new FeaturesFile().printGFFFormat( - ap.av.alignment.getDataset().getSequencesArray(), - ap.av.featuresDisplayed); - else - text = new FeaturesFile().printJalviewFormat( - ap.av.alignment.getDataset().getSequencesArray(), - ap.av.featuresDisplayed); + text = new FeaturesFile().printGFFFormat( + ap.av.alignment.getDataset().getSequencesArray(), + ap.av.featuresDisplayed); } else { - text = new AnnotationFile().printAnnotations( annotations ); + text = new FeaturesFile().printJalviewFormat( + ap.av.alignment.getDataset().getSequencesArray(), + ap.av.featuresDisplayed); } + } + else + { + text = new AnnotationFile().printAnnotations( + annotations, + sequenceGroups, + alignmentProperties); + } - try - { - java.io.PrintWriter out = new java.io.PrintWriter( - new java.io.FileWriter(chooser.getSelectedFile())); + try + { + java.io.PrintWriter out = new java.io.PrintWriter( + new java.io.FileWriter(chooser.getSelectedFile())); - out.print(text); - out.close(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } + out.print(text); + out.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); } + } + + close_actionPerformed(null); } public void toTextbox_actionPerformed(ActionEvent e) { String text = "No features found on alignment"; - if(features) + if (features) { if (GFFFormat.isSelected()) + { text = new FeaturesFile().printGFFFormat( ap.av.alignment.getDataset().getSequencesArray(), ap.av.featuresDisplayed); + } else + { text = new FeaturesFile().printJalviewFormat( ap.av.alignment.getDataset().getSequencesArray(), - ap.av.featuresDisplayed); + ap.av.featuresDisplayed); + } } - else if(!features) + else if (!features) { - text = new AnnotationFile().printAnnotations( annotations ); + text = new AnnotationFile().printAnnotations( + annotations, + sequenceGroups, + alignmentProperties); } - CutAndPasteTransfer cap = new CutAndPasteTransfer(); cap.setText(text); Desktop.addInternalFrame(cap, - (features ? "Features for - " : "Annotations for - ") + (features ? "Features for - " : + "Annotations for - ") + ap.alignFrame.getTitle(), 600, 500); - + close_actionPerformed(null); } public void close_actionPerformed(ActionEvent e) { - try{ + try + { frame.setClosed(true); - }catch(java.beans.PropertyVetoException ex) + } + catch (java.beans.PropertyVetoException ex) {} } - - private void jbInit() throws Exception {