/// <summary>Sets linearGradientBuilder.</summary> /// <remarks> /// Sets linearGradientBuilder. /// <para /> /// Makes image null as far as we can't have them both. It also makes background-repeat: no-repeat. /// </remarks> /// <param name="linearGradientBuilder"> /// /// <see cref="iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder"/> /// to be set. /// </param> /// <returns> /// this /// <see cref="Builder"/>. /// </returns> public virtual BackgroundImage.Builder SetLinearGradientBuilder(AbstractLinearGradientBuilder linearGradientBuilder ) { this.linearGradientBuilder = linearGradientBuilder; this.repeat = new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.NO_REPEAT); this.image = null; return(this); }
public virtual void OneBackgroundRepeatValueConstructorTest() { BackgroundRepeat backgroundRepeat = new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.ROUND); NUnit.Framework.Assert.AreEqual(BackgroundRepeat.BackgroundRepeatValue.ROUND, backgroundRepeat.GetXAxisRepeat ()); NUnit.Framework.Assert.AreEqual(BackgroundRepeat.BackgroundRepeatValue.ROUND, backgroundRepeat.GetYAxisRepeat ()); }
public virtual void DefaultConstructorTest() { BackgroundRepeat backgroundRepeat = new BackgroundRepeat(); NUnit.Framework.Assert.AreEqual(BackgroundRepeat.BackgroundRepeatValue.REPEAT, backgroundRepeat.GetXAxisRepeat ()); NUnit.Framework.Assert.AreEqual(BackgroundRepeat.BackgroundRepeatValue.REPEAT, backgroundRepeat.GetYAxisRepeat ()); }
public virtual void PrepareRectangleSpaceSpaceNoAvailableSpaceTest() { BackgroundRepeat repeat = new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.SPACE); Rectangle imageRect = new Rectangle(0, -5, 50, 60); Rectangle originalRect = new Rectangle(imageRect); Rectangle availableArea = new Rectangle(0, 0, 45, 55); Point whitespace = repeat.PrepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize ()); NUnit.Framework.Assert.AreEqual(0, whitespace.GetX(), EPSILON); NUnit.Framework.Assert.AreEqual(0, whitespace.GetY(), EPSILON); NUnit.Framework.Assert.IsTrue(originalRect.EqualsWithEpsilon(imageRect)); }
/// <summary> /// Gets image /// <see cref="BackgroundRepeat"/> /// instance. /// </summary> /// <returns>the image background repeat</returns> public virtual BackgroundRepeat GetRepeat() { // Remove this if-blocks after removing repeatX and repeatY if (repeatX == repeat.IsNoRepeatOnXAxis()) { repeat = new BackgroundRepeat(repeatX ? BackgroundRepeat.BackgroundRepeatValue.REPEAT : BackgroundRepeat.BackgroundRepeatValue .NO_REPEAT, repeat.GetYAxisRepeat()); } if (repeatY == repeat.IsNoRepeatOnYAxis()) { repeat = new BackgroundRepeat(repeat.GetXAxisRepeat(), repeatY ? BackgroundRepeat.BackgroundRepeatValue.REPEAT : BackgroundRepeat.BackgroundRepeatValue.NO_REPEAT); } return(repeat); }
public virtual void IsNoRepeatOnAxis() { BackgroundRepeat backgroundRepeat = new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.SPACE, BackgroundRepeat.BackgroundRepeatValue .REPEAT); NUnit.Framework.Assert.IsFalse(backgroundRepeat.IsNoRepeatOnXAxis()); NUnit.Framework.Assert.IsFalse(backgroundRepeat.IsNoRepeatOnYAxis()); backgroundRepeat = new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.NO_REPEAT, BackgroundRepeat.BackgroundRepeatValue .ROUND); NUnit.Framework.Assert.IsTrue(backgroundRepeat.IsNoRepeatOnXAxis()); NUnit.Framework.Assert.IsFalse(backgroundRepeat.IsNoRepeatOnYAxis()); backgroundRepeat = new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.NO_REPEAT); NUnit.Framework.Assert.IsTrue(backgroundRepeat.IsNoRepeatOnXAxis()); NUnit.Framework.Assert.IsTrue(backgroundRepeat.IsNoRepeatOnYAxis()); }
public virtual void PrepareRectangleRoundRoundLessHalfImageSizeTest() { BackgroundRepeat repeat = new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.ROUND); Rectangle imageRect = new Rectangle(0, 0, 50, 70); Rectangle availableArea = new Rectangle(0, 0, 120, 160); Point whitespace = repeat.PrepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize ()); NUnit.Framework.Assert.AreEqual(0, whitespace.GetX(), EPSILON); NUnit.Framework.Assert.AreEqual(0, whitespace.GetY(), EPSILON); NUnit.Framework.Assert.AreEqual(0, imageRect.GetX(), EPSILON); NUnit.Framework.Assert.AreEqual(-10, imageRect.GetY(), EPSILON); NUnit.Framework.Assert.AreEqual(60, imageRect.GetWidth(), EPSILON); NUnit.Framework.Assert.AreEqual(80, imageRect.GetHeight(), EPSILON); }
/// <summary> /// Creates a new /// <see cref="BackgroundImage"/> /// instance. /// </summary> /// <param name="image"> /// background-image property. /// <see cref="iText.Kernel.Pdf.Xobject.PdfXObject"/> /// instance. /// </param> /// <param name="repeat"> /// background-repeat property. /// <see cref="BackgroundRepeat"/> /// instance. /// </param> /// <param name="position"> /// background-position property. /// <see cref="BackgroundPosition"/> /// instance. /// </param> /// <param name="backgroundSize"> /// background-size property. /// <see cref="BackgroundSize"/> /// instance. /// </param> /// <param name="linearGradientBuilder"> /// background-image property. /// <see cref="iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder"/> /// instance. /// </param> /// <param name="blendMode"> /// the image's blend mode. /// <see cref="BlendMode"/> /// instance. /// </param> /// <param name="clip"> /// background-clip property. /// <see cref="BackgroundBox"/> /// instance. /// </param> /// <param name="origin"> /// background-origin property. /// <see cref="BackgroundBox"/> /// instance. /// </param> private BackgroundImage(PdfXObject image, BackgroundRepeat repeat, BackgroundPosition position, BackgroundSize backgroundSize, AbstractLinearGradientBuilder linearGradientBuilder, BlendMode blendMode, BackgroundBox clip, BackgroundBox origin) { this.image = image; if (repeat != null) { this.repeatX = !repeat.IsNoRepeatOnXAxis(); this.repeatY = !repeat.IsNoRepeatOnYAxis(); } this.repeat = repeat; this.position = position; this.backgroundSize = backgroundSize; this.linearGradientBuilder = linearGradientBuilder; if (blendMode != null) { this.blendMode = blendMode; } this.backgroundClip = clip; this.backgroundOrigin = origin; }
/// <summary>Sets background-repeat.</summary> /// <param name="repeat"> /// /// <see cref="BackgroundRepeat"/> /// to be set. /// </param> /// <returns> /// this /// <see cref="Builder"/>. /// </returns> public virtual BackgroundImage.Builder SetBackgroundRepeat(BackgroundRepeat repeat) { this.repeat = repeat; return(this); }
public BackgroundImage(PdfFormXObject image, BackgroundRepeat repeat) : this(image, repeat, new BackgroundPosition(), new BackgroundSize(), null, DEFAULT_BLEND_MODE, BackgroundBox .BORDER_BOX, BackgroundBox.PADDING_BOX) { }
public BackgroundImage(PdfFormXObject image, BackgroundRepeat repeat, BlendMode blendMode) : this(image, repeat, new BackgroundPosition(), new BackgroundSize(), null, blendMode, BackgroundBox.BORDER_BOX , BackgroundBox.PADDING_BOX) { }