Exemplo n.º 1
0
        public virtual void GetAffineTransformOneSingleTransformFewTimesTest()
        {
            Transform transform = new Transform(4);

            Transform.SingleTransform singleTransform = CreateSingleTransform(UnitValue.CreatePointValue(20f), UnitValue
                                                                              .CreatePointValue(30f));
            transform.AddSingleTransform(singleTransform);
            transform.AddSingleTransform(singleTransform);
            transform.AddSingleTransform(singleTransform);
            transform.AddSingleTransform(singleTransform);
            NUnit.Framework.Assert.AreEqual(new AffineTransform(new float[] { -524f, -105f, 140f, -419f, -700f, 2100f,
                                                                              type }), Transform.GetAffineTransform(transform, 60f, 60f));
        }
Exemplo n.º 2
0
        public virtual void GetAffineTransformDiffSingleTransformTest()
        {
            float     txUnitValue  = 20f;
            float     tyUnitValue2 = 30f;
            Transform transform    = new Transform(4);

            transform.AddSingleTransform(CreateSingleTransform(UnitValue.CreatePercentValue(txUnitValue), UnitValue.CreatePointValue
                                                                   (tyUnitValue2)));
            transform.AddSingleTransform(CreateSingleTransform(UnitValue.CreatePointValue(txUnitValue), UnitValue.CreatePercentValue
                                                                   (tyUnitValue2)));
            transform.AddSingleTransform(CreateSingleTransform(UnitValue.CreatePercentValue(txUnitValue), UnitValue.CreatePercentValue
                                                                   (tyUnitValue2)));
            transform.AddSingleTransform(CreateSingleTransform(UnitValue.CreatePointValue(txUnitValue), UnitValue.CreatePointValue
                                                                   (tyUnitValue2)));
            NUnit.Framework.Assert.AreEqual(new AffineTransform(new float[] { -524f, -105f, 140f, -419f, -788f, 2220f,
                                                                              type }), Transform.GetAffineTransform(transform, 60f, 80f));
        }
Exemplo n.º 3
0
        private static Transform.SingleTransform CreateSingleTransform(UnitValue xUnitVal, UnitValue yUnitVal)
        {
            float a = -2f;
            float b = 3f;
            float c = -4f;
            float d = -5f;

            return(new Transform.SingleTransform(a, b, c, d, xUnitVal, yUnitVal));
        }
Exemplo n.º 4
0
        public virtual void GetAffineTransformDifferentWidthHeightTest()
        {
            Transform transform = new Transform(1);

            transform.AddSingleTransform(CreateSingleTransform(UnitValue.CreatePercentValue(20f), UnitValue.CreatePercentValue
                                                                   (30f)));
            NUnit.Framework.Assert.AreEqual(new AffineTransform(new float[] { -2f, 3f, -4f, -5f, -10f, -6f, type }), Transform
                                            .GetAffineTransform(transform, -50f, -20f));
            NUnit.Framework.Assert.AreEqual(new AffineTransform(new float[] { -2f, 3f, -4f, -5f, 10f, -6f, type }), Transform
                                            .GetAffineTransform(transform, 50f, -20f));
            NUnit.Framework.Assert.AreEqual(new AffineTransform(new float[] { -2f, 3f, -4f, -5f, -10f, 6f, type }), Transform
                                            .GetAffineTransform(transform, -50f, 20f));
            NUnit.Framework.Assert.AreEqual(new AffineTransform(new float[] { -2f, 3f, -4f, -5f, 10f, 6f, type }), Transform
                                            .GetAffineTransform(transform, 50f, 20f));
        }
Exemplo n.º 5
0
        /// <summary>Converts all percentage and enum values to point equivalent.</summary>
        /// <param name="fullWidth">container width to calculate percentage.</param>
        /// <param name="fullHeight">container height to calculate percentage.</param>
        /// <param name="outXValue">
        ///
        /// <see cref="UnitValue"/>
        /// to store processed xPosition.
        /// </param>
        /// <param name="outYValue">
        ///
        /// <see cref="UnitValue"/>
        /// to store processed yPosition.
        /// </param>
        public virtual void CalculatePositionValues(float fullWidth, float fullHeight, UnitValue outXValue, UnitValue
                                                    outYValue)
        {
            int posMultiplier = ParsePositionXToUnitValueAndReturnMultiplier(outXValue);

            if (posMultiplier == 0 && xShift != null && Math.Abs(xShift.GetValue()) > EPS)
            {
                outXValue.SetValue(0);
            }
            else
            {
                outXValue.SetValue(CalculateValue(outXValue, fullWidth) + CalculateValue(xShift, fullWidth) * posMultiplier
                                   );
            }
            outXValue.SetUnitType(UnitValue.POINT);
            posMultiplier = ParsePositionYToUnitValueAndReturnMultiplier(outYValue);
            if (posMultiplier == 0 && yShift != null && Math.Abs(yShift.GetValue()) > EPS)
            {
                outYValue.SetValue(0);
            }
            else
            {
                outYValue.SetValue(CalculateValue(outYValue, fullHeight) + CalculateValue(yShift, fullHeight) * posMultiplier
                                   );
            }
            outYValue.SetUnitType(UnitValue.POINT);
        }
Exemplo n.º 6
0
 /// <summary>Sets vertical shift.</summary>
 /// <param name="yShift">shift in y-dimension</param>
 /// <returns>
 ///
 /// <see cref="BackgroundPosition"/>
 /// </returns>
 public virtual iText.Layout.Properties.BackgroundPosition SetYShift(UnitValue yShift)
 {
     this.yShift = yShift;
     return(this);
 }