Esempio n. 1
0
 public void testFitsValue()
 {
     sState.appendValue(new JDFMatrix("10 2 3 4 5 6"), null);
     sState.appendValue(new JDFMatrix("20 2 3 4 5 6"), EnumFitsValue.Present);
     sState.appendValue(new JDFMatrix("30 2 3 4 5 6"), EnumFitsValue.Allowed);
     Assert.IsTrue(sState.fitsValue("30 2 3 4 5 6", EnumFitsValue.Allowed));
     Assert.IsFalse(sState.fitsValue("30 2 3 4 5 6", EnumFitsValue.Present));
     Assert.IsFalse(sState.fitsValue("20 2 3 4 5 6", EnumFitsValue.Allowed));
     Assert.IsTrue(sState.fitsValue("20 2 3 4 5 6", EnumFitsValue.Present));
     Assert.IsTrue(sState.fitsValue("10 2 3 4 5 6", EnumFitsValue.Present));
     Assert.IsFalse(sState.fitsValue("40 2 3 4 5 6", EnumFitsValue.Present));
     Assert.IsTrue(sState.fitsValue("10 2 3 4 5 6", EnumFitsValue.Allowed));
     Assert.IsFalse(sState.fitsValue("40 2 3 4 5 6", EnumFitsValue.Allowed));
 }
Esempio n. 2
0
        public void testFitsValue_MatrixState()
        {
            JDFDoc  jdfDoc = new JDFDoc(ElementName.JDF);
            JDFNode root   = jdfDoc.getJDFRoot();

            JDFMatrix matrix1 = new JDFMatrix("1 0 0 1 3.14 21631.3");
            JDFMatrix matrix2 = new JDFMatrix("0 1 1 0 2 21000");

            List <ValuedEnum> transforms = new List <ValuedEnum>();

            transforms.Add(EnumOrientation.Rotate0);
            transforms.Add(EnumOrientation.Rotate270);
            transforms.Add(EnumOrientation.Flip0);
            JDFRectangle shift = new JDFRectangle("2 4 20000 23000");

            string value1 = "1 0 0 1 3.14 21631.3";

            JDFMatrixState k = (JDFMatrixState)root.appendElement("MatrixState");

            k.appendValue();
            // k.setValueValueUsage(0, EnumFitsValue.Allowed);
            k.setValueAllowedValue(0, matrix2);

            k.appendValue();
            // k.setValueValueUsage(1, EnumFitsValue.Present);
            k.setValueAllowedValue(1, matrix1);

            k.setAllowedTransforms(transforms);
            k.setAllowedShift(shift);
            k.setAllowedRotateMod(15);

            EnumListType lt = EnumListType.UniqueList;

            // JDFAbstractState.EnumListType lt = EnumListType.ListType.Unknown;
            // JDFAbstractState.EnumListType lt = EnumListType.ListType.List;
            k.setListType(lt);
            // EnumListType listType = k.getListType();

            Assert.IsTrue(k.fitsValue(value1, EnumFitsValue.Allowed), "Matrix OK");

            string @value = "1 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8";

            VString vs  = new VString(@value, JDFConstants.BLANK);
            int     siz = vs.Count;

            Assert.AreEqual(0, siz % 6, "It is not a Matrix");
            VString       matrixList = new VString();
            int           i          = 0;
            StringBuilder sb         = new StringBuilder(250);

            sb.Append(vs[i]);
            while ((i + 1) < siz)
            {
                do
                {
                    sb.Append(JDFConstants.BLANK);
                    i++;
                    sb.Append(vs[i]);
                } while ((i + 1) % 6 != 0);
                matrixList.Add(sb.ToString());
                if ((i + 1) < siz)
                {
                    i++;
                    sb = new StringBuilder(250);
                    sb.Append(vs[i]);
                }
            }
            for (int z = 0; z < matrixList.Count; z++)
            {
                JDFMatrix matrix3 = new JDFMatrix(matrixList.stringAt(z));
                //matrix3.A;
            }
        }