import java.io.File;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import jalview.gui.StructureViewer;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.AppletFormatAdapter;
+import jalview.io.BioJsHTMLOutput;
import jalview.io.DataSourceType;
import jalview.io.FileFormat;
import jalview.io.FileFormatException;
{
ArgValuesMap avm = argParser.getLinkedArgs(id);
theseArgsWereParsed = true;
- if (id == null)
- {
- theseArgsWereParsed &= processUnlinked(id);
- }
- else
- {
- theseArgsWereParsed &= processLinked(id);
- }
+ theseArgsWereParsed &= processLinked(id);
theseArgsWereParsed &= processImages(id);
// close ap
af.getCurrentView().setWrapAlignment(wrap);
// colour aligment?
- String colour = ArgParser.getFromSubValArgOrPref(avm, Arg.COLOUR,
- sv, null, "DEFAULT_COLOUR_PROT", "");
+ String colour = ArgParser.getFromSubValArgOrPref(avm, av,
+ Arg.COLOUR, sv, null, "DEFAULT_COLOUR_PROT", "");
if ("" != colour)
{
}
// change alignment frame title
- String title = ArgParser.getFromSubValArgOrPref(avm, Arg.TITLE,
- sv, null, null, null);
+ String title = ArgParser.getFromSubValArgOrPref(avm, av,
+ Arg.TITLE, sv, null, null, null);
if (title != null)
af.setTitle(title);
String type = "png"; // default
String fileName = subVal.getContent();
File file = new File(fileName);
- if (subVal.has("type"))
- {
- type = subVal.get("type");
- }
- else if (fileName != null)
+ String renderer = ArgParser.getValueFromSubValOrArg(avm, av,
+ Arg.RENDERER, subVal);
+ if (renderer == null)
+ renderer = "text";
+ type = ArgParser.getValueFromSubValOrArg(avm, av, Arg.TYPE, subVal);
+ if (type == null && fileName != null)
{
- for (String ext : new String[] { "svg", "png", "html" })
+ for (String ext : new String[] { "svg", "png", "html", "eps" })
{
if (fileName.toLowerCase(Locale.ROOT).endsWith("." + ext))
{
switch (type)
{
+
case "svg":
Console.debug("Outputting type '" + type + "' to " + fileName);
- af.createSVG(file);
+ af.createSVG(file, renderer);
break;
+
case "png":
Console.debug("Outputting type '" + type + "' to " + fileName);
af.createPNG(file);
break;
+
case "html":
Console.debug("Outputting type '" + type + "' to " + fileName);
HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
- htmlSVG.exportHTML(fileName);
+ htmlSVG.exportHTML(fileName, renderer);
+ break;
+
+ case "biojs":
+ try
+ {
+ BioJsHTMLOutput.refreshVersionInfo(
+ BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
+ } catch (URISyntaxException e)
+ {
+ e.printStackTrace();
+ }
+ BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
+ bjs.exportHTML(fileName);
+ Console.debug("Creating BioJS MSA Viwer HTML file: " + fileName);
break;
+
default:
Console.warn(Arg.IMAGE.argString() + " type '" + type
+ "' not known. Ignoring");
else
{
structfile = likelyStructure.getValue();
- Console.debug(
- "##### Comparing closest previous structure argument '"
- + structfile + "'");
}
}
}
COLOUR, FEATURES, GROOVY, GROUPS, HEADLESS, JABAWS, DISPLAY, GUI, NEWS,
SORTBYTREE, USAGESTATS, APPEND, OPEN, PROPS, QUESTIONNAIRE, SETPROP, TREE,
VDOC, VSESS, OUTPUT, SSANNOTATIONS, NOTEMPFAC, TEMPFAC, TITLE, PAEMATRIX,
- WRAP, NOSTRUCTURE, STRUCTURE, STRUCTUREVIEWER, IMAGE, QUIT, CLOSE,
- DEBUG("d"), QUIET("q"), ARGFILE, NEWFRAME, NPP("n++"), SUBSTITUTIONS,
- INITSUBSTITUTIONS, NIL, SPLASH, SETARGFILE, UNSETARGFILE,
+ WRAP, NOSTRUCTURE, STRUCTURE, STRUCTUREVIEWER, IMAGE, TYPE, RENDERER,
+ QUIT, CLOSE, DEBUG("d"), QUIET("q"), ARGFILE, NEWFRAME, NPP("n++"),
+ SUBSTITUTIONS, INITSUBSTITUTIONS, NIL, SPLASH, SETARGFILE, UNSETARGFILE,
WEBSERVICEDISCOVERY, ALLFRAMES;
protected static enum Opt
WRAP.setOptions(Opt.BOOLEAN, Opt.LINKED);
IMAGE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS,
Opt.ALLOWALL, Opt.REQUIREINPUT);
+ TYPE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWALL);
+ RENDERER.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWALL);
QUIT.setOptions(Opt.UNARY);
CLOSE.setOptions(Opt.UNARY, Opt.LINKED, Opt.ALLOWALL);
DEBUG.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP);
FIRST, BEFORE, AFTER
}
- public static String getValueFromSubValOrArg(ArgValuesMap avm, Arg a,
- SubVals sv)
+ // get from following Arg of type a or subval of same name (lowercase)
+ public static String getValueFromSubValOrArg(ArgValuesMap avm,
+ ArgValue av, Arg a, SubVals sv)
{
- return getFromSubValArgOrPref(avm, a, sv, null, null, null);
+ return getFromSubValArgOrPref(avm, av, a, sv, null, null, null);
}
- public static String getFromSubValArgOrPref(ArgValuesMap avm, Arg a,
- SubVals sv, String key, String pref, String def)
+ // get from following Arg of type a or subval key or preference pref or
+ // default def
+ public static String getFromSubValArgOrPref(ArgValuesMap avm, ArgValue av,
+ Arg a, SubVals sv, String key, String pref, String def)
{
- return getFromSubValArgOrPref(avm, a, Position.FIRST, null, sv, key,
- pref, def);
+ return getFromSubValArgOrPref(avm, a, Position.AFTER, av, sv, key, pref,
+ def);
}
+ // get from following(AFTER), first occurence of (FIRST) or previous (BEFORE)
+ // Arg of type a or subval key or preference pref or default def
public static String getFromSubValArgOrPref(ArgValuesMap avm, Arg a,
Position pos, ArgValue av, SubVals sv, String key, String pref,
String def)
return sv.get(key);
if (avm != null && avm.containsArg(a))
{
- String val = null;
if (pos == Position.FIRST && avm.getValue(a) != null)
return avm.getValue(a);
else if (pos == Position.BEFORE
@Override
public void createPNG(File f)
{
- alignPanel.makeAlignmentImage(TYPE.PNG, f);
+ createPNG(f, null);
+ }
+
+ public void createPNG(File f, String renderer)
+ {
+ alignPanel.makeAlignmentImage(TYPE.PNG, f, renderer);
}
/**
@Override
public void createEPS(File f)
{
- alignPanel.makeAlignmentImage(TYPE.EPS, f);
+ createEPS(f, null);
+ }
+
+ public void createEPS(File f, String renderer)
+ {
+ alignPanel.makeAlignmentImage(TYPE.EPS, f, renderer);
}
/**
@Override
public void createSVG(File f)
{
- alignPanel.makeAlignmentImage(TYPE.SVG, f);
+ createSVG(f, null);
+ }
+
+ public void createSVG(File f, String renderer)
+ {
+ alignPanel.makeAlignmentImage(TYPE.SVG, f, renderer);
}
@Override
*/
package jalview.gui;
-import jalview.analysis.AnnotationSorter;
-import jalview.api.AlignViewportI;
-import jalview.api.AlignmentViewPanel;
-import jalview.bin.Cache;
-import jalview.bin.Console;
-import jalview.bin.Jalview;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.HiddenColumns;
-import jalview.datamodel.SearchResultsI;
-import jalview.datamodel.SequenceFeature;
-import jalview.datamodel.SequenceGroup;
-import jalview.datamodel.SequenceI;
-import jalview.gui.ImageExporter.ImageWriterI;
-import jalview.io.HTMLOutput;
-import jalview.jbgui.GAlignmentPanel;
-import jalview.math.AlignmentDimension;
-import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.Comparison;
-import jalview.util.ImageMaker;
-import jalview.util.MessageManager;
-import jalview.viewmodel.ViewportListenerI;
-import jalview.viewmodel.ViewportRanges;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import javax.swing.SwingUtilities;
+import jalview.analysis.AnnotationSorter;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.bin.Cache;
+import jalview.bin.Console;
+import jalview.bin.Jalview;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.SearchResultsI;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
+import jalview.io.HTMLOutput;
+import jalview.jbgui.GAlignmentPanel;
+import jalview.math.AlignmentDimension;
+import jalview.schemes.ResidueProperties;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.Comparison;
+import jalview.util.ImageMaker;
+import jalview.util.MessageManager;
+import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
+
/**
* DOCUMENT ME!
*
// set idCanvas bufferedImage to null
// to prevent drawing old image
FontMetrics fm = getFontMetrics(av.getFont());
-
- // update the flag controlling whether the grid is too small to render the font
+
+ // update the flag controlling whether the grid is too small to render the
+ // font
av.validCharWidth = fm.charWidth('M') <= av.getCharWidth();
scalePanelHolder.setPreferredSize(
*/
alignmentGraphics.translate(alignmentGraphicsOffset,
alignmentDrawnHeight);
+ updateLayout();
getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
alignmentGraphics, -1, startRes, endRes + 1);
}
* @param type
* @param file
*/
- void makeAlignmentImage(ImageMaker.TYPE type, File file)
+ void makeAlignmentImage(ImageMaker.TYPE type, File file, String renderer)
{
final int borderBottomOffset = 5;
int imageWidth = aDimension.getWidth();
int imageHeight = aDimension.getHeight() + borderBottomOffset;
String of = MessageManager.getString("label.alignment");
- exporter.doExport(file, this, imageWidth, imageHeight, of);
+ exporter.doExport(file, this, imageWidth, imageHeight, of, renderer);
}
/**
}
else
{
- // no row (or row that can be adjusted) was pressed. Simulate a ruler click
+ // no row (or row that can be adjusted) was pressed. Simulate a ruler
+ // click
ap.getScalePanel().mousePressed(evt);
}
}
av.sendSelection();
return true;
}
+
/**
* Construct and display a context menu at the right-click position
*
}
if (rowIndex[0] != toRowIndex[0])
{
- jalview.bin.Console.trace("Drag went to another row. needs to be clipped");
+ jalview.bin.Console
+ .trace("Drag went to another row. needs to be clipped");
}
// rectangular selection on matrix style annotation
rowIndex[1] - deltaY);
// mark rectangular region formed by drag
- jalview.bin.Console.trace("Matrix Selection from last(" + fromXc + ",["
- + lastXci.cStart + "," + lastXci.cEnd + "]) to cur(" + toXc
- + ",[" + cXci.cStart + "," + cXci.cEnd + "])");
+ jalview.bin.Console.trace("Matrix Selection from last(" + fromXc
+ + ",[" + lastXci.cStart + "," + lastXci.cEnd + "]) to cur("
+ + toXc + ",[" + cXci.cStart + "," + cXci.cEnd + "])");
int fr, to;
fr = Math.min(lastXci.cStart, lastXci.cEnd);
to = Math.max(lastXci.cStart, lastXci.cEnd);
return;
}
}
- imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes()
- + 1) * av.getCharWidth();
+ updateFadedImageWidth();
if (imgWidth < 1)
{
return;
g.drawImage(image, 0, 0, this);
}
+ public void updateFadedImageWidth()
+ {
+ imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes()
+ + 1) * av.getCharWidth();
+
+ }
+
/**
* set true to enable redraw timing debug output on stderr
*/
@Override
public int getFadedImageWidth()
{
+ updateFadedImageWidth();
return imgWidth;
}
public void doExport(File file, Component parent, int width, int height,
String imageSource)
{
+ doExport(file, parent, width, height, imageSource, null);
+ }
+
+ public void doExport(File file, Component parent, int width, int height,
+ String imageSource, String renderer)
+ {
final long messageId = System.currentTimeMillis();
setStatus(
MessageManager.formatMessage(
* for this as EPS_RENDERING / SVG_RENDERING
* Always set to Text for JalviewJS as Lineart (glyph fonts) not available
*/
- String renderStyle = Cache.getDefault(
- imageType.getName() + "_RENDERING",
- LineartOptions.PROMPT_EACH_TIME);
+ String renderStyle = renderer == null
+ ? Cache.getDefault(imageType.getName() + "_RENDERING",
+ LineartOptions.PROMPT_EACH_TIME)
+ : renderer;
if (Platform.isJS())
{
renderStyle = "Text";
*/
public class LineartOptions extends JPanel
{
- static final String PROMPT_EACH_TIME = "Prompt each time";
+ public static final String PROMPT_EACH_TIME = "Prompt each time";
JvOptionPane dialog;
private OptionsParam promptEachTimeOpt = new OptionsParam(
MessageManager.getString("label.prompt_each_time"),
- "Prompt each time");
+ LineartOptions.PROMPT_EACH_TIME);
private OptionsParam lineArtOpt = new OptionsParam(
MessageManager.getString("label.lineart"), "Lineart");
*/
package jalview.io;
-import jalview.bin.Cache;
-import jalview.gui.AlignmentPanel;
-import jalview.gui.OOMWarning;
-import jalview.json.binding.biojs.BioJSReleasePojo;
-import jalview.json.binding.biojs.BioJSRepositoryPojo;
-import jalview.util.MessageManager;
-
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.util.Objects;
import java.util.TreeMap;
+import jalview.bin.Cache;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.OOMWarning;
+import jalview.json.binding.biojs.BioJSReleasePojo;
+import jalview.json.binding.biojs.BioJSRepositoryPojo;
+import jalview.util.MessageManager;
+
public class BioJsHTMLOutput extends HTMLOutput
{
private static File currentBJSTemplateFile;
}
+ @Override
+ public void run(String s)
+ {
+ run();
+ }
+
}
public void exportHTML(String outputFile)
{
+ exportHTML(outputFile, null);
+ }
+
+ public void exportHTML(String outputFile, String renderer)
+ {
setProgressMessage(MessageManager.formatMessage(
"status.exporting_alignment_as_x_file", getDescription()));
try
}
if (Jalview.isHeadlessMode())
{
- this.run();
+ this.run(renderer);
}
else
{
{
return description;
}
+
+ // used to pass an option such as render to run
+ public abstract void run(String string);
}
\ No newline at end of file
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.Locale;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
@Override
public void run()
{
+ run(null);
+ }
+
+ @Override
+ public void run(String renderer)
+ {
try
{
- String renderStyle = Cache.getDefault("HTML_RENDERING",
- "Prompt each time");
+ String renderStyle = renderer == null
+ ? Cache.getDefault("HTML_RENDERING",
+ LineartOptions.PROMPT_EACH_TIME)
+ : renderer;
AtomicBoolean textOption = new AtomicBoolean(
- !"Lineart".equals(renderStyle));
+ !"lineart".equals(renderStyle.toLowerCase(Locale.ROOT)));
/*
* configure the action to run on OK in the dialog
/*
* Prompt for character rendering style if preference is not set
*/
- if (renderStyle.equalsIgnoreCase("Prompt each time") && !isHeadless())
+ if (renderStyle.equalsIgnoreCase(LineartOptions.PROMPT_EACH_TIME)
+ && !isHeadless())
{
LineartOptions svgOption = new LineartOptions("HTML", textOption);
svgOption.setResponseAction(1, () -> {