Commit 302aeb8a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

structural state should be between species and reaction

parent b13c6e18
...@@ -4,6 +4,7 @@ import java.util.ArrayList; ...@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Set;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -13,12 +14,13 @@ import lcsb.mapviewer.common.comparator.DoubleComparator; ...@@ -13,12 +14,13 @@ import lcsb.mapviewer.common.comparator.DoubleComparator;
import lcsb.mapviewer.common.comparator.StringComparator; import lcsb.mapviewer.common.comparator.StringComparator;
import lcsb.mapviewer.model.map.Drawable; import lcsb.mapviewer.model.map.Drawable;
import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
import lcsb.mapviewer.model.map.species.field.SpeciesWithModificationResidue;
import lcsb.mapviewer.model.map.species.field.StructuralState; import lcsb.mapviewer.model.map.species.field.StructuralState;
/** /**
...@@ -41,18 +43,7 @@ public class ZIndexPopulator { ...@@ -41,18 +43,7 @@ public class ZIndexPopulator {
* z-values. * z-values.
*/ */
public void populateZIndex(final Model model) { public void populateZIndex(final Model model) {
List<Drawable> drawables = new ArrayList<>(); Set<Drawable> drawables = model.getDrawables();
for (Layer layer : model.getLayers()) {
drawables.addAll(layer.getOvals());
drawables.addAll(layer.getRectangles());
drawables.addAll(layer.getTexts());
}
drawables.addAll(model.getBioEntities());
for (Species species : model.getSpeciesList()) {
if (species.getStructuralState() != null) {
drawables.add(species.getStructuralState());
}
}
populateZIndex(drawables); populateZIndex(drawables);
...@@ -129,6 +120,16 @@ public class ZIndexPopulator { ...@@ -129,6 +120,16 @@ public class ZIndexPopulator {
for (final Drawable drawable : sortedDrawables) { for (final Drawable drawable : sortedDrawables) {
if (drawable.getZ() == null) { if (drawable.getZ() == null) {
drawable.setZ(++maxZIndex); drawable.setZ(++maxZIndex);
if (drawable instanceof Species) {
if (((Species) drawable).getStructuralState() != null) {
((Species) drawable).getStructuralState().setZ(++maxZIndex);
}
}
if (drawable instanceof SpeciesWithModificationResidue) {
for (ModificationResidue mr : ((SpeciesWithModificationResidue) drawable).getModificationResidues()) {
mr.setZ(++maxZIndex);
}
}
} }
} }
} }
......
...@@ -96,7 +96,7 @@ public class ZIndexPopulatorTest { ...@@ -96,7 +96,7 @@ public class ZIndexPopulatorTest {
} }
@Test @Test
public void testZIndexReactionShouldBeBeforeElement() { public void testZIndexReactionShouldBeAfterStructuralState() {
Model model = new ModelFullIndexed(null); Model model = new ModelFullIndexed(null);
Species species = createProtein(); Species species = createProtein();
StructuralState state = new StructuralState(); StructuralState state = new StructuralState();
...@@ -114,8 +114,9 @@ public class ZIndexPopulatorTest { ...@@ -114,8 +114,9 @@ public class ZIndexPopulatorTest {
populator.populateZIndex(model); populator.populateZIndex(model);
assertTrue(reaction.getZ() > species.getZ()); assertTrue(reaction.getZ() > species.getZ());
// structural state should be over reaction and species // structural state should be below reaction and above species
assertTrue(species.getStructuralState().getZ() > reaction.getZ()); assertTrue(species.getStructuralState().getZ() < reaction.getZ());
assertTrue(species.getStructuralState().getZ() > species.getZ());
} }
@Test @Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment