Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic moving from applet to canvas (Read 3737 times)
hans
Junior Member
**
Offline


I Love MindFusion!

Posts: 81
Location: Netherlands
Joined: Mar 17th, 2012
moving from applet to canvas
Jan 15th, 2013 at 8:17pm
Print Post  
I have a few questions about moving from applet to diagramming.js

1) is it correct that a diagram saved from applet and then  loaded in canvas loses the pictures?
2) When collapsing a branch of nodes, the anchorpoints stay on the canvas. how can I prevent this ?
3) In my applet website I created a new node by dragging from an existing node with the code below.
Behavior="DrawLinks"
But in Canvas-mode this doesn't work.

InitializeLinkScript doesn't seem to be
invoked at all.

Do you have a hint how to get the same result ?

my applet-scriptcode:

function InitializeLinkScript(diagram, args) {
    diagram1.setAllowUnconnectedLinks(true);
}

function LinkCreatingScript(diagram, args) {
    var link = args.getLink();
    var origin = link.getOrigin();
    // allow links start only from ShapeNodes
    if (!origin.getClass().toString().match("ShapeNode")) {
        diagram1.setAllowUnconnectedLinks(false);
        return false;
    }
}

function LinkCreatedScript(diagram, args) {
    // get info about the DiagramLink just created
    var link = args.getLink();
    var points = link.getControlPoints();
    var destPoint = points.get(points.size() - 1);
    var orgNode = link.getOrigin();
    var dest = link.getDestination();

    var destNode;
    if (!dest.getClass().toString().match("ShapeNode")) {
        // create a new ShapeNode
        destNode = diagram1.getFactory().createShapeNode(destPoint.getX(), destPoint.getY(), 25, 6);
        destNode.setText("");
        destNode.setAnchorPattern(orgNode.getAnchorPattern());
        destNode.setShape(scriptHelper1.shapeFromId("RoundRect"));
    }
    else {
        destNode = dest;
    }
    // connect the link to the node and set its properties
    link.setDestination(destNode);
    diagram1.setAllowUnconnectedLinks(false);
}
  
Back to top
 
IP Logged
 
hans
Junior Member
**
Offline


I Love MindFusion!

Posts: 81
Location: Netherlands
Joined: Mar 17th, 2012
Re: moving from applet to canvas
Reply #1 - Jan 16th, 2013 at 1:03am
Print Post  
what type should an image be in node.setImage(image) ?
is it an url to a jpg or bmp ?
or a java.awt like in the applet?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: moving from applet to canvas
Reply #2 - Jan 16th, 2013 at 8:34am
Print Post  
Quote:
1) is it correct that a diagram saved from applet and then  loaded in canvas loses the pictures?


If you use the Image property, the image bytes cannot be decoded to an image object from JavaScript at this time. Use the ImageUrl property instead, as shown in the "Fractal Layout" sample project.

Quote:
2) When collapsing a branch of nodes, the anchorpoints stay on the canvas. how can I prevent this ?


I think this was fixed in the last release of the script, you could try replacing the one coming with NetDiagram with the latest stand-alone library:
http://mindfusion.eu/Forum/YaBB.pl?num=1357138514

We are releasing a new NetDiagram version with latest script included soon.

Quote:
3) In my applet website I created a new node by dragging from an existing node with the code below. Behavior="DrawLinks"


I think behaviors were implemented in one of the more recent JS library versions too. We'll try to add initialize events for the upcoming release.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: moving from applet to canvas
Reply #3 - Jan 17th, 2013 at 8:23am
Print Post  
This version of the script adds initializeLink and initializeNode events:
https://mindfusion.eu/_beta/jsdiag15.zip

Code
Select All
diagram.addEventListener(Events.initializeNode, onInitializeNode);

function onInitializeNode(sender, args)
{
	args.getNode().setBrush("lightBlue");
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint