Skip to content

Commit

Permalink
🐛 improved diamond alignment in gantt diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudroques committed Jan 3, 2025
1 parent a145ed8 commit e74c5f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/net/sourceforge/plantuml/project/GanttArrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private double getX(TaskAttribute taskAttribute, TaskDraw task, Direction direct
return task.getX1(taskAttribute);

if (direction == Direction.RIGHT)
return task.getX2(taskAttribute);
return task.getX2(taskAttribute) + 2;

return (task.getX1(taskAttribute) + (task.getX2(taskAttribute))) / 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public final Task getTask() {
public final double getY(StringBounder stringBounder, Direction direction) {
final Style style = getStyle();
final ClockwiseTopRightBottomLeft margin = style.getMargin();
final ClockwiseTopRightBottomLeft padding = style.getPadding();
// final ClockwiseTopRightBottomLeft padding = style.getPadding();

final double y1 = margin.getTop() + getY(stringBounder).getCurrentValue();
final double y2 = y1 + getShapeHeight(stringBounder);
Expand Down
12 changes: 8 additions & 4 deletions src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public double getHeightMax(StringBounder stringBounder) {

@Override
protected double getShapeHeight(StringBounder stringBounder) {
final String displayString = getTask().getDisplayString();
if (displayString == null)
return getDiamondHeight();

final TextBlock title = getTitle();
final XDimension2D titleDim = title.calculateDimension(stringBounder);
return Math.max(titleDim.getHeight(), getDiamondHeight());
Expand Down Expand Up @@ -127,8 +131,8 @@ final public void drawTitle(UGraphic ug, LabelStrategy labelStrategy, double col

@Override
protected TextBlock getTitle() {
return Display.getWithNewlines(getStyleBuilder().getSkinParam().getPragma(), prettyDisplay).create(getFontConfiguration(), HorizontalAlignment.LEFT,
new SpriteContainerEmpty());
return Display.getWithNewlines(getStyleBuilder().getSkinParam().getPragma(), prettyDisplay)
.create(getFontConfiguration(), HorizontalAlignment.LEFT, new SpriteContainerEmpty());
}

@Override
Expand All @@ -154,8 +158,8 @@ public void drawU(UGraphic ug) {
ug = ug.apply(UTranslate.dx(delta / 2));
drawShape(applyColors(ug));
} else {
final TextBlock draw = Display.getWithNewlines(getStyleBuilder().getSkinParam().getPragma(), displayString).create(getFontConfiguration(),
HorizontalAlignment.LEFT, new SpriteContainerEmpty());
final TextBlock draw = Display.getWithNewlines(getStyleBuilder().getSkinParam().getPragma(), displayString)
.create(getFontConfiguration(), HorizontalAlignment.LEFT, new SpriteContainerEmpty());
draw.drawU(ug);
}
if (url != null)
Expand Down

0 comments on commit e74c5f8

Please sign in to comment.