Ignore:
Timestamp:
2018-11-07T22:38:38+01:00 (5 years ago)
Author:
michael2402
Message:

Fix #16945: Only store changed overpass height if user changes it. Add minimum size to overpass query / map view

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadSourceSizingPolicy.java

    r12707 r14418  
    33
    44import java.awt.Component;
     5import java.util.function.IntSupplier;
    56
    67import org.openstreetmap.josm.data.preferences.AbstractProperty;
     
    6768
    6869        private final AbstractProperty<Integer> preference;
     70        private IntSupplier minHeight;
    6971
    7072        /**
    7173         * Create a new {@link AdjustableDownloadSizePolicy}
    72          * @param preference The preference key to use
     74         * @param preference The preference to use
    7375         */
    7476        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) {
    7587            this.preference = preference;
     88            this.minHeight = minHeight;
    7689        }
    7790
    7891        @Override
    7992        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());
    8198        }
    8299
Note: See TracChangeset for help on using the changeset viewer.