Class StyleCache


  • public final class StyleCache
    extends java.lang.Object
    Caches styles for a single primitive.

    This object is immutable.

    • Method Detail

      • put

        public StyleCache put​(StyleElementList o,
                              Range r,
                              boolean selected)
        Creates a new copy of this style cache with a new entry added.
        Parameters:
        o - The style to cache.
        r - The range the style is for.
        selected - The style list we should use (selected/unselected)
        Returns:
        The new object.
      • getWithRange

        public Pair<StyleElementList,​RangegetWithRange​(double scale,
                                                               boolean selected)
        Get the style for a specific style. Returns the range as well.
        Parameters:
        scale - The current scale
        selected - true to get the state for a selected element,
        Returns:
        The style and the range it is valid for.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • intern

        private StyleCache intern()
        Like String.intern() (reduce memory consumption). StyleCache must not be changed after it has been added to the intern pool.
        Returns:
        style cache
      • clearStyleCachePool

        static void clearStyleCachePool()
        Clears the style cache. This should only be used for testing. It may be removed some day and replaced by a WeakReference implementation that automatically forgets old entries.
      • getInternPoolSize

        public static int getInternPoolSize()
        Get the size of the intern pool. Only for tests!
        Returns:
        size of the intern pool