JAL-629 Fix --tempfac. Hide non-working --notempfac. Add --scale, --width, --height...
[jalview.git] / src / jalview / bin / Commands.java
index 3608295..679fbf4 100644 (file)
@@ -492,16 +492,23 @@ public class Commands
 
           // get TEMPFAC type from subvals or Arg.TEMPFAC in case user Adds
           // reference annotations
+          String tftString = ArgParser
+                  .getFromSubValArgOrPrefWithSubstitutions(argParser, avm,
+                          Arg.TEMPFAC, Position.AFTER, av, subVals, null,
+                          null, null);
+          boolean notempfac = ArgParser.getBoolFromSubValOrArg(avm,
+                  Arg.NOTEMPFAC, subVals);
+          TFType tft = notempfac ? null : TFType.DEFAULT;
+          /*
           String tftString = subVals.get("tempfac");
-          TFType tft = avm.getBoolean(Arg.NOTEMPFAC) ? null
-                  : TFType.DEFAULT;
           ArgValue tftAv = getArgAssociatedWithStructure(Arg.TEMPFAC, avm,
                   af, structureFilepath);
           if (tftString == null && tftAv != null)
           {
             tftString = tftAv.getSubVals().getContent();
           }
-          if (tftString != null)
+          */
+          if (tftString != null && !notempfac)
           {
             // get kind of temperature factor annotation
             try
@@ -546,8 +553,9 @@ public class Commands
             }
           }
 
-          boolean addTempFac = tft != null
-                  || Cache.getDefault("ADD_TEMPFACT_ANN", false);
+          boolean addTempFac = notempfac ? false
+                  : ((tft != null)
+                          || Cache.getDefault("ADD_TEMPFACT_ANN", false));
 
           // TODO use ssFromStructure
           StructureChooser.openStructureFileForSequence(null, null, ap, seq,
@@ -626,6 +634,50 @@ public class Commands
         if (renderer == null)
           renderer = "text";
         String type = "png"; // default
+
+        float bitmapscale = 0.0f;
+        int bitmapwidth = 0;
+        int bitmapheight = 0;
+        String scale = ArgParser.getValueFromSubValOrArg(avm, av, Arg.SCALE,
+                subVal);
+        if (scale != null)
+        {
+          try
+          {
+            bitmapscale = Float.parseFloat(scale);
+          } catch (NumberFormatException e)
+          {
+            Console.warn("Did not understand scale '" + scale
+                    + "', won't be used.");
+          }
+        }
+        String width = ArgParser.getValueFromSubValOrArg(avm, av, Arg.WIDTH,
+                subVal);
+        if (width != null)
+        {
+          try
+          {
+            bitmapwidth = Integer.parseInt(width);
+          } catch (NumberFormatException e)
+          {
+            Console.warn("Did not understand width '" + width
+                    + "', won't be used.");
+          }
+        }
+        String height = ArgParser.getValueFromSubValOrArg(avm, av,
+                Arg.HEIGHT, subVal);
+        if (height != null)
+        {
+          try
+          {
+            bitmapheight = Integer.parseInt(height);
+          } catch (NumberFormatException e)
+          {
+            Console.warn("Did not understand height '" + height
+                    + "', won't be used.");
+          }
+        }
+
         type = ArgParser.getValueFromSubValOrArg(avm, av, Arg.TYPE, subVal);
         if (type == null && fileName != null)
         {
@@ -651,7 +703,7 @@ public class Commands
 
         case "png":
           Console.debug("Outputting type '" + type + "' to " + fileName);
-          af.createPNG(file);
+          af.createPNG(file, null, bitmapscale, bitmapwidth, bitmapheight);
           break;
 
         case "html":