s3db: use non-exception version of parseColor
This commit is contained in:
parent
fd941858dd
commit
aa4a1de6f7
@ -223,4 +223,19 @@ public class Color {
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown color");
|
||||
}
|
||||
|
||||
public static int parseColor(String colorString, int fallBackColor) {
|
||||
if (colorString.charAt(0) == '#') {
|
||||
// Use a long to avoid rollovers on #ffXXXXXX
|
||||
long color = Long.parseLong(colorString.substring(1), 16);
|
||||
if (colorString.length() == 7) {
|
||||
// Set the alpha value
|
||||
color |= 0x00000000ff000000;
|
||||
} else if (colorString.length() != 9) {
|
||||
return fallBackColor;
|
||||
}
|
||||
return (int) color;
|
||||
}
|
||||
return fallBackColor;
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,11 +55,8 @@ public class S3DBLayer extends TileLayer {
|
||||
|
||||
static int getColor(String color, boolean roof) {
|
||||
|
||||
try {
|
||||
return Color.parseColor(color);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
if (color.charAt(0) == '#')
|
||||
return Color.parseColor(color, Color.CYAN);
|
||||
|
||||
if (roof) {
|
||||
if ("brown" == color)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user