Skip to content

Commit a38e784

Browse files
SnipxiText-CI
authored andcommitted
Add convenience methods to increase and decrease widths of rectangle in chain
Autoported commit. Original commit hash: [e83df626e]
1 parent ca0ee8d commit a38e784

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

itext.tests/itext.kernel.tests/itext/kernel/geom/RectangleTest.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,5 +611,19 @@ public virtual void CloneTest() {
611611
NUnit.Framework.Assert.AreEqual(typeof(PageSize), copyAsPageSize.GetType());
612612
NUnit.Framework.Assert.AreEqual(typeof(PageSize), copyAsRectangle.GetType());
613613
}
614+
615+
[NUnit.Framework.Test]
616+
public virtual void DecreaseWidthTest() {
617+
Rectangle rectangle = new Rectangle(100, 200);
618+
rectangle.DecreaseWidth(10);
619+
NUnit.Framework.Assert.AreEqual(90, rectangle.GetWidth(), Rectangle.EPS);
620+
}
621+
622+
[NUnit.Framework.Test]
623+
public virtual void IncreaseWidthTest() {
624+
Rectangle rectangle = new Rectangle(100, 200);
625+
rectangle.IncreaseWidth(10);
626+
NUnit.Framework.Assert.AreEqual(110, rectangle.GetWidth(), Rectangle.EPS);
627+
}
614628
}
615629
}

itext/itext.kernel/itext/kernel/geom/Rectangle.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ source product.
5151
namespace iText.Kernel.Geom {
5252
/// <summary>Class that represent rectangle object.</summary>
5353
public class Rectangle {
54-
private static float EPS = 1e-4f;
54+
internal static float EPS = 1e-4f;
5555

5656
protected internal float x;
5757

@@ -412,6 +412,32 @@ public virtual iText.Kernel.Geom.Rectangle DecreaseHeight(float extra) {
412412
return this;
413413
}
414414

415+
/// <summary>Increases the width of rectangle by the given value.</summary>
416+
/// <remarks>Increases the width of rectangle by the given value. May be used in chain.</remarks>
417+
/// <param name="extra">the value of the extra wudth to be added.</param>
418+
/// <returns>
419+
/// this
420+
/// <see cref="Rectangle"/>
421+
/// instance.
422+
/// </returns>
423+
public virtual iText.Kernel.Geom.Rectangle IncreaseWidth(float extra) {
424+
this.width += extra;
425+
return this;
426+
}
427+
428+
/// <summary>Decreases the width of rectangle by the given value.</summary>
429+
/// <remarks>Decreases the width of rectangle by the given value. May be used in chain.</remarks>
430+
/// <param name="extra">the value of the extra width to be subtracted.</param>
431+
/// <returns>
432+
/// this
433+
/// <see cref="Rectangle"/>
434+
/// instance.
435+
/// </returns>
436+
public virtual iText.Kernel.Geom.Rectangle DecreaseWidth(float extra) {
437+
this.width -= extra;
438+
return this;
439+
}
440+
415441
/// <summary>Gets the X coordinate of the left edge of the rectangle.</summary>
416442
/// <remarks>
417443
/// Gets the X coordinate of the left edge of the rectangle. Same as:

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f895f395b8dda88bfd0c4a4fa669683268ba2742
1+
e83df626e1a8ca26e1bc0e8b03a54d3dc9110cf0

0 commit comments

Comments
 (0)