Skip to content

Commit

Permalink
Correct arrow index when empty no components.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Sep 25, 2015
1 parent a872dca commit 60fdbdf
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -92,17 +92,24 @@ public ReactionDepiction(RendererModel model,
this.mainComp.add(reactant);
this.mainComp.add(plus);
}

// replacing trailing plus with placeholder for arrow
this.mainComp.set(this.mainComp.size() - 1, new Bounds());
if (reactants.isEmpty())
this.mainComp.add(new Bounds());
else
this.mainComp.set(this.mainComp.size() - 1, new Bounds());

for (Bounds product : products) {
this.mainComp.add(product);
this.mainComp.add(plus);
}

// trailing plus not needed
this.mainComp.remove(this.mainComp.size() - 1);
if (!products.isEmpty())
this.mainComp.remove(this.mainComp.size() - 1);

// arrow params
this.arrowIdx = reactants.size() + reactants.size() - 1;
this.arrowIdx = Math.max(reactants.size() + reactants.size() - 1, 0);
this.direction = direction;
this.arrowHeight = plus.height();

Expand Down

0 comments on commit 60fdbdf

Please sign in to comment.