Esempio n. 1
0
        internal DEdge(DNode source, DNode target, DrawingEdge drawingEdgeParam, ConnectionToGraph connection)
            : base(source.ParentObject)
        {
            this.DrawingEdge = drawingEdgeParam;
            this.Source = source;
            this.Target = target;

            if (connection == ConnectionToGraph.Connected)
            {
                if (source == target)
                    source.AddSelfEdge(this);
                else
                {
                    source.AddOutEdge(this);
                    target.AddInEdge(this);
                }
            }

            if (drawingEdgeParam.Label != null)
                this.Label = new DTextLabel(this, DrawingEdge.Label);
        }
Esempio n. 2
0
 public IViewerNode CreateIViewerNode(DrawingNode drawingNode, MsaglPoint center, object visualElement)
 {
     DNode ret = new DNode(this, drawingNode);
     // not sure what I'm supposed to do here...
     return ret;
 }
Esempio n. 3
0
 public IViewerNode CreateNode(DrawingNode node)
 {
     DNode ret = new DNode(this, node);
     node.LabelText = null;
     SetNodeBoundaryCurve(Graph, node);
     return ret;
 }
Esempio n. 4
0
        static void DrawEllipseOnPosition(DNode dNode, NodeAttr nodeAttr, Canvas g, float x, float y, float width,
                                          float height, Brush pen)
        {
            throw new NotImplementedException();
            /*
            if (NeedToFill(dNode.FillColor))
                g.FillEllipse(new SolidBrush(dNode.FillColor), x, y, width, height);
            if (nodeAttr.Shape == Shape.Point)
                g.FillEllipse(new SolidBrush(pen.Color), x, y, width, height);

            g.DrawEllipse(pen, x, y, width, height); //*/
        }
Esempio n. 5
0
        internal static void DrawFromMsaglCurve(Canvas g, Brush pen, DNode dNode)
        {
            throw new NotImplementedException();
            /*
            NodeAttr attr = dNode.DrawingNode.Attr;
            var c = attr.GeometryNode.BoundaryCurve as Curve;
            if (c != null)
            {
                var path = new GraphicsPath();
                foreach (ICurve seg in c.Segments)
                    AddSegToPath(seg, ref path);

                if (NeedToFill(dNode.FillColor))
                {
                    g.FillPath(new SolidBrush(dNode.FillColor), path);
                }
                g.DrawPath(pen, path);
            }
            else
            {
                var ellipse = attr.GeometryNode.BoundaryCurve as Ellipse;
                if (ellipse != null)
                {
                    double w = ellipse.AxisA.X;
                    double h = ellipse.AxisB.Y;
                    DrawEllipseOnPosition(dNode, dNode.DrawingNode.Attr, g, (float)(ellipse.Center.X - w),
                                          (float)(ellipse.Center.Y - h),
                                          (float)w * 2, (float)h * 2, pen);
                }
            }*/
        }
Esempio n. 6
0
 internal void AddNode(DNode node)
 {
     m_Nodes.Add(node);
 }
Esempio n. 7
0
        public void ResizeNodeToLabel(DNode node)
        {
            if (node.Label == null)
                return;
            double width = Math.Max(node.Label.ActualWidth, node.Label.Width);
            double height = Math.Max(node.Label.ActualHeight, node.Label.Height);
            width += 2 * node.Node.Attr.LabelMargin;
            height += 2 * node.Node.Attr.LabelMargin;
            if (width < Graph.Attr.MinNodeWidth)
                width = Graph.Attr.MinNodeWidth;
            if (height < Graph.Attr.MinNodeHeight)
                height = Graph.Attr.MinNodeHeight;

            SetNodeBoundaryCurve(Graph, node.DrawingNode, node.Label);

            var allEdges = node.Edges.Concat(CrossEdges.Where(ed => ed.Source == node || ed.Target == node));
            foreach (GeometryEdge e in allEdges.Select(ed => ed.GeometryEdge))
            {
                if (e.UnderlyingPolyline != null)
                {
                    Curve curve = e.UnderlyingPolyline.CreateCurve();
                    if (!Arrowheads.TrimSplineAndCalculateArrowheads(e.EdgeGeometry, e.Source.BoundaryCurve, e.Target.BoundaryCurve, curve, false, true))
                        Arrowheads.CreateBigEnoughSpline(e);
                }
            }

            if (UpdateGraphBoundingBoxPreservingCenter())
                Invalidate();
            else
            {
                Invalidate(node);
                foreach (DObject obj in node.Edges)
                    Invalidate(obj);
            }
        }
Esempio n. 8
0
        private DEdge AddCrossEdge(DNode source, DNode target)
        {
            DEdge dEdge = new DEdge(source, target, new DrawingEdge(source.Node, target.Node, ConnectionToGraph.Disconnected), ConnectionToGraph.Disconnected);
            GeometryEdge gEdge = new GeometryEdge(source.GeometryNode, target.GeometryNode) { GeometryParent = Graph.GeometryGraph };
            dEdge.GeometryEdge = gEdge;
            dEdge.ArrowheadAtTarget = ArrowStyle.Normal;

            m_CrossEdges.Add(dEdge);

            return dEdge;

            /*DEdge ret;
            var s = VisualTreeHelper.GetRoot(this);
            var ss = VisualTreeHelper.GetRoot(source);
            var ts = VisualTreeHelper.GetRoot(target);
            if (s != ss || s != ts || ss != ts)
                ret = new DEdge(source, target, null, ConnectionToGraph.Disconnected);
            else
                ret = NestedGraphHelper.DrawCrossEdge(this, source, target);
            m_CrossEdges.Add(ret);
            return ret;*/
        }
Esempio n. 9
0
        internal static void DrawBox(PathGeometry pg, DNode dNode)
        {
            throw new NotImplementedException();

            /*
            NodeAttr nodeAttr = dNode.DrawingNode.Attr;
            if (nodeAttr.XRadius == 0 || nodeAttr.YRadius == 0)
            {
                double x = nodeAttr.Pos.X - nodeAttr.Width / 2.0f;
                double y = nodeAttr.Pos.Y - nodeAttr.Height / 2.0f;

                if (NeedToFill(dNode.FillColor))
                {
                    Color fc = FillColor(nodeAttr);
                    g.FillRectangle(new SolidBrush(fc), (float)x, (float)y, (float)nodeAttr.Width,
                                    (float)nodeAttr.Height);
                }

                g.DrawRectangle(pen, (float)x, (float)y, (float)nodeAttr.Width, (float)nodeAttr.Height);
            }
            else
            {
                var width = (float)nodeAttr.Width;
                var height = (float)nodeAttr.Height;
                var xRadius = (float)nodeAttr.XRadius;
                var yRadius = (float)nodeAttr.YRadius;
                using (var path = new GraphicsPath())
                {
                    FillTheGraphicsPath(nodeAttr, width, height, ref xRadius, ref yRadius, path);

                    if (NeedToFill(dNode.FillColor))
                    {
                        g.FillPath(new SolidBrush(dNode.FillColor), path);
                    }

                    g.DrawPath(pen, path);
                }
            }
             * */
        }
Esempio n. 10
0
 private void Clustering_ApplyNodeAttributes(DNode n)
 {
     n.DrawingNode.Attr.Color = MsaglColor.Green;
     n.DrawingNode.Attr.LineWidth = 2.0;
     n.DrawingNode.Attr.Shape = MsaglShape.Box;
     n.DrawingNode.Attr.XRadius = 5.0;
     n.DrawingNode.Attr.YRadius = 5.0;
 }
Esempio n. 11
0
 private DEdge Nesting_Cell_AddEdge(DGraph graph, DNode source, DNode target, string label)
 {
     DEdge ret = graph.AddEdgeBetweenNodes(source, target);
     if (label != null)
         ret.Label = new DTextLabel(ret, label);
     ret.DrawingEdge.Attr.Color = MsaglColor.Red;
     return ret;
 }
Esempio n. 12
0
        public DEdge AddEdgeBetweenNodes(DNode source, DNode target)
        {
            DEdge dEdge = new DEdge(source, target, new DrawingEdge(source.Node, target.Node, ConnectionToGraph.Disconnected), ConnectionToGraph.Disconnected);
            GeometryEdge gEdge = new GeometryEdge(source.GeometryNode, target.GeometryNode) { GeometryParent = Graph.GeometryGraph };
            dEdge.GeometryEdge = gEdge;
            dEdge.ArrowheadAtTarget = ArrowStyle.Normal;

            AddEdge(dEdge, false);

            return dEdge;
        }
Esempio n. 13
0
 static BBNode BuildBBHierarchyUnderDNode(DNode dNode)
 {
     var bbNode = new BBNode();
     bbNode.geometry = new Geometry(dNode);
     bbNode.bBox = dNode.DrawingNode.BoundingBox;
     return bbNode;
 }
Esempio n. 14
0
 public void AddNodeToCluster(DCluster owner, DNode node)
 {
     node.ParentObject = owner;
     owner.AddNode(node);
     owner.DrawingCluster.AddNode(node.DrawingNode);
     owner.GeometryCluster.AddChild(node.GeometryNode);
 }
Esempio n. 15
0
        internal static void DrawDiamond(Canvas g, Brush pen, DNode dNode)
        {
            throw new NotImplementedException();
            /*
            NodeAttr nodeAttr = dNode.DrawingNode.Attr;
            double w2 = nodeAttr.Width / 2.0f;
            double h2 = nodeAttr.Height / 2.0f;
            double cx = nodeAttr.Pos.X;
            double cy = nodeAttr.Pos.Y;
            var ps = new[]{
                              new PointF((float) cx - (float) w2, (float) cy),
                              new PointF((float) cx, (float) cy + (float) h2),
                              new PointF((float) cx + (float) w2, (float) cy),
                              new PointF((float) cx, (float) cy - (float) h2)
                          };

            if (NeedToFill(dNode.FillColor))
            {
                Color fc = FillColor(nodeAttr);
                g.FillPolygon(new SolidBrush(fc), ps);
            }

            g.DrawPolygon(pen, ps); //*/
        }
Esempio n. 16
0
 private bool IsContainedSub(DNode n)
 {
     if (Nodes().Contains(n))
         return true;
     foreach (DGraph g in NestedGraphs)
         if (g.IsContainedSub(n))
             return true;
     return false;
 }
Esempio n. 17
0
        internal static void DrawDoubleCircle(Canvas g, Brush pen, DNode dNode)
        {
            throw new NotImplementedException();
            /*
            NodeAttr nodeAttr = dNode.DrawingNode.Attr;
            double x = nodeAttr.Pos.X - nodeAttr.Width / 2.0f;
            double y = nodeAttr.Pos.Y - nodeAttr.Height / 2.0f;
            if (NeedToFill(dNode.FillColor))
            {
                g.FillEllipse(new SolidBrush(dNode.FillColor), (float)x, (float)y, (float)nodeAttr.Width,
                              (float)nodeAttr.Height);
            }

            g.DrawEllipse(pen, (float)x, (float)y, (float)nodeAttr.Width, (float)nodeAttr.Height);
            var w = (float)nodeAttr.Width;
            var h = (float)nodeAttr.Height;
            float m = Math.Max(w, h);
            float coeff = (float)1.0 - (float)(DoubleCircleOffsetRatio);
            x += coeff * m / 2.0;
            y += coeff * m / 2.0;
            g.DrawEllipse(pen, (float)x, (float)y, w - coeff * m, h - coeff * m);
             * */
        }
Esempio n. 18
0
        public DEdge AddEdgeBetweenNodes(DNode source, DNode target)
        {
            if (!IsContainedSub(source))
                throw new InvalidOperationException("The edge source node must be in the graph or in one of its nested graphs.");
            if (!IsContainedSub(target))
                throw new InvalidOperationException("The edge target node must be in the graph or in one of its nested graphs.");
            if (source.ParentGraph == this && target.ParentGraph == this)
            {
                DEdge dEdge = new DEdge(source, target, new DrawingEdge(source.Node, target.Node, ConnectionToGraph.Disconnected), ConnectionToGraph.Disconnected);
                GeometryEdge gEdge = new GeometryEdge(source.GeometryNode, target.GeometryNode) { GeometryParent = Graph.GeometryGraph };
                dEdge.GeometryEdge = gEdge;
                dEdge.ArrowheadAtTarget = ArrowStyle.Normal;

                AddEdge(dEdge, false);

                return dEdge;
            }
            else
                return AddCrossEdge(source, target);
        }
Esempio n. 19
0
        internal static void DrawEllipse(Canvas g, Brush pen, DNode dNode)
        {
            var node = dNode.DrawingNode;
            NodeAttr nodeAttr = node.Attr;
            var x = (float)(node.GeometryNode.Center.X - node.Width / 2.0);
            var y = (float)(node.GeometryNode.Center.Y - node.Height / 2.0);
            var width = (float)node.Width;
            var height = (float)node.Height;

            DrawEllipseOnPosition(dNode, nodeAttr, g, x, y, width, height, pen);
        }
 void ApplyNodeTypeToInsertedNode(NodeTypeEntry nte, DNode node)
 {
     node.DrawingNode.Attr.Shape = nte.Shape;
     if (nte.XRadius != 0)
         node.DrawingNode.Attr.XRadius = nte.XRadius;
     if (nte.YRadius != 0)
         node.DrawingNode.Attr.YRadius = nte.YRadius;
     node.Tag = nte.Tag;
     Graph.ResizeNodeToLabel(node);
 }
 internal void AddNode(DNode node)
 {
     m_Nodes.Add(node);
 }