1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-22 21:15:09 +00:00

Fix arrow constraint position

This commit is contained in:
Arnaud Roques 2021-10-04 23:01:59 +02:00
parent 9383a24be7
commit 5fb770cb57
2 changed files with 19 additions and 9 deletions

View File

@ -76,6 +76,10 @@ public class TimeConstraint {
this.styleBuilder = skinParam.getCurrentStyleBuilder();
}
public final boolean containsStrict(TimeTick other) {
return tick1.compareTo(other) < 0 && tick2.compareTo(other) > 0;
}
public final TimeTick getTick1() {
return tick1;
}

View File

@ -347,18 +347,16 @@ public class Histogram implements PDrawing {
private void drawConstraints(UGraphic ug) {
for (TimeConstraint constraint : constraints) {
final String state1 = last(getStatesAt(constraint.getTick1()));
final String state2 = getStatesAt(constraint.getTick2()).get(0);
final double y1 = yOfState(state1);
final double y2 = yOfState(state2);
constraint.drawU(ug.apply(UTranslate.dy(y1)), ruler);
double y = yOfState(constraint.getTick1());
for (ChangeState change : changes) {
if (constraint.containsStrict(change.getWhen())) {
y = Math.min(y, yOfState(change.getWhen()));
}
}
constraint.drawU(ug.apply(UTranslate.dy(y)), ruler);
}
}
private static String last(List<String> list) {
return list.get(list.size() - 1);
}
private Point2D.Double getInitialPoint() {
return new Point2D.Double(-getInitialWidth(), yOfState(initialState));
}
@ -380,6 +378,14 @@ public class Histogram implements PDrawing {
return stepHeight() * nb;
}
private double yOfState(TimeTick when) {
return yOfState(last(getStatesAt(when)));
}
private static String last(List<String> list) {
return list.get(list.size() - 1);
}
private double stepHeight() {
if (suggestedHeight == 0 || allStates.size() <= 1) {
return 20;