Commit b1473e5f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1356-reference-to-alias-from-text-glyph' into 'master'

Resolve "reference to alias from textGlyph is taken from wrong attribute"

Closes #1354 and #1356

See merge request !1238
parents 28333f55 954aa768
Pipeline #31293 failed with stage
in 15 minutes and 35 seconds
minerva (15.1.0~beta.1) unstable; urgency=medium
* Bug fix: SBML import - label aligned to top of species was inproperly drawn
(#1354)
* Bug fix: SBML text labels that were referencing layout aliases using
layout:graphicalObject attribute were not handled properly (#1356)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 17 Aug 2020 16:00:00 +0200
minerva (15.1.0~beta.0) unstable; urgency=medium minerva (15.1.0~beta.0) unstable; urgency=medium
* Small improvement: annotations are exported in SBGN extension that can be * Small improvement: annotations are exported in SBGN extension that can be
opened by newt (#1296) opened by newt (#1296)
......
...@@ -162,7 +162,11 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen ...@@ -162,7 +162,11 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen
"Don't know what to do with celldesigner:point for class: " + result.getClass()); "Don't know what to do with celldesigner:point for class: " + result.getClass());
} }
} else if (node.getNodeName().equalsIgnoreCase("celldesigner:namePoint")) { } else if (node.getNodeName().equalsIgnoreCase("celldesigner:namePoint")) {
result.setNamePoint(getCommonParser().getPosition(node)); Point2D position = getCommonParser().getPosition(node);
result.setNameX(position.getX());
result.setNameY(position.getY());
result.setNameWidth(result.getWidth() - (result.getNameX() - result.getX()));
result.setNameHeight(result.getHeight() - (result.getNameY() - result.getY()));
result.setNameHorizontalAlign(HorizontalAlign.LEFT); result.setNameHorizontalAlign(HorizontalAlign.LEFT);
result.setNameVerticalAlign(VerticalAlign.TOP); result.setNameVerticalAlign(VerticalAlign.TOP);
} else { } else {
...@@ -171,9 +175,13 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen ...@@ -171,9 +175,13 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen
} }
} }
} }
if (result.getNamePoint()==null) { if (result.getNameX() == null || result.getNameY() == null || result.getNameWidth() == null
logger.warn(new LogMarker(ProjectLogEntryType.PARSING_ISSUE,result),"Name point is not defined"); || result.getNameHeight() == null) {
result.setNamePoint(new Point2D.Double(result.getX(), result.getY())); logger.warn(new LogMarker(ProjectLogEntryType.PARSING_ISSUE, result), "Name point is not defined");
result.setNameX(result.getX());
result.setNameY(result.getY());
result.setNameWidth(result.getWidth());
result.setNameHeight(result.getHeight());
result.setNameHorizontalAlign(HorizontalAlign.LEFT); result.setNameHorizontalAlign(HorizontalAlign.LEFT);
result.setNameVerticalAlign(VerticalAlign.TOP); result.setNameVerticalAlign(VerticalAlign.TOP);
} }
...@@ -222,8 +230,8 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen ...@@ -222,8 +230,8 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen
} }
sb.append("<celldesigner:namePoint "); sb.append("<celldesigner:namePoint ");
sb.append("x=\"" + compartment.getNamePoint().getX() + "\" "); sb.append("x=\"" + compartment.getNameX() + "\" ");
sb.append("y=\"" + compartment.getNamePoint().getY() + "\"/>\n"); sb.append("y=\"" + compartment.getNameY() + "\"/>\n");
sb.append(getDoubleLineNode(compartment)); sb.append(getDoubleLineNode(compartment));
......
package lcsb.mapviewer.converter.model.celldesigner.alias; package lcsb.mapviewer.converter.model.celldesigner.alias;
import java.awt.geom.Point2D;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -176,7 +175,10 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> { ...@@ -176,7 +175,10 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> {
} }
complexAliasesMapById.put(result.getElementId(), result); complexAliasesMapById.put(result.getElementId(), result);
species.updateModelElementAfterLayoutAdded(result); species.updateModelElementAfterLayoutAdded(result);
result.setNamePoint(new Point2D.Double(result.getCenterX(), result.getY() + result.getHeight() - 2)); result.setNameX(result.getX());
result.setNameY(result.getY());
result.setNameWidth(result.getWidth());
result.setNameHeight(result.getHeight());
result.setNameHorizontalAlign(HorizontalAlign.CENTER); result.setNameHorizontalAlign(HorizontalAlign.CENTER);
result.setNameVerticalAlign(VerticalAlign.BOTTOM); result.setNameVerticalAlign(VerticalAlign.BOTTOM);
return result; return result;
......
...@@ -156,7 +156,10 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> { ...@@ -156,7 +156,10 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> {
} }
species.updateModelElementAfterLayoutAdded(result); species.updateModelElementAfterLayoutAdded(result);
result.setNamePoint(result.getCenter()); result.setNameX(result.getX());
result.setNameY(result.getY());
result.setNameWidth(result.getWidth());
result.setNameHeight(result.getHeight());
result.setNameHorizontalAlign(HorizontalAlign.CENTER); result.setNameHorizontalAlign(HorizontalAlign.CENTER);
result.setNameVerticalAlign(VerticalAlign.MIDDLE); result.setNameVerticalAlign(VerticalAlign.MIDDLE);
return result; return result;
......
...@@ -227,10 +227,10 @@ public abstract class CellDesignerTestFunctions { ...@@ -227,10 +227,10 @@ public abstract class CellDesignerTestFunctions {
Model model2 = serializeModel(model); Model model2 = serializeModel(model);
ModelComparator comparator = new ModelComparator(); ModelComparator comparator = new ModelComparator();
//import of unbounded compartments is problematic // import of unbounded compartments is problematic
for (Compartment compartment :model.getCompartments()) { for (Compartment compartment : model.getCompartments()) {
if (compartment instanceof BottomSquareCompartment || if (compartment instanceof BottomSquareCompartment ||
compartment instanceof TopSquareCompartment || compartment instanceof TopSquareCompartment ||
compartment instanceof LeftSquareCompartment || compartment instanceof LeftSquareCompartment ||
compartment instanceof RightSquareCompartment) { compartment instanceof RightSquareCompartment) {
...@@ -261,26 +261,39 @@ public abstract class CellDesignerTestFunctions { ...@@ -261,26 +261,39 @@ public abstract class CellDesignerTestFunctions {
GenericProtein protein = new GenericProtein("id" + (idCounter++)); GenericProtein protein = new GenericProtein("id" + (idCounter++));
protein.setActivity(true); protein.setActivity(true);
protein.setFontSize(4); protein.setFontSize(4);
protein.setHeight(10);
protein.setWidth(20);
protein.setX(30);
protein.setY(40);
protein.setStateLabel("xxx"); protein.setStateLabel("xxx");
protein.setStatePrefix("yyy"); protein.setStatePrefix("yyy");
protein.setNamePoint(protein.getCenter());
protein.setNameHorizontalAlign(HorizontalAlign.CENTER); assignCoordinates(30, 40, 10, 20, protein);
protein.setNameVerticalAlign(VerticalAlign.MIDDLE);
return protein; return protein;
} }
protected SimpleMolecule createSimpleMolecule() { protected SimpleMolecule createSimpleMolecule() {
SimpleMolecule result = new SimpleMolecule("id" + (idCounter++)); SimpleMolecule result = new SimpleMolecule("id" + (idCounter++));
result.setX(50); assignCoordinates(50, 60, 20, 20, result);
result.setY(60);
result.setNamePoint(result.getCenter());
result.setNameHorizontalAlign(HorizontalAlign.CENTER);
result.setNameVerticalAlign(VerticalAlign.MIDDLE);
return result; return result;
} }
static int zIndex = 10;
protected static void assignCoordinates(lcsb.mapviewer.model.map.species.Element element) {
assignCoordinates(10, 20, 30, 40, element);
}
protected static void assignCoordinates(double x, double y, double width, double height,
lcsb.mapviewer.model.map.species.Element element) {
element.setX(x);
element.setY(y);
element.setZ(zIndex++);
element.setWidth(width);
element.setHeight(height);
element.setNameX(x);
element.setNameY(y);
element.setNameWidth(width);
element.setNameHeight(height);
element.setNameVerticalAlign(VerticalAlign.MIDDLE);
element.setNameHorizontalAlign(HorizontalAlign.CENTER);
}
} }
...@@ -2,7 +2,6 @@ package lcsb.mapviewer.converter.model.celldesigner.alias; ...@@ -2,7 +2,6 @@ package lcsb.mapviewer.converter.model.celldesigner.alias;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.awt.geom.Point2D;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -285,11 +284,7 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { ...@@ -285,11 +284,7 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions {
private Compartment createCompartment(String id) { private Compartment createCompartment(String id) {
Compartment compartment = new SquareCompartment(id); Compartment compartment = new SquareCompartment(id);
compartment.setName("name" + id); compartment.setName("name" + id);
compartment.setX(13); assignCoordinates(13, 14, 100, 120, compartment);
compartment.setY(14);
compartment.setWidth(100);
compartment.setHeight(120);
compartment.setNamePoint(new Point2D.Double(0, 1));
return compartment; return compartment;
} }
......
...@@ -2,8 +2,6 @@ package lcsb.mapviewer.converter.model.celldesigner.alias; ...@@ -2,8 +2,6 @@ package lcsb.mapviewer.converter.model.celldesigner.alias;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.awt.geom.Point2D;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.junit.*; import org.junit.*;
...@@ -54,8 +52,10 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { ...@@ -54,8 +52,10 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
assertEquals(compartment.getWidth(), alias2.getWidth(), 1e-6); assertEquals(compartment.getWidth(), alias2.getWidth(), 1e-6);
assertEquals(compartment.getX(), alias2.getX(), 1e-6); assertEquals(compartment.getX(), alias2.getX(), 1e-6);
assertEquals(compartment.getY(), alias2.getY(), 1e-6); assertEquals(compartment.getY(), alias2.getY(), 1e-6);
assertEquals(compartment.getNamePoint().getX(), alias2.getNamePoint().getX(), 1e-6); assertEquals(compartment.getNameX(), alias2.getNameX(), 1e-6);
assertEquals(compartment.getNamePoint().getY(), alias2.getNamePoint().getY(), 1e-6); assertEquals(compartment.getNameY(), alias2.getNameY(), 1e-6);
assertEquals(compartment.getNameWidth(), alias2.getNameWidth(), 1e-6);
assertEquals(compartment.getNameHeight(), alias2.getNameHeight(), 1e-6);
assertNotNull(alias2.getNameHorizontalAlign()); assertNotNull(alias2.getNameHorizontalAlign());
assertNotNull(alias2.getNameVerticalAlign()); assertNotNull(alias2.getNameVerticalAlign());
} }
...@@ -63,11 +63,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { ...@@ -63,11 +63,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
private Compartment createCompartment() { private Compartment createCompartment() {
Compartment compartment = new SquareCompartment("comp_id"); Compartment compartment = new SquareCompartment("comp_id");
compartment.setName("name"); compartment.setName("name");
compartment.setX(13); assignCoordinates(13, 14, 100, 120, compartment);
compartment.setY(14);
compartment.setWidth(100);
compartment.setHeight(120);
compartment.setNamePoint(new Point2D.Double(0, 1));
return compartment; return compartment;
} }
...@@ -127,8 +123,9 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { ...@@ -127,8 +123,9 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
assertEquals(139.0, alias.getX(), 1e-6); assertEquals(139.0, alias.getX(), 1e-6);
assertEquals(55.0, alias.getY(), 1e-6); assertEquals(55.0, alias.getY(), 1e-6);
assertEquals(522.0, alias.getWidth(), 1e-6); assertEquals(522.0, alias.getWidth(), 1e-6);
assertEquals(392.5, alias.getNamePoint().getX(), 1e-6); assertEquals(392.5, alias.getNameX(), 1e-6);
assertEquals(196.5, alias.getNamePoint().getY(), 1e-6); assertEquals(196.5, alias.getNameY(), 1e-6);
assertEquals(522.0, alias.getNameWidth(), 1e-6);
assertEquals(0xffcccc00, alias.getFillColor().getRGB()); assertEquals(0xffcccc00, alias.getFillColor().getRGB());
} }
...@@ -142,7 +139,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { ...@@ -142,7 +139,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
@Test @Test
public void testLeftToXml() throws Exception { public void testLeftToXml() throws Exception {
Compartment alias = new LeftSquareCompartment("id"); Compartment alias = new LeftSquareCompartment("id");
alias.setNamePoint(new Point2D.Double()); assignCoordinates(alias);
String xml = parser.toXml(alias); String xml = parser.toXml(alias);
assertNotNull(xml); assertNotNull(xml);
} }
...@@ -150,7 +147,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { ...@@ -150,7 +147,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
@Test @Test
public void testRightToXml() throws Exception { public void testRightToXml() throws Exception {
Compartment alias = new RightSquareCompartment("id"); Compartment alias = new RightSquareCompartment("id");
alias.setNamePoint(new Point2D.Double()); assignCoordinates(alias);
String xml = parser.toXml(alias); String xml = parser.toXml(alias);
assertNotNull(xml); assertNotNull(xml);
} }
...@@ -158,7 +155,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { ...@@ -158,7 +155,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
@Test @Test
public void testTopToXml() throws Exception { public void testTopToXml() throws Exception {
Compartment alias = new TopSquareCompartment("id"); Compartment alias = new TopSquareCompartment("id");
alias.setNamePoint(new Point2D.Double()); assignCoordinates(alias);
String xml = parser.toXml(alias); String xml = parser.toXml(alias);
assertNotNull(xml); assertNotNull(xml);
} }
...@@ -166,7 +163,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { ...@@ -166,7 +163,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions {
@Test @Test
public void testBotttomToXml() throws Exception { public void testBotttomToXml() throws Exception {
Compartment alias = new BottomSquareCompartment("id"); Compartment alias = new BottomSquareCompartment("id");
alias.setNamePoint(new Point2D.Double()); assignCoordinates(alias);
String xml = parser.toXml(alias); String xml = parser.toXml(alias);
assertNotNull(xml); assertNotNull(xml);
} }
......
...@@ -73,7 +73,10 @@ public class ComplexAliasXmlParserTest extends CellDesignerTestFunctions { ...@@ -73,7 +73,10 @@ public class ComplexAliasXmlParserTest extends CellDesignerTestFunctions {
assertEquals(100.0, alias.getWidth(), Configuration.EPSILON); assertEquals(100.0, alias.getWidth(), Configuration.EPSILON);
assertEquals(744.0, alias.getX(), Configuration.EPSILON); assertEquals(744.0, alias.getX(), Configuration.EPSILON);
assertEquals(0.0, alias.getY(), Configuration.EPSILON); assertEquals(0.0, alias.getY(), Configuration.EPSILON);
assertNotNull(alias.getNamePoint()); assertNotNull(alias.getNameX());
assertNotNull(alias.getNameY());
assertNotNull(alias.getNameWidth());
assertNotNull(alias.getNameHeight());
assertNotNull(alias.getNameHorizontalAlign()); assertNotNull(alias.getNameHorizontalAlign());
assertNotNull(alias.getNameVerticalAlign()); assertNotNull(alias.getNameVerticalAlign());
} }
......
...@@ -67,7 +67,10 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { ...@@ -67,7 +67,10 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions {
assertEquals(11813.0, alias.getX(), 1e-6); assertEquals(11813.0, alias.getX(), 1e-6);
assertEquals(2840.5, alias.getY(), 1e-6); assertEquals(2840.5, alias.getY(), 1e-6);
assertEquals("ca1", alias.getCompartment().getElementId()); assertEquals("ca1", alias.getCompartment().getElementId());
assertNotNull(alias.getNamePoint()); assertNotNull(alias.getNameX());
assertNotNull(alias.getNameY());
assertNotNull(alias.getNameWidth());
assertNotNull(alias.getNameHeight());
assertNotNull(alias.getNameHorizontalAlign()); assertNotNull(alias.getNameHorizontalAlign());
assertNotNull(alias.getNameVerticalAlign()); assertNotNull(alias.getNameVerticalAlign());
} }
......
...@@ -19,7 +19,6 @@ import lcsb.mapviewer.common.exception.NotImplementedException; ...@@ -19,7 +19,6 @@ import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
import lcsb.mapviewer.model.map.*; import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.layout.graphics.LayerText;
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.*; import lcsb.mapviewer.model.map.species.*;
......
...@@ -2,8 +2,6 @@ package lcsb.mapviewer.converter.model.celldesigner.compartment; ...@@ -2,8 +2,6 @@ package lcsb.mapviewer.converter.model.celldesigner.compartment;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.awt.geom.Point2D;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.junit.*; import org.junit.*;
...@@ -137,7 +135,7 @@ public class CompartmentParserTests extends CellDesignerTestFunctions { ...@@ -137,7 +135,7 @@ public class CompartmentParserTests extends CellDesignerTestFunctions {
Model model = new ModelFullIndexed(null); Model model = new ModelFullIndexed(null);
Compartment compartment = new SquareCompartment("c"); Compartment compartment = new SquareCompartment("c");
compartment.setName("xyz"); compartment.setName("xyz");
compartment.setNamePoint(new Point2D.Double()); assignCoordinates(compartment);
model.addElement(compartment); model.addElement(compartment);
Model model2 = super.serializeModel(model); Model model2 = super.serializeModel(model);
...@@ -148,7 +146,7 @@ public class CompartmentParserTests extends CellDesignerTestFunctions { ...@@ -148,7 +146,7 @@ public class CompartmentParserTests extends CellDesignerTestFunctions {
public void testToXmlWithCompartmentIdNotRecognizedByCellDesignerAndChildren() throws Exception { public void testToXmlWithCompartmentIdNotRecognizedByCellDesignerAndChildren() throws Exception {
Model model = new ModelFullIndexed(null); Model model = new ModelFullIndexed(null);
Compartment compartment = new SquareCompartment("c"); Compartment compartment = new SquareCompartment("c");
compartment.setNamePoint(new Point2D.Double()); assignCoordinates(compartment);
compartment.setName("xyz"); compartment.setName("xyz");
model.addElement(compartment); model.addElement(compartment);
......
...@@ -17,7 +17,6 @@ import org.xml.sax.InputSource; ...@@ -17,7 +17,6 @@ import org.xml.sax.InputSource;
import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.Pair;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions;
import lcsb.mapviewer.converter.model.celldesigner.species.ProteinXmlParserTest;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment;
import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.Compartment;
......
...@@ -3,18 +3,14 @@ package lcsb.mapviewer.converter.model.celldesigner.types; ...@@ -3,18 +3,14 @@ package lcsb.mapviewer.converter.model.celldesigner.types;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.lang.reflect.Field;
import org.junit.*; import org.junit.*;
import org.mockito.Mockito; import org.mockito.Mockito;
import lcsb.mapviewer.common.exception.*; import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.reaction.*; import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Species;
public class ModifierTypeUtilsTest extends CellDesignerTestFunctions { public class ModifierTypeUtilsTest extends CellDesignerTestFunctions {
......
...@@ -494,6 +494,12 @@ public class SbgnmlXmlExporter { ...@@ -494,6 +494,12 @@ public class SbgnmlXmlExporter {
private Label getGlyphLabelFromAlias(Element element) { private Label getGlyphLabelFromAlias(Element element) {
Label label = new Label(); Label label = new Label();
label.setText(element.getName()); label.setText(element.getName());
Bbox box = new Bbox();
box.setX(element.getNameX().floatValue());
box.setY(element.getNameY().floatValue());
box.setW(element.getNameWidth().floatValue());
box.setH(element.getNameHeight().floatValue());
label.setBbox(box);
return label; return label;
} }
......
...@@ -761,13 +761,17 @@ public class SbgnmlXmlParser { ...@@ -761,13 +761,17 @@ public class SbgnmlXmlParser {
if (g.getLabel() != null) { if (g.getLabel() != null) {
newSpecies.setName(g.getLabel().getText()); newSpecies.setName(g.getLabel().getText());
if (g.getLabel().getBbox() != null) { if (g.getLabel().getBbox() != null) {
double x = g.getLabel().getBbox().getX() + g.getLabel().getBbox().getW() / 2; newSpecies.setNameX(g.getLabel().getBbox().getX());
double y = g.getLabel().getBbox().getY() + g.getLabel().getBbox().getH() / 2; newSpecies.setNameY(g.getLabel().getBbox().getY());
newSpecies.setNamePoint(x, y); newSpecies.setNameWidth(g.getLabel().getBbox().getW());
newSpecies.setNameHeight(g.getLabel().getBbox().getH());
newSpecies.setNameHorizontalAlign(HorizontalAlign.CENTER); newSpecies.setNameHorizontalAlign(HorizontalAlign.CENTER);
newSpecies.setNameVerticalAlign(VerticalAlign.MIDDLE); if (newSpecies instanceof Complex) {
newSpecies.setNameVerticalAlign(VerticalAlign.BOTTOM);
} else {
newSpecies.setNameVerticalAlign(VerticalAlign.MIDDLE);
}
} }
} else { } else {
newSpecies.setName("");