Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagram Link without destination (Read 3908 times)
Gaurav Dubey
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 9
Joined: Sep 28th, 2016
Diagram Link without destination
Jan 26th, 2017 at 3:49pm
Print Post  
In our application, we are supporting different types of dynamic link creation using context menu, However it is 3 step process for us right now, first user have to select link type from context menu and then he has to again select component to draw the link.

Is it possible to raise DiagramLink option as soon as user select option from context menu, so that he only needs to select destination.

Currently DiagramLink api only create link if we have source and destination points.

Please suggest
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Diagram Link without destination
Reply #1 - Jan 26th, 2017 at 5:29pm
Print Post  
You can create a link connected only to origin node like this -
Code
Select All
DiagramLink currentLink;
...
createLinkMenuItem.addActionListener(new ActionListener()
{
	public void actionPerformed(ActionEvent e)
	{
		DiagramNode origin = (DiagramNode)diagram.getActiveItem();
		currentLink = diagram.getFactory().createDiagramLink(origin, origin.getCenter());
		currentLink.setPen(new Pen(0, Color.gray, DashStyle.Dot));
	}
}); 



then update its end point position from mouseMoved event handler -
Code
Select All
diagramView.addMouseMotionListener(new MouseAdapter()
{
    public void mouseMoved(MouseEvent e)
    {
        Point2D.Float diagramPoint = diagramView.deviceToDoc(e.getPoint());
        if (currentLink != null)
        {
        	currentLink.setEndPoint(diagramPoint);
        	currentLink.updateFromPoints();
        	diagramView.repaint();
        }
    }
}); 



and connect it to destination node from nodeClicked handler -
Code
Select All
public void nodeClicked(NodeEvent e)
{
	if (currentLink != null)
	{
		currentLink.setDestination(e.getNode());
		currentLink.setPen(new Pen(0, Color.black));
		currentLink = null;
	}
} 



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


I Love MindFusion!

Posts: 9
Joined: Sep 28th, 2016
Re: Diagram Link without destination
Reply #2 - Jan 27th, 2017 at 1:51pm
Print Post  
Thanks a lot for quick solution, it solves the problem
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint