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

point on line is computed properly

parent 3ea58610
......@@ -19,6 +19,7 @@ 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.converter.model.celldesigner.types.ModifierTypeUtils;
import lcsb.mapviewer.model.graphics.ArrowType;
import lcsb.mapviewer.model.graphics.PolylineData;
......@@ -57,6 +58,8 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
private static final int SPECIES_WIDTH = 90;
private static final int SPECIES_HEIGHT = 30;
private static final double COMPLEX_PADDING = 5;
private PointTransformation pt = new PointTransformation();
public ApplySimpleLayoutModelCommand(Model model, Collection<BioEntity> bioEntities, Double minX, Double minY,
Double maxX, Double maxY, boolean addReactionPrefixes) {
......@@ -240,9 +243,9 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
Element productElement = reaction.getProducts().get(0).getElement();
Element reactantElement = reaction.getReactants().get(0).getElement();
Point2D centerLineStart = getMiddlePoint(reactantElement.getCenter(), productElement.getCenter(), 0.4);
Point2D centerLineEnd = getMiddlePoint(reactantElement.getCenter(), productElement.getCenter(), 0.6);
Point2D middle = getMiddlePoint(reactantElement.getCenter(), productElement.getCenter(), 0.5);
Point2D centerLineStart = pt.getPointOnLine(reactantElement.getCenter(), productElement.getCenter(), 0.4);
Point2D centerLineEnd = pt.getPointOnLine(reactantElement.getCenter(), productElement.getCenter(), 0.6);
Point2D middle = pt.getPointOnLine(reactantElement.getCenter(), productElement.getCenter(), 0.5);
// for self reactions
if (productElement.equals(reactantElement)) {
......@@ -263,10 +266,6 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
}
}
private Point2D.Double getMiddlePoint(Point2D middle, Point2D productPoint, double coef) {
return new Point2D.Double((productPoint.getX() + middle.getX()) / 2, (productPoint.getY() + middle.getY()) / 2);
}
private void modifyReactants(Reaction reaction, Point2D middle) {
NodeOperator operator = null;
if (reaction.getReactants().size() > 1) {
......@@ -276,7 +275,7 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
operator = new AndOperator();
}
Point2D productPoint = reaction.getReactants().get(0).getElement().getCenter();
Point2D operatorPoint = getMiddlePoint(middle, productPoint, 0.5);
Point2D operatorPoint = pt.getPointOnLine(middle, productPoint, 0.5);
operator.setLine(new PolylineData(operatorPoint, middle));
reaction.addNode(operator);
middle = operatorPoint;
......@@ -315,7 +314,7 @@ public class ApplySimpleLayoutModelCommand extends ApplyLayoutModelCommand {
operator = new SplitOperator();
}
Point2D productPoint = reaction.getProducts().get(0).getElement().getCenter();
Point2D operatorPoint = getMiddlePoint(middle, productPoint, 0.5);
Point2D operatorPoint = pt.getPointOnLine(middle, productPoint, 0.5);
operator.setLine(new PolylineData(operatorPoint, middle));
reaction.addNode(operator);
middle = operatorPoint;
......
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