org.openstreetmap.josm.gui.mappaint
Class StyleCache

java.lang.Object
  extended by org.openstreetmap.josm.gui.mappaint.StyleCache

public class StyleCache
extends java.lang.Object

Caches styles for a single primitive. Splits the range of possible scale values (0 < scale < +Infinity) into multiple subranges, for each scale range it keeps a list of styles. Immutable class, equals & hashCode is required (the same for StyleList, ElemStyle and its subclasses).


Nested Class Summary
static class StyleCache.StyleList
          List of Styles, immutable
 
Field Summary
(package private)  java.util.ArrayList<java.lang.Double> bd
           
(package private)  java.util.ArrayList<StyleCache.StyleList> data
           
static StyleCache EMPTY_STYLECACHE
           
private static Storage<StyleCache> internPool
           
 
Constructor Summary
private StyleCache()
           
private StyleCache(StyleCache s)
           
 
Method Summary
 void consistencyTest()
           
 boolean equals(java.lang.Object obj)
           
 StyleCache.StyleList get(double scale)
          looks up styles for a certain scale value
 Pair<StyleCache.StyleList,Range> getWithRange(double scale)
          looks up styles for a certain scale value and additionally returns the scale range for the returned styles
 int hashCode()
           
 StyleCache intern()
          Like String.intern() (reduce memory consumption).
 StyleCache put(StyleCache.StyleList sl, double lower, double upper)
          add a new styles to the cache.
 StyleCache put(StyleCache.StyleList sl, Range r)
           
private  void putImpl(StyleCache.StyleList sl, double lower, double upper)
          ASCII-art explanation: data[i] --|-------|---------|-- bd[i-1] bd[i] bd[i+1] (--------] lower upper
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

bd

java.util.ArrayList<java.lang.Double> bd

data

java.util.ArrayList<StyleCache.StyleList> data

internPool

private static final Storage<StyleCache> internPool

EMPTY_STYLECACHE

public static final StyleCache EMPTY_STYLECACHE
Constructor Detail

StyleCache

private StyleCache()

StyleCache

private StyleCache(StyleCache s)
Method Detail

get

public StyleCache.StyleList get(double scale)
looks up styles for a certain scale value


getWithRange

public Pair<StyleCache.StyleList,Range> getWithRange(double scale)
looks up styles for a certain scale value and additionally returns the scale range for the returned styles


put

public StyleCache put(StyleCache.StyleList sl,
                      Range r)

put

public StyleCache put(StyleCache.StyleList sl,
                      double lower,
                      double upper)
add a new styles to the cache. this is only possible, if for this scale range, there is nothing in the cache yet.


putImpl

private void putImpl(StyleCache.StyleList sl,
                     double lower,
                     double upper)
ASCII-art explanation: data[i] --|-------|---------|-- bd[i-1] bd[i] bd[i+1] (--------] lower upper


consistencyTest

public void consistencyTest()

intern

public StyleCache intern()
Like String.intern() (reduce memory consumption). StyleCache must not be changed after it has been added to the intern pool.


equals

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

hashCode

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

toString

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


JOSM