Commit 26c965d6 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

conversion of top and left compartment fixed

parent e1cd9cc4
......@@ -113,12 +113,14 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen
if (result instanceof BottomSquareCompartment) {
result.setY(XmlParser.getNodeAttr("y", node));
} else if (result instanceof LeftSquareCompartment) {
result.setX(XmlParser.getNodeAttr("x", node));
result.setWidth(XmlParser.getNodeAttr("x", node));
result.setX(0.0);
} else if (result instanceof RightSquareCompartment) {
result.setX(XmlParser.getNodeAttr("x", node));
result.setWidth(result.getWidth() - result.getX());
} else if (result instanceof TopSquareCompartment) {
result.setY(XmlParser.getNodeAttr("y", node));
result.setHeight(XmlParser.getNodeAttr("y", node));
result.setY(0.0);
} else {
throw new InvalidXmlSchemaException(
"Don't know what to do with celldesigner:point for class: " + result.getClass());
......
package lcsb.mapviewer.converter.model.celldesigner.compartment;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model;
public class CompartmentParserTests extends CellDesignerTestFunctions {
......@@ -23,6 +26,11 @@ public class CompartmentParserTests extends CellDesignerTestFunctions {
@Test
public void testParseCompartmensBottom() throws Exception {
Model model = getModelForFile("testFiles/compartment/bottom_compartment.xml");
Compartment c = model.getElementByElementId("ca4");
assertTrue(c.getY() > 0);
assertTrue(c.getWidth() > 0);
assertTrue(c.getHeight() > 0);
assertEquals(0, c.getX(), Configuration.EPSILON);
assertEquals(1, model.getElements().size());
}
......@@ -31,19 +39,33 @@ public class CompartmentParserTests extends CellDesignerTestFunctions {
public void testParseCompartmensTop() throws Exception {
Model model = getModelForFile("testFiles/compartment/top_compartment.xml");
Compartment c = model.getElementByElementId("ca3");
assertEquals(0, c.getX(), Configuration.EPSILON);
assertEquals(0, c.getY(), Configuration.EPSILON);
assertTrue(c.getWidth() > 0);
assertTrue(c.getHeight() < model.getHeight());
assertEquals(1, model.getElements().size());
}
@Test
public void testParseCompartmensRight() throws Exception {
Model model = getModelForFile("testFiles/compartment/right_compartment.xml");
Compartment c = model.getElementByElementId("ca2");
assertTrue(c.getX() > 0);
assertTrue(c.getWidth() > 0);
assertTrue(c.getHeight() > 0);
assertEquals(0, c.getY(), Configuration.EPSILON);
assertEquals(1, model.getElements().size());
}
@Test
public void testParseCompartmensLeft() throws Exception {
Model model = getModelForFile("testFiles/compartment/left_compartment.xml");
Compartment c = model.getElementByElementId("ca1");
assertEquals(0, c.getX(), Configuration.EPSILON);
assertEquals(0, c.getY(), Configuration.EPSILON);
assertTrue(c.getWidth() < model.getWidth());
assertTrue(c.getHeight() > 0);
assertEquals(1, model.getElements().size());
}
......
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