Changeset 14418 in josm for trunk/src/org/openstreetmap/josm/gui/download/DownloadSourceSizingPolicy.java
- Timestamp:
- 2018-11-07T22:38:38+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/DownloadSourceSizingPolicy.java
r12707 r14418 3 3 4 4 import java.awt.Component; 5 import java.util.function.IntSupplier; 5 6 6 7 import org.openstreetmap.josm.data.preferences.AbstractProperty; … … 67 68 68 69 private final AbstractProperty<Integer> preference; 70 private IntSupplier minHeight; 69 71 70 72 /** 71 73 * Create a new {@link AdjustableDownloadSizePolicy} 72 * @param preference The preference keyto use74 * @param preference The preference to use 73 75 */ 74 76 public AdjustableDownloadSizePolicy(AbstractProperty<Integer> preference) { 77 this(preference, () -> 1); 78 } 79 80 /** 81 * Create a new {@link AdjustableDownloadSizePolicy} 82 * @param preference The preference to use 83 * @param minHeight A supplier that gives the minimum height of the component. Must be positive or 0. 84 * @since 14418 85 */ 86 public AdjustableDownloadSizePolicy(AbstractProperty<Integer> preference, IntSupplier minHeight) { 75 87 this.preference = preference; 88 this.minHeight = minHeight; 76 89 } 77 90 78 91 @Override 79 92 public int getComponentHeight() { 80 return Math.max(1, preference.get()); 93 int computedMinHeight = this.minHeight.getAsInt(); 94 if (computedMinHeight < 0) { 95 throw new IllegalStateException("Illegal minimum component height:" + computedMinHeight); 96 } 97 return Math.max(computedMinHeight, preference.get()); 81 98 } 82 99
Note:
See TracChangeset
for help on using the changeset viewer.