Fixed #1847 shape viewer and PDF exporter - correct drawing of pure vertical/horizontal shapes (zero width/height)

This commit is contained in:
Jindra Petřík
2022-10-23 10:56:31 +02:00
parent 1b136913b2
commit bfae9f6871
2 changed files with 8 additions and 9 deletions

View File

@@ -167,7 +167,10 @@ public class BitmapExporter extends ShapeExporterBase {
ExportRectangle bounds = new ExportRectangle(shape.getBounds());
ExportRectangle transformedBounds = strokeTransformation.transform(bounds);
this.strokeTransformation = Matrix.getScaleInstance(transformedBounds.getWidth() / bounds.getWidth(), transformedBounds.getHeight() / bounds.getHeight());
this.strokeTransformation = Matrix.getScaleInstance(
Double.compare(bounds.getWidth(), 0.0d) == 0 /*horizontal line or single point */ ? 1 : transformedBounds.getWidth() / bounds.getWidth(),
Double.compare(bounds.getHeight(), 0.0d) == 0 /*vertical line or single point */ ? 1 : transformedBounds.getHeight() / bounds.getHeight()
);
graphics = (Graphics2D) image.getGraphics();
AffineTransform at = transformation.toTransform();
@@ -411,14 +414,8 @@ public class BitmapExporter extends ShapeExporterBase {
}
}
if (Double.isNaN(thickness) || Double.compare(thickness, 0.0d) == 0) { //for example when bounding box width/height is zero
lineStroke = null;
lineColor = null;
return;
} else {
if (thickness < 0) {
thickness = -thickness;
}
if (thickness < 0) {
thickness = -thickness;
}
if (joinStyle == BasicStroke.JOIN_MITER) {