X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationExporter.java;h=a6ccc7b05fa51d92501903005adcd5ddfa0fab36;hb=6ff6b518cb8befa795ffd2d8942fc29aa7febb72;hp=be0ef742a5b5fd8a59b9b812209834b6e6f7a19b;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git diff --git a/src/jalview/gui/AnnotationExporter.java b/src/jalview/gui/AnnotationExporter.java index be0ef74..a6ccc7b 100755 --- a/src/jalview/gui/AnnotationExporter.java +++ b/src/jalview/gui/AnnotationExporter.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, 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 file is part of Jalview. * - * 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. + * Jalview 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 3 of the License, or (at your option) any later version. * - * 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 + * Jalview 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 Jalview. If not, see . */ package jalview.gui; @@ -62,7 +61,7 @@ public class AnnotationExporter extends JPanel frame = new JInternalFrame(); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); - Desktop.addInternalFrame(frame, "", 260, 125); + Desktop.addInternalFrame(frame, "", frame.getPreferredSize().width, frame.getPreferredSize().height); } public void exportFeatures(AlignmentPanel ap) @@ -89,8 +88,8 @@ public class AnnotationExporter extends JPanel 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" @@ -108,13 +107,13 @@ public class AnnotationExporter extends JPanel { text = new FeaturesFile().printGFFFormat(ap.av.alignment .getDataset().getSequencesArray(), - ap.av.featuresDisplayed); + getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());// ap.av.featuresDisplayed//); } else { text = new FeaturesFile().printJalviewFormat(ap.av.alignment .getDataset().getSequencesArray(), - ap.av.featuresDisplayed); + getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); // ap.av.featuresDisplayed); } } else @@ -154,12 +153,14 @@ public class AnnotationExporter extends JPanel if (GFFFormat.isSelected()) { text = new FeaturesFile().printGFFFormat(ap.av.alignment - .getDataset().getSequencesArray(), ap.av.featuresDisplayed); + .getDataset().getSequencesArray(), + getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); } else { text = new FeaturesFile().printJalviewFormat(ap.av.alignment - .getDataset().getSequencesArray(), ap.av.featuresDisplayed); + .getDataset().getSequencesArray(), + getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); } } else if (!features) @@ -176,14 +177,42 @@ public class AnnotationExporter extends JPanel } CutAndPasteTransfer cap = new CutAndPasteTransfer(); - cap.setText(text); - Desktop.addInternalFrame(cap, (features ? "Features for - " - : "Annotations for - ") - + ap.alignFrame.getTitle(), 600, 500); + try + { + cap.setText(text); + Desktop.addInternalFrame(cap, (features ? "Features for - " + : "Annotations for - ") + ap.alignFrame.getTitle(), 600, 500); + } catch (OutOfMemoryError oom) + { + new OOMWarning("generating " + + (features ? "Features for - " : "Annotations for - ") + + ap.alignFrame.getTitle(), oom); + cap.dispose(); + } close_actionPerformed(null); } + private Hashtable getDisplayedFeatureCols() + { + Hashtable fcols = new Hashtable(); + if (ap.av.featuresDisplayed == null) + { + return fcols; + } + Enumeration en = ap.av.featuresDisplayed.keys(); + FeatureRenderer fr = ap.seqPanel.seqCanvas.getFeatureRenderer(); // consider + // higher + // level + // method ? + while (en.hasMoreElements()) + { + Object col = en.nextElement(); + fcols.put(col, fr.featureColours.get(col)); + } + return fcols; + } + public void close_actionPerformed(ActionEvent e) { try @@ -196,7 +225,8 @@ public class AnnotationExporter extends JPanel private void jbInit() throws Exception { - this.setLayout(flowLayout1); + this.setLayout(new BorderLayout()); + toFile.setText("to File"); toFile.addActionListener(new ActionListener() { @@ -244,8 +274,8 @@ public class AnnotationExporter extends JPanel buttonGroup.add(jalviewFormat); buttonGroup.add(GFFFormat); buttonGroup.add(CSVFormat); - this.add(jPanel3, null); - this.add(jPanel1, null); + this.add(jPanel3, BorderLayout.CENTER); + this.add(jPanel1, BorderLayout.SOUTH); } JPanel jPanel1 = new JPanel();