Commit 6757baca authored by Piotr Gawron's avatar Piotr Gawron
Browse files

textGlyph reference is taken from proper attribute

parent d9172505
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
......
package lcsb.mapviewer.converter.model.sbml;
import java.awt.*;
import java.awt.Color;
import java.util.*;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -198,11 +197,15 @@ public class SbmlBioEntityParser {
* @return
*/
protected List<TextGlyph> getTextGlyphsByLayoutElementId(AbstractReferenceGlyph glyph) {
Layout layout = getLayout();
if (textGlyphByElementId == null) {
textGlyphByElementId = new HashMap<>();
if (layout != null) {
for (TextGlyph textGlyph : layout.getListOfTextGlyphs()) {
String id = textGlyph.getReference();
String id = textGlyph.getGraphicalObject();
if (id == null || id.isEmpty()) {
id = textGlyph.getReference();
}
if (textGlyphByElementId.get(id) == null) {
textGlyphByElementId.put(id, new ArrayList<>());
}
......
......@@ -48,7 +48,7 @@ public abstract class SbmlElementExporter<T extends Element, S extends org.sbml.
double height = element.getNameHeight();
double x = element.getNameX();
double y = element.getNameY();
textGlyph.setReference(speciesGlyph.getId());
textGlyph.setGraphicalObject(speciesGlyph.getId());
if (isExtensionEnabled(SbmlExtension.RENDER)) {
LocalRenderInformation renderInformation = getRenderInformation(getRenderPlugin());
......
......@@ -22,6 +22,7 @@ import lcsb.mapviewer.converter.model.sbml.species.AllSbmlSpeciesTests;
GeneratedSbmlValidationTests.class,
MultiParserTest.class,
ReactionPropertiesExportToMultiTest.class,
SbmlBioEntityParserTest.class,
SbmlBioEntityExporterTest.class,
SbmlElementParserTest.class,
SbmlExporterTest.class,
......
package lcsb.mapviewer.converter.model.sbml;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import org.mockito.Mockito;
import org.sbml.jsbml.ext.layout.*;
public class SbmlBioEntityParserTest extends SbmlTestFunctions {
@Test
public void testGetTextGlyphsByLayoutElementIdForReference() {
AbstractReferenceGlyph glyph = new SpeciesGlyph("id");
SbmlBioEntityParser parser = Mockito.mock(SbmlBioEntityParser.class, Mockito.CALLS_REAL_METHODS);
Layout layout = new Layout();
TextGlyph textGlyph = new TextGlyph();
textGlyph.setReference(glyph.getId());
layout.addTextGlyph(textGlyph);
Mockito.when(parser.getLayout()).thenReturn(layout);
List<TextGlyph> texts = parser.getTextGlyphsByLayoutElementId(glyph);
assertEquals(1, texts.size());
}
@Test
public void testGetTextGlyphsByLayoutElementIdForGraphicalObject() {
AbstractReferenceGlyph glyph = new SpeciesGlyph("id");
SbmlBioEntityParser parser = Mockito.mock(SbmlBioEntityParser.class, Mockito.CALLS_REAL_METHODS);
Layout layout = new Layout();
TextGlyph textGlyph = new TextGlyph();
textGlyph.setGraphicalObject(glyph.getId());
layout.addTextGlyph(textGlyph);
Mockito.when(parser.getLayout()).thenReturn(layout);
List<TextGlyph> texts = parser.getTextGlyphsByLayoutElementId(glyph);
assertEquals(1, texts.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