mirror of
https://github.com/octoleo/plantuml.git
synced 2025-01-05 08:02:11 +00:00
Simplify ImageBuilder.getFinalDimension() and cache calculated result.
This commit is contained in:
parent
f47a2a14fc
commit
5c2634cf4e
@ -264,8 +264,7 @@ public class ImageBuilder {
|
|||||||
|
|
||||||
private ImageData writeImageInternal(FileFormatOption fileFormatOption, OutputStream os,
|
private ImageData writeImageInternal(FileFormatOption fileFormatOption, OutputStream os,
|
||||||
Animation animationArg) throws IOException {
|
Animation animationArg) throws IOException {
|
||||||
Dimension2D dim = (dimension == null)
|
Dimension2D dim = getFinalDimension();
|
||||||
? getFinalDimension(fileFormatOption.getDefaultStringBounder(getSvgCharSizeHack())) : dimension;
|
|
||||||
double dx = 0;
|
double dx = 0;
|
||||||
double dy = 0;
|
double dy = 0;
|
||||||
if (animationArg != null) {
|
if (animationArg != null) {
|
||||||
@ -324,15 +323,14 @@ public class ImageBuilder {
|
|||||||
ug2.apply(color).apply(color.bg()).draw(new URectangle(1, 1));
|
ug2.apply(color).apply(color.bg()).draw(new URectangle(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dimension2D getFinalDimension(StringBounder stringBounder) {
|
private Dimension2D getFinalDimension() {
|
||||||
final LimitFinder limitFinder = new LimitFinder(stringBounder, true);
|
if (dimension == null) {
|
||||||
|
final LimitFinder limitFinder = new LimitFinder(fileFormatOption.getDefaultStringBounder(getSvgCharSizeHack()), true);
|
||||||
udrawable.drawU(limitFinder);
|
udrawable.drawU(limitFinder);
|
||||||
return new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin.getLeft() + margin.getRight(),
|
dimension = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin.getLeft() + margin.getRight(),
|
||||||
limitFinder.getMaxY() + 1 + margin.getTop() + margin.getBottom());
|
limitFinder.getMaxY() + 1 + margin.getTop() + margin.getBottom());
|
||||||
}
|
}
|
||||||
|
return dimension;
|
||||||
private Dimension2D getFinalDimension() {
|
|
||||||
return getFinalDimension(fileFormatOption.getDefaultStringBounder(getSvgCharSizeHack()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private UGraphic handwritten(UGraphic ug) {
|
private UGraphic handwritten(UGraphic ug) {
|
||||||
|
Loading…
Reference in New Issue
Block a user