Skip to content
Snippets Groups Projects

issues that were discovered during biohackathon 2019 in Paris

Merged Piotr Gawron requested to merge wikipathways-issues into master
3 files
+ 73
37
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -10,8 +10,8 @@ import lcsb.mapviewer.commands.CommandExecutionException;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.common.geometry.DoubleDimension;
import lcsb.mapviewer.common.geometry.PointTransformation;
import lcsb.mapviewer.common.geometry.*;
import lcsb.mapviewer.converter.ZIndexPopulator;
import lcsb.mapviewer.converter.model.celldesigner.types.ModifierTypeUtils;
import lcsb.mapviewer.model.graphics.ArrowType;
import lcsb.mapviewer.model.graphics.PolylineData;
@@ -36,7 +36,7 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
/**
* Default class logger.
*/
private Logger logger = LogManager.getLogger(ApplySimpleLayoutModelCommand.class);
private Logger logger = LogManager.getLogger();
private PointTransformation pt = new PointTransformation();
public ApplySimpleLayoutModelCommand(Model model, Collection<BioEntity> bioEntities, Double minX, Double minY,
@@ -79,7 +79,6 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
modifyElementLocation(elements, null, minPoint, dimension);
modifyReactionLocation(reactions);
}
protected void modifyElementLocation(Collection<Element> elements, Compartment parent, Point2D minPoint,
@@ -241,9 +240,14 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
middle = operatorPoint;
}
for (Reactant reactant : reaction.getReactants()) {
Element element = reactant.getElement();
PolylineData line = new PolylineData();
line.addPoint(reactant.getElement().getCenter());
line.addPoint(element.getCenter());
line.addPoint(middle);
Point2D startPoint = findCrossPoint(element, line);
if (startPoint != null) {
line.getBeginPoint().setLocation(startPoint);
}
if (reaction.isReversible()) {
line.getBeginAtd().setArrowType(ArrowType.FULL);
}
@@ -254,9 +258,22 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
}
}
private Point2D findCrossPoint(Element element, PolylineData line) {
LineTransformation lt = new LineTransformation();
Point2D startPoint = lt.getIntersectionWithPathIterator(
new Line2D.Double(line.getBeginPoint(), line.getEndPoint()),
element.getBorder().getPathIterator(new AffineTransform()));
return startPoint;
}
private void modifyModifiers(Reaction reaction, Point2D middle) {
for (Modifier modifier : reaction.getModifiers()) {
PolylineData line = new PolylineData(middle, modifier.getElement().getCenter());
Element element = modifier.getElement();
PolylineData line = new PolylineData(element.getCenter(), middle);
Point2D startPoint = findCrossPoint(element, line);
if (startPoint != null) {
line.getBeginPoint().setLocation(startPoint);
}
modifier.setLine(line);
new ModifierTypeUtils().updateLineEndPoint(modifier);
}
@@ -279,7 +296,12 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
middle = operatorPoint;
}
for (Product product : reaction.getProducts()) {
PolylineData line = new PolylineData(middle, product.getElement().getCenter());
Element element = product.getElement();
PolylineData line = new PolylineData(middle, element.getCenter());
Point2D endPoint = findCrossPoint(element, line);
if (endPoint != null) {
line.getEndPoint().setLocation(endPoint);
}
line.getEndAtd().setArrowType(ArrowType.FULL);
product.setLine(line);
if (operator != null) {
@@ -427,8 +449,14 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
}
protected Dimension2D estimateDimension(Collection<BioEntity> bioEntites) {
double suggestedSize = Math.max(100 * bioEntites.size() / 4,
Math.sqrt((SPECIES_WIDTH + 10) * (SPECIES_HEIGHT + 10) * bioEntites.size()));
int elementsCount = 0;
for (BioEntity bioEntity : bioEntites) {
if (bioEntity instanceof Element) {
elementsCount++;
}
}
double suggestedSize = Math.max(100 * elementsCount,
Math.sqrt((SPECIES_WIDTH + 10) * (SPECIES_HEIGHT + 10) * elementsCount));
if (bioEntites.size() > 0) {
suggestedSize = Math.max(suggestedSize, 2 * (SPECIES_WIDTH + 10));
}
@@ -467,6 +495,7 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
}
createLayout(model, bioEntites, null, minPoint, dimension);
}
new ZIndexPopulator().populateZIndex(bioEntites);
}
}
Loading