Commit 2e6c58ec authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch 'gpml-prototype' into 'master'

Gpml prototype

Closes #959

See merge request !990
parents 16327644 6eda7ed1
minerva (15.0.0~alpha.0) stable; urgency=medium
* Improvement: logs provided for validation data model are structurized (#325)
* Improvement: import/export of GPML implemented
* Small improvement: compartments in not layouted SBML file are more
scattered (#326)
* Small improvement: when downloading a map results in too big file (>1MB)
......
......@@ -78,7 +78,9 @@ public class Pair<L, R> implements Serializable {
@Override
public String toString() {
return "Pair: " + getLeft().toString() + ", " + getRight().toString();
String left = getLeft() == null ? "null" : getLeft().toString();
String right = getRight() == null ? "null" : getRight().toString();
return "Pair: " + left + ", " + right;
}
}
\ No newline at end of file
package lcsb.mapviewer.common.comparator;
import java.util.Comparator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public abstract class AbstractComparator<T> implements Comparator<T> {
private Logger logger = LogManager.getLogger();
public int compare(T o1, T o2, String objectName) {
int result = compare(o1, o2);
if (result != 0) {
logger.debug(objectName + " different: " + o1 + "\t" + o2);
}
return result;
}
}
package lcsb.mapviewer.common.comparator;
import java.awt.*;
import java.util.Comparator;
import java.awt.Color;
/**
* Comparator implementation for {@link Color} class.
......@@ -9,7 +8,7 @@ import java.util.Comparator;
* @author Piotr Gawron
*
*/
public class ColorComparator implements Comparator<Color> {
public class ColorComparator extends AbstractComparator<Color> {
@Override
public int compare(Color arg0, Color arg1) {
......
package lcsb.mapviewer.common.comparator;
import java.util.Comparator;
import lcsb.mapviewer.common.Configuration;
/**
......@@ -10,7 +8,7 @@ import lcsb.mapviewer.common.Configuration;
* @author Piotr Gawron
*
*/
public class DoubleComparator implements Comparator<Double> {
public class DoubleComparator extends AbstractComparator<Double> {
/**
* Epsilon value used for comparison of doubles.
......
package lcsb.mapviewer.common.comparator;
import java.util.Comparator;
/**
* Comparator implemented for {@link Integer} class.
*
* @author Piotr Gawron
*
*/
public class IntegerComparator implements Comparator<Integer> {
public class IntegerComparator extends AbstractComparator<Integer> {
@Override
public int compare(Integer arg0, Integer arg1) {
......
package lcsb.mapviewer.common.comparator;
import java.util.Comparator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -12,7 +10,7 @@ import org.apache.logging.log4j.Logger;
* @author Piotr Gawron
*
*/
public class StringComparator implements Comparator<String> {
public class StringComparator extends AbstractComparator<String> {
/**
* Default class logger.
*/
......
......@@ -67,6 +67,13 @@
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframework.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.xerces.parsers.DOMParser;
import org.springframework.stereotype.Component;
import org.w3c.dom.*;
import lcsb.mapviewer.common.*;
......@@ -55,6 +56,7 @@ import lcsb.mapviewer.model.map.species.Element;
* @author Piotr Gawron
*
*/
@Component
public class CellDesignerXmlParser extends Converter {
/**
......
......@@ -9,12 +9,14 @@ import org.apache.commons.text.StringEscapeUtils;
import org.apache.logging.log4j.core.LogEvent;
import org.sbgn.SbgnUtil;
import org.sbgn.bindings.Sbgn;
import org.springframework.stereotype.Component;
import lcsb.mapviewer.common.MimeType;
import lcsb.mapviewer.common.MinervaLoggerAppender;
import lcsb.mapviewer.converter.*;
import lcsb.mapviewer.model.map.model.Model;
@Component
public class SbgnmlXmlConverter extends Converter {
@Override
......
......@@ -420,8 +420,8 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert
public void drawText(final T species, final Graphics2D graphics, final ConverterParams params) {
String text = getText(species);
Font oldFont = graphics.getFont();
Font font = getFont(species, params);
Color oldColor = graphics.getColor();
Font font = getFont(species, params);
graphics.setColor(species.getFontColor());
graphics.setFont(font);
......
......@@ -13,6 +13,7 @@ import org.sbml.jsbml.ext.SBasePlugin;
import org.sbml.jsbml.ext.layout.Layout;
import org.sbml.jsbml.ext.layout.LayoutModelPlugin;
import org.sbml.jsbml.ext.multi.MultiModelPlugin;
import org.springframework.stereotype.Component;
import lcsb.mapviewer.commands.CommandExecutionException;
import lcsb.mapviewer.commands.layout.ApplySimpleLayoutModelCommand;
......@@ -33,6 +34,7 @@ import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
import lcsb.mapviewer.model.map.species.field.SpeciesWithModificationResidue;
@Component
public class SbmlParser extends Converter {
/**
......
......@@ -40,7 +40,6 @@ public class ZIndexPopulator {
int maxZIndex = 0;
List<Drawable> bioEntities = new ArrayList<>();
bioEntities.addAll(model.getBioEntities());
for (Layer layer : model.getLayers()) {
bioEntities.addAll(layer.getOvals());
bioEntities.addAll(layer.getRectangles());
......
......@@ -260,15 +260,17 @@ public class PolylineData implements Serializable, Drawable {
* @param distToTrim
* distance by which end of line should be trimmed
*/
public void trimEnd(double distToTrim) {
public double trimEnd(double distToTrim) {
Point2D last = points.get(points.size() - 1);
Point2D last2 = points.get(points.size() - 2);
double oldDist = last.distance(last2);
if (distToTrim < 0 && oldDist <= Configuration.EPSILON) {
logger.debug("Cannot extend empty line");
last.setLocation(last2);
return 0;
} else if (oldDist <= distToTrim) {
last.setLocation(last2);
return oldDist;
} else {
double newDistr = oldDist - distToTrim;
double ratio = newDistr / oldDist;
......@@ -277,6 +279,7 @@ public class PolylineData implements Serializable, Drawable {
dx *= ratio;
dy *= ratio;
last.setLocation(last2.getX() + dx, last2.getY() + dy);
return distToTrim;
}
}
......@@ -286,12 +289,13 @@ public class PolylineData implements Serializable, Drawable {
* @param distToTrim
* distance by which beginning of line should be trimmed
*/
public void trimBegin(double distToTrim) {
public double trimBegin(double distToTrim) {
Point2D last = points.get(0);
Point2D last2 = points.get(1);
double oldDist = last.distance(last2);
if (oldDist <= distToTrim) {
last.setLocation(last2);
return oldDist;
} else {
double newDistr = oldDist - distToTrim;
double ratio = newDistr / oldDist;
......@@ -300,6 +304,7 @@ public class PolylineData implements Serializable, Drawable {
dx *= ratio;
dy *= ratio;
last.setLocation(last2.getX() + dx, last2.getY() + dy);
return distToTrim;
}
}
......
......@@ -50,7 +50,7 @@ public class Compartment extends Element {
/**
* Default thickness of compartment border.
*/
private static final int DEFAULT_COMPARTMENT_THICKNESS = 12;
public static final int DEFAULT_COMPARTMENT_THICKNESS = 12;
/**
* Default class logger.
......
......@@ -6,6 +6,7 @@ import org.apache.logging.log4j.Logger;
import lcsb.mapviewer.common.Comparator;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.comparator.*;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.graphics.PolylineDataComparator;
/**
......@@ -88,40 +89,32 @@ public class LayerComparator extends Comparator<Layer> {
return integerComparator.compare(arg0.getOvals().size(), arg1.getOvals().size());
}
LayerTextComparator textComparator = new LayerTextComparator(epsilon);
for (int i = 0; i < arg0.getTexts().size(); i++) {
int status = textComparator.compare(arg0.getTexts().get(i), arg1.getTexts().get(i));
if (status != 0) {
logger.debug("layer texts different");
return status;
}
ListComparator<LayerText> textComparator = new ListComparator<>(new LayerTextComparator(epsilon));
int status = textComparator.compare(arg0.getTexts(), arg1.getTexts());
if (status != 0) {
logger.debug("layer texts different");
return status;
}
LayerOvalComparator ovalComparator = new LayerOvalComparator(epsilon);
for (int i = 0; i < arg0.getOvals().size(); i++) {
int status = ovalComparator.compare(arg0.getOvals().get(i), arg1.getOvals().get(i));
if (status != 0) {
logger.debug("layer ovals different");
return status;
}
ListComparator<LayerOval> ovalComparator = new ListComparator<>(new LayerOvalComparator(epsilon));
status = ovalComparator.compare(arg0.getOvals(), arg1.getOvals());
if (status != 0) {
logger.debug("layer ovals different");
return status;
}
LayerRectComparator rectComparator = new LayerRectComparator(epsilon);
for (int i = 0; i < arg0.getRectangles().size(); i++) {
int status = rectComparator.compare(arg0.getRectangles().get(i), arg1.getRectangles().get(i));
if (status != 0) {
logger.debug("layer rectangles different ");
return status;
}
ListComparator<LayerRect> rectComparator = new ListComparator<>(new LayerRectComparator(epsilon));
status = rectComparator.compare(arg0.getRectangles(), arg1.getRectangles());
if (status != 0) {
logger.debug("layer rectangles different ");
return status;
}
PolylineDataComparator lineComparator = new PolylineDataComparator(epsilon);
for (int i = 0; i < arg0.getLines().size(); i++) {
int status = lineComparator.compare(arg0.getLines().get(i), arg1.getLines().get(i));
if (status != 0) {
logger.debug("layer lines different ");
return status;
}
ListComparator<PolylineData> lineComparator = new ListComparator<>(new PolylineDataComparator(epsilon));
status = lineComparator.compare(arg0.getLines(), arg1.getLines());
if (status != 0) {
logger.debug("layer lines different ");
return status;
}
return 0;
......
package lcsb.mapviewer.model.map.layout.graphics;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import lcsb.mapviewer.common.Comparator;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.comparator.*;
......@@ -13,6 +16,8 @@ import lcsb.mapviewer.common.comparator.*;
*/
public class LayerTextComparator extends Comparator<LayerText> {
private Logger logger = LogManager.getLogger();
/**
* Epsilon value used for comparison of doubles.
*/
......@@ -44,35 +49,35 @@ public class LayerTextComparator extends Comparator<LayerText> {
IntegerComparator integerComparator = new IntegerComparator();
if (doubleComparator.compare(arg0.getWidth(), arg1.getWidth()) != 0) {
return doubleComparator.compare(arg0.getWidth(), arg1.getWidth());
return doubleComparator.compare(arg0.getWidth(), arg1.getWidth(), "width");
}
if (doubleComparator.compare(arg0.getHeight(), arg1.getHeight()) != 0) {
return doubleComparator.compare(arg0.getHeight(), arg1.getHeight());
return doubleComparator.compare(arg0.getHeight(), arg1.getHeight(), "height");
}
if (doubleComparator.compare(arg0.getX(), arg1.getX()) != 0) {
return doubleComparator.compare(arg0.getX(), arg1.getX());
return doubleComparator.compare(arg0.getX(), arg1.getX(), "x");
}
if (doubleComparator.compare(arg0.getY(), arg1.getY()) != 0) {
return doubleComparator.compare(arg0.getY(), arg1.getY());
return doubleComparator.compare(arg0.getY(), arg1.getY(), "y");
}
if (colorComparator.compare(arg0.getColor(), arg1.getColor()) != 0) {
return colorComparator.compare(arg0.getColor(), arg1.getColor());
return colorComparator.compare(arg0.getColor(), arg1.getColor(), "color");
}
if (stringComparator.compare(arg0.getNotes(), arg1.getNotes()) != 0) {
return stringComparator.compare(arg0.getNotes(), arg1.getNotes());
return stringComparator.compare(arg0.getNotes(), arg1.getNotes(), "notes");
}
if (doubleComparator.compare(arg0.getFontSize(), arg1.getFontSize()) != 0) {
return doubleComparator.compare(arg0.getFontSize(), arg1.getFontSize());
return doubleComparator.compare(arg0.getFontSize(), arg1.getFontSize(), "fontSize");
}
if (integerComparator.compare(arg0.getZ(), arg1.getZ()) != 0) {
return integerComparator.compare(arg0.getZ(), arg1.getZ());
return integerComparator.compare(arg0.getZ(), arg1.getZ(), "z");
}
return 0;
......
......@@ -117,7 +117,7 @@ public class ElementComparator extends Comparator<Element> {
}
if (colorComparator.compare(arg0.getFontColor(), arg1.getFontColor()) != 0) {
logger.debug("Border Font different: " + arg0.getFontColor() + ", " + arg1.getFontColor());
logger.debug("Font color different: " + arg0.getFontColor() + ", " + arg1.getFontColor());
return colorComparator.compare(arg0.getFontColor(), arg1.getFontColor());
}
......
......@@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
......@@ -15,6 +20,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
......@@ -22,8 +32,11 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
......@@ -8,7 +8,7 @@
<artifactId>pathvisio</artifactId>
<name>Pathvisio plugin</name>
<packaging>bundle</packaging>
<!-- <packaging>bundle</packaging>
<build>
<plugins>
......@@ -128,7 +128,7 @@
</plugin>
</plugins>
</build>
-->
<repositories>
<repository>
<id>repo</id>
......
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