Example #1
0
        public Connection AttachConnection(NetronGraphvizLayouter layout, IEdge e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            if (!this.VisitedGraph.ContainsEdge(e))
            {
                throw new ArgumentException("edge already in graph");
            }
            if (this.EdgeConnections.Contains(e))
            {
                throw new ArgumentException("connection already associtated with this edge");
            }

            // create edge
            Connection conn = this.ConnectionProvider.ProvideConnection(e);

            // set points
            layout.PositionConnection(e, conn);
            Connect(e, conn);

            // connect to target
            Modify m = new Modify();

            m.AddInsertConnection(conn, conn.From, conn.To, this.Panel.AbstractShape);
            this.Panel.AbstractShape.History.Do(m);

            return(conn);
        }
Example #2
0
        public void PopulatePanel(Graphics g)
        {
            // add shapes
            foreach (IVertex v in VisitedGraph.Vertices)
            {
                // do not add vertex if already in panel
                if (VertexShapes.Contains(v))
                {
                    continue;
                }
                AttachShape(v);
            }

            // udpate shape sizes if possible and build size dictionary
            NetronGraphvizLayouter layout = new NetronGraphvizLayouter(this);

            layout.Layouter.DpiX          = g.DpiX;
            layout.Layouter.DpiY          = g.DpiY;
            layout.Layouter.RankDirection = this.RankDirection;
            foreach (DictionaryEntry de in this.ShapeVertices)
            {
                if (de.Key is Netron.Shape)
                {
                    Netron.Shape shape = (Netron.Shape)de.Key;
                    layout.VertexSizes[(IVertex)de.Value] = shape.Size;
                }
                else
                {
                    throw new Exception("Shapes must derive from Netron.Shape");
                }
            }
            layout.Compute();
            layout.PositionVertices();

            foreach (IEdge e in VisitedGraph.Edges)
            {
                // check if edge alreay in graph
                if (EdgeConnections.Contains(e))
                {
                    continue;
                }
                AttachConnection(layout, e);
            }

            // reposition connections
            //	layout.PositionConnections();

            // redraw panel
            this.Panel.Invalidate();
            this.graphDirty = false;
        }
        public void PopulatePanel(Graphics g)
        {
            // add shapes
            foreach(IVertex v in VisitedGraph.Vertices)
            {
                // do not add vertex if already in panel
                if (VertexShapes.Contains(v))
                    continue;
                AttachShape(v);
            }

            // udpate shape sizes if possible and build size dictionary
            NetronGraphvizLayouter layout = new NetronGraphvizLayouter(this);
            layout.Layouter.DpiX = g.DpiX;
            layout.Layouter.DpiY = g.DpiY;
            layout.Layouter.RankDirection = this.RankDirection;
            foreach(DictionaryEntry de in this.ShapeVertices)
            {
                if (de.Key is Netron.Shape)
                {
                    Netron.Shape shape = (Netron.Shape)de.Key;
                    layout.VertexSizes[(IVertex)de.Value] = shape.Size;
                }
                else
                    throw new Exception("Shapes must derive from Netron.Shape");
            }
            layout.Compute();
            layout.PositionVertices();

            foreach(IEdge e in VisitedGraph.Edges)
            {
                // check if edge alreay in graph
                if (EdgeConnections.Contains(e))
                    continue;
                AttachConnection(layout,e);
            }

            // reposition connections
            //	layout.PositionConnections();

            // redraw panel
            this.Panel.Invalidate();
            this.graphDirty = false;
        }
        public Connection AttachConnection(NetronGraphvizLayouter layout,IEdge e)
        {
            if (e==null)
                throw new ArgumentNullException("e");
            if (!this.VisitedGraph.ContainsEdge(e))
                throw new ArgumentException("edge already in graph");
            if (this.EdgeConnections.Contains(e))
                throw new ArgumentException("connection already associtated with this edge");

            // create edge
            Connection conn = this.ConnectionProvider.ProvideConnection(e);
            // set points
            layout.PositionConnection(e,conn);
            Connect(e,conn);

            // connect to target
            Modify m = new Modify();
            m.AddInsertConnection(conn, conn.From, conn.To,this.Panel.AbstractShape);
            this.Panel.AbstractShape.History.Do(m);

            return conn;
        }