Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Creating shape dynamically (Read 1233 times)
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Creating shape dynamically
Jul 28th, 2011 at 2:18pm
Print Post  
Is it possible to create a shape dynamically? This is without using the ShapeListBox.

For example, I want to create two shapes in my codebehind - Plan and Unit. They are rectangles, but have different colours and id's.

Then I want to be able to add these to the diagram using javascript. So I want to be able to write something like:

''''The plan shape was created in the codebehind
diagram.getFactory.createShapeNodeById(Plan);

I also want to be able to get the shape id when a user clicks on a node, i.e.

if (childNode.getShape().getId() == 'plan') {
.......
} else if (childNode.getShape().getId() == 'unit') {
....
}
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Creating shape dynamically
Reply #1 - Jul 29th, 2011 at 8:09am
Print Post  
You can create diagram objects in JavaScript using the diagram's Factory object:

Code
Select All
var factory = view.getDiagram().getFactory();
var node1 = factory.createShapeNode(10, 10, 100, 100);
var node2 = factory.createShapeNode(210, 210, 100, 100);
// Set any node properties
factory.createDiagramLink(node1, node2); 


In the above code view references a DiagramView object.

I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint