Exemple #1
0
        public override IList<IElement> End(IWorkerContext ctx, Tag tag,
                    IList<IElement> currentContent)
        {

            IList<IElement> elems = new List<IElement>();

            IDictionary<String, String> attributes = tag.Attributes;

            if (attributes != null && attributes.ContainsKey(POINTS))
            {
                String str = attributes[POINTS];

                StringTokenizer tokenizer = new StringTokenizer(CleanPath(str), ", \t\n\r\f");
                IList<String> values = new List<String>();
                while (tokenizer.HasMoreTokens())
                {
                    String value = tokenizer.NextToken().Trim();
                    //System.out.Println(value);
                    values.Add(value);
                }
                PathBean.Builder pathBuilder = new PathBean.Builder();
                if (values.Count % 2 == 1)
                {
                    values.RemoveAt(values.Count - 1);
                }

                if (values.Count % 2 == 0)
                {
                    for (int i = 0; i < (values.Count / 2); i++)
                    {
                        PathItem.Builder itemBuilder = new PathItem.Builder();
                        if (i == 0)
                        {
                            itemBuilder.SetType('M');
                        }
                        else
                        {
                            itemBuilder.SetType('L');
                        }
                        itemBuilder.AddCoordinate(values[i * 2]);
                        itemBuilder.AddCoordinate(values[(i * 2) + 1]);
                        pathBuilder.SetPathItem(itemBuilder.Build());
                    }
                }
                if (tag.Name.Equals(SvgTagNames.POLYGON))
                {
                    PathItem.Builder itemBuilder = new PathItem.Builder();
                    itemBuilder.SetType('z');
                    pathBuilder.SetPathItem(itemBuilder.Build());
                }

                elems.Add(new Path(pathBuilder.Build(), tag.CSS));
                return elems;
            } else {
                return new List<IElement>(0);
            }
        }
Exemple #2
0
 protected static int[] CompactRanges(List<int[]> ranges) {
     List<int[]> simp = new List<int[]>();
     for (int k = 0; k < ranges.Count; ++k) {
         int[] r = ranges[k];
         for (int j = 0; j < r.Length; j += 2) {
             simp.Add(new int[]{Math.Max(0, Math.Min(r[j], r[j + 1])), Math.Min(0xffff, Math.Max(r[j], r[j + 1]))});
         }
     }
     for (int k1 = 0; k1 < simp.Count - 1; ++k1) {
         for (int k2 = k1 + 1; k2 < simp.Count; ++k2) {
             int[] r1 = simp[k1];
             int[] r2 = simp[k2];
             if ((r1[0] >= r2[0] && r1[0] <= r2[1]) || (r1[1] >= r2[0] && r1[0] <= r2[1])) {
                 r1[0] = Math.Min(r1[0], r2[0]);
                 r1[1] = Math.Max(r1[1], r2[1]);
                 simp.RemoveAt(k2);
                 --k2;
             }
         }
     }
     int[] s = new int[simp.Count * 2];
     for (int k = 0; k < simp.Count; ++k) {
         int[] r = simp[k];
         s[k * 2] = r[0];
         s[k * 2 + 1] = r[1];
     }
     return s;
 }
Exemple #3
0
 private string GetTitleFromFilePath(string p)
 {
     var title = Path.GetFileNameWithoutExtension(p);
     var titleList = new List<string>(title.Split('_'));
     titleList.RemoveAt(0);
     return String.Join("_", titleList);
 }