if (!isDragActive())
return;
if ((e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) == (InputEvent.BUTTON1_DOWN_MASK)) {
final MainView mainView = (MainView) e.getSource();
final NodeView nodeV = getNodeView(e);
final MapView mapView = nodeV.getMap();
final Point point = e.getPoint();
findGridPoint(point);
UITools.convertPointToAncestor(nodeV, point, JScrollPane.class);
ModeController c = Controller.getCurrentController().getModeController();
final Point dragNextPoint = point;
if (!Compat.isCtrlEvent(e)) {
final NodeModel node = nodeV.getModel();
final LocationModel locationModel = LocationModel.createLocationModel(node);
final int hGapChange = getHGapChange(dragNextPoint, node);
if(hGapChange != 0){
locationModel.setHGap(originalHGap + hGapChange);
}
final int shiftYChange = getNodeShiftYChange(dragNextPoint, node);
if(shiftYChange != 0){
locationModel.setShiftY(originalShiftY + shiftYChange);
}
if(hGapChange != 0 || shiftYChange != 0)
c.getMapController().nodeRefresh(node);
else
return;
}
else {
final NodeModel parentNode = nodeV.getVisibleParentView().getModel();
final int vGapChange = getVGapChange(dragNextPoint, parentNode);
if(vGapChange != 0){
LocationModel.createLocationModel(parentNode).setVGap(Math.max(0, originalParentVGap - vGapChange));
final MapController mapController = c.getMapController();
mapController.nodeRefresh(parentNode);
mapController.nodeRefresh(nodeV.getModel());
}
else
return;
}
EventQueue.invokeLater(new Runnable() {
public void run() {
final Rectangle r = mainView.getBounds();
UITools.convertRectangleToAncestor(mainView.getParent(), r, mapView);
final boolean isEventPointVisible = mapView.getVisibleRect().contains(r);
if (!isEventPointVisible) {
mapView.scrollRectToVisible(r);
}
}
});
}
}