Commit 5ca7ef77 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

CellDesigner incorrectly encode transparent colors

parent bc3b1871
Pipeline #21397 passed with stage
in 21 minutes and 29 seconds
......@@ -3,6 +3,7 @@ minerva (14.0.9) stable; urgency=medium
500 Internal Server Error (#1110)
* Bug fix: refresh data overlay did not hide data overlays that were removed
and selected (#1097)
* Bug fix: transparent complexes are shown with wrong color (#1103)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 3 Feb 2020 15:00:00 +0200
......
......@@ -286,7 +286,7 @@ final public class XmlParser {
*
* @param color
* string representing color
* @return Color object for the fiven string
* @return Color object for the given string
*/
public static Color stringToColor(final String color) {
try {
......
package lcsb.mapviewer.converter.model.celldesigner;
import java.awt.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.geom.Point2D;
import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Node;
import lcsb.mapviewer.common.XmlParser;
......@@ -16,6 +18,7 @@ import lcsb.mapviewer.converter.model.celldesigner.structure.fields.View;
*
*/
public class CommonXmlParser {
/**
* Parse xml representation of position into Poin2D object.
*
......@@ -50,7 +53,7 @@ public class CommonXmlParser {
*
* @param node
* xml node to parse
* @return sinle line object (with width field)
* @return single line object (with width field)
*/
public SingleLine getSingleLine(Node node) {
SingleLine result = new SingleLine();
......@@ -67,6 +70,9 @@ public class CommonXmlParser {
*/
public Color getColor(Node node) {
String color = XmlParser.getNodeAttr("color", node);
// cellDesigner has a bug that removes info about alpha when alpha is 0 (#1103)
color = StringUtils.leftPad(color, 8, "0");
return XmlParser.stringToColor(color);
}
......
......@@ -71,7 +71,8 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
public void testSubstanceUnitAsType() throws Exception {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
Model model = parser
.createModel(new ConverterParams().filename("testFiles/problematic/substance_defined_as_type.xml").sizeAutoAdjust(false));
.createModel(new ConverterParams().filename("testFiles/problematic/substance_defined_as_type.xml")
.sizeAutoAdjust(false));
assertNotNull(model);
assertNotNull(model.getSpeciesList().get(0).getSubstanceUnits());
super.testXmlSerialization(model);
......@@ -861,4 +862,16 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
Configuration.EPSILON);
}
@Test
public void testTransparentComplex() throws Exception {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
Model model = parser.createModel(new ConverterParams().filename("testFiles/problematic/transparent_complex.xml"));
Color c1 = model.getElementByElementId("csa1").getColor();
Color c2 = model.getElementByElementId("csa2").getColor();
assertNotEquals(c1.getAlpha(), c2.getAlpha());
assertEquals(c1.getRed(), c2.getRed());
assertEquals(c1.getGreen(), c2.getGreen());
assertEquals(c1.getBlue(), c2.getBlue());
}
}
<?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="s1" name="s1">
<celldesigner:notes>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>
</head>
<body/>
</html>
</celldesigner:notes>
<celldesigner:annotation>
<celldesigner:complexSpecies>s3</celldesigner:complexSpecies>
<celldesigner:speciesIdentity>
<celldesigner:class>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>pr1</celldesigner:proteinReference>
</celldesigner:speciesIdentity>
</celldesigner:annotation>
</celldesigner:species>
</celldesigner:listOfIncludedSpecies>
<celldesigner:listOfCompartmentAliases/>
<celldesigner:listOfComplexSpeciesAliases>
<celldesigner:complexSpeciesAlias id="csa1" species="s3">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="235.0" y="117.0" w="100.0" h="120.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<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="100.0" height="120.0"/>
<celldesigner:singleLine width="2.0"/>
<celldesigner:paint color="f7f7f7" 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:complexSpeciesAlias id="csa2" species="s4">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="395.0" y="101.0" w="100.0" h="120.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<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="100.0" height="120.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="sa1" species="s1" complexSpeciesAlias="csa1">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="242.0" y="130.0" w="80.0" h="40.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="7.0" y="13.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:listOfSpeciesAliases>
<celldesigner:listOfGroups/>
<celldesigner:listOfProteins>
<celldesigner:protein id="pr1" name="s1" 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="s3" id="s3" name="zeroALFA" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
<celldesigner:speciesIdentity>
<celldesigner:class>COMPLEX</celldesigner:class>
<celldesigner:name>zeroALFA</celldesigner:name>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
<species metaid="s4" id="s4" name="ALFA100" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
<celldesigner:speciesIdentity>
<celldesigner:class>COMPLEX</celldesigner:class>
<celldesigner:name>ALFA100</celldesigner:name>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
</listOfSpecies>
</model>
</sbml>
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