mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +00:00
Minor bug fix
This commit is contained in:
parent
51b9bfb05a
commit
ebf7613792
@ -70,17 +70,17 @@ public class ConstraintSet {
|
||||
}
|
||||
|
||||
public Constraint getConstraint(Pushable p1, Pushable p2) {
|
||||
if (p1 == null || p2 == null || p1 == p2) {
|
||||
if (p1 == null || p2 == null || p1 == p2)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
final int i1 = participantList.indexOf(p1);
|
||||
final int i2 = participantList.indexOf(p2);
|
||||
if (i1 == -1 || i2 == -1) {
|
||||
if (i1 == -1 || i2 == -1)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (i1 > i2) {
|
||||
|
||||
if (i1 > i2)
|
||||
return getConstraint(p2, p1);
|
||||
}
|
||||
|
||||
final List<Pushable> key = Arrays.asList(p1, p2);
|
||||
Constraint result = constraints.get(key);
|
||||
if (result == null) {
|
||||
@ -108,16 +108,16 @@ public class ConstraintSet {
|
||||
|
||||
private Pushable getOtherParticipant(Pushable p, int delta) {
|
||||
final int i = participantList.indexOf(p);
|
||||
if (i == -1) {
|
||||
if (i == -1)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
return participantList.get(i + delta);
|
||||
}
|
||||
|
||||
public void takeConstraintIntoAccount(StringBounder stringBounder) {
|
||||
for (int dist = 1; dist < participantList.size(); dist++) {
|
||||
for (int dist = 1; dist < participantList.size(); dist++)
|
||||
pushEverybody(stringBounder, dist);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void pushEverybody(StringBounder stringBounder, int dist) {
|
||||
@ -130,22 +130,22 @@ public class ConstraintSet {
|
||||
}
|
||||
|
||||
public void pushToLeftParticipantBox(double deltaX, Pushable firstToChange, boolean including) {
|
||||
if (deltaX <= 0) {
|
||||
if (deltaX <= 0)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
Objects.requireNonNull(firstToChange);
|
||||
// freeX += deltaX;
|
||||
boolean founded = false;
|
||||
for (Pushable box : participantList) {
|
||||
if (box.equals(firstToChange)) {
|
||||
founded = true;
|
||||
if (including == false) {
|
||||
if (including == false)
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
if (founded) {
|
||||
if (founded)
|
||||
box.pushToLeft(deltaX);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,18 +154,17 @@ public class ConstraintSet {
|
||||
}
|
||||
|
||||
private void ensureSpaceAfter(StringBounder stringBounder, Pushable p1, Pushable p2, double space) {
|
||||
if (p1.equals(p2)) {
|
||||
if (p1.equals(p2))
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
if (p1.getCenterX(stringBounder) > p2.getCenterX(stringBounder)) {
|
||||
ensureSpaceAfter(stringBounder, p2, p1, space);
|
||||
return;
|
||||
}
|
||||
assert p1.getCenterX(stringBounder) < p2.getCenterX(stringBounder);
|
||||
final double existingSpace = p2.getCenterX(stringBounder) - p1.getCenterX(stringBounder);
|
||||
if (existingSpace < space) {
|
||||
if (existingSpace < space)
|
||||
pushToLeftParticipantBox(space - existingSpace, p2, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -56,11 +56,11 @@ final class NotesBoxes extends GraphicalElement implements InGroupable {
|
||||
public void add(NoteBox noteBox, ParticipantBox participantBox1, ParticipantBox participantBox2) {
|
||||
notes.add(noteBox);
|
||||
participants1.add(participantBox1);
|
||||
if (participantBox2 == null) {
|
||||
if (participantBox2 == null)
|
||||
participants2.add(participantBox1);
|
||||
} else {
|
||||
else
|
||||
participants2.add(participantBox2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ensureConstraints(StringBounder stringBounder, ConstraintSet constraintSet) {
|
||||
@ -79,7 +79,9 @@ final class NotesBoxes extends GraphicalElement implements InGroupable {
|
||||
final NoteBox noteBox2 = notes.get(j);
|
||||
final ParticipantBox otherParticipantBox1 = participants1.get(j);
|
||||
final double width2 = noteBox2.getPreferredWidth(stringBounder);
|
||||
constraintSet.getConstraint(participantBox2, otherParticipantBox1).ensureValue((width + width2) / 2);
|
||||
if (participantBox2 != otherParticipantBox1)
|
||||
constraintSet.getConstraint(participantBox2, otherParticipantBox1)
|
||||
.ensureValue((width + width2) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,9 +90,9 @@ final class NotesBoxes extends GraphicalElement implements InGroupable {
|
||||
double result = Double.MAX_VALUE;
|
||||
for (NoteBox n : notes) {
|
||||
final double m = n.getMinX(stringBounder);
|
||||
if (m < result) {
|
||||
if (m < result)
|
||||
result = m;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -99,9 +101,9 @@ final class NotesBoxes extends GraphicalElement implements InGroupable {
|
||||
double result = -Double.MAX_VALUE;
|
||||
for (NoteBox n : notes) {
|
||||
final double m = n.getMaxX(stringBounder);
|
||||
if (m > result) {
|
||||
if (m > result)
|
||||
result = m;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -112,9 +114,9 @@ final class NotesBoxes extends GraphicalElement implements InGroupable {
|
||||
|
||||
@Override
|
||||
protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
|
||||
for (NoteBox n : notes) {
|
||||
for (NoteBox n : notes)
|
||||
n.drawInternalU(ug, maxX, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -122,9 +124,9 @@ final class NotesBoxes extends GraphicalElement implements InGroupable {
|
||||
double result = Double.MAX_VALUE;
|
||||
for (NoteBox n : notes) {
|
||||
final double m = n.getStartingX(stringBounder);
|
||||
if (m < result) {
|
||||
if (m < result)
|
||||
result = m;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -140,9 +142,9 @@ final class NotesBoxes extends GraphicalElement implements InGroupable {
|
||||
double result = 0;
|
||||
for (NoteBox n : notes) {
|
||||
final double m = n.getPreferredHeight(stringBounder);
|
||||
if (m > result) {
|
||||
if (m > result)
|
||||
result = m;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user