Class StyleCache
java.lang.Object
org.openstreetmap.josm.gui.mappaint.StyleCache
Caches styles for a single primitive.
This object is immutable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StyleCacheAn empty style cache entryprivate static final Map<StyleCache,StyleCache> private DividedScale<StyleElementList>private DividedScale<StyleElementList> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidClears the style cache.booleanstatic intGet the size of the intern pool.getWithRange(double scale, boolean selected) Get the style for a specific style.inthashCode()private StyleCacheintern()Like String.intern() (reduce memory consumption).put(StyleElementList o, Range r, boolean selected) Creates a new copy of this style cache with a new entry added.private static DividedScale<StyleElementList>scale(DividedScale<StyleElementList> scale) toString()
-
Field Details
-
internPool
-
EMPTY_STYLECACHE
An empty style cache entry -
plainStyle
-
selectedStyle
-
-
Constructor Details
-
StyleCache
-
StyleCache
private StyleCache()
-
-
Method Details
-
put
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.
-
scale
-
getWithRange
Get the style for a specific style. Returns the range as well.- Parameters:
scale- The current scaleselected- true to get the state for a selected element,- Returns:
- The style and the range it is valid for.
-
toString
-
hashCode
-
equals
-
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
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
Get the size of the intern pool. Only for tests!- Returns:
- size of the intern pool
-