X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FImageMaker.java;h=252bae1bce842be04355122af6c0b0a233a9075f;hb=ab43013b7e357b84b4abade0dba949668dfb2a0e;hp=1953a6033ae0a1366a6ff20587990a1ed879ade6;hpb=a3b4ec9805c4cee4c2dbe2a4c98913ee9c189c6b;p=jalview.git diff --git a/src/jalview/util/ImageMaker.java b/src/jalview/util/ImageMaker.java index 1953a60..252bae1 100755 --- a/src/jalview/util/ImageMaker.java +++ b/src/jalview/util/ImageMaker.java @@ -1,5 +1,5 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1) * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. @@ -21,6 +21,7 @@ package jalview.util; import jalview.gui.EPSOptions; +import jalview.gui.SVGOptions; import jalview.io.JalviewFileChooser; import java.awt.Component; @@ -34,18 +35,11 @@ import java.io.FileOutputStream; import javax.imageio.ImageIO; import org.jfree.graphics2d.svg.SVGGraphics2D; +import org.jfree.graphics2d.svg.SVGHints; import org.jibble.epsgraphics.EpsGraphics2D; public class ImageMaker { - // public static final int EPS = 0; - // - // public static final int PNG = 1; - // - // public static final int SVG = 2; - // - // int type = -1; - EpsGraphics2D pg; SVGGraphics2D g2; @@ -103,20 +97,16 @@ public class ImageMaker if (file == null) { JalviewFileChooser chooser; - // chooser = type == EPS ? getEPSChooser() : getPNGChooser(); chooser = type.getChooser(); - chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle(title); chooser.setToolTipText(MessageManager.getString("action.save")); - int value = chooser.showSaveDialog(parent); if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION) { jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser .getSelectedFile().getParent()); - file = chooser.getSelectedFile(); } } @@ -165,12 +155,14 @@ public class ImageMaker pg.close(); break; case SVG: - String svg = ((SVGGraphics2D) getGraphics()).getSVGDocument(); - out.write(svg.getBytes()); + String svgData = ((SVGGraphics2D) getGraphics()).getSVGDocument(); + out.write(svgData.getBytes()); + out.flush(); out.close(); break; case PNG: ImageIO.write(bi, "png", out); + out.flush(); out.close(); break; } @@ -229,11 +221,39 @@ public class ImageMaker Graphics2D ig2 = (Graphics2D) graphics; ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + } void setupSVG(int width, int height, String title) { + g2 = new SVGGraphics2D(width, height); + Graphics2D ig2 = g2; + + String renderStyle = jalview.bin.Cache.getDefault("SVG_RENDERING", + "Prompt each time"); + + // If we need to prompt, and if the GUI is visible then + // Prompt for EPS rendering style + if (renderStyle.equalsIgnoreCase("Prompt each time") + && !(System.getProperty("java.awt.headless") != null && System + .getProperty("java.awt.headless").equals("true"))) + { + SVGOptions svgOption = new SVGOptions(); + renderStyle = svgOption.getValue(); + + if (renderStyle == null || svgOption.cancelled) + { + return; + } + } + + if (renderStyle.equalsIgnoreCase("lineart")) + { + ig2.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE, + SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR); + } + graphics = g2; }