Skip to content
Snippets Groups Projects
Commit 8628ce0e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

optimization: model.getBioEntities is computed per call - changing order increase speed by 2

parent 38a94dbf
No related branches found
No related tags found
1 merge request!195Resolve "data overlay with miriam ids"
Pipeline #
......@@ -4,8 +4,10 @@ import java.awt.Color;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
......@@ -289,9 +291,10 @@ public class ColorModelCommand extends ModelCommand {
List<Model> models = new ArrayList<>();
models.add(getModel());
models.addAll(getModel().getSubmodels());
for (Model model : models) {
for (ColorSchema schema : schemas) {
for (BioEntity element : model.getBioEntities()) {
for (BioEntity element : model.getBioEntities()) {
for (ColorSchema schema : schemas) {
if (match(element, schema)) {
if (result.get(element) != null
&& !colorExtractor.getNormalizedColor(result.get(element)).equals(Color.WHITE)) {
......
......@@ -2,6 +2,7 @@ package lcsb.mapviewer.commands;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.awt.Color;
......@@ -537,4 +538,32 @@ public class ColorModelCommandTest extends CommandTestFunctions {
}
}
@Test
public void testGetModifiedElements() throws Exception {
try {
Reaction reaction = new Reaction();
reaction.addMiriamData(new MiriamData(MiriamType.PUBMED, "1234"));
Model model = new ModelFullIndexed(null);
model.addReaction(reaction);
GenericColorSchema colorSchema = new GenericColorSchema();
colorSchema.addMiriamData(new MiriamData(MiriamType.PUBMED,"1234"));
List<ColorSchema> schemas = new ArrayList<>();
schemas.add(colorSchema);
ColorModelCommand factory = new ColorModelCommand(model, schemas, colorExtractor);
assertNotNull(factory.getModifiedElements().get(reaction));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment