Class DividedScale<T>
java.lang.Object
org.openstreetmap.josm.gui.mappaint.DividedScale<T>
- Type Parameters:
T- the type of the data objects
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).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis exception type is for debugging #8997 and can later be replaced by AssertionError -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRuns a consistency test.booleanget(double scale) Looks up the data object for a certain scale value.getWithRange(double scale) Looks up the data object for a certain scale value and additionally returns the scale range where the object is valid.inthashCode()Add data object which is valid for the given range.private voidImplementation of theputoperation.toString()
-
Field Details
-
ranges
-
data
-
-
Constructor Details
-
DividedScale
protected DividedScale() -
DividedScale
-
-
Method Details
-
get
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
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
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 objectr- the valid range- Returns:
- a new, updated,
DividedScaleobject
-
putImpl
Implementation of theputoperation. ASCII-art explanation: data[i-1] data[i] data[i+1 |--------------|------------|--------------| (--range[i-1]--] (--range[i]--] (--range[i+1]--] (--------] lower upper- Parameters:
o- data objectlower- lower boundupper- upper bound
-
consistencyTest
Runs a consistency test.- Throws:
AssertionError- When an invariant is broken.
-
equals
-
hashCode
-
toString
-