Merge branch 'feature/JAL-629_--output_-_means_output_to_STDOUT' into merge/big_merge...
[jalview.git] / src / jalview / bin / Commands.java
index e409c77..b1b8288 100644 (file)
@@ -6,7 +6,6 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -166,13 +165,9 @@ public class Commands
     if (avm == null)
       return true;
 
-    /*
-     * // script to execute after all loading is completed one way or another String
-     * groovyscript = m.get(Arg.GROOVY) == null ? null :
-     * m.get(Arg.GROOVY).getValue(); String file = m.get(Arg.OPEN) == null ? null :
-     * m.get(Arg.OPEN).getValue(); String data = null; FileFormatI format = null;
-     * DataSourceType protocol = null;
-     */
+    // set wrap scope here so it can be applied after structures are opened
+    boolean wrap = false;
+
     if (avm.containsArg(Arg.APPEND) || avm.containsArg(Arg.OPEN))
     {
       commandArgsProvided = true;
@@ -256,11 +251,6 @@ public class Commands
           af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
                   format);
 
-          // wrap alignment?
-          boolean wrap = ArgParser.getFromSubValArgOrPref(avm, Arg.WRAP, sv,
-                  null, "WRAP_ALIGNMENT", false);
-          af.getCurrentView().setWrapAlignment(wrap);
-
           // colour alignment?
           String colour = ArgParser.getFromSubValArgOrPref(avm, av,
                   Arg.COLOUR, sv, null, "DEFAULT_COLOUR_PROT", "");
@@ -365,6 +355,12 @@ public class Commands
                     false, false);
           }
 
+          // wrap alignment? do this last for formatting reasons
+          wrap = ArgParser.getFromSubValArgOrPref(avm, Arg.WRAP, sv, null,
+                  "WRAP_ALIGNMENT", false);
+          // af.setWrapFormat(wrap) is applied after structures are opened for
+          // annotation reasons
+
           // store the AlignFrame for this id
           afMap.put(id, af);
 
@@ -556,20 +552,7 @@ public class Commands
           String sViewer = ArgParser.getFromSubValArgOrPref(avm,
                   Arg.STRUCTUREVIEWER, Position.AFTER, av, subVals, null,
                   null, "jmol");
-          ViewerType viewerType = null;
-          if (!"none".equals(sViewer))
-          {
-            for (ViewerType v : EnumSet.allOf(ViewerType.class))
-            {
-              String name = v.name().toLowerCase(Locale.ROOT)
-                      .replaceAll(" ", "");
-              if (sViewer.equals(name))
-              {
-                viewerType = v;
-                break;
-              }
-            }
-          }
+          ViewerType viewerType = ViewerType.getFromString(sViewer);
 
           // TODO use ssFromStructure
           StructureViewer sv = StructureChooser
@@ -693,6 +676,15 @@ public class Commands
       }
     }
 
+    if (wrap)
+    {
+      AlignFrame af = afMap.get(id);
+      if (af != null)
+      {
+        af.setWrapFormat(wrap, true);
+      }
+    }
+
     /*
     boolean doShading = avm.getBoolean(Arg.TEMPFAC_SHADING);
     if (doShading)
@@ -811,7 +803,7 @@ public class Commands
 
           case "biojs":
             Console.debug(
-                    "Creating BioJS MSA Viwer HTML file: " + fileName);
+                    "Outputting BioJS MSA Viwer HTML file: " + fileName);
             try
             {
               BioJsHTMLOutput.refreshVersionInfo(
@@ -825,12 +817,12 @@ public class Commands
             break;
 
           case "eps":
-            Console.debug("Creating EPS file: " + fileName);
-            af.createEPS(file, name);
+            Console.debug("Outputting EPS file: " + fileName);
+            af.createEPS(file, renderer);
             break;
 
           case "imagemap":
-            Console.debug("Creating ImageMap file: " + fileName);
+            Console.debug("Outputting ImageMap file: " + fileName);
             af.createImageMap(file, name);
             break;
 
@@ -1001,7 +993,7 @@ public class Commands
         seq = al.getSequenceAt(subVals.getIndex());
       }
     }
-    else if (idAv != null)
+    if (seq == null && idAv != null)
     {
       seq = al.findName(idAv.getValue());
     }