Commit 0b36888f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

export to gpml uses proper colors

parent effb0b26
package lcsb.mapviewer.wikipathway.XML;
import java.awt.Color;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.HashSet;
......@@ -9,6 +10,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.geometry.ColorParser;
import lcsb.mapviewer.converter.ConverterException;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.BioEntity;
......@@ -66,6 +68,8 @@ public class ModelToGPML {
*/
private BiopaxParser biopaxParser = new BiopaxParser();
private ColorParser colorParser = new ColorParser();
/**
* Returns new unique identifier for the model.
*
......@@ -265,7 +269,7 @@ public class ModelToGPML {
/**
* This function transform Compartments into Shapes (Oval or Rectangle) from
* PathVisio. LineThickness=3.0 and Color=ffcc66. It can be easily changed.
* PathVisio.
*
* @param model
* model where compartments are placed
......@@ -297,7 +301,7 @@ public class ModelToGPML {
+ "Valign=\"Bottom\" "
+ "ShapeType=\"" + shape + "\" "
+ "LineThickness=\"3.0\" "
+ "Color=\"ffcc66\" "
+ "Color=\"" + colorToString(ca.getFillColor()) + "\" "
+ "Rotation=\"0.0\" />\n");
comparments.append(" </Shape>\n");
}
......@@ -310,7 +314,7 @@ public class ModelToGPML {
* model).
*
* @param rn
* object representing rectanat/product/modifier
* object representing reactant/product/modifier
* @param anchId
* identifier of the anchor where it will be connected
* @param anchors
......@@ -393,7 +397,7 @@ public class ModelToGPML {
}
/**
* This function encode SpeciesAliases into DataNodes from .gpml format. Empty
* This function encode SpeciesAliases into DataNodes from GPML format. Empty
* complexes are also transformed into DataNodes.
*
* @param model
......@@ -419,31 +423,18 @@ public class ModelToGPML {
dataNodes.append(" <Comment>" + species.getNotes() + "</Comment>\n");
dataNodes.append(biopaxParser.toReferenceXml(species.getMiriamData()));
String red = Integer.toHexString(species.getFillColor().getRed());
String green = Integer.toHexString(species.getFillColor().getGreen());
String blue = Integer.toHexString(species.getFillColor().getBlue());
if (red.length() == 1) {
red = "0" + red;
}
if (green.length() == 1) {
green = "0" + green;
}
if (blue.length() == 1) {
blue = "0" + blue;
}
String color = red + green + blue;
Rectangle2D rec = species.getBorder();
dataNodes.append(
" <Graphics CenterX=\"" + rec.getCenterX() +
"\" CenterY=\"" + rec.getCenterY() +
"\" Width=\"" + rec.getWidth() +
"\" Height=\"" + rec.getHeight() +
"\" ZOrder=\"" + species.getZ() +
"\" FontSize=\"" + species.getFontSize() + "\"" +
" Valign=\"Middle\" "
+ "Color=\"" + "0000ff"
+ "\" FillColor=\"" + color + "\"/>\n");
" <Graphics CenterX=\"" + rec.getCenterX() + "\" " +
"CenterY=\"" + rec.getCenterY() + "\" " +
"Width=\"" + rec.getWidth() + "\" " +
"Height=\"" + rec.getHeight() + "\" " +
"ZOrder=\"" + species.getZ() + "\" " +
"FontSize=\"" + species.getFontSize() + "\" " +
"Valign=\"Middle\" " +
"Color=\"" + colorToString(species.getFontColor()) + "\" " +
"FillColor=\"" + colorToString(species.getFillColor()) + "\"/>\n");
dataNodes.append(referenceParser.toXml(species.getMiriamData()));
dataNodes.append(" </DataNode>\n");
......@@ -464,16 +455,16 @@ public class ModelToGPML {
Rectangle2D rec = ca.getBorder();
dataNodes.append(
" <Graphics CenterX=\"" + rec.getCenterX() +
"\" CenterY=\"" + rec.getCenterY() +
"\" Width=\"" + rec.getWidth() +
"\" Height=\"" + rec.getHeight() +
"\" ZOrder=\"" + ca.getZ() +
"\" FontSize=\"" + ca.getFontSize() + "\"" +
" Valign=\"Middle\" " +
"Color=\"0000ff\" " +
"FillColor=\"ffffcc\"" +
" LineStyle=\"Broken\"/>\n");
" <Graphics CenterX=\"" + rec.getCenterX() + "\" " +
"CenterY=\"" + rec.getCenterY() + "\" " +
"Width=\"" + rec.getWidth() + "\" " +
"Height=\"" + rec.getHeight() + "\" " +
"ZOrder=\"" + ca.getZ() + "\" " +
"FontSize=\"" + ca.getFontSize() + "\" " +
"Valign=\"Middle\" " +
"Color=\"" + colorToString(ca.getFontColor()) + "\" " +
"FillColor=\"" + colorToString(ca.getFillColor()) + "\" " +
"LineStyle=\"Broken\"/>\n");
dataNodes.append(referenceParser.toXml(ca.getMiriamData()));
dataNodes.append(" </DataNode>\n");
......@@ -484,11 +475,11 @@ public class ModelToGPML {
}
/**
* This function encode ComplexAliases into Groups from .gpml format.
* This function encode ComplexAliases into Groups from GPML format.
*
* @param model
* model where aliases are placed
* @return string representing groups in gpml format
* @return string representing groups in GPML format
*/
protected String getGroups(Model model) {
StringBuilder groups = new StringBuilder("");
......@@ -506,11 +497,11 @@ public class ModelToGPML {
}
/**
* This function encode Reactions into Interactions from .gpml format.
* This function encode Reactions into Interactions from GPML format.
*
* @param model
* model where reactions are placed
* @return string with interactions in gpml format
* @return string with interactions in GPML format
* @throws ConverterException
* thrown when there is a problem with conversion
*/
......@@ -584,11 +575,11 @@ public class ModelToGPML {
}
/**
* This function returns Model in .gpml format.
* This function returns Model in GPML format.
*
* @param model
* model to transform
* @return string in gpml format representing model
* @return string in GPML format representing model
* @throws ConverterException
* thrown when there is a problem with conversion
*/
......@@ -617,4 +608,8 @@ public class ModelToGPML {
return gpml.toString();
}
private String colorToString(Color color) {
return colorParser.colorToHtml(color).substring(1);
}
}
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