mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 03:53:56 +00:00
avoid unnecessary HSV conversion when everything is an HSVColor anyhow
Change-Id: If01a348d864c5d73e636f00ef69cfad7f4e7a709
This commit is contained in:
1 parent
10fc56d287
commit
ba4d5e23be
1 file changed
+11
-6
+11
-6
@@ -89,14 +89,19 @@ public class ColorMapImpl<T> implements ColorMap<T> {
|
||||
* @return A color in hex/html-format (e.g. #ff0000)
|
||||
*/
|
||||
public Color getColorByID(T object) {
|
||||
final Color result;
|
||||
Color color = idColor.get(object);
|
||||
if (color == null) {
|
||||
HSVColor newColor;
|
||||
do {
|
||||
color = generateColor(colorCounter++);
|
||||
} while (isContainColor(blockedColors, convertFromColorToHSV(color)));
|
||||
idColor.put(object, color);
|
||||
newColor = generateColor(colorCounter++);
|
||||
} while (isContainColor(blockedColors, newColor));
|
||||
idColor.put(object, newColor);
|
||||
result = newColor;
|
||||
} else {
|
||||
result = color;
|
||||
}
|
||||
return color;
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isColorsClose(HSVColor blockedColor, HSVColor newColor) {
|
||||
@@ -130,7 +135,7 @@ public class ColorMapImpl<T> implements ColorMap<T> {
|
||||
|
||||
public boolean removeBlockedColor(Color color) {
|
||||
boolean result = false;
|
||||
if(color != null) {
|
||||
if (color != null) {
|
||||
result = blockedColors.remove(convertFromColorToHSV(color));
|
||||
}
|
||||
return result;
|
||||
@@ -157,7 +162,7 @@ public class ColorMapImpl<T> implements ColorMap<T> {
|
||||
* @return A color computed using the {@code index}.
|
||||
* @author Stsiapan_Tsybulski
|
||||
*/
|
||||
private Color generateColor(int index) {
|
||||
private HSVColor generateColor(int index) {
|
||||
int baseColorsCount = baseColors.length;
|
||||
int currentColorIndex = index % baseColorsCount;
|
||||
float saturationDecrease = STEP;
|
||||
|
||||
Reference in new issue
Block a user