use of org.freeplane.features.nodelocation.mindmapmode.MLocationController in project freeplane by freeplane.
the class MNodeMotionListener method mouseClicked.
@Override
public void mouseClicked(final MouseEvent e) {
boolean shoudResetPosition = e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2 && doubleClickTimer.getDelay() > 0;
if (shoudResetPosition) {
final MainView mainView = (MainView) e.getComponent();
if (mainView.getMouseArea().equals(MouseArea.MOTION)) {
final Controller controller = Controller.getCurrentController();
MLocationController locationController = (MLocationController) LocationController.getController(controller.getModeController());
if (e.getModifiersEx() == 0) {
final NodeView nodeV = getNodeView(e);
final NodeModel node = nodeV.getModel();
locationController.moveNodePosition(node, LocationModel.DEFAULT_HGAP, LocationModel.DEFAULT_SHIFT_Y);
return;
}
if (Compat.isCtrlEvent(e)) {
final NodeView nodeV = getNodeView(e);
NodeModel childDistanceContainer = nodeV.getParentView().getChildDistanceContainer().getModel();
locationController.setMinimalDistanceBetweenChildren(childDistanceContainer, LocationModel.DEFAULT_VGAP);
return;
}
} else {
if (Compat.isPlainEvent(e) && !isInFoldingRegion(e)) {
final MTextController textController = MTextController.getController();
textController.getEventQueue().activate(e);
textController.edit(FirstAction.EDIT_CURRENT, false);
}
}
}
super.mouseClicked(e);
}
use of org.freeplane.features.nodelocation.mindmapmode.MLocationController in project freeplane by freeplane.
the class MNodeMotionListener method mouseReleased.
@Override
public void mouseReleased(final MouseEvent e) {
final MainView v = (MainView) e.getSource();
if (!v.contains(e.getX(), e.getY())) {
v.setMouseArea(MouseArea.OUT);
}
if (!isDragActive()) {
super.mouseReleased(e);
return;
}
final NodeView nodeV = getNodeView(e);
final NodeModel node = nodeV.getModel();
final ModeController modeController = nodeV.getMap().getModeController();
final Controller controller = modeController.getController();
MLocationController locationController = (MLocationController) LocationController.getController(controller.getModeController());
final NodeView parentView = nodeV.getParentView();
final NodeView childDistanceContainerView = parentView.getChildDistanceContainer();
NodeModel childDistanceContainer = childDistanceContainerView.getModel();
final Quantity<LengthUnits> parentVGap = locationController.getMinimalDistanceBetweenChildren(childDistanceContainer);
Quantity<LengthUnits> hgap = LocationModel.getModel(node).getHGap();
final Quantity<LengthUnits> shiftY = LocationModel.getModel(node).getShiftY();
adjustNodeIndices(nodeV);
resetPositions(node);
final Quantity<LengthUnits> hGap = hgap;
locationController.moveNodePosition(node, hGap, shiftY);
locationController.setMinimalDistanceBetweenChildren(childDistanceContainer, parentVGap);
stopDrag();
}
Aggregations