From 48b24438c13037039c629c8d8ed47e5fc839d316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADcio=20Barros=20Cabral?= Date: Tue, 16 Jan 2024 00:31:39 -0300 Subject: [PATCH] (#117) Remove width and height parameters from Image constructor --- .../fabriciofx/cactoos/pdf/content/Image.java | 62 ++---------------- src/test/resources/document/fonts-images.pdf | Bin 74013 -> 74001 bytes src/test/resources/document/image-jpg.pdf | Bin 70065 -> 70059 bytes src/test/resources/document/image-png.pdf | Bin 3179 -> 3173 bytes 4 files changed, 6 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/github/fabriciofx/cactoos/pdf/content/Image.java b/src/main/java/com/github/fabriciofx/cactoos/pdf/content/Image.java index ccfd83e..bdc26c0 100644 --- a/src/main/java/com/github/fabriciofx/cactoos/pdf/content/Image.java +++ b/src/main/java/com/github/fabriciofx/cactoos/pdf/content/Image.java @@ -36,7 +36,6 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Locale; -import org.cactoos.Scalar; import org.cactoos.list.ListOf; import org.cactoos.text.FormattedText; import org.cactoos.text.UncheckedText; @@ -77,16 +76,6 @@ public final class Image implements Content { */ private final double posy; - /** - * Width. - */ - private final Scalar width; - - /** - * Height. - */ - private final Scalar height; - /** * Ctor. * @@ -108,40 +97,7 @@ public Image( id, format, posx, - posy, - () -> (double) format.width(), - () -> (double) format.height() - ); - } - - /** - * Ctor. - * - * @param id Id number - * @param format Raw image format - * @param posx Position X - * @param posy Position Y - * @param width Image width - * @param height Image height - * @checkstyle ParameterNumberCheck (10 lines) - */ - public Image( - final Id id, - final Format format, - final double posx, - final double posy, - final double width, - final double height - ) { - this( - id.increment(), - 0, - id, - format, - posx, - posy, - () -> width, - () -> height + posy ); } @@ -150,12 +106,10 @@ public Image( * * @param num Object number * @param generation Generation number - * @param id Id + * @param id Id number * @param format Raw image format * @param posx Position X * @param posy Position Y - * @param width Image width - * @param height Image height * @checkstyle ParameterNumberCheck (10 lines) */ public Image( @@ -164,9 +118,7 @@ public Image( final Id id, final Format format, final double posx, - final double posy, - final Scalar width, - final Scalar height + final double posy ) { this.num = num; this.generation = generation; @@ -174,8 +126,6 @@ public Image( this.fmt = format; this.posx = posx; this.posy = posy; - this.width = width; - this.height = height; } /** @@ -190,10 +140,10 @@ public String name() { @Override public byte[] asStream() throws Exception { return new FormattedText( - "q %.2f 0 0 %.2f %.2f %.2f cm /%s Do Q", + "q %d 0 0 %d %.2f %.2f cm /%s Do Q", Locale.ENGLISH, - this.width.value(), - this.height.value(), + this.fmt.width(), + this.fmt.height(), this.posx, this.posy, this.name() diff --git a/src/test/resources/document/fonts-images.pdf b/src/test/resources/document/fonts-images.pdf index 45a6e889f158d038cd57ed1c1dde098490ad52ee..bdc205926a79f9848d95fb3c06ac482b1d1143e1 100644 GIT binary patch delta 74 zcmbPxh-Km-mWC~i<+75-<_dOpT*W0tsfoE