/*
* Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
* Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview 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 3
* of the License, or (at your option) any later version.
*
* Jalview 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 Jalview. If not, see .
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.io;
import jalview.exceptions.NoFileSelectedException;
import jalview.gui.AlignmentPanel;
import jalview.gui.HTMLOptions;
import jalview.gui.OOMWarning;
import jalview.math.AlignmentDimension;
import jalview.util.MessageManager;
import java.awt.Graphics;
import java.awt.print.PrinterException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.jfree.graphics2d.svg.SVGGraphics2D;
import org.jfree.graphics2d.svg.SVGHints;
public class HtmlSvgOutput extends HTMLOutput
{
public HtmlSvgOutput(AlignmentPanel ap)
{
super(ap);
}
@Override
public void exportHTML(String outputFile)
{
exportStarted();
try
{
if (outputFile == null)
{
outputFile = getOutputFile();
}
generatedFile = new File(outputFile);
} catch (NoFileSelectedException e)
{
setProgressMessage(MessageManager.formatMessage(
"status.cancelled_image_export_operation", "HTML"));
return;
} catch (Exception e)
{
setProgressMessage(MessageManager
.formatMessage("info.error_creating_file", "HTML"));
e.printStackTrace();
return;
}
new Thread(this).start();
}
public int printUnwrapped(int pwidth, int pheight, int pi,
Graphics idGraphics, Graphics alignmentGraphics)
throws PrinterException
{
return ap.printUnwrapped(pwidth, pheight, pi, idGraphics,
alignmentGraphics);
}
public int printWrapped(int pwidth, int pheight, int pi, Graphics... pg)
throws PrinterException
{
return ap.printWrappedAlignment(pwidth, pheight, pi, pg[0]);
}
private String getHtml(String titleSvg, String alignmentSvg,
String jsonData, boolean wrapped)
{
StringBuilder htmlSvg = new StringBuilder();
htmlSvg.append("\n");
if (jsonData != null)
{
htmlSvg.append(
" ");
htmlSvg.append(
"");
htmlSvg.append(
"
"
+ jsonData + "
");
htmlSvg.append(" ");
}
htmlSvg.append("\n");
if (!wrapped)
{
htmlSvg.append("