Class DividedScale<T>

  • Type Parameters:
    T - the type of the data objects

    public class DividedScale<T>
    extends Object
    Splits the range of possible scale values (0 < scale < +Infinity) into multiple subranges, for each scale range it keeps a data object of a certain type T (can be null). Used for caching style information for different zoom levels. Immutable class, equals & hashCode is required (the same for StyleElementList, StyleElement and its subclasses).
    • Method Detail

      • get

        public T get​(double scale)
        Looks up the data object for a certain scale value.
        Parameters:
        scale - scale
        Returns:
        the data object at the given scale, can be null
      • getWithRange

        public Pair<T,​RangegetWithRange​(double scale)
        Looks up the data object for a certain scale value and additionally returns the scale range where the object is valid.
        Parameters:
        scale - scale
        Returns:
        pair containing data object and range
      • put

        public DividedScale<Tput​(T o,
                                   Range r)
        Add data object which is valid for the given range. This is only possible, if there is no data for the given range yet.
        Parameters:
        o - data object
        r - the valid range
        Returns:
        a new, updated, DividedScale object
      • putImpl

        private void putImpl​(T o,
                             double lower,
                             double upper)
        Implementation of the put operation. ASCII-art explanation: data[i-1] data[i] data[i+1 |--------------|------------|--------------| (--range[i-1]--] (--range[i]--] (--range[i+1]--] (--------] lower upper
        Parameters:
        o - data object
        lower - lower bound
        upper - upper bound