2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.util.imagemaker;
23 import jalview.bin.Cache;
25 public class BitmapImageSizing
27 private final float scale;
29 private final int width;
31 private final int height;
33 private boolean isDefault = false;
35 public BitmapImageSizing(float scale, int width, int height,
41 this.isDefault = isDefault;
44 public boolean isNull()
46 return scale == 0.0f && width == 0 && height == 0;
49 public static BitmapImageSizing nullBitmapImageSizing()
51 return new BitmapImageSizing(0.0f, 0, 0, false);
54 public static final String BITMAP_SCALE = "BITMAP_SCALE";
56 public static final String BITMAP_HEIGHT = "BITMAP_HEIGHT";
58 public static final String BITMAP_WIDTH = "BITMAP_WIDTH";
62 * @return bean configured from Cache keys
64 public static BitmapImageSizing defaultBitmapImageSizing()
66 return new BitmapImageSizing(0f, 0, 0, true);
69 private float defaultScale()
71 return Cache.getDefault(BITMAP_SCALE, 0f);
74 private int defaultWidth()
76 return Cache.getDefault(BITMAP_WIDTH, 0);
79 private int defaultHeight()
81 return Cache.getDefault(BITMAP_HEIGHT, 0);
86 return isDefault() ? defaultScale() : scale;
91 return isDefault() ? defaultWidth() : width;
96 return isDefault() ? defaultHeight() : height;
99 public boolean isDefault()