protected int beforeLinkState=0;
public void mouseDragged(MouseEvent e){
if (isReadOnly()) return;
if (!SwingUtilities.isLeftMouseButton(e)) return;
if (selected instanceof GraphicNode){
GraphicNode node=(GraphicNode)selected;
boolean sw=switchOnLinkCreation(e.getX(),e.getY());
if (state!=LINK_CREATION&&sw){
drawBarShadow(lastShadowX,lastLinkShadowY,true);
beforeLinkState=state;
state=LINK_CREATION;
selectCursor();
sourceNode=(GraphicNode)selected;
drawLinkSelectionBarShadow(sourceNode);
setLinkOrigin();
}
else if (state==LINK_CREATION&&!sw&&allowLinkSelectionToMove()){
drawLinkShadow(lastLinkShadowX,lastLinkShadowY,true);
drawBarShadow(lastShadowX,lastLinkShadowY,true);
state=beforeLinkState;
selectCursor();
sourceNode=null;
}
}
if (state==LINK_CREATION){
GraphZone zone=ui.getNodeAt(e.getX(),e.getY());
GraphicNode newDestinationNode=zone==null?null:(GraphicNode)zone.getObject();
drawLinkSelectionBarShadow(destinationNode);
drawLinkShadow(lastLinkShadowX,lastLinkShadowY,true);
scrollToVisible(e.getX(),e.getY());
drawLinkShadow(e.getX(),e.getY(),true);
if (newDestinationNode!=null && newDestinationNode.isLinkable() && sourceNode != newDestinationNode){
destinationNode=newDestinationNode;
drawLinkSelectionBarShadow(destinationNode);
}else destinationNode=null;
}else if (isMove()){
drawBarShadow(lastShadowX,lastShadowY,true);