From: James Procter Date: Thu, 7 Sep 2023 10:21:23 +0000 (+0100) Subject: JAL-4090 JAL-4160 JAL-4274 image export dimensions and scale factor configurable... X-Git-Tag: Release_2_11_4_0~185 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e93bc0a7b2def06392a2f6b0f563c1e07fb917a1;p=jalview.git JAL-4090 JAL-4160 JAL-4274 image export dimensions and scale factor configurable via .jalview_properties as well as command line --- diff --git a/help/help/html/io/export.html b/help/help/html/io/export.html index 04216da..c940373 100755 --- a/help/help/html/io/export.html +++ b/help/help/html/io/export.html @@ -50,8 +50,28 @@ -

+ PNG Export Options + +

+ Since Jalview 2.11.3 it is possible to specify options when exporting + figures via the command line to increase the resolution of the + exported PNG, and configure maximum width and height settings. + +

You can also configure default export settings by adding the + following lines to + +

.jalview_properties
+
BITMAP_SCALE=<Scale factor multiplied by 10>
+  BITMAP_WIDTH=Width of export in pixels
+  BITMAP_HEIGHT=Height of figure export in pixels
+  
+ 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. +

+

Exporting alignments as Web Pages

In Jalview 2.9, new HTML exporting options were introduced. The diff --git a/help/markdown/releases/release-2_11_3_0.md b/help/markdown/releases/release-2_11_3_0.md index fdfa3a5..2365cf3 100644 --- a/help/markdown/releases/release-2_11_3_0.md +++ b/help/markdown/releases/release-2_11_3_0.md @@ -23,6 +23,7 @@ channel: "release" - sequence descriptions are updated from database reference sources if not already defined - Visible adjuster marks to grab and adjust annotation panel height and id width +- Command line options and configurable bitmap export preferences for height, width and scale factor ### Improved support for working with computationally determined models diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 3750d9d..038a5a0 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -141,6 +141,9 @@ import jalview.ws.sifts.SiftsSettings; *

  • WRAP_ALIGNMENT
  • *
  • EPS_RENDERING (Prompt each time|Lineart|Text) default for EPS rendering * style check
  • + *
  • BITMAP_SCALE - scale factor for PNG export - default 0 - native resolution
  • + *
  • BITMAP_HEIGHT - height bound for PNG export or 0 for unbound
  • + *
  • BITMAP_WIDTH - width bound for PNG export or 0 for unbound
  • *
  • SORT_ALIGNMENT (No sort|Id|Pairwise Identity)
  • *
  • SEQUENCE_LINKS list of name|URL pairs for opening a url with * $SEQUENCE_ID$
  • @@ -1629,6 +1632,7 @@ public class Cache private static final Collection bootstrapProperties = new ArrayList<>( Arrays.asList(JALVIEWLOGLEVEL, BOOTSTRAP_TEST)); + public static Properties bootstrapProperties(String filename) { Properties bootstrapProps = new Properties(); diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index f674034..dba400e 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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) diff --git a/src/jalview/util/imagemaker/BitmapImageSizing.java b/src/jalview/util/imagemaker/BitmapImageSizing.java index 312b834..450b01b 100644 --- a/src/jalview/util/imagemaker/BitmapImageSizing.java +++ b/src/jalview/util/imagemaker/BitmapImageSizing.java @@ -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 index 0000000..49e1084 --- /dev/null +++ b/test/jalview/util/imagemaker/BitmapImageSizeTest.java @@ -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); + } +}