protected static <K> Map<K, Color> calculateScaling(Map<K, ? extends Number> scaling, Color colorMin, Color colorMax) {
		float min = Float.MAX_VALUE;
		float max = Float.MIN_VALUE;
		for(Number num : scaling.values()) {
			min = Math.min(min, num.floatValue());
			max = Math.max(max, num.floatValue());
		}

		float[] compMin = colorMin.getColorComponents(null);
		float[] compMax = colorMax.getColorComponents(null);
		
		Map<K, Color> colors = new HashMap<K, Color>();
		for(K key : scaling.keySet()) {
			if(min != max) {
				float s = (scaling.get(key).floatValue() - min) / (max - min);
				float[] comp = new float[] {
					s * (compMax[0] - compMin[0]) + compMin[0],
					s * (compMax[1] - compMin[1]) + compMin[1],
					s * (compMax[2] - compMin[2]) + compMin[2],
				};
				float alpha = ((s * (colorMax.getAlpha() - colorMin.getAlpha())) + colorMin.getAlpha()) / 255;
				colors.put(key, new Color(comp[0], comp[1], comp[2], alpha));
			}
			else {
				colors.put(key, colorMin);
			}
		}
		
		return colors;
	}