X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationExporter.java;h=be0ef742a5b5fd8a59b9b812209834b6e6f7a19b;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=ab3f0d1006903cc74bc1024c64ff6e2bf55970cf;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/jalview/gui/AnnotationExporter.java b/src/jalview/gui/AnnotationExporter.java index ab3f0d1..be0ef74 100755 --- a/src/jalview/gui/AnnotationExporter.java +++ b/src/jalview/gui/AnnotationExporter.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 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 * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.gui; import java.util.*; @@ -30,19 +29,24 @@ import jalview.io.*; /** * - * GUI dialog for exporting features or alignment annotations depending upon which method is called. + * GUI dialog for exporting features or alignment annotations depending upon + * which method is called. * * @author AMW - * + * */ -public class AnnotationExporter - extends JPanel +public class AnnotationExporter extends JPanel { JInternalFrame frame; + AlignmentPanel ap; + boolean features = true; + AlignmentAnnotation[] annotations; + Vector sequenceGroups; + Hashtable alignmentProperties; public AnnotationExporter() @@ -50,8 +54,7 @@ public class AnnotationExporter try { jbInit(); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } @@ -59,9 +62,7 @@ public class AnnotationExporter frame = new JInternalFrame(); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); - Desktop.addInternalFrame(frame, - "", - 260, 125); + Desktop.addInternalFrame(frame, "", 260, 125); } public void exportFeatures(AlignmentPanel ap) @@ -73,9 +74,8 @@ public class AnnotationExporter } public void exportAnnotations(AlignmentPanel ap, - AlignmentAnnotation[] annotations, - Vector sequenceGroups, - Hashtable alProperties) + AlignmentAnnotation[] annotations, Vector sequenceGroups, + Hashtable alProperties) { this.ap = ap; features = false; @@ -89,12 +89,12 @@ public class AnnotationExporter 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.setDialogTitle(features ? "Save Features to File" + : "Save Annotation to File"); chooser.setToolTipText("Save"); int value = chooser.showSaveDialog(this); @@ -106,15 +106,15 @@ public class AnnotationExporter { if (GFFFormat.isSelected()) { - text = new FeaturesFile().printGFFFormat( - ap.av.alignment.getDataset().getSequencesArray(), - ap.av.featuresDisplayed); + 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().printJalviewFormat(ap.av.alignment + .getDataset().getSequencesArray(), + ap.av.featuresDisplayed); } } else @@ -122,23 +122,22 @@ public class AnnotationExporter if (CSVFormat.isSelected()) { text = new AnnotationFile().printCSVAnnotations(annotations); - } else { - text = new AnnotationFile().printAnnotations( - annotations, - sequenceGroups, - alignmentProperties); + } + else + { + text = new AnnotationFile().printAnnotations(annotations, + sequenceGroups, alignmentProperties); } } try { java.io.PrintWriter out = new java.io.PrintWriter( - new java.io.FileWriter(chooser.getSelectedFile())); + new java.io.FileWriter(chooser.getSelectedFile())); out.print(text); out.close(); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } @@ -154,15 +153,13 @@ public class AnnotationExporter { if (GFFFormat.isSelected()) { - text = new FeaturesFile().printGFFFormat( - ap.av.alignment.getDataset().getSequencesArray(), - ap.av.featuresDisplayed); + 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().printJalviewFormat(ap.av.alignment + .getDataset().getSequencesArray(), ap.av.featuresDisplayed); } } else if (!features) @@ -170,22 +167,19 @@ public class AnnotationExporter if (CSVFormat.isSelected()) { text = new AnnotationFile().printCSVAnnotations(annotations); - } else { - text = new AnnotationFile().printAnnotations( - annotations, - sequenceGroups, - alignmentProperties); + } + else + { + text = new AnnotationFile().printAnnotations(annotations, + sequenceGroups, alignmentProperties); } } CutAndPasteTransfer cap = new CutAndPasteTransfer(); cap.setText(text); - Desktop.addInternalFrame(cap, - (features ? "Features for - " : - "Annotations for - ") - + ap.alignFrame.getTitle(), - 600, - 500); + Desktop.addInternalFrame(cap, (features ? "Features for - " + : "Annotations for - ") + + ap.alignFrame.getTitle(), 600, 500); close_actionPerformed(null); } @@ -195,13 +189,12 @@ public class AnnotationExporter try { frame.setClosed(true); + } catch (java.beans.PropertyVetoException ex) + { } - catch (java.beans.PropertyVetoException ex) - {} } - private void jbInit() - throws Exception + private void jbInit() throws Exception { this.setLayout(flowLayout1); toFile.setText("to File"); @@ -256,15 +249,25 @@ public class AnnotationExporter } JPanel jPanel1 = new JPanel(); + JButton toFile = new JButton(); + JButton toTextbox = new JButton(); + JButton close = new JButton(); + ButtonGroup buttonGroup = new ButtonGroup(); + JRadioButton jalviewFormat = new JRadioButton(); + JRadioButton GFFFormat = new JRadioButton(); + JRadioButton CSVFormat = new JRadioButton(); + JLabel jLabel1 = new JLabel(); + JPanel jPanel3 = new JPanel(); + FlowLayout flowLayout1 = new FlowLayout(); }