if (sview instanceof AppJmol)
{
AppJmol jmol = (AppJmol) sview;
- jmol.makePDBImage(structureImageFile, imageType, renderer,
+ try {
+ jmol.makePDBImage(structureImageFile, imageType, renderer,
userBis);
+ }
+ catch (ImageOutputException ioexc)
+ {
+ Console.warn("Unexpected error whilst exporting image to "+structureImageFile,ioexc);
+ }
+
}
break;
default:
import jalview.io.HtmlSvgOutput;
import jalview.io.IdentifyFile;
import jalview.io.NewickFile;
+import jalview.io.exceptions.ImageOutputException;
import jalview.io.gff.SequenceOntologyFactory;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
String imageName = "unnamed.png";
while (aparser.getSize() > 1)
{
- String outputFormat = aparser.nextValue();
- file = aparser.nextValue();
-
- if (outputFormat.equalsIgnoreCase("png"))
- {
- af.createPNG(new File(file));
- imageName = (new File(file)).getName();
- System.out.println("Creating PNG image: " + file);
- continue;
- }
- else if (outputFormat.equalsIgnoreCase("svg"))
- {
- File imageFile = new File(file);
- imageName = imageFile.getName();
- af.createSVG(imageFile);
- System.out.println("Creating SVG image: " + file);
- continue;
- }
- else if (outputFormat.equalsIgnoreCase("html"))
+ try
{
- File imageFile = new File(file);
- imageName = imageFile.getName();
- HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
- htmlSVG.exportHTML(file);
+ String outputFormat = aparser.nextValue();
+ file = aparser.nextValue();
- System.out.println("Creating HTML image: " + file);
- continue;
- }
- else if (outputFormat.equalsIgnoreCase("biojsmsa"))
- {
- if (file == null)
+ if (outputFormat.equalsIgnoreCase("png"))
{
- System.err.println("The output html file must not be null");
- return;
+ System.out.println("Creating PNG image: " + file);
+ af.createPNG(new File(file));
+ imageName = (new File(file)).getName();
+ continue;
}
- try
+ else if (outputFormat.equalsIgnoreCase("svg"))
{
- BioJsHTMLOutput.refreshVersionInfo(
- BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
- } catch (URISyntaxException e)
+ System.out.println("Creating SVG image: " + file);
+ File imageFile = new File(file);
+ imageName = imageFile.getName();
+ af.createSVG(imageFile);
+ continue;
+ }
+ else if (outputFormat.equalsIgnoreCase("html"))
{
- e.printStackTrace();
+ File imageFile = new File(file);
+ imageName = imageFile.getName();
+ HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
+
+ System.out.println("Creating HTML image: " + file);
+ htmlSVG.exportHTML(file);
+ continue;
}
- BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
- bjs.exportHTML(file);
- System.out
- .println("Creating BioJS MSA Viwer HTML file: " + file);
- continue;
- }
- else if (outputFormat.equalsIgnoreCase("imgMap"))
- {
- af.createImageMap(new File(file), imageName);
- System.out.println("Creating image map: " + file);
- continue;
- }
- else if (outputFormat.equalsIgnoreCase("eps"))
- {
- File outputFile = new File(file);
- System.out.println(
- "Creating EPS file: " + outputFile.getAbsolutePath());
- af.createEPS(outputFile);
- continue;
- }
- FileFormatI outFormat = null;
- try
- {
- outFormat = FileFormats.getInstance().forName(outputFormat);
- } catch (Exception formatP)
- {
- System.out.println("Couldn't parse " + outFormat
- + " as a valid Jalview format string.");
- }
- if (outFormat != null)
- {
- if (!outFormat.isWritable())
+ else if (outputFormat.equalsIgnoreCase("biojsmsa"))
+ {
+ if (file == null)
+ {
+ System.err.println("The output html file must not be null");
+ return;
+ }
+ try
+ {
+ BioJsHTMLOutput.refreshVersionInfo(
+ BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
+ } catch (URISyntaxException e)
+ {
+ e.printStackTrace();
+ }
+ BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
+ System.out.println(
+ "Creating BioJS MSA Viwer HTML file: " + file);
+ bjs.exportHTML(file);
+ continue;
+ }
+ else if (outputFormat.equalsIgnoreCase("imgMap"))
+ {
+ System.out.println("Creating image map: " + file);
+ af.createImageMap(new File(file), imageName);
+ continue;
+ }
+ else if (outputFormat.equalsIgnoreCase("eps"))
{
+ File outputFile = new File(file);
System.out.println(
- "This version of Jalview does not support alignment export as "
- + outputFormat);
+ "Creating EPS file: " + outputFile.getAbsolutePath());
+ af.createEPS(outputFile);
+ continue;
+ }
+
+ FileFormatI outFormat = null;
+ try
+ {
+ outFormat = FileFormats.getInstance().forName(outputFormat);
+ } catch (Exception formatP)
+ {
+ System.out.println("Couldn't parse " + outFormat
+ + " as a valid Jalview format string.");
}
- else
+ if (outFormat != null)
{
- af.saveAlignment(file, outFormat);
- if (af.isSaveAlignmentSuccessful())
+ if (!outFormat.isWritable())
{
- System.out.println("Written alignment in "
- + outFormat.getName() + " format to " + file);
+ System.out.println(
+ "This version of Jalview does not support alignment export as "
+ + outputFormat);
}
else
{
- System.out.println("Error writing file " + file + " in "
- + outFormat.getName() + " format!!");
+ af.saveAlignment(file, outFormat);
+ if (af.isSaveAlignmentSuccessful())
+ {
+ System.out.println("Written alignment in "
+ + outFormat.getName() + " format to " + file);
+ }
+ else
+ {
+ System.out.println("Error writing file " + file + " in "
+ + outFormat.getName() + " format!!");
+ }
}
}
+ } catch (ImageOutputException ioexc)
+ {
+ System.out.println(
+ "Unexpected error whilst exporting image to " + file);
+ ioexc.printStackTrace();
}
}
import jalview.io.NewickFile;
import jalview.io.ScoreMatrixFile;
import jalview.io.TCoffeeScoreFile;
+import jalview.io.exceptions.ImageOutputException;
import jalview.io.vcf.VCFLoader;
import jalview.jbgui.GAlignFrame;
import jalview.project.Jalview2XML;
protected void htmlMenuItem_actionPerformed(ActionEvent e)
{
HtmlSvgOutput htmlSVG = new HtmlSvgOutput(alignPanel);
- htmlSVG.exportHTML(null);
+ try {
+ htmlSVG.exportHTML(null);
+ } catch (ImageOutputException x) {
+ // report problem to console and raise dialog
+ }
}
@Override
public void bioJSMenuItem_actionPerformed(ActionEvent e)
{
BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel);
+ try {
bjs.exportHTML(null);
+ } catch (ImageOutputException x) {
+ // report problem to console and raise dialog
+ }
}
public void createImageMap(File file, String image)
{
+ try {
alignPanel.makePNGImageMap(file, image);
+ } catch (ImageOutputException x) {
+ // report problem to console and raise dialog
+ }
}
+ @Override
+ public void createPNG_actionPerformed(ActionEvent e) {
+ try{
+ createPNG(null);
+ } catch (ImageOutputException ioex)
+ {
+ // raise dialog, and report via console
+ }
+ }
+ @Override
+ public void createEPS_actionPerformed(ActionEvent e) {
+ try{
+ createEPS(null);
+ } catch (ImageOutputException ioex)
+ {
+ // raise dialog, and report via console
+ }
+
+ }
+ @Override
+ public void createSVG_actionPerformed(ActionEvent e) {
+ try{
+ createSVG(null);
+ } catch (ImageOutputException ioex)
+ {
+ // raise dialog, and report via console
+ }
+
+ }
/**
* Creates a PNG image of the alignment and writes it to the given file. If
* the file is null, the user is prompted to choose a file.
*
* @param f
*/
- @Override
- public void createPNG(File f)
+ public void createPNG(File f) throws ImageOutputException
{
createPNG(f, null, BitmapImageSizing.nullBitmapImageSizing());
}
- public void createPNG(File f, String renderer, BitmapImageSizing userBis)
+ public void createPNG(File f, String renderer, BitmapImageSizing userBis) throws ImageOutputException
{
alignPanel.makeAlignmentImage(TYPE.PNG, f, renderer, userBis);
}
*
* @param f
*/
- @Override
- public void createEPS(File f)
+ public void createEPS(File f) throws ImageOutputException
{
createEPS(f, null);
}
- public void createEPS(File f, String renderer)
+ public void createEPS(File f, String renderer) throws ImageOutputException
{
alignPanel.makeAlignmentImage(TYPE.EPS, f, renderer);
}
*
* @param f
*/
- @Override
- public void createSVG(File f)
+ public void createSVG(File f) throws ImageOutputException
{
createSVG(f, null);
}
- public void createSVG(File f, String renderer)
+ public void createSVG(File f, String renderer) throws ImageOutputException
{
alignPanel.makeAlignmentImage(TYPE.SVG, f, renderer);
}
import jalview.datamodel.SequenceI;
import jalview.gui.ImageExporter.ImageWriterI;
import jalview.io.HTMLOutput;
+import jalview.io.exceptions.ImageOutputException;
import jalview.jbgui.GAlignmentPanel;
import jalview.math.AlignmentDimension;
import jalview.schemes.ResidueProperties;
return (w > 0 ? w : calculateIdWidth().width);
}
- void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer)
+ void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer) throws ImageOutputException
{
makeAlignmentImage(type, file, renderer,
BitmapImageSizing.nullBitmapImageSizing());
* @param bitmapscale
*/
void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer,
- BitmapImageSizing userBis)
+ BitmapImageSizing userBis) throws ImageOutputException
{
final int borderBottomOffset = 5;
}
- public void makePNGImageMap(File imgMapFile, String imageName)
+ public void makePNGImageMap(File imgMapFile, String imageName) throws ImageOutputException
{
// /////ONLY WORKS WITH NON WRAPPED ALIGNMENTS
// ////////////////////////////////////////////
} catch (Exception ex)
{
- ex.printStackTrace();
+ throw new ImageOutputException("couldn't write ImageMap due to unexpected error",ex);
}
} // /////////END OF IMAGE MAP
import jalview.datamodel.StructureViewerModel.StructureData;
import jalview.gui.ImageExporter.ImageWriterI;
import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.exceptions.ImageOutputException;
import jalview.structure.StructureCommand;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.BrowserLauncher;
@Override
public void makePDBImage(ImageMaker.TYPE type)
{
+ try {
makePDBImage(null, type, null,
BitmapImageSizing.nullBitmapImageSizing());
+ } catch (ImageOutputException ioex) {
+ Console.error("Unexpected error whilst writing "+type.toString(),ioex);
+ }
}
public void makePDBImage(File file, ImageMaker.TYPE type, String renderer,
- BitmapImageSizing userBis)
+ BitmapImageSizing userBis) throws ImageOutputException
{
int width = getWidth();
int height = getHeight();
.toLowerCase(Locale.ROOT);
ImageExporter exporter = new ImageExporter(writer,
getProgressIndicator(), type, getTitle());
+
exporter.doExport(file, this, width, height, view, renderer, userBis);
+
}
@Override
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
+import jalview.io.exceptions.ImageOutputException;
import jalview.jbgui.GSplitFrame;
import jalview.jbgui.GStructureViewer;
import jalview.project.Jalview2XML;
String title = "View of desktop";
ImageExporter exporter = new ImageExporter(writer, null, TYPE.EPS,
title);
- exporter.doExport(of, this, width, height, title);
+ try {
+ exporter.doExport(of, this, width, height, title);
+ } catch (ImageOutputException ioex) {
+ jalview.bin.Console.error("Unexpected error whilst writing Jalview desktop snapshot as EPS",ioex);
+ }
}
/**
import jalview.bin.Jalview;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
+import jalview.io.exceptions.ImageOutputException;
import jalview.util.ImageMaker;
import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
* what the image is of e.g. Tree, Alignment
*/
public void doExport(File file, Component parent, int width, int height,
- String imageSource)
+ String imageSource) throws ImageOutputException
{
doExport(file, parent, width, height, imageSource, null,
BitmapImageSizing.nullBitmapImageSizing());
}
public void doExport(File file, Component parent, int width, int height,
- String imageSource, String renderer, BitmapImageSizing userBis)
+ String imageSource, String renderer, BitmapImageSizing userBis) throws ImageOutputException
{
final long messageId = System.currentTimeMillis();
setStatus(
import jalview.datamodel.SequenceI;
import jalview.gui.ImageExporter.ImageWriterI;
import jalview.gui.JalviewColourChooser.ColourChooserListener;
+import jalview.io.exceptions.ImageOutputException;
import jalview.jbgui.GPCAPanel;
import jalview.math.RotatableMatrix.Axis;
import jalview.util.ImageMaker;
};
String pca = MessageManager.getString("label.pca");
ImageExporter exporter = new ImageExporter(writer, null, type, pca);
- exporter.doExport(null, this, width, height, pca);
+ try {
+ exporter.doExport(null, this, width, height, pca);
+ } catch (ImageOutputException ioex) {
+ Console.error("Unexpected error whilst writing "+type.toString(),ioex);
+ }
}
@Override
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.io.NewickFile;
+import jalview.io.exceptions.ImageOutputException;
import jalview.jbgui.GTreePanel;
import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
String tree = MessageManager.getString("label.tree");
ImageExporter exporter = new ImageExporter(writer, null, imageFormat,
tree);
+ try {
exporter.doExport(null, this, width, height,
tree.toLowerCase(Locale.ROOT));
+ } catch (ImageOutputException ioex) {
+ Console.error("Unexpected error whilst writing "+imageFormat.toString(),ioex);
+ }
}
/**
import jalview.gui.JvSwingUtils;
import jalview.gui.Preferences;
import jalview.io.FileFormats;
+import jalview.io.exceptions.ImageOutputException;
import jalview.schemes.ResidueColourScheme;
import jalview.util.MessageManager;
import jalview.util.Platform;
@Override
public void actionPerformed(ActionEvent e)
{
- createPNG(null);
+ createPNG_actionPerformed(e);
}
});
createPNG.setActionCommand(
@Override
public void actionPerformed(ActionEvent e)
{
- createEPS(null);
+ createEPS_actionPerformed(e);
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- createSVG(null);
+ createSVG_actionPerformed(e);
}
});
// selectMenu.add(listenToViewSelections);
}
+ protected void createPNG_actionPerformed(ActionEvent object)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ protected void createEPS_actionPerformed(ActionEvent object)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ protected void createSVG_actionPerformed(ActionEvent object)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
protected void copyHighlightedColumns_actionPerformed(
ActionEvent actionEvent)
{
{
}
- public void createPNG(java.io.File f)
- {
- }
protected void font_actionPerformed(ActionEvent e)
{
}
- public void createEPS(java.io.File f)
- {
- }
-
- public void createSVG(java.io.File f)
- {
-
- }
protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
{