Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Devrim Gunyel
core
Commits
6ccf2fdf
Commit
6ccf2fdf
authored
Nov 11, 2019
by
Piotr Gawron
Browse files
parsing of colors without hash didn't work
parent
4deed6ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java
View file @
6ccf2fdf
package
lcsb.mapviewer.common.geometry
;
import
java.awt.
*
;
import
java.awt.
Color
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -57,6 +57,9 @@ public class ColorParser {
"Invalid color value: "
+
string
+
". Correct format: #xxxxxx (where x is a hex value)"
);
}
if
(
string
.
charAt
(
0
)
!=
'#'
)
{
string
=
"#"
+
string
;
}
if
(
string
.
length
()
==
COLOR_STRING_LENGTH_WITHOUT_ALPHA
)
{
return
parseColorWithoutAlpha
(
string
);
}
else
{
...
...
@@ -100,14 +103,14 @@ public class ColorParser {
public
Color
parseColorWithAlpha
(
String
string
)
{
if
(
string
==
null
||
string
.
isEmpty
())
{
throw
new
InvalidArgumentException
(
"Invalid color value: "
+
string
+
". Correct format: #xxxxxx (where x is a hex value)"
);
"Invalid color value: "
+
string
+
". Correct format: #xxxxxx
xx
(where x is a hex value)"
);
}
if
(
string
.
charAt
(
0
)
!=
'#'
)
{
string
=
"#"
+
string
;
}
if
(
string
.
length
()
!=
COLOR_STRING_LENGTH_WITH_ALPHA
)
{
throw
new
InvalidArgumentException
(
"Invalid color value: "
+
string
+
". Correct format: #xxxxxx (where x is a hex value)"
);
"Invalid color value: "
+
string
+
". Correct format: #xxxxxx
xx
(where x is a hex value)"
);
}
else
{
return
new
Color
(
Integer
.
valueOf
(
string
.
substring
(
COLOR_SUBSTRING_START_RED
,
COLOR_SUBSTRING_START_GREEN
),
HEX_BASE
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment