Skip to content

Commit fa93fbb

Browse files
committed
Fix the issue
1 parent 9850e08 commit fa93fbb

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/main/java/com/mxgraph/svg2xml/Svg2Xml.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,8 +1460,10 @@ private Map<String, String> parseFillDefs(Node root)
14601460

14611461
if (currEl.getNodeName().equals("linearGradient") || currEl.getNodeName().equals("radialGradient"))
14621462
{
1463-
String avgColor = getAvgGradientColor(currEl);
1464-
fillTable.put(currEl.getAttribute("id"), avgColor);
1463+
String avgColor = getAvgGradientColor(currEl);
1464+
if (avgColor != null) {
1465+
fillTable.put(currEl.getAttribute("id"), avgColor);
1466+
}
14651467
}
14661468

14671469
fillTable.putAll(parseFillDefs(currChild));
@@ -1496,8 +1498,10 @@ private Map<String, String> parseStrokeDefs(Node root)
14961498

14971499
if (currEl.getNodeName().equals("linearGradient") || currEl.getNodeName().equals("radialGradient"))
14981500
{
1499-
String avgColor = getAvgGradientColor(currEl);
1500-
strokeTable.put(currEl.getAttribute("id"), avgColor);
1501+
String avgColor = getAvgGradientColor(currEl);
1502+
if (avgColor != null) {
1503+
strokeTable.put(currEl.getAttribute("id"), avgColor);
1504+
}
15011505
}
15021506

15031507
strokeTable.putAll(parseStrokeDefs(currChild));
@@ -1537,15 +1541,15 @@ private String getAvgGradientColor(Element element)
15371541
Color col = new Color(0, 0, 0);
15381542
String colS = currEl.getAttribute("stop-color");
15391543

1540-
if (colS.charAt(0) == '#')
1544+
if (colS == null || colS.equals(""))
15411545
{
1542-
col = Color.decode(colS);
1546+
return null;
15431547
}
1544-
else if (colS == null || colS.equals(""))
1548+
else if (colS.charAt(0) == '#')
15451549
{
1546-
return null;
1550+
col = Color.decode(colS);
15471551
}
1548-
else
1552+
else
15491553
{
15501554
col = stringToColor(colS);
15511555
}

0 commit comments

Comments
 (0)