Skip to content

Commit

Permalink
Check existence of listOfColorDefinitions
Browse files Browse the repository at this point in the history
  Check if listOfColorDefinitions exists when converting from sbgnml to
  json.
  • Loading branch information
msalihaltun committed Apr 5, 2021
1 parent a330c4b commit 69020f5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/utilities/sbgnml-to-json-converter-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,10 +871,12 @@ module.exports = function () {

sbgnmlToJson.applyStyle = function (renderInformation, nodes, edges) {
// get all color id references to their value
var colorList = renderInformation.listOfColorDefinitions.colorDefinitions;
var colorIDToValue = {};
for (var i=0; i < colorList.length; i++) {
colorIDToValue[colorList[i].id] = colorList[i].value;
if (renderInformation.listOfColorDefinitions) {
var colorList = renderInformation.listOfColorDefinitions.colorDefinitions;
var colorIDToValue = {};
for (var i=0; i < colorList.length; i++) {
colorIDToValue[colorList[i].id] = colorList[i].value;
}
}
// get all background image id references to their value
if(renderInformation.listOfBackgroundImages){
Expand All @@ -894,10 +896,10 @@ module.exports = function () {
var renderGroup = style.renderGroup;

// convert color references
if (renderGroup.stroke != null) {
if (renderGroup.stroke != null && colorIDToValue) {
renderGroup.stroke = colorIDToValue[renderGroup.stroke];
}
if (renderGroup.fill != null) {
if (renderGroup.fill != null && colorIDToValue) {
renderGroup.fill = colorIDToValue[renderGroup.fill];
}
// convert background image references
Expand Down

0 comments on commit 69020f5

Please sign in to comment.