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

compartments have parent compartments assigned

parent a3512012
No related branches found
No related tags found
1 merge request!44Resolve "semantic zoom"
......@@ -62,6 +62,7 @@ import lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction;
import lcsb.mapviewer.model.map.reaction.type.UnknownTransitionReaction;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Degraded;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Gene;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Phenotype;
......@@ -622,49 +623,58 @@ public class SbgnmlXmlParser {
}
}
parseAlias(g, newSpecies, model);
parseSpecies(g, newSpecies, model);
}
/**
* Method used to create a new alias from SBGN-ML glyph.
*
* @param g
* @param glyph
* SBGN-ML glyph representing the alias
* @param newSpecies
* @param species
* species of the alias
* @param model
* model to be updated
*/
private void parseAlias(Glyph g, Species newSpecies, Model model) {
newSpecies.setHeight(new Double(g.getBbox().getH()));
newSpecies.setWidth(new Double(g.getBbox().getW()));
newSpecies.setX(new Double(g.getBbox().getX()));
newSpecies.setY(new Double(g.getBbox().getY()));
private void parseSpecies(Glyph glyph, Species species, Model model) {
species.setHeight(new Double(glyph.getBbox().getH()));
species.setWidth(new Double(glyph.getBbox().getW()));
species.setX(new Double(glyph.getBbox().getX()));
species.setY(new Double(glyph.getBbox().getY()));
Compartment parentCompartment = null;
if (g.getCompartmentRef() != null) {
Glyph compartmentGlyph = (Glyph) g.getCompartmentRef();
if (glyph.getCompartmentRef() != null) {
Glyph compartmentGlyph = (Glyph) glyph.getCompartmentRef();
parentCompartment = model.getElementByElementId(compartmentGlyph.getId());
} else if (newSpecies.getComplex() == null) {
// If the alias is in any compartment, assign it to that compartment
parentCompartment = findParentCompartment(newSpecies, model);
} else if (species.getComplex() == null) {
parentCompartment = findParentCompartment(species, model);
}
if (parentCompartment!=null) {
newSpecies.setCompartment(parentCompartment);
parentCompartment.addElement(newSpecies);
if (parentCompartment != null) {
species.setCompartment(parentCompartment);
parentCompartment.addElement(species);
}
// Parse units of information
for (Glyph child : g.getGlyph()) {
for (Glyph child : glyph.getGlyph()) {
if (GlyphClazz.fromClazz(child.getClazz()).equals(GlyphClazz.UNIT_OF_INFORMATION)) {
parseUnitOfInformation(child, newSpecies);
parseUnitOfInformation(child, species);
}
}
model.addElement(newSpecies);
model.addElement(species);
}
private Compartment findParentCompartment(Species child, Model model) {
/**
* Finds a compartment where element should be located (base on the
* coordinates).
*
* @param child
* {@link Element} for which we want to find compartment
* @param model
* {@link Model} where we look for a compartment
* @return parent {@link Compartment}
*/
private Compartment findParentCompartment(Element child, Model model) {
Compartment nullParent = new Compartment("null");
nullParent.setWidth(Double.MAX_VALUE);
nullParent.setHeight(Double.MAX_VALUE);
......@@ -1514,6 +1524,11 @@ public class SbgnmlXmlParser {
compartment.setNamePoint(
compartment.getX() + compartment.getThickness() + CONTAINER_NAME_MARGIN, compartment.getY() + compartment.getThickness() + CONTAINER_NAME_MARGIN);
}
Compartment parent = findParentCompartment(compartment, model);
if (parent != null) {
compartment.setCompartment(parent);
parent.addElement(compartment);
}
model.addElement(compartment);
}
......
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