JAL-629 --structureimage with formatting args.
[jalview.git] / src / jalview / bin / argparser / Arg.java
index 958569e..2354cdd 100644 (file)
@@ -128,9 +128,6 @@ public enum Arg
                   + "none,\n" + "jmol,\n" + "chimera,\n" + "chimerax,\n"
                   + "pymol.",
           Opt.STRING, Opt.LINKED, Opt.MULTI),
-  STRUCTUREIMAGE(Type.STRUCTURE,
-          "Export an image of a 3D structure opened in JMOL", Opt.STRING,
-          Opt.LINKED, Opt.MULTI),
   NOTEMPFAC(Type.STRUCTURE,
           "Do not show the temperature factor annotation for the preceding --structure.",
           Opt.UNARY, Opt.LINKED, Opt.ALLOWALL, Opt.SECRET), // keep this secret
@@ -146,11 +143,11 @@ public enum Arg
           Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS, Opt.ALLOWALL,
           Opt.REQUIREINPUT, Opt.OUTPUT, Opt.PRIMARY),
   TYPE(Type.IMAGE,
-          "Set the image format for the preceding --image to name. Valid values for name are: svg,\n"
-                  + "png,\n" + "eps,\n" + "html,\n" + "biojs.",
+          "Set the image format for the preceding --image. Valid values are:\n"
+                  + "svg,\n" + "png,\n" + "eps,\n" + "html,\n" + "biojs.",
           Opt.STRING, Opt.LINKED, Opt.ALLOWALL),
   TEXTRENDERER(Type.IMAGE,
-          "Sets whether text in a vector image format (SVG, HTML, EPS) should be rendered as text or vector line-art. Possible values for name are:\n"
+          "Sets whether text in a vector image format (SVG, HTML, EPS) should be rendered as text or vector line-art. Possible values are:\n"
                   + "text,\n" + "lineart.",
           Opt.STRING, Opt.LINKED, Opt.ALLOWALL),
   SCALE(Type.IMAGE,
@@ -162,6 +159,28 @@ public enum Arg
   HEIGHT(Type.IMAGE,
           "Sets a height for bitmap image format (PNG) with the width maintaining the aspect ratio. Should be given as a positive integer. If used in conjunction with --scale and --width then the smallest scaling will be used (scale, width and height provide bounds for the image).",
           Opt.STRING, Opt.LINKED, Opt.ALLOWALL),
+  STRUCTUREIMAGE(Type.IMAGE,
+          "Export an image of a 3D structure opened in JMOL", Opt.STRING,
+          Opt.LINKED, Opt.MULTI),
+
+  STRUCTUREIMAGETYPE(Type.IMAGE,
+          "Set the structure image format for the preceding --structureimage. Valid values are:\n"
+                  + "svg,\n" + "png,\n" + "eps,\n" + "html,\n" + "biojs.",
+          Opt.STRING, Opt.LINKED, Opt.ALLOWALL),
+  STRUCTUREIMAGETEXTRENDERER(Type.IMAGE,
+          "Sets whether text in a vector structure image format (SVG, HTML, EPS) should be rendered as text or vector line-art. Possible values are:\n"
+                  + "text,\n" + "lineart.",
+          Opt.STRING, Opt.LINKED, Opt.ALLOWALL),
+  STRUCTUREIMAGESCALE(Type.IMAGE,
+          "Sets a scaling for bitmap structure image format (PNG). Should be given as a floating point number. If used in conjunction with --structureimagewidth and --structureimageheight then the smallest scaling will be used (structureimagescale, structureimagewidth and structureimageheight provide bounds for the structure image).",
+          Opt.STRING, Opt.LINKED, Opt.ALLOWALL),
+  STRUCTUREIMAGEWIDTH(Type.IMAGE,
+          "Sets a width for bitmap structure image format (PNG) with the height maintaining the aspect ratio. Should be given as a positive integer. If used in conjunction with --structureimagescale and --structureimageheight then the smallest scaling will be used (structureimagescale, structureimagewidth and structureimageheight provide bounds for the structure image).",
+          Opt.STRING, Opt.LINKED, Opt.ALLOWALL),
+  STRUCTUREIMAGEHEIGHT(Type.IMAGE,
+          "Sets a height for bitmap structure image format (PNG) with the width maintaining the aspect ratio. Should be given as a positive integer. If used in conjunction with --structureimagescale and --structureimagewidth then the smallest scaling will be used (structureimagescale, structureimagewidth and structureimageheight provide bounds for the structure image).",
+          Opt.STRING, Opt.LINKED, Opt.ALLOWALL),
+
   OUTPUT(Type.OUTPUT,
           "Export the open alignment to file filename. The format name is specified by the subval modifier format=name, a following --format name argument or guessed from the file extension. Valid format names (and file extensions) are:\n"
                   + "fasta (fa, fasta, mfa, fastq),\n" + "pfam (pfam),\n"
@@ -197,8 +216,9 @@ public enum Arg
           "Move on to a new alignment window. This will ensure --append will start a new alignment window and other linked arguments will apply to the new alignment window.",
           Opt.UNARY, Opt.MULTI, Opt.NOACTION, Opt.INCREMENTDEFAULTCOUNTER),
   SUBSTITUTIONS(Type.FLOW,
-          "The following argument values allow (or don't allow) subsituting filename parts. This is initially true. Valid substitutions are {basename} - the filename-without-extension of the currently --opened file (or first --appended file),\n"
-                  + "{dirname}, - the directory (folder) name of the currently --opened file (or first --appended file),\n"
+          "The following argument values allow (or don't allow) subsituting filename parts. This is initially true. Valid substitutions are:\n"
+                  + "{basename} - the filename-without-extension of the currently --opened file (or first --appended file),\n"
+                  + "{dirname} - the directory (folder) name of the currently --opened file (or first --appended file),\n"
                   + "{argfilebasename} - the filename-without-extension of the current --argfile,\n"
                   + "{argfiledirname} - the directory (folder) name of the current --argfile,\n"
                   + "{n} - the value of the index counter (starting at 0).\n"
@@ -521,9 +541,9 @@ public enum Arg
   {
     StringBuilder sb = new StringBuilder();
 
-    sb.append("usage: jalview [" + Arg.HEADLESS.argString() + "] ["
+    sb.append("usage: jalview [" + Arg.HEADLESS.argString() + "] [["
             + Arg.OPEN.argString() + "/" + Arg.APPEND.argString()
-            + " file(s)] [args]");
+            + "] file(s)] [args]");
     sb.append(System.lineSeparator());
     sb.append(System.lineSeparator());
 
@@ -566,6 +586,7 @@ public enum Arg
       }
 
       Iterator<Arg> argsI = args.iterator();
+      Type typeSection = null;
       while (argsI.hasNext())
       {
         Arg a = argsI.next();
@@ -576,10 +597,27 @@ public enum Arg
           continue;
         }
 
+        if (a.getType() != typeSection)
+        {
+          typeSection = a.getType();
+          String typeDescription = a.getType().description();
+          if (typeDescription != null && typeDescription.length() > 0)
+          {
+            // typeDescription = typeDescription.substring(0,
+            // 1).toUpperCase(Locale.ROOT) + typeDescription.substring(1);
+            typeDescription = typeDescription.toUpperCase(Locale.ROOT);
+            sb.append(typeDescription);
+            sb.append(System.lineSeparator());
+            sb.append(System.lineSeparator());
+          }
+        }
+
         appendArgUsage(sb, a, maxArgLength);
 
         if (argsI.hasNext())
+        {
           sb.append(System.lineSeparator());
+        }
       }
     }
     return sb.toString();
@@ -703,15 +741,8 @@ public enum Arg
       while (line.length() > descLength)
       {
         int splitIndex = line.lastIndexOf(" ", descLength);
-        if (splitIndex > descLength)
-        {
-          break;
-        }
-        else
-        {
-          splitDescLinesList.add(line.substring(0, splitIndex));
-          line = line.substring(splitIndex + 1);
-        }
+        splitDescLinesList.add(line.substring(0, splitIndex));
+        line = line.substring(splitIndex + 1);
       }
       splitDescLinesList.add(line);
     }
@@ -723,11 +754,15 @@ public enum Arg
       while (splitDescLines.hasNext())
       {
         if (first)
+        {
           sb.append(ARGDESCRIPTIONSEPARATOR);
+        }
         else
+        {
           sb.append(String.format("%-"
                   + (maxArgLength + ARGDESCRIPTIONSEPARATOR.length()) + "s",
                   ""));
+        }
         sb.append(splitDescLines.next());
         sb.append(System.lineSeparator());
         first = false;