SEBSERV-57 fixed
This commit is contained in:
parent
a0ca72e3ea
commit
64b496e4ac
3 changed files with 24 additions and 12 deletions
|
@ -15,6 +15,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -247,14 +248,20 @@ public class POSTMapper {
|
|||
.map(ts -> {
|
||||
try {
|
||||
final String[] split = StringUtils.split(ts, Constants.EMBEDDED_LIST_SEPARATOR);
|
||||
return new Threshold(Double.parseDouble(
|
||||
split[0]),
|
||||
(split.length > 1) ? split[1] : null,
|
||||
(split.length > 2) ? split[2] : null);
|
||||
Double val = null;
|
||||
try {
|
||||
val = Double.parseDouble(split[0]);
|
||||
} catch (final Exception e) {
|
||||
}
|
||||
return new Threshold(
|
||||
val,
|
||||
(split.length > 1) ? Utils.parseColorString(Utils.parseRGB(split[1])) : null,
|
||||
(split.length > 2 && "null".equals(split[2])) ? split[2] : null);
|
||||
} catch (final Exception e) {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -578,6 +578,9 @@ public final class Utils {
|
|||
* @param rgb foreground or text color
|
||||
* @return true of the background color for given foreground color shall be dark or false if it shall be light */
|
||||
public static boolean darkColorContrast(final RGB rgb) {
|
||||
if (rgb == null) {
|
||||
return true;
|
||||
}
|
||||
return rgb.red + rgb.green + rgb.blue > DARK_COLOR_THRESHOLD;
|
||||
}
|
||||
|
||||
|
@ -592,15 +595,16 @@ public final class Utils {
|
|||
}
|
||||
|
||||
public static RGB parseRGB(final String colorString) {
|
||||
if (StringUtils.isBlank(colorString)) {
|
||||
try {
|
||||
|
||||
final int r = Integer.parseInt(colorString.substring(0, 2), 16);
|
||||
final int g = Integer.parseInt(colorString.substring(2, 4), 16);
|
||||
final int b = Integer.parseInt(colorString.substring(4, 6), 16);
|
||||
|
||||
return new RGB(r, g, b);
|
||||
} catch (final Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int r = Integer.parseInt(colorString.substring(0, 2), 16);
|
||||
final int g = Integer.parseInt(colorString.substring(2, 4), 16);
|
||||
final int b = Integer.parseInt(colorString.substring(4, 6), 16);
|
||||
|
||||
return new RGB(r, g, b);
|
||||
}
|
||||
|
||||
public static String toColorFractionString(final int fraction) {
|
||||
|
|
|
@ -121,11 +121,12 @@ public final class ThresholdList extends Composite {
|
|||
|
||||
public Collection<Threshold> getThresholds() {
|
||||
removeInvalidListEntries();
|
||||
return this.thresholds
|
||||
final List<Threshold> collect = this.thresholds
|
||||
.stream()
|
||||
.map(entry -> new Threshold(entry.getValue(), entry.getColor(),
|
||||
null /* TODO add icon selection here */))
|
||||
.collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
|
||||
private void removeInvalidListEntries() {
|
||||
|
|
Loading…
Reference in a new issue