Search in sources :

Example 16 with MainView

use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.

the class MNodeDropListener method getNode.

private MainView getNode(final DropTargetEvent e) {
    final Component draggedNode = e.getDropTargetContext().getComponent();
    final MainView mainView = (MainView) draggedNode;
    return mainView;
}
Also used : MainView(org.freeplane.view.swing.map.MainView) Component(java.awt.Component)

Example 17 with MainView

use of org.freeplane.view.swing.map.MainView 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 NodeModel parentNode = nodeV.getModel().getParentNode();
    final int parentVGap = LocationModel.getModel(parentNode).getVGap();
    int hgap = LocationModel.getModel(node).getHGap();
    final int shiftY = LocationModel.getModel(node).getShiftY();
    adjustNodeIndices(nodeV);
    resetPositions(node);
    final Controller controller = modeController.getController();
    MLocationController locationController = (MLocationController) LocationController.getController(controller.getModeController());
    locationController.moveNodePosition(node, parentVGap, hgap, shiftY);
    stopDrag();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) 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) Point(java.awt.Point)

Example 18 with MainView

use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.

the class MNodeMotionListener method mouseClicked.

@Override
public void mouseClicked(final MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2 && doubleClickTimer.getDelay() > 0) {
        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.getModel(node).getVGap(), LocationModel.HGAP, 0);
                return;
            }
            if (Compat.isCtrlEvent(e)) {
                final NodeView nodeV = getNodeView(e);
                final NodeModel node = nodeV.getModel();
                locationController.moveNodePosition(node, LocationModel.VGAP, LocationModel.getModel(node).getHGap(), LocationModel.getModel(node).getShiftY());
                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 19 with MainView

use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.

the class MMapViewController method createEditor.

public EditNodeBase createEditor(final NodeModel node, final EditNodeBase.IEditControl editControl, String text, final boolean editLong) {
    final String htmlEditingOption = ResourceController.getResourceController().getProperty("html_editing_option");
    final boolean editInternalWysiwyg = editLong && StringUtils.equals(htmlEditingOption, "internal-wysiwyg");
    final boolean editExternal = editLong && StringUtils.equals(htmlEditingOption, "external");
    if (!HtmlUtils.isHtmlNode(text)) {
        text = HtmlUtils.plainToHTML(text);
    }
    if (editInternalWysiwyg) {
        final EditNodeWYSIWYG editNodeWYSIWYG = new EditNodeWYSIWYG(node, text, editControl, true);
        final ViewController viewController = Controller.getCurrentModeController().getController().getViewController();
        if (EditedComponent.TEXT.equals(editControl.getEditType())) {
            int preferredHeight = (int) (getComponent(node).getHeight() * 1.2);
            preferredHeight = Math.max(preferredHeight, Integer.parseInt(ResourceController.getResourceController().getProperty("el__min_default_window_height")));
            preferredHeight = Math.min(preferredHeight, Integer.parseInt(ResourceController.getResourceController().getProperty("el__max_default_window_height")));
            int preferredWidth = (int) (getComponent(node).getWidth() * 1.2);
            preferredWidth = Math.max(preferredWidth, Integer.parseInt(ResourceController.getResourceController().getProperty("el__min_default_window_width")));
            preferredWidth = Math.min(preferredWidth, Integer.parseInt(ResourceController.getResourceController().getProperty("el__max_default_window_width")));
            final Dimension preferredSize = new Dimension(preferredWidth, preferredHeight);
            editNodeWYSIWYG.setPreferredSize(preferredSize);
        }
        final MainView mainView = (MainView) getComponent(node);
        final NodeView nodeView = mainView.getNodeView();
        if (EditedComponent.TEXT.equals(editControl.getEditType())) {
            final Font font = getFont(node);
            editNodeWYSIWYG.setTitle("edit_long_node");
            editNodeWYSIWYG.setFont(font);
            final Color nodeTextColor = getTextColor(node);
            editNodeWYSIWYG.setTextColor(nodeTextColor);
            editNodeWYSIWYG.setBackground(nodeView.getTextBackground());
        } else if (EditedComponent.DETAIL.equals(editControl.getEditType())) {
            final MapView map = nodeView.getMap();
            editNodeWYSIWYG.setTitle("edit_details");
            editNodeWYSIWYG.setFont(map.getDetailFont());
            editNodeWYSIWYG.setTextColor(map.getDetailForeground());
            editNodeWYSIWYG.setBackground(nodeView.getDetailBackground());
        } else if (EditedComponent.NOTE.equals(editControl.getEditType())) {
            final MapView map = nodeView.getMap();
            editNodeWYSIWYG.setTitle("edit_note");
            editNodeWYSIWYG.setFont(map.getDefaultNoteFont());
            editNodeWYSIWYG.setBackground(Color.WHITE);
        }
        return editNodeWYSIWYG;
    } else if (editExternal) {
        return new EditNodeExternalApplication(node, text, editControl);
    } else {
        final EditNodeBase textfield = createEditor(node, editControl.getEditType(), text, editControl);
        if (textfield != null)
            return textfield;
    }
    return createEditor(node, editControl, text, true);
}
Also used : MainView(org.freeplane.view.swing.map.MainView) EditNodeBase(org.freeplane.features.text.mindmapmode.EditNodeBase) Color(java.awt.Color) Dimension(java.awt.Dimension) EditNodeWYSIWYG(org.freeplane.features.text.mindmapmode.EditNodeWYSIWYG) NodeView(org.freeplane.view.swing.map.NodeView) Font(java.awt.Font) MapViewController(org.freeplane.view.swing.map.MapViewController) ViewController(org.freeplane.features.ui.ViewController) MapView(org.freeplane.view.swing.map.MapView)

Example 20 with MainView

use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.

the class DefaultNodeMouseMotionListener method mouseMoved.

public void mouseMoved(final MouseEvent e) {
    if (!nodeSelector.isRelevant(e))
        return;
    final MainView node = ((MainView) e.getComponent());
    String link = node.getLink(e.getPoint());
    boolean followLink = link != null;
    Controller currentController = Controller.getCurrentController();
    if (!followLink) {
        followLink = node.isInFollowLinkRegion(e.getX());
        if (followLink) {
            link = LinkController.getController(currentController.getModeController()).getLinkShortText(node.getNodeView().getModel());
        }
    }
    final Cursor requiredCursor;
    if (followLink) {
        currentController.getViewController().out(link);
        requiredCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
        node.setMouseArea(MouseArea.LINK);
    } else if (isInFoldingRegion(e)) {
        requiredCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
        node.setMouseArea(MouseArea.FOLDING);
    } else {
        requiredCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
        node.setMouseArea(MouseArea.DEFAULT);
    }
    if (node.getCursor().getType() != requiredCursor.getType() || requiredCursor.getType() == Cursor.CUSTOM_CURSOR && node.getCursor() != requiredCursor) {
        node.setCursor(requiredCursor);
    }
    nodeSelector.createTimer(e);
}
Also used : MainView(org.freeplane.view.swing.map.MainView) MapController(org.freeplane.features.map.MapController) FoldingController(org.freeplane.features.map.FoldingController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) ResourceController(org.freeplane.core.resources.ResourceController) LinkController(org.freeplane.features.link.LinkController) Cursor(java.awt.Cursor)

Aggregations

MainView (org.freeplane.view.swing.map.MainView)26 NodeView (org.freeplane.view.swing.map.NodeView)11 NodeModel (org.freeplane.features.map.NodeModel)10 ModeController (org.freeplane.features.mode.ModeController)9 MapView (org.freeplane.view.swing.map.MapView)9 Point (java.awt.Point)7 MapController (org.freeplane.features.map.MapController)6 Controller (org.freeplane.features.mode.Controller)5 Component (java.awt.Component)4 ResourceController (org.freeplane.core.resources.ResourceController)4 MMapController (org.freeplane.features.map.mindmapmode.MMapController)4 Dimension (java.awt.Dimension)3 Rectangle (java.awt.Rectangle)3 MTextController (org.freeplane.features.text.mindmapmode.MTextController)3 Color (java.awt.Color)2 Cursor (java.awt.Cursor)2 Transferable (java.awt.datatransfer.Transferable)2 JPopupMenu (javax.swing.JPopupMenu)2 LinkController (org.freeplane.features.link.LinkController)2 LocationController (org.freeplane.features.nodelocation.LocationController)2