Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Different link shape for onLinkCreated (Read 2246 times)
Jessenberg
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Joined: Dec 20th, 2021
Different link shape for onLinkCreated
Jan 21st, 2022 at 3:44am
Print Post  
hello there, i'm now working on the different linkshape everytime someone created a link based on what link type they've chosen from the dropdown

[code javascript]SupportedBy(sender, args) {
var shape = mf.Diagramming.Shape.fromId("Triangle");
// var shape = "";
//...setLinkShape()

var origin = args.getLink().getOrigin().content.fileName;
console.log(shape);
args.getLink().setHeadShape(shape);
args.getLink().brush = "black";
if (origin == "/static/media/Solution.537801ea.svg") {
console.log("kiw");
this.state.diagram.removeItem(args.getLink());
}

// var DashStyle = mf.Drawing.DashStyle.Dash;
// args.getLink().strokeDashStyle = DashStyle;
}[/code]

how do i change the linkshape the moment a link is created ?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Different link shape for onLinkCreated
Reply #1 - Jan 21st, 2022 at 7:50am
Print Post  
Hi,

If you mean Polyline / Bezier / etc shape of link segments, you could set the Diagram.linkShape property in response to the dropdown change, and the control will then assign that automatically to the shape property of newly drawn links.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Jessenberg
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Joined: Dec 20th, 2021
Re: Different link shape for onLinkCreated
Reply #2 - Jan 21st, 2022 at 8:09am
Print Post  
hello, so i tried doing that on the onChange function but somethings weird is happening

this is the onSelectChange:

Code (Javascript)
Select All
 onSelectChange(event) {
    console.log("Before value set " + this.state.behavior);
    this.setState({
      behavior: +event.target.value,
    });
    console.log("After value set " + this.state.behavior);
  }  



this is the dropdown when it's called
Code (Javascript)
Select All
 <select
                className="item"
                defaultValue="4"
                onChange={this.onSelectChange.bind(this)}
              >
                <option value="4">Supported By</option>
                <option value="4.1">In Context Of</option>
                <option value="4.2">Asserted</option>
                <option value="4.3">Defeated</option>
                <option value="4.4">Axiomatic</option>
                <option value="4.5">NeedsSupport</option>
                <option value="4.6">Assumed</option>
                <option value="4.7">Abstract</option>
                <option value="4.8">AsCited</option>

                <option value="3">LinkShapes</option> </select> 



and this is on the link created :
Code (Javascript)
Select All
  onLinkCreated={(sender, args) => {
                var behave = this.state.behavior;
                console.log("actual value " + behave);  



they return different values so i was confused, on the link created the behaviour value is correct but on the on change value it's wrong, since i'm trying to use a conditional for each linkshape

do you have any idea why is this happening? below is the log
  

Screenshot_9.png ( 4 KB | 88 Downloads )
Screenshot_9.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Different link shape for onLinkCreated
Reply #3 - Jan 21st, 2022 at 11:09am
Print Post  
Hi,

I'm not sure what that has to do with link.shape / diagram.linkShape if it's what you were referring to in initial post. I guess there's some other code changing the state.behavior in between onSelectChange and onLinkCreated calls.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Different link shape for onLinkCreated
Reply #4 - Jan 21st, 2022 at 1:35pm
Print Post  
Setting e.g. link.shape = LinkShape.Bezier in that loop should change the shape. Or link.setShape(LinkShape.Bezier) if you are still on V3 API. Bezier curvature might not be immediately visible, with control points staying on a straight line. You could offset the 2nd/3d coordinates of link.controlPoints a bit to add curvature, or try calling link.route() method.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Jessenberg
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Joined: Dec 20th, 2021
Re: Different link shape for onLinkCreated
Reply #5 - Jan 25th, 2022 at 7:29am
Print Post  
Hello there, so i have question, this is my code to create a link
Code (Javascript)
Select All
 AssertedContex(sender, args) {
    var shape = mf.Diagramming.Shape.fromId("Triangle");
    var brush = mf.Drawing.Brush;
    console.log(shape);
    args.getLink().setHeadShape(shape);
    args.getLink().brush = "black";

    console.log(shape);
    var lab = "\u25CF";
    var label = args.link.addLabel(lab);
    // label.brush = "white";
    var Font = mf.Drawing.Font;

    label.font = new Font("Roboto", 5);
    label.horizontalAlign = mf.Diagramming.Alignment.Center;
    label.verticalAlign = mf.Diagramming.Alignment.Center;
    args.getLink().brush = "black";
  }
 



i'm wondering how could i put the square so that it stay on the second control point or the point where the arrow converge

below is what i have now
  

Screenshot_22.png ( 6 KB | 78 Downloads )
Screenshot_22.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Different link shape for onLinkCreated
Reply #6 - Jan 25th, 2022 at 7:51am
Print Post  
Hi,

Try the LinkLabel.setControlPointPosition method.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Jessenberg
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Joined: Dec 20th, 2021
Re: Different link shape for onLinkCreated
Reply #7 - Jan 27th, 2022 at 6:43am
Print Post  
thank you, it works just fine
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint