mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-23 03:19:06 +00:00
fix: clear cache when StringBounder has changed
https://github.com/plantuml/plantuml/issues/1575 https://forum.plantuml.net/18480/teoz-produces-odd-legend-for-sequence-diagrams
This commit is contained in:
parent
6d158d1196
commit
dbb535473c
@ -1,4 +1,4 @@
|
|||||||
# Warning, "version" should be the same in gradle.properties and Version.java
|
# Warning, "version" should be the same in gradle.properties and Version.java
|
||||||
# Any idea anyone how to magically synchronize those :-) ?
|
# Any idea anyone how to magically synchronize those :-) ?
|
||||||
version = 1.2024.0beta2
|
version = 1.2024.0beta3
|
||||||
org.gradle.workers.max = 3
|
org.gradle.workers.max = 3
|
@ -81,6 +81,7 @@ public class AtomTable extends AbstractAtom implements Atom {
|
|||||||
private final List<Line> lines = new ArrayList<>();
|
private final List<Line> lines = new ArrayList<>();
|
||||||
private final Map<Atom, Position> positions = new HashMap<Atom, Position>();
|
private final Map<Atom, Position> positions = new HashMap<Atom, Position>();
|
||||||
private final HColor lineColor;
|
private final HColor lineColor;
|
||||||
|
private Class<? extends StringBounder> lastCaller;
|
||||||
|
|
||||||
public AtomTable(HColor lineColor) {
|
public AtomTable(HColor lineColor) {
|
||||||
this.lineColor = lineColor;
|
this.lineColor = lineColor;
|
||||||
@ -110,14 +111,14 @@ public class AtomTable extends AbstractAtom implements Atom {
|
|||||||
.draw(URectangle.build(x2 - x1, y2 - y1));
|
.draw(URectangle.build(x2 - x1, y2 - y1));
|
||||||
}
|
}
|
||||||
for (int j = 0; j < getNbCols(); j++) {
|
for (int j = 0; j < getNbCols(); j++) {
|
||||||
if (j >= line.cells.size()) {
|
if (j >= line.cells.size())
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
final Atom cell = line.cells.get(j);
|
final Atom cell = line.cells.get(j);
|
||||||
HorizontalAlignment align = HorizontalAlignment.LEFT;
|
HorizontalAlignment align = HorizontalAlignment.LEFT;
|
||||||
if (cell instanceof SheetBlock1) {
|
if (cell instanceof SheetBlock1)
|
||||||
align = ((SheetBlock1) cell).getCellAlignment();
|
align = ((SheetBlock1) cell).getCellAlignment();
|
||||||
}
|
|
||||||
final HColor cellBackColor = line.cellsBackColor.get(j);
|
final HColor cellBackColor = line.cellsBackColor.get(j);
|
||||||
final double x1 = getStartingX(j);
|
final double x1 = getStartingX(j);
|
||||||
final double x2 = getStartingX(j + 1);
|
final double x2 = getStartingX(j + 1);
|
||||||
@ -131,11 +132,11 @@ public class AtomTable extends AbstractAtom implements Atom {
|
|||||||
final Position pos = positions.get(cell);
|
final Position pos = positions.get(cell);
|
||||||
final XDimension2D dimCell = cell.calculateDimension(ug.getStringBounder());
|
final XDimension2D dimCell = cell.calculateDimension(ug.getStringBounder());
|
||||||
final double dx;
|
final double dx;
|
||||||
if (align == HorizontalAlignment.RIGHT) {
|
if (align == HorizontalAlignment.RIGHT)
|
||||||
dx = cellWidth - dimCell.getWidth();
|
dx = cellWidth - dimCell.getWidth();
|
||||||
} else {
|
else
|
||||||
dx = 0;
|
dx = 0;
|
||||||
}
|
|
||||||
if (cellBackColor == null)
|
if (cellBackColor == null)
|
||||||
cell.drawU(ug.apply(pos.getTranslate().compose(UTranslate.dx(dx))));
|
cell.drawU(ug.apply(pos.getTranslate().compose(UTranslate.dx(dx))));
|
||||||
else
|
else
|
||||||
@ -144,20 +145,25 @@ public class AtomTable extends AbstractAtom implements Atom {
|
|||||||
}
|
}
|
||||||
ug = ug.apply(lineColor);
|
ug = ug.apply(lineColor);
|
||||||
final ULine hline = ULine.hline(getEndingX(getNbCols() - 1));
|
final ULine hline = ULine.hline(getEndingX(getNbCols() - 1));
|
||||||
for (int i = 0; i <= getNbLines(); i++) {
|
for (int i = 0; i <= getNbLines(); i++)
|
||||||
ug.apply(UTranslate.dy(getStartingY(i))).draw(hline);
|
ug.apply(UTranslate.dy(getStartingY(i))).draw(hline);
|
||||||
}
|
|
||||||
final ULine vline = ULine.vline(getEndingY(getNbLines() - 1));
|
final ULine vline = ULine.vline(getEndingY(getNbLines() - 1));
|
||||||
for (int i = 0; i <= getNbCols(); i++) {
|
for (int i = 0; i <= getNbCols(); i++)
|
||||||
ug.apply(UTranslate.dx(getStartingX(i))).draw(vline);
|
ug.apply(UTranslate.dx(getStartingX(i))).draw(vline);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMap(StringBounder stringBounder) {
|
private void initMap(StringBounder stringBounder) {
|
||||||
if (positions.size() > 0) {
|
final Class<? extends StringBounder> currentCaller = stringBounder.getClass();
|
||||||
|
if (lastCaller != currentCaller)
|
||||||
|
positions.clear();
|
||||||
|
|
||||||
|
this.lastCaller = currentCaller;
|
||||||
|
|
||||||
|
if (positions.size() > 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
for (Line line : lines) {
|
for (Line line : lines) {
|
||||||
for (Atom cell : line.cells) {
|
for (Atom cell : line.cells) {
|
||||||
final XDimension2D dim = cell.calculateDimension(stringBounder);
|
final XDimension2D dim = cell.calculateDimension(stringBounder);
|
||||||
@ -179,33 +185,33 @@ public class AtomTable extends AbstractAtom implements Atom {
|
|||||||
|
|
||||||
private double getStartingX(int col) {
|
private double getStartingX(int col) {
|
||||||
double result = 0;
|
double result = 0;
|
||||||
for (int i = 0; i < col; i++) {
|
for (int i = 0; i < col; i++)
|
||||||
result += getColWidth(i);
|
result += getColWidth(i);
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getEndingX(int col) {
|
private double getEndingX(int col) {
|
||||||
double result = 0;
|
double result = 0;
|
||||||
for (int i = 0; i <= col; i++) {
|
for (int i = 0; i <= col; i++)
|
||||||
result += getColWidth(i);
|
result += getColWidth(i);
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getStartingY(int line) {
|
private double getStartingY(int line) {
|
||||||
double result = 0;
|
double result = 0;
|
||||||
for (int i = 0; i < line; i++) {
|
for (int i = 0; i < line; i++)
|
||||||
result += getLineHeight(i);
|
result += getLineHeight(i);
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getEndingY(int line) {
|
private double getEndingY(int line) {
|
||||||
double result = 0;
|
double result = 0;
|
||||||
for (int i = 0; i <= line; i++) {
|
for (int i = 0; i <= line; i++)
|
||||||
result += getLineHeight(i);
|
result += getLineHeight(i);
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,9 +219,9 @@ public class AtomTable extends AbstractAtom implements Atom {
|
|||||||
double result = 0;
|
double result = 0;
|
||||||
for (int i = 0; i < getNbLines(); i++) {
|
for (int i = 0; i < getNbLines(); i++) {
|
||||||
final Position position = getPosition(i, col);
|
final Position position = getPosition(i, col);
|
||||||
if (position == null) {
|
if (position == null)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
final double width = position.getWidth();
|
final double width = position.getWidth();
|
||||||
result = Math.max(result, width);
|
result = Math.max(result, width);
|
||||||
}
|
}
|
||||||
@ -226,9 +232,9 @@ public class AtomTable extends AbstractAtom implements Atom {
|
|||||||
double result = 0;
|
double result = 0;
|
||||||
for (int i = 0; i < getNbCols(); i++) {
|
for (int i = 0; i < getNbCols(); i++) {
|
||||||
final Position position = getPosition(line, i);
|
final Position position = getPosition(line, i);
|
||||||
if (position == null) {
|
if (position == null)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
final double height = position.getHeight();
|
final double height = position.getHeight();
|
||||||
result = Math.max(result, height);
|
result = Math.max(result, height);
|
||||||
}
|
}
|
||||||
@ -236,13 +242,13 @@ public class AtomTable extends AbstractAtom implements Atom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Position getPosition(int line, int col) {
|
private Position getPosition(int line, int col) {
|
||||||
if (line >= lines.size()) {
|
if (line >= lines.size())
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
final Line l = lines.get(line);
|
final Line l = lines.get(line);
|
||||||
if (col >= l.cells.size()) {
|
if (col >= l.cells.size())
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
final Atom atom = l.cells.get(col);
|
final Atom atom = l.cells.get(col);
|
||||||
return positions.get(atom);
|
return positions.get(atom);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class Version {
|
|||||||
|
|
||||||
// Warning, "version" should be the same in gradle.properties and Version.java
|
// Warning, "version" should be the same in gradle.properties and Version.java
|
||||||
// Any idea anyone how to magically synchronize those :-) ?
|
// Any idea anyone how to magically synchronize those :-) ?
|
||||||
private static final String version = "1.2024.0beta2";
|
private static final String version = "1.2024.0beta3";
|
||||||
|
|
||||||
public static String versionString() {
|
public static String versionString() {
|
||||||
return version;
|
return version;
|
||||||
|
Loading…
Reference in New Issue
Block a user