Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
core
Commits
6ccf2fdf
Commit
6ccf2fdf
authored
5 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
parsing of colors without hash didn't work
parent
4deed6ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1009
Resolve "when processing color codes allow colors with alpha"
Pipeline
#16540
failed
5 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java
+6
-3
6 additions, 3 deletions
...main/java/lcsb/mapviewer/common/geometry/ColorParser.java
with
6 additions
and
3 deletions
commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java
+
6
−
3
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
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment