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
7a031fdc
Commit
7a031fdc
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
common functionality for match and apply coloring added
parent
4cabe7e5
No related branches found
No related tags found
1 merge request
!171
Resolve "data overlay should support element id"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java
+33
-31
33 additions, 31 deletions
.../main/java/lcsb/mapviewer/commands/ColorModelCommand.java
with
33 additions
and
31 deletions
model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java
+
33
−
31
View file @
7a031fdc
...
...
@@ -11,6 +11,7 @@ import org.apache.log4j.Logger;
import
lcsb.mapviewer.common.Pair
;
import
lcsb.mapviewer.common.comparator.StringComparator
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.model.graphics.ArrowTypeData
;
import
lcsb.mapviewer.model.map.BioEntity
;
...
...
@@ -189,6 +190,22 @@ public class ColorModelCommand extends ModelCommand {
}
}
protected
boolean
match
(
BioEntity
element
,
ColorSchema
schema
)
{
if
(
schema
.
getElementId
()
!=
null
&&
!
schema
.
getElementId
().
isEmpty
())
{
if
(!
element
.
getElementId
().
equalsIgnoreCase
(
schema
.
getElementId
()))
{
return
false
;
}
}
if
(
element
instanceof
Element
)
{
return
match
((
Element
)
element
,
schema
);
}
else
if
(
element
instanceof
Reaction
)
{
return
match
((
Reaction
)
element
,
schema
);
}
else
{
throw
new
InvalidArgumentException
(
"Don't know how to handle object: "
+
element
);
}
}
/**
* Checks if the coloring schema should be used for the {@link Element}.
*
...
...
@@ -209,11 +226,6 @@ public class ColorModelCommand extends ModelCommand {
return
false
;
}
}
if
(
schema
.
getElementId
()
!=
null
&&
!
schema
.
getElementId
().
isEmpty
())
{
if
(!
element
.
getElementId
().
equalsIgnoreCase
(
schema
.
getElementId
()))
{
return
false
;
}
}
if
(
schema
.
getTypes
().
size
()
>
0
)
{
boolean
found
=
false
;
for
(
Class
<?>
clazz
:
schema
.
getTypes
())
{
...
...
@@ -277,16 +289,12 @@ public class ColorModelCommand extends ModelCommand {
List
<
ColorSchema
>
result
=
new
ArrayList
<
ColorSchema
>();
for
(
ColorSchema
schema
:
schemas
)
{
boolean
found
=
false
;
for
(
Element
element
:
getModel
().
getElements
())
{
for
(
BioEntity
element
:
getModel
().
getBioEntities
())
{
if
(
match
(
element
,
schema
))
{
found
=
true
;
}
}
for
(
Reaction
reaction
:
getModel
().
getReactions
())
{
if
(
match
(
reaction
,
schema
))
{
found
=
true
;
}
}
if
(!
found
)
{
result
.
add
(
schema
);
}
...
...
@@ -310,28 +318,18 @@ public class ColorModelCommand extends ModelCommand {
List
<
Model
>
models
=
new
ArrayList
<>();
models
.
add
(
getModel
());
models
.
addAll
(
getModel
().
getSubmodels
());
for
(
Model
model
2
:
models
)
{
for
(
Model
model
:
models
)
{
for
(
ColorSchema
schema
:
schemas
)
{
for
(
Element
element
:
model
2
.
get
Element
s
())
{
for
(
BioEntity
element
:
model
.
get
BioEntitie
s
())
{
if
(
match
(
element
,
schema
))
{
if
(
result
.
get
(
element
)
!=
null
&&
!
colorExtractor
.
getNormalizedColor
(
result
.
get
(
element
)).
equals
(
Color
.
WHITE
))
{
throw
new
InvalidColorSchemaException
(
eu
.
getElementTag
(
element
)
+
"
Element
is colored by more than one rule."
);
eu
.
getElementTag
(
element
)
+
"
BioEntity
is colored by more than one rule."
);
}
result
.
put
(
element
,
schema
);
}
}
for
(
Reaction
reaction
:
model2
.
getReactions
())
{
if
(
match
(
reaction
,
schema
))
{
if
(
result
.
get
(
reaction
)
!=
null
&&
!
colorExtractor
.
getNormalizedColor
(
result
.
get
(
reaction
)).
equals
(
Color
.
WHITE
))
{
throw
new
InvalidColorSchemaException
(
eu
.
getElementTag
(
reaction
)
+
"Reaction is colored by more than one rule."
);
}
result
.
put
(
reaction
,
schema
);
}
}
}
}
return
result
;
...
...
@@ -371,18 +369,12 @@ public class ColorModelCommand extends ModelCommand {
}
for
(
ColorSchema
schema
:
schemas
)
{
for
(
Element
element
:
result
.
get
Element
s
())
{
for
(
BioEntity
element
:
result
.
get
BioEntitie
s
())
{
if
(
match
(
element
,
schema
))
{
schema
.
setMatches
(
schema
.
getMatches
()
+
1
);
applyColor
(
element
,
schema
);
}
}
for
(
Reaction
reaction
:
result
.
getReactions
())
{
if
(
match
(
reaction
,
schema
))
{
schema
.
setMatches
(
schema
.
getMatches
()
+
1
);
applyColor
(
reaction
,
schema
);
}
}
}
if
(
top
)
{
...
...
@@ -393,6 +385,16 @@ public class ColorModelCommand extends ModelCommand {
}
private
void
applyColor
(
BioEntity
element
,
ColorSchema
schema
)
throws
InvalidColorSchemaException
{
if
(
element
instanceof
Element
)
{
applyColor
((
Element
)
element
,
schema
);
}
else
if
(
element
instanceof
Reaction
)
{
applyColor
((
Reaction
)
element
,
schema
);
}
else
{
throw
new
InvalidArgumentException
(
"Don't know how to handle: "
+
element
);
}
}
@Override
protected
void
executeImplementation
()
throws
CommandExecutionException
{
try
{
...
...
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