From 81abee58fa0ec4e05d84938da4b74003c48f95b6 Mon Sep 17 00:00:00 2001 From: matthew16550 Date: Wed, 7 Apr 2021 18:38:29 +1000 Subject: [PATCH] Refactor duplicate scaleFactor calculations. --- src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java index 51f4c818a..4e837a95e 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -279,8 +279,8 @@ public class ImageBuilder { dx = -minmax.getMinX(); dy = -minmax.getMinY(); } - - final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy); + final double scaleFactor = (scale == null ? 1 : scale.getScale(dim.getWidth(), dim.getHeight())) * dpi / 96.0; + final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy, scaleFactor); UGraphic ug2 = ug; maybeDrawBorder(ug, dim); if (randomPixel) { @@ -295,7 +295,6 @@ public class ImageBuilder { if (ug instanceof UGraphicG2d) { final Set urls = ((UGraphicG2d) ug).getAllUrlsEncountered(); if (urls.size() > 0) { - final double scaleFactor = (scale == null ? 1 : scale.getScale(dim.getWidth(), dim.getHeight())) * dpi / 96.0; final CMapData cmap = CMapData.cmapString(urls, scaleFactor); return new ImageDataComplex(dim, cmap, warningOrError, status); } @@ -412,8 +411,7 @@ public class ImageBuilder { } private UGraphic2 createUGraphic(FileFormatOption option, final Dimension2D dim, Animation animationArg, - double dx, double dy) { - final double scaleFactor = (scale == null ? 1 : scale.getScale(dim.getWidth(), dim.getHeight())) * dpi / 96.0; + double dx, double dy, double scaleFactor) { switch (option.getFileFormat()) { case PNG: return createUGraphicPNG(scaleFactor, dim, animationArg, dx, dy,