- Welcome, Guest. Please Login or Register
MindFusion  
  Version 2 of our Xamarin Calendar component adds Resource view and support for Universal Windows Platform. Now beta testing spreadsheet component for Java Swing.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Diagram Link without destination
Read 189 times

Gaurav Dubey   Offline
YaBB Newbies
*
Posts: 5
I Love MindFusion!


   
     
 
Diagram Link without destination
Jan 26th, 2017 at 3:49pm
 
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
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 881
Gender: male
tech.support


   
     
 
Re: Diagram Link without destination
Reply #1 - Jan 26th, 2017 at 5:29pm
 
You can create a link connected only to origin node like this -
Code:
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:
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:
public void nodeClicked(NodeEvent e)
{
	if (currentLink != null)
	{
		currentLink.setDestination(e.getNode());
		currentLink.setPen(new Pen(0, Color.black));
		currentLink = null;
	}
} 



Regards,
Slavcho
Mindfusion
 
 
 
IP Logged    
 
     

Gaurav Dubey   Offline
YaBB Newbies
*
Posts: 5
I Love MindFusion!


   
     
 
Re: Diagram Link without destination
Reply #2 - Jan 27th, 2017 at 1:51pm
 
Thanks a lot for quick solution, it solves the problem
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print