JAL-4265 Added --bgcolour for --structureimage output. Saves and restores Jmol state...
[jalview.git] / src / jalview / gui / AppJmol.java
index cfbac04..5b935b7 100644 (file)
@@ -264,6 +264,8 @@ public class AppJmol extends StructureViewerBase
     }
     jmb.executeCommand(new StructureCommand(command), false);
     jmb.executeCommand(new StructureCommand("set hoverDelay=0.1"), false);
+    jmb.executeCommand(new StructureCommand("set antialiasdisplay on"),
+            false);
     jmb.setFinishedInit(true);
   }
 
@@ -432,7 +434,7 @@ public class AppJmol extends StructureViewerBase
     try
     {
       makePDBImage(null, type, null,
-              BitmapImageSizing.defaultBitmapImageSizing());
+              BitmapImageSizing.defaultBitmapImageSizing(), null);
     } catch (ImageOutputException ioex)
     {
       Console.error("Unexpected error whilst writing " + type.toString(),
@@ -441,7 +443,8 @@ public class AppJmol extends StructureViewerBase
   }
 
   public void makePDBImage(File file, ImageMaker.TYPE type, String renderer,
-          BitmapImageSizing userBis) throws ImageOutputException
+          BitmapImageSizing userBis, List<String> extraCommands)
+          throws ImageOutputException
   {
     int width = getWidth();
     int height = getHeight();
@@ -470,9 +473,24 @@ public class AppJmol extends StructureViewerBase
           }
         }
 
-        jmb.jmolViewer.antialiased = true;
+        String saveStateNameTemp = "JalviewSaveStateTemp";
+        jmb.executeCommand(
+                new StructureCommand("save STATE " + saveStateNameTemp),
+                false);
+
+        if (extraCommands != null)
+        {
+          for (String cmd : extraCommands)
+          {
+            jmb.executeCommand(new StructureCommand(cmd), false);
+          }
+        }
+
         jmb.jmolViewer.requestRepaintAndWait("image export");
         jmb.jmolViewer.renderScreenImage(ig2, usewidth, useheight);
+        jmb.executeCommand(
+                new StructureCommand("restore STATE " + saveStateNameTemp),
+                false);
       }
     };
     String view = MessageManager.getString("action.view")