-
Notifications
You must be signed in to change notification settings - Fork 2
Color Maps
Color Maps are a segment-based representation of PMWeather's ColorTables.
Each segment has a range of values, and the end of one segment is the start of the next. Each segment also has a start and end color, and the segment smoothly interpolates between them.
To create a Color Map, use the Builder pattern, defining the base color to use:
ColorMap.Builder builder = ColorMap.builder.of(Color.BLACK);Then, you must add points in sequential order of threshold values. 0.0 must come before 10.0, and 15.0 must come before 30.0. If you switch the order up, it will break
// Actual values here are from the PMWeather Reflectivity ColorMap
ColorMap.Builder builder = builder
.addPoint(new Color(0x5C9DAE), 19.0F)
.addPoint(new Color(0x0B6409), 27.0F)
.addPoint(new Color(0xC5B300), 40.0F)
.override(new Color(0xFA9400), 40.0F)
.addPoint(new Color(0xB2590C), 50.0F)
.override(new Color(0xF9230B), 50.0F)
.addPoint(new Color(0x822820), 60.0F)
.override(new Color(0xCA99B4), 60.0F)
.addPoint(new Color(0xC21C72), 70.0F)There are also two additional methods you can call depending on your needs:
// Values greater than an override threshold will use that color.
// Values equal to an override threshold will use the previous colors.
builder.overrideModeGreater();
// Sets the resolution of the lookup table.
// Defaults to 0.1F by default.
builder.lookupResolution(0.1F)To finish the builder, call #build
ColorMap reflectivity = builder.build(Color.WHITE, 70.0F)From here, you can use the map to get the color of a specific value:
Color color = ColorMaps.REFLECTIVITY.get(24.0F) // Returns Color(41, 121, 70);Some of PMWeather's Color Tables are in a ColorMaps class.
They are:
- Reflectivity
- Velocity (split into + and -)
- Windspeed
This is a graphic showing the values for each map based on the input value for the above ColorMaps
