Merge branch 'releases/Release_2_11_3_Branch'
[jalview.git] / src / jalview / util / imagemaker / BitmapImageSizing.java
index 8bd8ec3..0ff24b0 100644 (file)
@@ -1,20 +1,44 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.util.imagemaker;
 
 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()
@@ -24,7 +48,7 @@ public class BitmapImageSizing
 
   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";
@@ -39,10 +63,41 @@ public class BitmapImageSizing
    */
   public static BitmapImageSizing defaultBitmapImageSizing()
   {
+    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;
+  }
 
-    return new BitmapImageSizing(Cache.getDefault(BITMAP_SCALE, 0) / 10f,
-            Cache.getDefault(BITMAP_WIDTH, 0),
-            Cache.getDefault(BITMAP_HEIGHT, 0));
+  public int height()
+  {
+    return isDefault() ? defaultHeight() : height;
+  }
 
+  public boolean isDefault()
+  {
+    return isDefault;
   }
 }