Profile Picture

How to change the type of an edge

Posted By Sandor Nagy 14 Years Ago
Author
Message
Sandor Nagy
questionmark Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 7, Visits: 1
Hi,

I'm using the NGraphDataSourceImporter class to import the vertices and edges into the diagram. By default the types of the edges is NRoutableConnector.
How can I change the type of some edges to e.g. NArrowShape in the NGraphDataSourceImporter.EdgeImported event?

Thanks,
Sandor Nagy

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi,
You can create a shape factory (by implementing the INShapeFactory interface) that creates the edge types you want and assign it to the EdgesShapeFactory property of the graph importer.

Best Regards,
Nevron Support Team



Sandor Nagy
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 7, Visits: 1
Hi,
Can you provide me a sample code?

Thanks,
Sandor Nagy

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Sandor,

The following is a simple implementation of a shape factory:

 

public class MyEdgeShapeFactory : NShapesFactory

{

      public MyEdgeShapeFactory()

            : base("MyEdgeShapeFactory")

      {

      }

 

      public override int ShapesCount

      {

            get

            {

                  return Enum.GetValues(GetEnumType()).Length;

            }

      }

     

      public override NShape CreateShape(int index)

      {

            switch ((MyEdgeShapes)index)

            {

                  case MyEdgeShapes.ArrowShape:

                        NArrowShape arrowShape = new NArrowShape(new NPointF(0, 0), new NPointF(DefaultSize.Width, DefaultSize.Height));

                        return arrowShape;

 

                  default:

                        throw new Exception("New shape type ?");

            }

      }

      protected override NShapeInfo CreateShapeInfo(int index)

      {

            MyEdgeShapes edgeShape = (MyEdgeShapes)index;

            NShapeInfo info = new NShapeInfo(NSystem.InsertSpacesBeforeUppers(edgeShape.ToString()));

            return info;

      }

      protected override Type GetEnumType()

      {

            return typeof(MyEdgeShapes);

      }

}

 

public enum MyEdgeShapes

{

      ArrowShape

}

 

To make the graph data importer use this shape factory to create edges, use the following piece of code:

 

MyEdgeShapeFactory edgesFactory = new MyEdgeShapeFactory();

edgesFactory.DefaultSize = new NSizeF(60, 30);

graphImporter.EdgeShapesFactory = edgesFactory;

graphImporter.EdgeShapesName = MyEdgeShapes.ArrowShape.ToString();



Best Regards,
Nevron Support Team



Sandor Nagy
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 7, Visits: 1
Hi,

Thanks, it is working. But I have another question.
With this sample code all edges will be NArrowShape edges. But I need different edge types during importing edges using NGraphDataSourceImporter.
So the selected edge type should be determined based on the current database record in the MyEdgeShapeFactory.CreateShape method. How can I do this?
When a breakpoint is hit in the NGraphDataSourceImporter.EdgeImported event, the edge is already created as NArrowShape.

Thanks,
Sandor Nagy



Similar Topics


Reading This Topic