| 1 | /** |
| 2 | * Copyright 2009- 21 Simon Andrews |
| 3 | * |
| 4 | * This file is part of SeqMonk. |
| 5 | * |
| 6 | * SeqMonk is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * SeqMonk is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with SeqMonk; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | package uk.ac.babraham.FastQC.Utilities.ImageSaver; |
| 21 | |
| 22 | import java.awt.Component; |
| 23 | import java.io.OutputStream; |
| 24 | import java.io.PrintWriter; |
| 25 | |
| 26 | |
| 27 | /** |
| 28 | * A utility class which acts as a wrapper for the SVG or PNG generating |
| 29 | * code which can be used to save (almost) any component which uses the |
| 30 | * standard Graphics interface to draw itself. |
| 31 | */ |
| 32 | public class SVGImageSaver { |
| 33 | |
| 34 | public static String saveImage (Component c, OutputStream os) { |
| 35 | PrintWriter pr = new PrintWriter(os); |
| 36 | String svgData = SVGGenerator.writeSVG(c); |
| 37 | pr.write(svgData); |
| 38 | pr.flush(); |
| 39 | return(svgData); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | |
| 44 | } |