+ for (ArgValue structureImageArgValue : avm
+ .getArgValueList(Arg.STRUCTUREIMAGE))
+ {
+ String structureImageFilename = argParser.makeSubstitutions(
+ structureImageArgValue.getValue(), id, true);
+ if (structureViewer != null && structureImageFilename != null)
+ {
+ SubVals structureImageSubVals = null;
+ structureImageSubVals = structureImageArgValue.getSubVals();
+ File structureImageFile = new File(structureImageFilename);
+ String width = avm.getValueFromSubValOrArg(
+ structureImageArgValue, Arg.WIDTH,
+ structureImageSubVals);
+ String height = avm.getValueFromSubValOrArg(
+ structureImageArgValue, Arg.HEIGHT,
+ structureImageSubVals);
+ String scale = avm.getValueFromSubValOrArg(
+ structureImageArgValue, Arg.SCALE,
+ structureImageSubVals);
+ String renderer = avm.getValueFromSubValOrArg(
+ structureImageArgValue, Arg.TEXTRENDERER,
+ structureImageSubVals);
+ String typeS = avm.getValueFromSubValOrArg(
+ structureImageArgValue, Arg.TYPE,
+ structureImageSubVals);
+ if (typeS == null || typeS.length() == 0)
+ {
+ typeS = FileUtils.getExtension(structureImageFile);
+ }
+ TYPE imageType;
+ try
+ {
+ imageType = Enum.valueOf(TYPE.class,
+ typeS.toUpperCase(Locale.ROOT));
+ } catch (IllegalArgumentException e)
+ {
+ addWarn("Do not know image format '" + typeS
+ + "', using PNG");
+ imageType = TYPE.PNG;
+ }
+ BitmapImageSizing userBis = ImageMaker
+ .parseScaleWidthHeightStrings(scale, width, height);
+
+ String imageColour = avm.getValueFromSubValOrArg(
+ structureImageArgValue, Arg.IMAGECOLOUR,
+ structureImageSubVals);
+ ColourSchemeI originalColourScheme = this
+ .getColourScheme(af);
+ this.colourAlignFrame(af, imageColour);
+
+ List<String> extraCommands = new ArrayList<>();
+ // these don't actually do anything to the output image since we
+ // renderScreenImage
+ // extraCommands.add("set antialiasImages on");
+ // extraCommands.add("set antialiasTranslucent on");
+
+ String bgcolour = avm.getValueFromSubValOrArg(
+ structureImageArgValue, Arg.BGCOLOUR,
+ structureImageSubVals);
+ if (bgcolour != null && bgcolour.length() > 0)
+ {
+ if (bgcolour.charAt(0) == '#')
+ {
+ bgcolour = "[x" + bgcolour.substring(1) + "]";
+ }
+ extraCommands.add("background " + bgcolour);
+ }
+
+ // TODO MAKE THIS VIEWER INDEPENDENT!!
+ switch (StructureViewer.getViewerType())
+ {
+ case JMOL:
+ JalviewStructureDisplayI sview = structureViewer
+ .getJalviewStructureDisplay();
+ if (sview instanceof AppJmol)
+ {
+ AppJmol jmol = (AppJmol) sview;
+ try
+ {
+ boolean success = this.checksBeforeWritingToFile(avm,
+ subVals, false, structureImageFilename,
+ "structure image", isError);
+ if (!success)
+ {
+ continue;
+ }
+
+ Console.debug(
+ "Rendering image to " + structureImageFile);
+ jmol.makePDBImage(structureImageFile, imageType,
+ renderer, userBis, extraCommands);
+ Console.debug("Finished Rendering image to "
+ + structureImageFile);
+
+ } catch (ImageOutputException ioexc)
+ {
+ addError("Unexpected error whilst exporting image to "
+ + structureImageFile, ioexc);
+ isError = true;
+ continue;
+ }
+
+ }
+ break;
+ default:
+ addWarn("Cannot export image for structure viewer "
+ + structureViewer.getViewerType() + " yet");
+ continue;
+ }
+ this.colourAlignFrame(af, originalColourScheme);
+ }
+ }