Пример #1
0
        public static List <String> svgGenerator(List <NestPath> list, List <List <Placement> > applied, double binwidth, double binHeight)
        {
            List <String> strings = new List <String>();
            int           x       = 0; //代表离y轴初始边的距离
            int           y       = 0; //代表离轴初始边的距离

            foreach (List <Placement> binlist in applied)
            {
                String s = " <g transform=\"translate(" + x + "  " + y + ")\">" + "\n";
                s += "    <rect x=\"0\" y=\"0\" width=\"" + binwidth + "\" height=\"" + binHeight + "\"  fill=\"none\" stroke=\"#010101\" stroke-width=\"1\" />\n";
                foreach (Placement placement in binlist)
                {
                    int      bid      = placement.bid;
                    NestPath nestPath = getNestPathByBid(bid, list);
                    double   ox       = placement.translate.x;
                    double   oy       = placement.translate.y;
                    double   rotate   = placement.rotate;

                    var translateX = ox + x;
                    var translateY = oy + y;

                    s += "<g transform=\"translate(" + translateX + " " + translateY + ") rotate(" + rotate + ")\"> \n";
                    //s += "<path d=\"";
                    //for (int i = 0; i < nestPath.getSegments().Count; i++)
                    //{
                    //    if (i == 0)
                    //    {
                    //        s += "M";
                    //    }
                    //    else
                    //    {
                    //        s += "L";
                    //    }
                    //    Segment segment = nestPath.get(i);
                    //    s += segment.x + " " + segment.y + " ";
                    //}
                    //s += "Z\" fill=\"#8498d1\" stroke=\"#010101\" stroke-width=\"1\" />" + " \n";
                    s += nestPath.getElement();
                    s += "</g> \n";
                }
                s += "</g> \n";
                y += (int)(binHeight + 0);
                strings.Add(s);
            }
            return(strings);
        }