Skip to content

Commit

Permalink
(#117) Remove width and height parameters from Image constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriciofx committed Jan 16, 2024
1 parent e6265d2 commit 48b2443
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 56 deletions.
62 changes: 6 additions & 56 deletions src/main/java/com/github/fabriciofx/cactoos/pdf/content/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -77,16 +76,6 @@ public final class Image implements Content {
*/
private final double posy;

/**
* Width.
*/
private final Scalar<Double> width;

/**
* Height.
*/
private final Scalar<Double> height;

/**
* Ctor.
*
Expand All @@ -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
);
}

Expand All @@ -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(
Expand All @@ -164,18 +118,14 @@ public Image(
final Id id,
final Format format,
final double posx,
final double posy,
final Scalar<Double> width,
final Scalar<Double> height
final double posy
) {
this.num = num;
this.generation = generation;
this.id = id;
this.fmt = format;
this.posx = posx;
this.posy = posy;
this.width = width;
this.height = height;
}

/**
Expand All @@ -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()
Expand Down
Binary file modified src/test/resources/document/fonts-images.pdf
Binary file not shown.
Binary file modified src/test/resources/document/image-jpg.pdf
Binary file not shown.
Binary file modified src/test/resources/document/image-png.pdf
Binary file not shown.

0 comments on commit 48b2443

Please sign in to comment.