+ String imageColour = avm.getValueFromSubValOrArg(imageAv,
+ Arg.IMAGECOLOUR, imageSubVals);
+ ColourSchemeI originalColourScheme = this.getColourScheme(af);
+ this.colourAlignFrame(af, imageColour);
+
+ Console.info("Writing " + file);
+
+ boolean success = checksBeforeWritingToFile(avm, imageSubVals,
+ false, fileName, "image", isError);
+ if (!success)
+ {
+ continue;
+ }
+
+ try
+ {
+ switch (type)
+ {
+
+ case "svg":
+ Console.debug("Outputting type '" + type + "' to " + fileName);
+ af.createSVG(file, renderer);
+ break;
+
+ case "png":
+ Console.debug("Outputting type '" + type + "' to " + fileName);
+ af.createPNG(file, null, userBis);
+ break;
+
+ case "html":
+ Console.debug("Outputting type '" + type + "' to " + fileName);
+ HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
+ htmlSVG.exportHTML(fileName, renderer);
+ break;
+
+ case "biojs":
+ Console.debug(
+ "Outputting BioJS MSA Viwer HTML file: " + fileName);
+ try
+ {
+ BioJsHTMLOutput.refreshVersionInfo(
+ BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
+ } catch (URISyntaxException e)
+ {
+ e.printStackTrace();
+ }
+ BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
+ bjs.exportHTML(fileName);
+ break;
+
+ case "eps":
+ Console.debug("Outputting EPS file: " + fileName);
+ af.createEPS(file, renderer);
+ break;
+
+ case "imagemap":
+ Console.debug("Outputting ImageMap file: " + fileName);
+ af.createImageMap(file, name);
+ break;
+
+ default:
+ addWarn(Arg.IMAGE.argString() + " type '" + type
+ + "' not known. Ignoring");
+ break;
+ }
+ } catch (Exception ioex)
+ {
+ addError("Unexpected error during export to '" + fileName + "'",
+ ioex);
+ isError = true;
+ }
+
+ this.colourAlignFrame(af, originalColourScheme);
+ }
+ }
+ return !isError;
+ }
+
+ protected boolean processOutput(String id)
+ {
+ ArgValuesMap avm = argParser.getLinkedArgs(id);
+ AlignFrame af = afMap.get(id);
+
+ if (af == null)
+ {
+ addWarn("Did not have an alignment window for id=" + id);
+ return false;
+ }
+
+ Boolean isError = Boolean.valueOf(false);
+
+ if (avm.containsArg(Arg.OUTPUT))
+ {
+ for (ArgValue av : avm.getArgValueList(Arg.OUTPUT))
+ {
+ String val = av.getValue();
+ SubVals subVals = av.getSubVals();
+ String fileName = subVals.getContent();
+ boolean stdout = ArgParser.STDOUTFILENAME.equals(fileName);
+ File file = new File(fileName);
+
+ String name = af.getName();
+ String format = avm.getValueFromSubValOrArg(av, Arg.FORMAT,
+ subVals);
+ FileFormats ffs = FileFormats.getInstance();
+ List<String> validFormats = ffs.getWritableFormats(false);
+
+ FileFormatI ff = null;
+ if (format == null && fileName != null)
+ {
+ FORMAT: for (String fname : validFormats)
+ {
+ FileFormatI tff = ffs.forName(fname);
+ String[] extensions = tff.getExtensions().split(",");
+ for (String ext : extensions)
+ {
+ if (fileName.toLowerCase(Locale.ROOT).endsWith("." + ext))
+ {
+ ff = tff;
+ format = ff.getName();
+ break FORMAT;
+ }
+ }
+ }
+ }
+ if (ff == null && format != null)
+ {
+ ff = ffs.forName(format);
+ }
+ if (ff == null)
+ {
+ if (stdout)
+ {
+ ff = FileFormat.Fasta;
+ }
+ else
+ {
+ StringBuilder validSB = new StringBuilder();
+ for (String f : validFormats)
+ {
+ if (validSB.length() > 0)
+ validSB.append(", ");
+ validSB.append(f);
+ FileFormatI tff = ffs.forName(f);
+ validSB.append(" (");
+ validSB.append(tff.getExtensions());
+ validSB.append(")");
+ }
+
+ addError("No valid format specified for "
+ + Arg.OUTPUT.argString() + ". Valid formats are "
+ + validSB.toString() + ".");
+ continue;
+ }
+ }
+
+ boolean success = checksBeforeWritingToFile(avm, subVals, true,
+ fileName, ff.getName(), isError);
+ if (!success)
+ {
+ continue;
+ }
+
+ boolean backups = avm.getFromSubValArgOrPref(Arg.BACKUPS, subVals,
+ null, Platform.isHeadless() ? null : BackupFiles.ENABLED,
+ !Platform.isHeadless());
+
+ Console.info("Writing " + fileName);
+
+ af.saveAlignment(fileName, ff, stdout, backups);
+ if (af.isSaveAlignmentSuccessful())
+ {
+ Console.debug("Written alignment '" + name + "' in "
+ + ff.getName() + " format to '" + file + "'");
+ }
+ else