/* PrintBamView * created: 2012 * This file is part of Artemis * * Copyright(C) 2012 Genome Research Limited * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ package uk.ac.sanger.artemis.components.alignment; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; import javax.swing.Box; import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import org.apache.batik.dom.GenericDOMImplementation; import org.apache.batik.svggen.SVGGeneratorContext; import org.apache.batik.svggen.SVGGraphics2D; import org.apache.batik.svggen.SVGGraphics2DIOException; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import uk.ac.sanger.artemis.Options; import uk.ac.sanger.artemis.components.PrintArtemis; import uk.ac.sanger.artemis.components.StickyFileChooser; public class PrintBamView { /** * Print to a jpeg or png file */ public static void print(JPanel containerPanel) { // file chooser final StickyFileChooser fc = new StickyFileChooser(); File fselect = new File(fc.getCurrentDirectory()+ System.getProperty("file.separator")+ "bamview.png"); fc.setSelectedFile(fselect); // file name prefix Box YBox = Box.createVerticalBox(); JLabel labFormat = new JLabel("Select Format:"); Font font = labFormat.getFont(); labFormat.setFont(font.deriveFont(Font.BOLD)); YBox.add(labFormat); Box bacross = Box.createHorizontalBox(); final JComboBox formatSelect = new JComboBox(PrintArtemis.getImageFormats()); formatSelect.setSelectedItem("png"); formatSelect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { String selected; if(fc.getSelectedFile() != null) { selected = fc.getSelectedFile().getAbsolutePath(); String fmts[] = PrintArtemis.getImageFormats(); for(int i=0; i