/// <summary>Prepares the image rectangle for drawing.</summary> /// <remarks> /// Prepares the image rectangle for drawing. This means that the size and position of the image /// rectangle will be changed to match the /// <see cref="BackgroundRepeatValue"/> /// values for the axes. /// </remarks> /// <param name="imageRectangle">the image rectangle which will be changed</param> /// <param name="backgroundArea">the background available area</param> /// <returns>the necessary whitespace between backgrounds</returns> public virtual Point PrepareRectangleToDrawingAndGetWhitespace(Rectangle imageRectangle, Rectangle backgroundArea , BackgroundSize backgroundSize) { if (BackgroundRepeat.BackgroundRepeatValue.ROUND == xAxisRepeat) { int ratio = iText.Layout.Properties.BackgroundRepeat.CalculateRatio(backgroundArea.GetWidth(), imageRectangle .GetWidth()); float initialImageRatio = imageRectangle.GetHeight() / imageRectangle.GetWidth(); imageRectangle.SetWidth(backgroundArea.GetWidth() / ratio); if (BackgroundRepeat.BackgroundRepeatValue.ROUND != yAxisRepeat && backgroundSize.GetBackgroundHeightSize( ) == null) { imageRectangle.MoveUp(imageRectangle.GetHeight() - imageRectangle.GetWidth() * initialImageRatio); imageRectangle.SetHeight(imageRectangle.GetWidth() * initialImageRatio); } } if (BackgroundRepeat.BackgroundRepeatValue.ROUND == yAxisRepeat) { int ratio = iText.Layout.Properties.BackgroundRepeat.CalculateRatio(backgroundArea.GetHeight(), imageRectangle .GetHeight()); float initialImageRatio = imageRectangle.GetWidth() / imageRectangle.GetHeight(); imageRectangle.MoveUp(imageRectangle.GetHeight() - backgroundArea.GetHeight() / ratio); imageRectangle.SetHeight(backgroundArea.GetHeight() / ratio); if (BackgroundRepeat.BackgroundRepeatValue.ROUND != xAxisRepeat && backgroundSize.GetBackgroundWidthSize() == null) { imageRectangle.SetWidth(imageRectangle.GetHeight() * initialImageRatio); } } return(ProcessSpaceValueAndCalculateWhitespace(imageRectangle, backgroundArea)); }
public virtual void ConstructorTest() { BackgroundSize size = new BackgroundSize(); NUnit.Framework.Assert.IsFalse(size.IsContain()); NUnit.Framework.Assert.IsFalse(size.IsCover()); NUnit.Framework.Assert.IsNull(size.GetBackgroundWidthSize()); NUnit.Framework.Assert.IsNull(size.GetBackgroundHeightSize()); }
public virtual void ClearAndSetToContainTest() { BackgroundSize size = new BackgroundSize(); size.SetBackgroundSizeToValues(UnitValue.CreatePointValue(10), UnitValue.CreatePointValue(10)); size.SetBackgroundSizeToContain(); NUnit.Framework.Assert.IsTrue(size.IsContain()); NUnit.Framework.Assert.IsFalse(size.IsCover()); NUnit.Framework.Assert.IsNull(size.GetBackgroundWidthSize()); NUnit.Framework.Assert.IsNull(size.GetBackgroundHeightSize()); }