X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FImageMaker.java;h=632c2ad293ac9ad49adb85dc55955050e7c75ee2;hb=1b5ee75e7538b6229da397b28a91296e612d23e8;hp=59244ebdfadbaf8b0e8c262a02fa6f8666c9597f;hpb=eda4e3368f30e54448e303c51d0cb717aed57f90;p=jalview.git diff --git a/src/jalview/util/ImageMaker.java b/src/jalview/util/ImageMaker.java index 59244eb..632c2ad 100755 --- a/src/jalview/util/ImageMaker.java +++ b/src/jalview/util/ImageMaker.java @@ -1,17 +1,32 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 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.util; -import java.awt.event.ActionEvent; -import java.awt.RenderingHints; -import javax.imageio.ImageIO; -import org.jibble.epsgraphics.EpsGraphics2D; -import jalview.gui.EPSOptions; -import java.awt.Graphics2D; import java.io.*; -import java.awt.image.BufferedImage; -import java.awt.Graphics; -import jalview.io.*; +import javax.imageio.*; + import java.awt.*; +import java.awt.image.*; +import org.jibble.epsgraphics.*; +import jalview.gui.*; +import jalview.io.*; public class ImageMaker { @@ -25,7 +40,7 @@ public class ImageMaker BufferedImage bi; public ImageMaker(Component parent, int type, String title, - int width, int height, File file, String EPStitle) + int width, int height, File file, String EPStitle) { this.type = type; @@ -49,16 +64,20 @@ public class ImageMaker } } - if(file!=null) + if (file != null) { try { out = new FileOutputStream(file); if (type == EPS) + { setupEPS(width, height, EPStitle); + } else + { setupPNG(width, height); + } } catch (Exception ex) { @@ -73,21 +92,21 @@ public class ImageMaker return graphics; } - void setupPNG(int width, int height) { - bi = new BufferedImage(width, height, - BufferedImage.TYPE_INT_RGB); - graphics = bi.getGraphics(); - Graphics2D ig2 = (Graphics2D) graphics; - ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + bi = new BufferedImage(width, height, + BufferedImage.TYPE_INT_RGB); + graphics = bi.getGraphics(); + Graphics2D ig2 = (Graphics2D) graphics; + ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); } public void writeImage() { - try{ - switch(type) + try + { + switch (type) { case EPS: pg.flush(); @@ -101,7 +120,7 @@ public class ImageMaker } catch (Exception ex) { - ex.printStackTrace(); + ex.printStackTrace(); } } @@ -123,7 +142,9 @@ public class ImageMaker renderStyle = eps.getValue(); if (renderStyle == null || eps.cancelled) + { return; + } } if (renderStyle.equalsIgnoreCase("text")) @@ -131,9 +152,10 @@ public class ImageMaker accurateText = false; } - try { + try + { pg = new EpsGraphics2D(title, out, 0, 0, width, - height); + height); Graphics2D ig2 = (Graphics2D) pg; ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); @@ -142,10 +164,10 @@ public class ImageMaker graphics = pg; } - catch (Exception ex) { } + catch (Exception ex) + {} } - JalviewFileChooser getPNGChooser() { return new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty(