X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2Fimagemaker%2FBitmapImageSizing.java;fp=src%2Fjalview%2Futil%2Fimagemaker%2FBitmapImageSizing.java;h=e170f0eb8e4066fac53185e08baa3f5df724431b;hb=fb90be25f2e516b6653c22ef7903eeaf6981b014;hp=450b01be8db3176db14fc748d4a23d303a8887e5;hpb=5bf5a9cf55ceac67c622781b4c5d866d2fba6393;p=jalview.git diff --git a/src/jalview/util/imagemaker/BitmapImageSizing.java b/src/jalview/util/imagemaker/BitmapImageSizing.java index 450b01b..e170f0e 100644 --- a/src/jalview/util/imagemaker/BitmapImageSizing.java +++ b/src/jalview/util/imagemaker/BitmapImageSizing.java @@ -4,24 +4,33 @@ import jalview.bin.Cache; public class BitmapImageSizing { - public final float scale; + private final float scale; - public final int width; + private final int width; - public final int height; + private final int height; - public BitmapImageSizing(float scale, int width, int height) + private boolean isDefault = false; + + public BitmapImageSizing(float scale, int width, int height, + boolean isDefault) { this.scale = scale; this.width = width; this.height = height; + this.isDefault = isDefault; + } + + public boolean isNull() + { + return scale == 0.0f && width == 0 && height == 0; } public static BitmapImageSizing nullBitmapImageSizing() { - return new BitmapImageSizing(0.0f, 0, 0); + return new BitmapImageSizing(0.0f, 0, 0, false); } - + public static final String BITMAP_SCALE = "BITMAP_SCALE"; public static final String BITMAP_HEIGHT = "BITMAP_HEIGHT"; @@ -34,8 +43,41 @@ public class BitmapImageSizing */ public static BitmapImageSizing defaultBitmapImageSizing() { - - return new BitmapImageSizing(Cache.getDefault(BITMAP_SCALE,0)/10f,Cache.getDefault(BITMAP_WIDTH,0),Cache.getDefault(BITMAP_HEIGHT,0)); - + return new BitmapImageSizing(0f, 0, 0, true); + } + + private float defaultScale() + { + return Cache.getDefault(BITMAP_SCALE, 0f); + } + + private int defaultWidth() + { + return Cache.getDefault(BITMAP_WIDTH, 0); + } + + private int defaultHeight() + { + return Cache.getDefault(BITMAP_HEIGHT, 0); + } + + public float scale() + { + return isDefault() ? defaultScale() : scale; + } + + public int width() + { + return isDefault() ? defaultWidth() : width; + } + + public int height() + { + return isDefault() ? defaultHeight() : height; + } + + public boolean isDefault() + { + return isDefault; } }