Commit 3c063d71 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

center line is properly break between product operator and reactant operator

parent df5ca33b
......@@ -306,6 +306,10 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
operator = new AndOperator();
}
PolylineData line = extractCurve(reactionGlyph, reactionWithLayout, operator.getClass());
if (line.getPoints().size() == 0) {
line.addPoint(reactionWithLayout.getReactants().get(0).getLine().getEndPoint());
line.addPoint(reactionWithLayout.getReactants().get(0).getLine().getEndPoint());
}
operator.addInputs(reactionWithLayout.getReactants());
operator.setLine(line);
return operator;
......@@ -344,7 +348,7 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
return new PolylineData();
}
int requiredLines = 1;
int requiredLines = 0;
if (reaction.getReactants().size() > 1) {
requiredLines++;
}
......@@ -353,20 +357,18 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
}
int existingLines = curve.getCurveSegmentCount();
int reactantBreak;
int productBreak;
if (requiredLines == 3) {
reactantBreak = (existingLines - 1) / 2;
} else if (requiredLines == 2 && reaction.getReactants().size() > 1) {
reactantBreak = existingLines - 1;
} else if (requiredLines == 2 && reaction.getProducts().size() > 1) {
reactantBreak = 0;
int breakPoint;
if (requiredLines == 2) {
breakPoint = existingLines / 2;
} else if (reaction.getReactants().size() > 1) {
breakPoint = existingLines;
} else if (reaction.getProducts().size() > 1) {
breakPoint = 0;
} else {
throw new InvalidArgumentException(
new ElementUtils().getElementTag(reaction) + "Reaction has no products and reactants");
}
productBreak = reactantBreak + 1;
PolylineData result = new PolylineData();
if (operator == TruncationOperator.class ||
operator == DissociationOperator.class ||
......@@ -374,22 +376,18 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
// Product operator
if (existingLines >= requiredLines) {
CurveSegment segment = curve.getCurveSegment(productBreak);
CurveSegment segment = curve.getCurveSegment(breakPoint);
result.addPoint(new Point2D.Double(segment.getStart().getX(), segment.getStart().getY()));
for (int i = productBreak; i < curve.getCurveSegmentCount(); i++) {
for (int i = breakPoint; i < curve.getCurveSegmentCount(); i++) {
segment = curve.getCurveSegment(i);
result.addPoint(new Point2D.Double(segment.getEnd().getX(), segment.getEnd().getY()));
}
} else if (existingLines == 1) {
} else {
CurveSegment segment = curve.getCurveSegment(0);
double startX = segment.getStart().getX() + (segment.getEnd().getX() - segment.getStart().getX()) * (requiredLines-1) / requiredLines;
double startY = segment.getStart().getY() + (segment.getEnd().getY() - segment.getStart().getY()) * (requiredLines-1) / requiredLines;
double startX = segment.getStart().getX() + (segment.getEnd().getX() - segment.getStart().getX()) / 2;
double startY = segment.getStart().getY() + (segment.getEnd().getY() - segment.getStart().getY()) / 2;
result.addPoint(new Point2D.Double(startX, startY));
result.addPoint(new Point2D.Double(segment.getEnd().getX(), segment.getEnd().getY()));
} else {
CurveSegment segment = curve.getCurveSegment(1);
result.addPoint(new Point2D.Double(segment.getStart().getX(), segment.getStart().getY()));
result.addPoint(new Point2D.Double(segment.getEnd().getX(), segment.getEnd().getY()));
}
} else if (operator == AssociationOperator.class || operator == AndOperator.class) {
......@@ -398,16 +396,10 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
if (existingLines >= requiredLines) {
CurveSegment segment = curve.getCurveSegment(0);
result.addPoint(new Point2D.Double(segment.getStart().getX(), segment.getStart().getY()));
for (int i = 0; i < reactantBreak; i++) {
for (int i = 0; i < breakPoint; i++) {
segment = curve.getCurveSegment(i);
result.addPoint(new Point2D.Double(segment.getEnd().getX(), segment.getEnd().getY()));
}
} else if (existingLines == 1) {
CurveSegment segment = curve.getCurveSegment(0);
result.addPoint(new Point2D.Double(segment.getStart().getX(), segment.getStart().getY()));
double endX = segment.getStart().getX() + (segment.getEnd().getX() - segment.getStart().getX()) / requiredLines;
double endY = segment.getStart().getY() + (segment.getEnd().getY() - segment.getStart().getY()) / requiredLines;
result.addPoint(new Point2D.Double(endX, endY));
} else {
CurveSegment segment = curve.getCurveSegment(0);
result.addPoint(new Point2D.Double(segment.getStart().getX(), segment.getStart().getY()));
......
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