Пример #1
0
 public virtual void CreateDefaultSingleTransformTest()
 {
     Transform.SingleTransform defaultSingleTransform = new Transform.SingleTransform();
     UnitValue[] defaultUnitValues = defaultSingleTransform.GetUnitValues();
     NUnit.Framework.Assert.AreEqual(new float[] { 1f, 0f, 0f, 1f }, defaultSingleTransform.GetFloats());
     NUnit.Framework.Assert.AreEqual(2, defaultUnitValues.Length);
     NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(0), defaultUnitValues[0]);
     NUnit.Framework.Assert.AreEqual(UnitValue.CreatePointValue(0), defaultUnitValues[1]);
 }
Пример #2
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));
        }
Пример #3
0
        /// <summary>
        /// Converts the
        /// <see cref="Transform"/>
        /// instance, i.e. the list of
        /// <see cref="SingleTransform"/>
        /// instances,
        /// to the equivalent
        /// <see cref="iText.Kernel.Geom.AffineTransform"/>
        /// instance relatively to the available area,
        /// including resolving of percent values to point values.
        /// </summary>
        /// <param name="t">
        /// a
        /// <see cref="Transform"/>
        /// instance to convert
        /// </param>
        /// <param name="width">the width of available area, the point value of which is equivalent to 100% for percentage resolving
        ///     </param>
        /// <param name="height">the height of available area, the point value of which is equivalent to 100% for percentage resolving
        ///     </param>
        public static AffineTransform GetAffineTransform(iText.Layout.Properties.Transform t, float width, float height
                                                         )
        {
            IList <Transform.SingleTransform> multipleTransform = t.GetMultipleTransform();
            AffineTransform affineTransform = new AffineTransform();

            for (int k = multipleTransform.Count - 1; k >= 0; k--)
            {
                Transform.SingleTransform transform = multipleTransform[k];
                float[] floats = new float[6];
                for (int i = 0; i < 4; i++)
                {
                    floats[i] = transform.GetFloats()[i];
                }
                for (int i = 4; i < 6; i++)
                {
                    floats[i] = transform.GetUnitValues()[i - 4].GetUnitType() == UnitValue.POINT ? transform.GetUnitValues()[
                        i - 4].GetValue() : transform.GetUnitValues()[i - 4].GetValue() / 100 * (i == 4 ? width : height);
                }
                affineTransform.PreConcatenate(new AffineTransform(floats));
            }
            return(affineTransform);
        }
Пример #4
0
 /// <summary>
 /// Adds a
 /// <see cref="SingleTransform"/>
 /// in a list of single transforms to process later.
 /// </summary>
 /// <param name="singleTransform">
 /// a
 /// <see cref="SingleTransform"/>
 /// instance
 /// </param>
 public virtual void AddSingleTransform(Transform.SingleTransform singleTransform)
 {
     multipleTransform.Add(singleTransform);
 }