Пример #1
0
        public void DrawGroup(GroupBean groupbean)
        {
            if (groupbean == null) return;
            List<PointDrawer> lp_temp = convertToTrueListPoints(groupbean.lchildern);

            Draw(DrawItem.POINT, PointType.GROUP, lp_temp.ToArray());

            List<RouteDrawer> lr_temp = null;
            lr_temp = new List<RouteDrawer>();
            foreach(NetworkBean networkbean in MyXml.networks)
            {
                List<LinkBean> l = networkbean.llb.FindAll(delegate(LinkBean lb)
                {
                    return groupbean.lchildern.Contains(lb.source) &&
                           groupbean.lchildern.Contains(lb.target);
                });
                if(l != null && l.Count > 0) lr_temp.AddRange(DrawConverter(l));
            }

            List<RouteDrawer> lld = convertToTrueListRoutes(lr_temp, lp_temp);

            if (lld != null)
                Draw(DrawItem.ROUTE, RouteType.GROUP, lld.ToArray());

            graph.Flush();
        }
Пример #2
0
        public static NodeBean findNodeBeanById(string id, GroupBean gb)
        {
            if (gb == null) return null;

            return gb.lchildern.Find(delegate(NodeBean nodebean){
                return nodebean.id.Equals(id);
            });
        }
Пример #3
0
        public static NodeBean findNodeBeanById(string id, GroupBean gb)
        {
            if (gb == null)
            {
                return(null);
            }

            return(gb.lchildern.Find(delegate(NodeBean nodebean){
                return nodebean.id.Equals(id);
            }));
        }
Пример #4
0
        public void getGroups(ref List<GroupBean> groups)
        {
            if (groups == null) groups = new List<GroupBean>();

            XmlNodeList xmlNodeList = getNodeClasses();
            foreach (XmlNode node in xmlNodeList)
            {
                GroupBean gb = new GroupBean();
                gb.id = getNodeAttrValue(node, AttrType.Id);
                gb.group_type = getNodeAttrValue(node, AttrType.Type);
                getNodes(gb, node);
                groups.Add(gb);
            }
        }
Пример #5
0
        public void getGroups(ref List <GroupBean> groups)
        {
            if (groups == null)
            {
                groups = new List <GroupBean>();
            }

            XmlNodeList xmlNodeList = getNodeClasses();

            foreach (XmlNode node in xmlNodeList)
            {
                GroupBean gb = new GroupBean();
                gb.id         = getNodeAttrValue(node, AttrType.Id);
                gb.group_type = getNodeAttrValue(node, AttrType.Type);
                getNodes(gb, node);
                groups.Add(gb);
            }
        }
Пример #6
0
        private void getNodes(GroupBean gb, XmlNode nodeclass)
        {
            XmlNodeList xmlNodeList = getChildern(nodeclass);

            foreach (XmlNode node in xmlNodeList)
            {
                NodeBean nodebean = new NodeBean();

                nodebean.id    = getNodeAttrValue(node, AttrType.Id);
                nodebean.group = gb;

                XmlAttributeCollection collection = getNodeAttrs(node);
                foreach (XmlAttribute atrr in collection)
                {
                    nodebean.AddAttribute(atrr.Name, atrr.Value);
                }

                gb.lchildern.Add(nodebean);
            }
        }
Пример #7
0
 public static bool Equals(GroupBean bean1, GroupBean bean2)
 {
     return (bean1 == null || bean2 == null) ? ((bean1 == null) ? (bean2 == null) : false) : (bean1.id.Equals(bean2.id));
 }
Пример #8
0
        private void getNodes(GroupBean gb, XmlNode nodeclass)
        {
            XmlNodeList xmlNodeList = getChildern(nodeclass);
            foreach(XmlNode node in xmlNodeList)
            {
                NodeBean nodebean = new NodeBean();

                nodebean.id = getNodeAttrValue(node, AttrType.Id);
                nodebean.group = gb;

                XmlAttributeCollection collection = getNodeAttrs(node);
                foreach(XmlAttribute atrr in collection)
                {
                    nodebean.AddAttribute(atrr.Name, atrr.Value);
                }

                gb.lchildern.Add(nodebean);
            }
        }
Пример #9
0
 public static bool Equals(GroupBean bean1, GroupBean bean2)
 {
     return((bean1 == null || bean2 == null) ? ((bean1 == null) ? (bean2 == null) : false) : (bean1.id.Equals(bean2.id)));
 }
Пример #10
0
        private List<GroupBean> removeGroup(List<GroupBean> lst, GroupBean group)
        {
            // 这边将消耗很多内存!!
            List<GroupBean> lgb = new List<GroupBean>();
            foreach(GroupBean grp in lst)
            {
                if (!GroupBean.Equals(group, grp))
                {
                    GroupBean g = new GroupBean();
                    g.id = grp.id;
                    g.lchildern = grp.lchildern;

                    lgb.Add(g);
                }
            }
            return lgb;
        }
Пример #11
0
        private List<GroupBean> newC(GroupBean Ci, GroupBean Cj)
        {
            // Not append it to the result set but replace the original one at the
            // the position where it was!
            int index = findLocation(C(), Ci);
            List<GroupBean> newSolution = removeGroup(C(), Ci);
            newSolution.Insert(index, mergeGroup(Ci, Cj));
            newSolution = removeGroup(newSolution, Cj);

            return newSolution;
        }
Пример #12
0
 public NetworkBean(GroupBean g1, GroupBean g2)
 {
     this.group1 = g1;
     this.group2 = g2;
     llb = new List<LinkBean>();
 }
Пример #13
0
        private void initializeGroups()
        {
            int count = 0;

            List<GroupBean> lgb = new List<GroupBean>();
            foreach(NodeBean bean in MyXml.getAllNodes())
            {
                GroupBean gb = new GroupBean();
                gb.id = count.ToString();
                gb.group_type = bean.group.group_type;
                gb.lchildern.Add(bean);

                lgb.Add(gb);
                count++;
            }

            lstC.Add(lgb);
        }
Пример #14
0
 private int findLocation(List<GroupBean> lst, GroupBean group)
 {
     int count = 0;
     foreach (GroupBean grp in lst)
     {
         if (GroupBean.Equals(group, grp))
         {
             break;
         }
         count++;
     }
     return count;
 }
Пример #15
0
 public NetworkBean(GroupBean g1, GroupBean g2)
 {
     this.group1 = g1;
     this.group2 = g2;
     llb         = new List <LinkBean>();
 }
Пример #16
0
 public NodeBean(string id, GroupBean group)
 {
     this.id = id;
     this.group = group;
     this.attributes = new Hashtable();
 }
Пример #17
0
        private GroupBean mergeGroup(GroupBean a, GroupBean b)
        {
            GroupBean newGroup = new GroupBean();
            newGroup.id = a.id + "+" + b.id;
            newGroup.lchildern.AddRange(a.lchildern);

            foreach(NodeBean nb in b.lchildern)
            {
                if(!a.lchildern.Contains(nb))
                    newGroup.lchildern.Add(nb);
                //NodeBean bean = a.lchildern.Find(delegate(NodeBean nodebean)
                //{
                //    return nodebean.id.Equals(nb.id);
                //});
                //if(bean == null)
                //    newGroup.lchildern.Add(nb);
            }
            return newGroup;
        }
Пример #18
0
 public NodeBean(string id, GroupBean group)
 {
     this.id         = id;
     this.group      = group;
     this.attributes = new Hashtable();
 }