JAL-4090 JAL-4160 JAL-4274 image export dimensions and scale factor configurable...
authorJames Procter <j.procter@dundee.ac.uk>
Thu, 7 Sep 2023 10:21:23 +0000 (11:21 +0100)
committerJames Procter <j.procter@dundee.ac.uk>
Thu, 7 Sep 2023 13:57:36 +0000 (14:57 +0100)
help/help/html/io/export.html
help/markdown/releases/release-2_11_3_0.md
src/jalview/bin/Cache.java
src/jalview/gui/AlignFrame.java
src/jalview/util/imagemaker/BitmapImageSizing.java
test/jalview/util/imagemaker/BitmapImageSizeTest.java [new file with mode: 0644]

index 04216da..c940373 100755 (executable)
     </li>
 
   </ul>
-  <a name="htmlexport" />
   <p>
+    <strong>PNG Export Options</strong>
+  
+  <p>
+    <em>Since Jalview 2.11.3</em> it is possible to specify options when <a
+      href="../features/clarguments-reference.html#exportingimagefiles">exporting
+      figures via the command line</a> to increase the resolution of the
+    exported PNG, and configure maximum width and height settings.
+  
+  <p>You can also configure default export settings by adding the
+    following lines to
+  
+  <pre>.jalview_properties</pre>
+  <pre>BITMAP_SCALE=&lt;Scale factor multiplied by 10&gt;
+  BITMAP_WIDTH=Width of export in pixels
+  BITMAP_HEIGHT=Height of figure export in pixels
+  </pre>
+  When scale is not set, the figure will be scaled to fit in the smallest
+  specified dimension. Scale will be ignored if it results in an image
+  dimension greater than the smallest specified dimension.
+  <p>
+  <a name="htmlexport" /><p>
     <strong>Exporting alignments as Web Pages</strong>
   <p>
     In Jalview 2.9, new HTML exporting options were introduced. The
index fdfa3a5..2365cf3 100644 (file)
@@ -23,6 +23,7 @@ channel: "release"
 - <!-- JAL-4221 --> sequence descriptions are updated from database reference sources if not already defined
 - <!-- JAL-4273 --> Visible adjuster marks to grab and adjust annotation panel height and id width
 
+- <!-- JAL-4274 --> Command line options and configurable bitmap export preferences for height, width and scale factor
 
 ### Improved support for working with computationally determined models
 
index 3750d9d..038a5a0 100755 (executable)
@@ -141,6 +141,9 @@ import jalview.ws.sifts.SiftsSettings;
  * <li>WRAP_ALIGNMENT</li>
  * <li>EPS_RENDERING (Prompt each time|Lineart|Text) default for EPS rendering
  * style check</li>
+ * <li>BITMAP_SCALE - scale factor for PNG export - default 0 - native resolution</li>
+ * <li>BITMAP_HEIGHT - height bound for PNG export or 0 for unbound</li>
+ * <li>BITMAP_WIDTH - width bound for PNG export or 0 for unbound</li>
  * <li>SORT_ALIGNMENT (No sort|Id|Pairwise Identity)</li>
  * <li>SEQUENCE_LINKS list of name|URL pairs for opening a url with
  * $SEQUENCE_ID$</li>
@@ -1629,6 +1632,7 @@ public class Cache
   private static final Collection<String> bootstrapProperties = new ArrayList<>(
           Arrays.asList(JALVIEWLOGLEVEL, BOOTSTRAP_TEST));
 
+
   public static Properties bootstrapProperties(String filename)
   {
     Properties bootstrapProps = new Properties();
index f674034..dba400e 100644 (file)
@@ -1562,7 +1562,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   public void createPNG(File f) throws ImageOutputException
   {
-    createPNG(f, null, BitmapImageSizing.nullBitmapImageSizing());
+    createPNG(f, null, BitmapImageSizing.defaultBitmapImageSizing());
   }
 
   public void createPNG(File f, String renderer, BitmapImageSizing userBis)
index 312b834..450b01b 100644 (file)
@@ -1,5 +1,7 @@
 package jalview.util.imagemaker;
 
+import jalview.bin.Cache;
+
 public class BitmapImageSizing
 {
   public final float scale;
@@ -19,4 +21,21 @@ public class BitmapImageSizing
   {
     return new BitmapImageSizing(0.0f, 0, 0);
   }
+  
+  public static final String BITMAP_SCALE = "BITMAP_SCALE";
+
+  public static final String BITMAP_HEIGHT = "BITMAP_HEIGHT";
+
+  public static final String BITMAP_WIDTH = "BITMAP_WIDTH";
+
+  /**
+   * 
+   * @return bean configured from Cache keys
+   */
+  public static BitmapImageSizing defaultBitmapImageSizing()
+  {
+    
+    return new BitmapImageSizing(Cache.getDefault(BITMAP_SCALE,0)/10f,Cache.getDefault(BITMAP_WIDTH,0),Cache.getDefault(BITMAP_HEIGHT,0));
+    
+  }
 }
diff --git a/test/jalview/util/imagemaker/BitmapImageSizeTest.java b/test/jalview/util/imagemaker/BitmapImageSizeTest.java
new file mode 100644 (file)
index 0000000..49e1084
--- /dev/null
@@ -0,0 +1,43 @@
+package jalview.util.imagemaker;
+
+import static org.testng.Assert.assertEquals;
+
+import org.testng.annotations.Test;
+
+import jalview.bin.Cache;
+
+public class BitmapImageSizeTest {
+  @Test(groups = {"Functional"})
+  public void testCacheSettingsRecovery() {
+    Cache.setPropsAreReadOnly(true);
+    Cache.loadProperties("test/jalview/bin/testProps.jvprops");
+    
+    Cache.removeProperty(BitmapImageSizing.BITMAP_HEIGHT);
+    Cache.removeProperty(BitmapImageSizing.BITMAP_SCALE);
+    Cache.removeProperty(BitmapImageSizing.BITMAP_WIDTH);
+    
+    BitmapImageSizing def = BitmapImageSizing.defaultBitmapImageSizing();
+    BitmapImageSizing zero = BitmapImageSizing.nullBitmapImageSizing();
+
+    assertEquals(def.height, zero.height);
+    assertEquals(def.width, zero.width);
+    assertEquals(def.scale, zero.scale);
+    
+    Cache.setProperty(BitmapImageSizing.BITMAP_HEIGHT,"120");
+    Cache.setProperty(BitmapImageSizing.BITMAP_SCALE,"240");
+    Cache.setProperty(BitmapImageSizing.BITMAP_WIDTH,"360");
+    
+    def = BitmapImageSizing.defaultBitmapImageSizing();
+    
+    assertEquals(def.height, 120);
+    assertEquals(def.width, 360);
+    assertEquals(def.scale, 24f);
+    
+    Cache.removeProperty(BitmapImageSizing.BITMAP_WIDTH);
+    
+    def = BitmapImageSizing.defaultBitmapImageSizing();
+    assertEquals(def.height, 120);
+    assertEquals(def.width, zero.width);
+    assertEquals(def.scale, 24f);    
+  }
+}