Search in sources :

Example 6 with MLocationController

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);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MainView(org.freeplane.view.swing.map.MainView) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) ResourceController(org.freeplane.core.resources.ResourceController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) LocationController(org.freeplane.features.nodelocation.LocationController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) NodeView(org.freeplane.view.swing.map.NodeView)

Example 7 with MLocationController

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();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) LengthUnits(org.freeplane.core.ui.LengthUnits) MainView(org.freeplane.view.swing.map.MainView) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView) MTextController(org.freeplane.features.text.mindmapmode.MTextController) ResourceController(org.freeplane.core.resources.ResourceController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) LocationController(org.freeplane.features.nodelocation.LocationController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController)

Aggregations

MLocationController (org.freeplane.features.nodelocation.mindmapmode.MLocationController)7 MMapController (org.freeplane.features.map.mindmapmode.MMapController)6 MTextController (org.freeplane.features.text.mindmapmode.MTextController)6 Controller (org.freeplane.features.mode.Controller)5 LocationController (org.freeplane.features.nodelocation.LocationController)5 ResourceController (org.freeplane.core.resources.ResourceController)4 MapController (org.freeplane.features.map.MapController)4 NodeModel (org.freeplane.features.map.NodeModel)4 ModeController (org.freeplane.features.mode.ModeController)4 AttributeController (org.freeplane.features.attribute.AttributeController)3 MAttributeController (org.freeplane.features.attribute.mindmapmode.MAttributeController)3 CloudController (org.freeplane.features.cloud.CloudController)3 MCloudController (org.freeplane.features.cloud.mindmapmode.MCloudController)3 EdgeController (org.freeplane.features.edge.EdgeController)3 MEdgeController (org.freeplane.features.edge.mindmapmode.MEdgeController)3 MIconController (org.freeplane.features.icon.mindmapmode.MIconController)3 LinkController (org.freeplane.features.link.LinkController)3 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)3 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)3 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)3