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
Merge requests
!1473
consider situations where there are custom colors in genetic overlay
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
consider situations where there are custom colors in genetic overlay
1686-legend
into
devel_16.1.x
Overview
0
Commits
1
Pipelines
1
Changes
3
Merged
Piotr Gawron
requested to merge
1686-legend
into
devel_16.1.x
2 years ago
Overview
0
Commits
1
Pipelines
1
Changes
3
Expand
Closes
#1686 (closed)
0
0
Merge request reports
Compare
devel_16.1.x
devel_16.1.x (base)
and
latest version
latest version
4049d4f8
1 commit,
2 years ago
3 files
+
24
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/LegendGenerator.java
+
19
−
8
Options
@@ -80,22 +80,33 @@ public class LegendGenerator {
Color
oldColor
=
graphics
.
getColor
();
Font
oldFont
=
graphics
.
getFont
();
Map
<
Integer
,
Color
>
color
s
=
new
HashMap
<>();
Map
<
Integer
,
Set
<
Color
>
>
color
ByCount
=
new
HashMap
<>();
for
(
DataOverlayEntry
entry
:
overlay
.
getEntries
())
{
colors
.
put
(((
GeneVariantDataOverlayEntry
)
entry
).
getGeneVariants
().
size
(),
colorExtractor
.
getNormalizedColor
(
entry
));
int
count
=
((
GeneVariantDataOverlayEntry
)
entry
).
getGeneVariants
().
size
();
Set
<
Color
>
colors
=
colorByCount
.
get
(
count
);
if
(
colors
==
null
)
{
colors
=
new
HashSet
<>();
colorByCount
.
put
(
count
,
colors
);
}
colors
.
add
(
colorExtractor
.
getNormalizedColor
(
entry
));
}
int
width
=
WIDTH
-
2
*
MARGIN
;
double
elementWidth
=
((
double
)
width
)
/
(
double
)
(
color
s
.
size
());
double
elementWidth
=
((
double
)
width
)
/
(
double
)
(
color
ByCount
.
size
());
List
<
Integer
>
counters
=
new
ArrayList
<>(
color
s
.
keySet
());
List
<
Integer
>
counters
=
new
ArrayList
<>(
color
ByCount
.
keySet
());
Collections
.
sort
(
counters
);
for
(
int
i
=
0
;
i
<
counters
.
size
();
i
++)
{
int
count
=
counters
.
get
(
i
);
Rectangle2D
rectangle
=
new
Rectangle2D
.
Double
(
MARGIN
+
i
*
elementWidth
,
MARGIN
,
elementWidth
,
COLOR_HEIGHT
);
graphics
.
setColor
(
colors
.
get
(
count
));
graphics
.
fill
(
rectangle
);
List
<
Color
>
colors
=
new
ArrayList
<>(
colorByCount
.
get
(
count
));
for
(
int
j
=
0
;
j
<
colors
.
size
();
j
++)
{
Color
color
=
colors
.
get
(
j
);
double
x
=
MARGIN
+
i
*
elementWidth
+
elementWidth
/
colors
.
size
()
*
j
;
Rectangle2D
rectangle
=
new
Rectangle2D
.
Double
(
x
,
MARGIN
,
elementWidth
/
colors
.
size
(),
COLOR_HEIGHT
);
graphics
.
setColor
(
color
);
graphics
.
fill
(
rectangle
);
}
}
graphics
.
setFont
(
new
Font
(
Font
.
SANS_SERIF
,
0
,
18
));
@@ -196,7 +207,7 @@ public class LegendGenerator {
for
(
int
i
=
0
;
i
<
width
;
i
++)
{
Rectangle2D
rectangle
=
new
Rectangle2D
.
Double
(
MARGIN
+
i
,
MARGIN
,
1
,
COLOR_HEIGHT
);
GenericDataOverlayEntry
entry
=
new
GenericDataOverlayEntry
();
entry
.
setValue
(
((
double
)
(
i
-
width
/
2
)
)
/
(
double
)
(
width
/
2.0
));
entry
.
setValue
((
i
-
width
/
2
)
/
(
width
/
2.0
));
graphics
.
setColor
(
colorExtractor
.
getNormalizedColor
(
entry
));
graphics
.
fill
(
rectangle
);
}
Loading