Exemplo n.º 1
0
        protected override Point OnOriginalPosition(YodiiGraphVertex v, Point p)
        {
            // Keep existing positions
            if (p.IsValid())
            {
                return(p);
            }

            Point newPoint = new Point(0, 0);

            if (VertexPositions == null)
            {
                return(newPoint);
            }
            if (v.IsService)
            {
                if (v.LabServiceInfo.ServiceInfo.Generalization != null)
                {
                    // Find & get point of generalization
                    var generalizationQuery = VertexPositions.Where(kvp => kvp.Key.IsService && kvp.Key.LabServiceInfo.ServiceInfo == v.LabServiceInfo.ServiceInfo.Generalization);

                    if (generalizationQuery.Count() > 0)
                    {
                        Point generalizationPoint = generalizationQuery.First().Value;
                        if (generalizationPoint.IsValid())
                        {
                            newPoint.X = generalizationPoint.X;
                            newPoint.Y = generalizationPoint.Y + VERTICAL_MARGIN_SIZE;
                        }
                    }
                }
            }
            else if (v.IsPlugin)
            {
                if (v.LabPluginInfo.PluginInfo.Service != null)
                {
                    // Find & get point of service
                    var serviceQuery = VertexPositions.Where(kvp => kvp.Key.IsService && kvp.Key.LabServiceInfo.ServiceInfo == v.LabPluginInfo.PluginInfo.Service);

                    if (serviceQuery.Count() > 0)
                    {
                        Point generalizationPoint = serviceQuery.First().Value;
                        if (generalizationPoint.IsValid())
                        {
                            newPoint.X = generalizationPoint.X;
                            newPoint.Y = generalizationPoint.Y + VERTICAL_MARGIN_SIZE;
                        }
                    }
                }
            }

            return(newPoint);
        }
Exemplo n.º 2
0
        private void ArrangeRectangle(Rect rectangle, int groupId, Rect originalRect)
        {
            var offsetX = rectangle.X - originalRect.X;
            var offsetY = rectangle.Y - originalRect.Y;

            VertexPositions.Where(a => a.Key.GroupId == groupId).Select(a => a.Key).ToList().ForEach(a =>
            {
                VertexPositions[a] = new Point(VertexPositions[a].X + offsetX, VertexPositions[a].Y + offsetY);
            });
            var gp = _params.GroupParametersList.FirstOrDefault(a => a.GroupId == groupId);

            if (gp == null)
            {
                throw new GX_ObjectNotFoundException("Grouped graph -> Can't find group data after calc!");
            }
            gp.ZoneRectangle = rectangle;
        }
Exemplo n.º 3
0
        public IDictionary <HyperEdge, Point[]> RouteEdges()
        {
            var edges   = Graph.HyperEdges;
            var resDict = new Dictionary <HyperEdge, Point[]>();

            foreach (var edge in edges)
            {
                var vertexPositions = VertexPositions
                                      .Where(pair => edge.Vertices.Contains(pair.Key))
                                      .Select(pair => pair.Value).ToList();
                var medianPoint = new Point
                {
                    X = vertexPositions.Average(p => p.X),
                    Y = vertexPositions.Average(p => p.Y)
                };
                resDict.Add(edge, vertexPositions.Append(medianPoint).ToArray());
            }

            return(resDict);
        }