Commit a933265b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

border color is considered when creating/exporting pathways

parent bfa13b51
package lcsb.mapviewer.converter.model.celldesigner;
import java.awt.*;
import java.awt.Color;
import java.awt.geom.Point2D;
import java.util.*;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -502,6 +501,11 @@ public class LayerXmlParser {
result.setBackgroundColor(backgroundColor);
notes = removeBackgroundColor(notes);
}
Color borderColor = extractBorderColor(notes);
if (borderColor != null) {
result.setBorderColor(borderColor);
notes = removeBorderColor(notes);
}
result.setNotes(notes);
} else if (node.getNodeName().equalsIgnoreCase("celldesigner:paint")) {
result.setColor(commonParser.getColor(node));
......@@ -523,10 +527,18 @@ public class LayerXmlParser {
}
String removeBackgroundColor(String notes) {
return removeColor(notes, "BackgroundColor");
}
String removeBorderColor(String notes) {
return removeColor(notes, "BorderColor");
}
private String removeColor(String notes, String string) {
String lines[] = notes.split("[\n\r]+");
StringBuilder result = new StringBuilder("");
for (String line : lines) {
if (!line.startsWith("BackgroundColor=") && !line.startsWith("BackgroundColor:")) {
if (!line.startsWith(string + "=") && !line.startsWith(string + ":")) {
result.append(line + "\n");
}
}
......@@ -534,10 +546,18 @@ public class LayerXmlParser {
}
Color extractBackgroundColor(String notes) {
return extractColor(notes, "BackgroundColor");
}
Color extractBorderColor(String notes) {
return extractColor(notes, "BorderColor");
}
private Color extractColor(String notes, String string) {
String lines[] = notes.split("[\n\r]+");
for (String line : lines) {
if (line.startsWith("BackgroundColor=") ||line.startsWith("BackgroundColor:")) {
String colorString = line.replace("BackgroundColor=", "").replace("BackgroundColor:", "");
if (line.startsWith(string + "=") || line.startsWith(string + ":")) {
String colorString = line.replace(string + "=", "").replace(string + ":", "");
return new ColorParser().parse(colorString);
}
}
......@@ -562,6 +582,9 @@ public class LayerXmlParser {
if (!layer.getBackgroundColor().equals(Color.LIGHT_GRAY)) {
notes += "\nBackgroundColor:" + new ColorParser().colorToHtml(layer.getBackgroundColor());
}
if (!layer.getBorderColor().equals(Color.LIGHT_GRAY)) {
notes += "\nBorderColor:" + new ColorParser().colorToHtml(layer.getBorderColor());
}
result.append(notes);
result.append("\n</celldesigner:layerNotes>");
result.append("<celldesigner:paint color=\"" + XmlParser.colorToString(layer.getColor()) + "\"/>");
......
......@@ -326,8 +326,10 @@ public class LayerXmlParserTest extends CellDesignerTestFunctions {
public void testLayerTextToXmlWithCustomDefaultBackgroundColor() throws Exception {
LayerText text = new LayerText();
text.setBackgroundColor(Color.BLUE);
text.setBorderColor(Color.YELLOW);
String xml = parser.layerTextToXml(text);
assertTrue(xml.contains("BackgroundColor"));
assertTrue(xml.contains("BorderColor"));
}
}
......@@ -169,6 +169,7 @@ public class CreateHierarchyCommand extends ModelCommand {
compartment.setHeight(text.getHeight());
compartment.setFontColor(text.getColor());
compartment.setFillColor(text.getBackgroundColor());
compartment.setBorderColor(text.getBorderColor());
compartment.setName(extractNameFromText(text.getNotes()));
compartment.setNotes(extractNotesFromText(text.getNotes()));
compartment.setZ(text.getZ());
......
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