Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
76276054
Commit
76276054
authored
Dec 19, 2019
by
Piotr Gawron
Browse files
coloring wasn't applied to center
parent
934a2dbd
Pipeline
#17977
canceled with stage
in 1 minute and 9 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
76276054
...
...
@@ -7,6 +7,8 @@ minerva (14.0.6) stable; urgency=medium
displayed at all (regresion 14.0.5, #1045)
* Bug fix: when there is a problem with database during removing project,
project removal doesn'
t
hang
(#
1058
)
*
Bug
fix
:
coloring
of
the
reaction
wasn
't applied to center of reaction
(#1057)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 18 Dec 2019 12:00:00 +0200
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/reaction/ReactionConverter.java
View file @
76276054
...
...
@@ -296,8 +296,15 @@ public class ReactionConverter extends BioEntityConverter<Reaction> {
* {@link ColorSchema} to modify reaction
*/
private
void
applyColorSchema
(
Reaction
reaction
,
ColorSchema
colorSchema
)
{
PolylineData
pd
=
new
PolylineData
(
reaction
.
getLine
());
pd
.
setColor
(
colorExtractor
.
getNormalizedColor
(
colorSchema
));
if
(
colorSchema
.
getLineWidth
()
!=
null
)
{
pd
.
setWidth
(
colorSchema
.
getLineWidth
());
}
reaction
.
setLine
(
pd
);
for
(
AbstractNode
node
:
reaction
.
getNodes
())
{
PolylineData
pd
=
new
PolylineData
(
node
.
getLine
());
pd
=
new
PolylineData
(
node
.
getLine
());
pd
.
setColor
(
colorExtractor
.
getNormalizedColor
(
colorSchema
));
if
(
colorSchema
.
getLineWidth
()
!=
null
)
{
pd
.
setWidth
(
colorSchema
.
getLineWidth
());
...
...
model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java
View file @
76276054
...
...
@@ -81,13 +81,17 @@ public class ColorModelCommand extends ModelCommand {
* @throws InvalidColorSchemaException
* thrown when {@link Reaction} was already colored by other schema
*/
private
void
applyColor
(
Reaction
reaction
,
ColorSchema
schema
)
throws
InvalidColorSchemaException
{
void
applyColor
(
Reaction
reaction
,
ColorSchema
schema
)
throws
InvalidColorSchemaException
{
if
(!
reaction
.
getReactants
().
get
(
0
).
getLine
().
getColor
().
equals
(
Color
.
BLACK
))
{
throw
new
InvalidColorSchemaException
(
"At least two rows try to set color to reaction: "
+
reaction
.
getIdReaction
());
}
Color
color
=
colorExtractor
.
getNormalizedColor
(
schema
);
reaction
.
getLine
().
setColor
(
color
);
if
(
schema
.
getLineWidth
()
!=
null
)
{
reaction
.
getLine
().
setWidth
(
schema
.
getLineWidth
());
}
for
(
AbstractNode
node
:
reaction
.
getNodes
())
{
node
.
getLine
().
setColor
(
color
);
if
(
schema
.
getLineWidth
()
!=
null
)
{
...
...
@@ -342,6 +346,7 @@ public class ColorModelCommand extends ModelCommand {
element
.
setGlyph
(
null
);
}
for
(
Reaction
reaction
:
result
.
getReactions
())
{
reaction
.
getLine
().
setColor
(
Color
.
BLACK
);
for
(
AbstractNode
node
:
reaction
.
getNodes
())
{
node
.
getLine
().
setColor
(
Color
.
BLACK
);
}
...
...
model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java
View file @
76276054
...
...
@@ -2,9 +2,8 @@ package lcsb.mapviewer.commands;
import
static
org
.
junit
.
Assert
.*;
import
java.awt.
*
;
import
java.awt.
Color
;
import
java.util.*
;
import
java.util.List
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -460,4 +459,21 @@ public class ColorModelCommandTest extends CommandTestFunctions {
assertNotNull
(
factory
.
getModifiedElements
().
get
(
reaction
));
}
@Test
public
void
testApplyColorToReaction
()
throws
Exception
{
Model
model
=
getModelForFile
(
"testFiles/sample.xml"
,
false
);
Reaction
re4
=
model
.
getReactionByReactionId
(
"re1"
);
ColorSchema
schema
=
new
GenericColorSchema
();
schema
.
setElementId
(
"re1"
);
schema
.
setColor
(
Color
.
YELLOW
);
schema
.
setName
(
null
);
ColorModelCommand
factory
=
new
ColorModelCommand
(
model
,
new
ArrayList
<>(),
colorExtractor
);
factory
.
applyColor
(
re4
,
schema
);
assertEquals
(
Color
.
YELLOW
,
re4
.
getLine
().
getColor
());
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment