<classpathentry kind="lib" path="lib/jfreesvg-2.1.jar"/>
<classpathentry kind="lib" path="lib/quaqua-filechooser-only-8.0.jar"/>
<classpathentry kind="lib" path="lib/VAqua4.jar"/>
- <classpathentry kind="lib" path="lib/httpclient-4.5.6.jar"/>
- <classpathentry kind="lib" path="lib/httpcore-4.4.10.jar"/>
- <classpathentry kind="lib" path="lib/httpmime-4.5.6.jar"/>
- <classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/>
- <classpathentry kind="lib" path="lib/json-20180130.jar"/>
+ <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.0.3.jar"/>
+ <classpathentry kind="lib" path="lib/httpcore-4.0.1.jar"/>
+ <classpathentry kind="lib" path="lib/httpmime-4.0.3.jar"/>
+ <classpathentry kind="lib" path="lib/jersey-json-1.19.jar"/>
+ <classpathentry kind="lib" path="lib/gnujpdf.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin"/>
<classpathentry kind="lib" path="lib/xml-apis.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
createSVG(null);
}
});
+ JMenuItem createPDF = new JMenuItem("PDF");
+ createPDF.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ createPDF(null);
+ }
+ });
JMenuItem loadTreeMenuItem = new JMenuItem(
MessageManager.getString("label.load_associated_tree"));
exportImageMenu.add(createPNG);
exportImageMenu.add(createBioJS);
exportImageMenu.add(createSVG);
+ exportImageMenu.add(createPDF);
addSequenceMenu.add(addFromFile);
addSequenceMenu.add(addFromText);
addSequenceMenu.add(addFromURL);
{
}
+ public void createPDF(java.io.File f)
+ {
+ }
+
public void createSVG(java.io.File f)
{
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
+import java.awt.print.PageFormat;
+import java.awt.print.Paper;
import java.io.File;
import java.io.FileOutputStream;
import org.jfree.graphics2d.svg.SVGHints;
import org.jibble.epsgraphics.EpsGraphics2D;
+import gnu.jpdf.PDFJob;
+
public class ImageMaker
{
public static final String SVG_DESCRIPTION = "Scalable Vector Graphics";
public static final String PNG_DESCRIPTION = "Portable network graphics";
+ public static final String PDF_EXTENSION = "pdf";
+
+ public static final String PDF_DESCRIPTION = "Portable Document Format";
+
public static final String HTML_EXTENSION = "html";
public static final String HTML_DESCRIPTION = "Hypertext Markup Language";
SVGGraphics2D g2;
+
Graphics graphics;
FileOutputStream out;
private boolean headless;
+ private PDFJob pdfjob;
+
public enum TYPE
{
EPS("EPS", MessageManager.getString("label.eps_file"), getEPSChooser()),
PNG("PNG", MessageManager.getString("label.png_image"),
getPNGChooser()),
- SVG("SVG", "SVG", getSVGChooser());
+ SVG("SVG", "SVG", getSVGChooser()),
+ PDF("PDF","PDF",getPDFChooser());
private JalviewFileChooser chooser;
{
setupPNG(width, height);
}
+ else if (type == TYPE.PDF)
+ {
+ setupPDF(width, height, fileTitle);
+ }
} catch (Exception ex)
{
out.flush();
out.close();
break;
+ case PDF:
+ graphics = null;
+ pdfjob.end();
+ pdfjob = null;
}
} catch (Exception ex)
{
}
}
+ void setupPDF(int width, int height, String title)
+ {
+ boolean accurateText = true;
+
+ // String renderStyle = jalview.bin.Cache.getDefault("EPS_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")))
+ // {
+ // EPSOptions eps = new EPSOptions();
+ // renderStyle = eps.getValue();
+ //
+ // if (renderStyle == null || eps.cancelled)
+ // {
+ // setProgressMessage(MessageManager.formatMessage(
+ // "status.cancelled_image_export_operation", "EPS"));
+ // return;
+ // }
+ // }
+ //
+ // if (renderStyle.equalsIgnoreCase("text"))
+ // {
+ // accurateText = false;
+ // }
+
+ try
+ {
+ pdfjob = new PDFJob(out, title);
+
+ Paper paper = new Paper();
+ paper.setSize(width, height);
+ PageFormat pf = new PageFormat();
+ pf.setPaper(paper);
+ graphics = pdfjob.getGraphics(pf);
+ setProgressMessage(MessageManager
+ .formatMessage("status.export_complete", type.getName()));
+ } catch (Exception ex)
+ {
+ }
+ }
void setupPNG(int width, int height)
{
bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
return new JalviewFileChooser(PNG_EXTENSION, PNG_DESCRIPTION);
}
+ static JalviewFileChooser getPDFChooser()
+ {
+ if (Jalview.isHeadlessMode())
+ {
+ return null;
+ }
+ return new JalviewFileChooser(PDF_EXTENSION, PDF_DESCRIPTION);
+ }
+
static JalviewFileChooser getEPSChooser()
{
if (Jalview.isHeadlessMode())