+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
package jalview.util;\r
\r
-import java.awt.event.ActionEvent;\r
-import java.awt.RenderingHints;\r
-import javax.imageio.ImageIO;\r
-import org.jibble.epsgraphics.EpsGraphics2D;\r
-import jalview.gui.EPSOptions;\r
-import java.awt.Graphics2D;\r
import java.io.*;\r
-import java.awt.image.BufferedImage;\r
-import java.awt.Graphics;\r
-import jalview.io.*;\r
+import javax.imageio.*;\r
+\r
import java.awt.*;\r
+import java.awt.image.*;\r
\r
+import org.jibble.epsgraphics.*;\r
+import jalview.gui.*;\r
+import jalview.io.*;\r
\r
public class ImageMaker\r
{\r
BufferedImage bi;\r
\r
public ImageMaker(Component parent, int type, String title,\r
- int width, int height, File file, String EPStitle)\r
+ int width, int height, File file, String EPStitle)\r
{\r
this.type = type;\r
\r
}\r
}\r
\r
- try\r
+ if (file != null)\r
{\r
- out = new FileOutputStream(file);\r
-\r
- if (type == EPS)\r
- setupEPS(width, height, EPStitle);\r
- else\r
- setupPNG(width, height);\r
- }\r
- catch (Exception ex)\r
- {\r
- System.out.println("Error creating " + (type == EPS ? "EPS" : "PNG") +\r
- " file.");\r
+ try\r
+ {\r
+ out = new FileOutputStream(file);\r
+\r
+ if (type == EPS)\r
+ {\r
+ setupEPS(width, height, EPStitle);\r
+ }\r
+ else\r
+ {\r
+ setupPNG(width, height);\r
+ }\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ System.out.println("Error creating " + (type == EPS ? "EPS" : "PNG") +\r
+ " file.");\r
+ }\r
}\r
}\r
\r
return graphics;\r
}\r
\r
-\r
void setupPNG(int width, int height)\r
{\r
- bi = new BufferedImage(width, height,\r
- BufferedImage.TYPE_INT_RGB);\r
- graphics = bi.getGraphics();\r
- Graphics2D ig2 = (Graphics2D) graphics;\r
- ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
- RenderingHints.VALUE_ANTIALIAS_ON);\r
+ bi = new BufferedImage(width, height,\r
+ BufferedImage.TYPE_INT_RGB);\r
+ graphics = bi.getGraphics();\r
+ Graphics2D ig2 = (Graphics2D) graphics;\r
+ ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
+ RenderingHints.VALUE_ANTIALIAS_ON);\r
}\r
\r
public void writeImage()\r
{\r
- try{\r
- switch(type)\r
+ try\r
+ {\r
+ switch (type)\r
{\r
case EPS:\r
pg.flush();\r
}\r
catch (Exception ex)\r
{\r
- ex.printStackTrace();\r
+ ex.printStackTrace();\r
}\r
}\r
\r
renderStyle = eps.getValue();\r
\r
if (renderStyle == null || eps.cancelled)\r
+ {\r
return;\r
+ }\r
}\r
\r
if (renderStyle.equalsIgnoreCase("text"))\r
accurateText = false;\r
}\r
\r
- try {\r
+ try\r
+ {\r
pg = new EpsGraphics2D(title, out, 0, 0, width,\r
- height);\r
+ height);\r
Graphics2D ig2 = (Graphics2D) pg;\r
ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
RenderingHints.VALUE_ANTIALIAS_ON);\r
\r
graphics = pg;\r
}\r
- catch (Exception ex) { }\r
+ catch (Exception ex)\r
+ {}\r
}\r
\r
-\r
JalviewFileChooser getPNGChooser()\r
{\r
return new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty(\r