Esempio n. 1
0
        public static Chart GraphToAnb(GraphMapData graph)
        {
            Chart chart = new Chart();

            chart.chartItemCollection            = new ChartItemCollection();
            chart.chartItemCollection.chartItems = new Collection <ChartItem>();

            foreach (IconNodeMapData node in graph.GetNodes())
            {
                ChartItem chartItem = new ChartItem();
                chart.chartItemCollection.chartItems.Add(chartItem);

                chartItem.attrLabel = node.Label;

                string hexBackgroundColor = String.Format("#{0:x2}{1:x2}{2:x2}{3:x2}", node.BackgroundColor.A, node.BackgroundColor.R, node.BackgroundColor.G, node.BackgroundColor.B);
                chartItem.ciStyle      = new CIStyle();
                chartItem.ciStyle.font = new Font();
                chartItem.ciStyle.font.attrBackColour = hexBackgroundColor;

                chartItem.end                       = new End();
                chartItem.end.entity                = new Entity();
                chartItem.end.entity.icon           = new Icon();
                chartItem.end.entity.icon.iconStyle = new IconStyle();

                chartItem.attributeCollection            = new AttributeCollection();
                chartItem.attributeCollection.attributes = new Collection <Anb.Attribute>();
                foreach (KeyValuePair <string, AttributeMapData> kvp in node.Attributes)
                {
                    Anb.Attribute attribute = new Anb.Attribute();
                    chartItem.attributeCollection.attributes.Add(attribute);

                    attribute.attrAttributeClass = kvp.Key;
                    attribute.attrValue          = kvp.Value.Value;
                }
            }

            foreach (EdgeMapData edge in graph.GetEdges())
            {
                ChartItem chartItem = new ChartItem();
                chart.chartItemCollection.chartItems.Add(chartItem);

                chartItem.link            = new Link();
                chartItem.link.attrEnd1Id = edge.Source;
                chartItem.link.attrEnd2Id = edge.Target;

                chartItem.link.linkStyle          = new LinkStyle();
                chartItem.link.linkStyle.attrType = edge.Label;
            }

            return(chart);
        }
Esempio n. 2
0
        public static Chart GraphToAnb(GraphMapData graph)
        {
            Chart chart = new Chart();
            chart.chartItemCollection = new ChartItemCollection();
            chart.chartItemCollection.chartItems = new Collection<ChartItem>();

            foreach (IconNodeMapData node in graph.GetNodes())
            {
                ChartItem chartItem = new ChartItem();
                chart.chartItemCollection.chartItems.Add(chartItem);

                chartItem.attrLabel = node.Label;

                string hexBackgroundColor = String.Format("#{0:x2}{1:x2}{2:x2}{3:x2}", node.BackgroundColor.A, node.BackgroundColor.R, node.BackgroundColor.G, node.BackgroundColor.B);
                chartItem.ciStyle = new CIStyle();
                chartItem.ciStyle.font = new Font();
                chartItem.ciStyle.font.attrBackColour = hexBackgroundColor;

                chartItem.end = new End();
                chartItem.end.entity = new Entity();
                chartItem.end.entity.icon = new Icon();
                chartItem.end.entity.icon.iconStyle = new IconStyle();

                chartItem.attributeCollection = new AttributeCollection();
                chartItem.attributeCollection.attributes = new Collection<Anb.Attribute>();
                foreach (KeyValuePair<string, AttributeMapData> kvp in node.Attributes)
                {
                    Anb.Attribute attribute = new Anb.Attribute();
                    chartItem.attributeCollection.attributes.Add(attribute);

                    attribute.attrAttributeClass = kvp.Key;
                    attribute.attrValue = kvp.Value.Value;
                }
            }

            foreach (EdgeMapData edge in graph.GetEdges())
            {
                ChartItem chartItem = new ChartItem();
                chart.chartItemCollection.chartItems.Add(chartItem);

                chartItem.link = new Link();
                chartItem.link.attrEnd1Id = edge.Source;
                chartItem.link.attrEnd2Id = edge.Target;

                chartItem.link.linkStyle = new LinkStyle();
                chartItem.link.linkStyle.attrType = edge.Label;
            }

            return chart;
        }