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

renaming of methods

parent f8f31f96
No related branches found
No related tags found
1 merge request!186Resolve "upload of sbml"
......@@ -84,11 +84,11 @@ public abstract class SbmlBioEntityExporter<T extends BioEntity, S extends org.s
protected abstract void assignLayoutToGlyph(T element, AbstractReferenceGlyph compartmentGlyph);
protected AbstractReferenceGlyph createGlyph(T element) {
String sbmlCompartmentId = sbmlElementByElementId.get(element.getElementId()).getId();
String sbmlElementId = sbmlElementByElementId.get(element.getElementId()).getId();
String glyphId = element.getElementId();
AbstractReferenceGlyph compartmentGlyph = createElementGlyph(sbmlCompartmentId, glyphId);
assignLayoutToGlyph(element, compartmentGlyph);
return compartmentGlyph;
AbstractReferenceGlyph elementGlyph = createElementGlyph(sbmlElementId, glyphId);
assignLayoutToGlyph(element, elementGlyph);
return elementGlyph;
}
protected abstract AbstractReferenceGlyph createElementGlyph(String sbmlCompartmentId, String glyphId);
......
......@@ -17,7 +17,7 @@ public abstract class SbmlElementExporter<T extends Element, S extends org.sbml.
super(sbmlLayout, minervaModel);
}
protected void assignLayoutToGlyph(T element, AbstractReferenceGlyph compartmentGlyph) {
protected void assignLayoutToGlyph(T element, AbstractReferenceGlyph speciesGlyph) {
BoundingBox boundingBox = new BoundingBox();
boundingBox.setPosition(new Point(element.getX(), element.getY()));
......@@ -26,7 +26,7 @@ public abstract class SbmlElementExporter<T extends Element, S extends org.sbml.
dimensions.setHeight(element.getHeight());
boundingBox.setDimensions(dimensions);
compartmentGlyph.setBoundingBox(boundingBox);
speciesGlyph.setBoundingBox(boundingBox);
}
}
......@@ -3,6 +3,7 @@ package lcsb.mapviewer.converter.model.sbml;
import javax.xml.stream.XMLStreamException;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.log4j.Logger;
import org.sbml.jsbml.Model;
import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.SBMLException;
......@@ -17,6 +18,7 @@ import lcsb.mapviewer.model.map.InconsistentModelException;
import lcsb.mapviewer.model.map.species.Species;
public class SbmlExporter {
Logger logger = Logger.getLogger(SbmlExporter.class);
public String toXml(lcsb.mapviewer.model.map.model.Model model)
throws SBMLException, XMLStreamException, InconsistentModelException {
SBMLDocument doc = new SBMLDocument(3, 1);
......
......@@ -89,6 +89,7 @@ public class SbmlParser implements IConverter {
if (layout.getDimensions() != null) {
model.setWidth(layout.getDimensions().getWidth());
model.setHeight(layout.getDimensions().getHeight());
}
compartmentParser.mergeLayout(model.getCompartments(), layout, sbmlModel);
speciesParser.mergeLayout(model.getSpeciesList(), layout, sbmlModel);
......@@ -117,15 +118,14 @@ public class SbmlParser implements IConverter {
if (sbmlModel.getRuleCount() > 0) {
throw new NotImplementedException("Rule not implemented for model");
}
createLayout(model, layout);
createLayout(model, layout, params.isSizeAutoAdjust());
return model;
} catch (XMLStreamException e) {
throw new InvalidInputDataExecption(e);
}
}
private void createLayout(Model model, Layout layout) throws InvalidInputDataExecption {
private void createLayout(Model model, Layout layout, boolean resize) throws InvalidInputDataExecption {
if (model.getWidth() == null) {
double maxY = 0;
double maxX = 0;
......@@ -133,8 +133,10 @@ public class SbmlParser implements IConverter {
maxY = Math.max(maxY, element.getY() + element.getHeight() + 10);
maxX = Math.max(maxX, element.getX() + element.getWidth() + 10);
}
model.setWidth(maxX);
model.setHeight(maxY);
if (resize) {
model.setWidth(maxX);
model.setHeight(maxY);
}
}
Collection<BioEntity> bioEntitesRequiringLayout = new HashSet<>();
......@@ -150,7 +152,9 @@ public class SbmlParser implements IConverter {
}
}
try {
new ApplySimpleLayoutModelCommand(model, bioEntitesRequiringLayout, true).execute();
if (bioEntitesRequiringLayout.size() > 0) {
new ApplySimpleLayoutModelCommand(model, bioEntitesRequiringLayout, true).execute();
}
} catch (CommandExecutionException e) {
throw new InvalidInputDataExecption("Problem with generating layout", e);
}
......
......@@ -153,7 +153,6 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
nodeClass = Modulation.class;
}
if (minervaNode == null) {
logger.debug(nodeClass);
throw new InvalidInputDataExecption(
"Cannot find reaction node for layouted reaction: " + speciesGlyph.getSpecies() + ", " + glyph.getId());
}
......
......@@ -66,7 +66,7 @@ public class GenericSbmlToXmlParserTest {
String xmlFilePath = pathWithouExtension.concat(".xml");
converter.exportModelToFile(model, xmlFilePath);
Model model2 = converter.createModel(new ConverterParams().filename(xmlFilePath));
Model model2 = converter.createModel(new ConverterParams().filename(xmlFilePath).sizeAutoAdjust(false));
model2.setName(null);
assertNotNull(model2);
......
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