Commit 7f1ab133 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1304-complex-view' into 'devel_15.0.x'

parse coordinates properly for compact view

See merge request !1209
parents e62c4bdc 6466b4b7
Pipeline #29129 passed with stage
in 21 minutes and 41 seconds
......@@ -6,6 +6,8 @@ minerva (15.0.2) stable; urgency=medium
* Bug fix: export of notes could create invalid GPML file (#1299)
* Bug fix: there was an issue with exporting color and line type of reaction
additional reactant/product (#1303)
* Bug fix: coordinates of children in compact complexes in CellDesigner were
wrong (#1304)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 29 Jun 2020 11:00:00 +0200
......
......@@ -152,6 +152,10 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> {
result.setHeight(view.getBoxSize().getHeight());
result.setLineWidth(view.getSingleLine().getWidth());
result.setFillColor(view.getColor());
if (view.getInnerPosition() != null && state.equalsIgnoreCase("brief")) {
result.setX(result.getX() + view.getInnerPosition().getX());
result.setY(result.getY() + view.getInnerPosition().getY());
}
} else if (!state.equalsIgnoreCase("complexnoborder")) {
throw new InvalidXmlSchemaException("No view (" + state + ") in ComplexAlias for " + result.getElementId());
}
......@@ -235,14 +239,14 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> {
sb.append("<celldesigner:view state=\"usual\"/>\n");
sb.append("<celldesigner:usualView>");
sb.append("<celldesigner:innerPosition x=\"" + complex.getX() + "\" y=\"" + complex.getY() + "\"/>");
sb.append("<celldesigner:innerPosition x=\"0\" y=\"0\"/>");
sb.append("<celldesigner:boxSize width=\"" + complex.getWidth() + "\" height=\"" + complex.getHeight() + "\"/>");
sb.append("<celldesigner:singleLine width=\"" + complex.getLineWidth() + "\"/>");
sb.append(
"<celldesigner:paint color=\"" + XmlParser.colorToString(complex.getFillColor()) + "\" scheme=\"Color\"/>");
sb.append("</celldesigner:usualView>\n");
sb.append("<celldesigner:briefView>");
sb.append("<celldesigner:innerPosition x=\"" + complex.getX() + "\" y=\"" + complex.getY() + "\"/>");
sb.append("<celldesigner:innerPosition x=\"0\" y=\"0\"/>");
sb.append("<celldesigner:boxSize width=\"" + complex.getWidth() + "\" height=\"" + complex.getHeight() + "\"/>");
sb.append("<celldesigner:singleLine width=\"" + complex.getWidth() + "\"/>");
sb.append(
......
......@@ -16,7 +16,8 @@ import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Species;
/**
* Parser of CellDesigner xml used for parsing SpeciesAlias.
......@@ -124,6 +125,10 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> {
result.setHeight(view.getBoxSize().getHeight());
result.setLineWidth(view.getSingleLine().getWidth());
result.setFillColor(view.getColor());
if (view.getInnerPosition() != null && state.equalsIgnoreCase("brief")) {
result.setX(result.getX() + view.getInnerPosition().getX());
result.setY(result.getY() + view.getInnerPosition().getY());
}
} else {
throw new InvalidXmlSchemaException(errorPrefix + "No view in Alias");
}
......@@ -220,16 +225,18 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> {
// TODO to be improved
sb.append("<celldesigner:view state=\"usual\"/>\n");
sb.append("<celldesigner:usualView>");
sb.append("<celldesigner:innerPosition x=\"" + species.getX() + "\" y=\"" + species.getY() + "\"/>");
sb.append("<celldesigner:innerPosition x=\"0\" y=\"0\"/>");
sb.append("<celldesigner:boxSize width=\"" + species.getWidth() + "\" height=\"" + species.getHeight() + "\"/>");
sb.append("<celldesigner:singleLine width=\"" + species.getLineWidth() + "\"/>");
sb.append("<celldesigner:paint color=\"" + XmlParser.colorToString(species.getFillColor()) + "\" scheme=\"Color\"/>");
sb.append(
"<celldesigner:paint color=\"" + XmlParser.colorToString(species.getFillColor()) + "\" scheme=\"Color\"/>");
sb.append("</celldesigner:usualView>\n");
sb.append("<celldesigner:briefView>");
sb.append("<celldesigner:innerPosition x=\"" + species.getX() + "\" y=\"" + species.getY() + "\"/>");
sb.append("<celldesigner:innerPosition x=\"0\" y=\"0\"/>");
sb.append("<celldesigner:boxSize width=\"" + species.getWidth() + "\" height=\"" + species.getHeight() + "\"/>");
sb.append("<celldesigner:singleLine width=\"" + species.getLineWidth() + "\"/>");
sb.append("<celldesigner:paint color=\"" + XmlParser.colorToString(species.getFillColor()) + "\" scheme=\"Color\"/>");
sb.append(
"<celldesigner:paint color=\"" + XmlParser.colorToString(species.getFillColor()) + "\" scheme=\"Color\"/>");
sb.append("</celldesigner:briefView>\n");
if (species.getStateLabel() != null || species.getStatePrefix() != null) {
sb.append("<celldesigner:info state=\"open\" prefix=\"" + species.getStatePrefix() + "\" label=\""
......
......@@ -324,4 +324,11 @@ public class ComplexParserTests extends CellDesignerTestFunctions {
testXmlSerialization(model);
}
@Test
public void testParseCompactComplex() throws Exception {
Model model = getModelForFile("testFiles/complex_compact.xml");
assertTrue(model.getElementByElementId("sa6").getX()>218);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" xmlns:celldesigner="http://www.sbml.org/2001/ns/celldesigner" level="2" version="4">
<model metaid="untitled" id="untitled">
<annotation>
<celldesigner:extension>
<celldesigner:modelVersion>4.0</celldesigner:modelVersion>
<celldesigner:modelDisplay sizeX="600" sizeY="400"/>
<celldesigner:listOfIncludedSpecies>
<celldesigner:species id="s2" name="s2">
<celldesigner:notes>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>
</head>
<body/>
</html>
</celldesigner:notes>
<celldesigner:annotation>
<celldesigner:complexSpecies>s1</celldesigner:complexSpecies>
<celldesigner:speciesIdentity>
<celldesigner:class>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>pr1</celldesigner:proteinReference>
</celldesigner:speciesIdentity>
</celldesigner:annotation>
</celldesigner:species>
<celldesigner:species id="s3" name="s3">
<celldesigner:notes>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>
</head>
<body/>
</html>
</celldesigner:notes>
<celldesigner:annotation>
<celldesigner:complexSpecies>s1</celldesigner:complexSpecies>
<celldesigner:speciesIdentity>
<celldesigner:class>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>pr2</celldesigner:proteinReference>
</celldesigner:speciesIdentity>
</celldesigner:annotation>
</celldesigner:species>
<celldesigner:species id="s4" name="s4">
<celldesigner:notes>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>
</head>
<body/>
</html>
</celldesigner:notes>
<celldesigner:annotation>
<celldesigner:complexSpecies>s1</celldesigner:complexSpecies>
<celldesigner:speciesIdentity>
<celldesigner:class>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>pr3</celldesigner:proteinReference>
</celldesigner:speciesIdentity>
</celldesigner:annotation>
</celldesigner:species>
<celldesigner:species id="s5" name="s5">
<celldesigner:notes>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>
</head>
<body/>
</html>
</celldesigner:notes>
<celldesigner:annotation>
<celldesigner:complexSpecies>s1</celldesigner:complexSpecies>
<celldesigner:speciesIdentity>
<celldesigner:class>ION</celldesigner:class>
<celldesigner:name>s5</celldesigner:name>
</celldesigner:speciesIdentity>
</celldesigner:annotation>
</celldesigner:species>
</celldesigner:listOfIncludedSpecies>
<celldesigner:listOfCompartmentAliases/>
<celldesigner:listOfComplexSpeciesAliases>
<celldesigner:complexSpeciesAlias id="csa2" species="s1">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="218.5" y="140.0" w="80.0" h="60.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="brief"/>
<celldesigner:backupSize w="0.0" h="0.0"/>
<celldesigner:backupView state="none"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="221.0" height="186.0"/>
<celldesigner:singleLine width="2.0"/>
<celldesigner:paint color="fff7f7f7" scheme="Color"/>
</celldesigner:usualView>
<celldesigner:briefView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="60.0"/>
<celldesigner:singleLine width="2.0"/>
<celldesigner:paint color="fff7f7f7" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:complexSpeciesAlias>
</celldesigner:listOfComplexSpeciesAliases>
<celldesigner:listOfSpeciesAliases>
<celldesigner:speciesAlias id="sa3" species="s2" complexSpeciesAlias="csa2">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="218.0" y="140.0" w="80.0" h="60.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="brief"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="20.0" y="28.0"/>
<celldesigner:boxSize width="80.0" height="40.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffccffcc" scheme="Color"/>
</celldesigner:usualView>
<celldesigner:briefView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="60.0"/>
<celldesigner:singleLine width="0.0"/>
<celldesigner:paint color="3fff0000" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:speciesAlias>
<celldesigner:speciesAlias id="sa4" species="s3" complexSpeciesAlias="csa2">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="218.0" y="140.0" w="80.0" h="60.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="brief"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="119.0" y="27.0"/>
<celldesigner:boxSize width="80.0" height="50.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffffffcc" scheme="Color"/>
</celldesigner:usualView>
<celldesigner:briefView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="60.0"/>
<celldesigner:singleLine width="0.0"/>
<celldesigner:paint color="3fff0000" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:speciesAlias>
<celldesigner:speciesAlias id="sa5" species="s4" complexSpeciesAlias="csa2">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="218.0" y="140.0" w="80.0" h="60.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="brief"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="21.0" y="104.0"/>
<celldesigner:boxSize width="80.0" height="40.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffccffcc" scheme="Color"/>
</celldesigner:usualView>
<celldesigner:briefView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="60.0"/>
<celldesigner:singleLine width="0.0"/>
<celldesigner:paint color="3fff0000" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:speciesAlias>
<celldesigner:speciesAlias id="sa6" species="s5" complexSpeciesAlias="csa2">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="218.0" y="140.0" w="80.0" h="60.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="brief"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="147.5" y="114.5"/>
<celldesigner:boxSize width="25.0" height="25.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ff9999ff" scheme="Color"/>
</celldesigner:usualView>
<celldesigner:briefView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="60.0"/>
<celldesigner:singleLine width="0.0"/>
<celldesigner:paint color="3fff0000" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:speciesAlias>
</celldesigner:listOfSpeciesAliases>
<celldesigner:listOfGroups/>
<celldesigner:listOfProteins>
<celldesigner:protein id="pr1" name="s2" type="GENERIC"/>
<celldesigner:protein id="pr2" name="s3" type="RECEPTOR"/>
<celldesigner:protein id="pr3" name="s4" type="GENERIC"/>
</celldesigner:listOfProteins>
<celldesigner:listOfGenes/>
<celldesigner:listOfRNAs/>
<celldesigner:listOfAntisenseRNAs/>
<celldesigner:listOfLayers/>
<celldesigner:listOfBlockDiagrams/>
</celldesigner:extension>
</annotation>
<listOfUnitDefinitions>
<unitDefinition metaid="substance" id="substance" name="substance">
<listOfUnits>
<unit metaid="CDMT00001" kind="mole"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="volume" id="volume" name="volume">
<listOfUnits>
<unit metaid="CDMT00002" kind="litre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="area" id="area" name="area">
<listOfUnits>
<unit metaid="CDMT00003" kind="metre" exponent="2"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="length" id="length" name="length">
<listOfUnits>
<unit metaid="CDMT00004" kind="metre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="time" id="time" name="time">
<listOfUnits>
<unit metaid="CDMT00005" kind="second"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment metaid="default" id="default" size="1" units="volume"/>
</listOfCompartments>
<listOfSpecies>
<species metaid="s1" id="s1" name="s1" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
<celldesigner:speciesIdentity>
<celldesigner:class>COMPLEX</celldesigner:class>
<celldesigner:name>s1</celldesigner:name>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
</listOfSpecies>
</model>
</sbml>
Supports Markdown
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