1 package org.simantics.district.network.visualisations.model;
4 import java.util.Arrays;
7 public class DynamicColorMap {
9 static List<RGBIntensity> blues = Arrays.asList(new RGBIntensity(0, 0, 0.1), new RGBIntensity(0, 0, 0.5), new RGBIntensity(0, 0, 0.9));
11 public static final DynamicColorMap DEFAULT = new DynamicColorMap("default", blues);
14 private List<RGBIntensity> intensities;
16 public DynamicColorMap(String label, List<RGBIntensity> intensities) {
18 this.intensities = intensities;
21 public String getLabel() {
25 public List<RGBIntensity> getIntensities() {
29 public static class RGBIntensity {
35 public RGBIntensity(double red, double green, double blue) {
41 public double getRed() {
45 public double getGreen() {
49 public double getBlue() {
54 public Color getColor(double value, double defaultMin, double defaultMax) {
56 double gap = defaultMax - defaultMin;
57 double singleGap = gap / getIntensities().size();
60 while (i < getIntensities().size() - 1) {
61 if (value <= defaultMin + (i * singleGap)) {
67 RGBIntensity intensity = getIntensities().get(i);
68 return new Color((float)intensity.getRed(), (float)intensity.getGreen(), (float)intensity.getBlue());