Search in sources :

Example 1 with MainView

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

the class TextController method registerNodeTextTooltip.

private void registerNodeTextTooltip() {
    modeController.addToolTipProvider(NODE_TOOLTIP, new ITooltipProvider() {

        @Override
        public String getTooltip(final ModeController modeController, NodeModel node, Component view) {
            return getTooltip(modeController, node, (MainView) view);
        }

        private String getTooltip(final ModeController modeController, NodeModel node, MainView view) {
            if (!ShortenedTextModel.isShortened(node)) {
                return null;
            }
            final NodeStyleController style = modeController.getExtension(NodeStyleController.class);
            final Font font = style.getFont(node);
            float zoom = view.getNodeView().getMap().getZoom();
            final StringBuilder htmlBodyStyle = new StringBuilder("<body><div style=\"").append(new CssRuleBuilder().withHTMLFont(font).withColor(view.getForeground()).withBackground(view.getNodeView().getTextBackground()).withAlignment(view.getHorizontalAlignment()).withMaxWidthAsPt(zoom, style.getMaxWidth(node)));
            final Object data = node.getUserObject();
            String text;
            try {
                text = getTransformedText(data, node, data);
                if (text.equals(getShortText(text)))
                    return null;
            } catch (Exception e) {
                text = TextUtils.format("MainView.errorUpdateText", data, e.getLocalizedMessage());
                htmlBodyStyle.append("color:red;");
            }
            htmlBodyStyle.append("\">");
            if (!HtmlUtils.isHtmlNode(text)) {
                text = HtmlUtils.plainToHTML(text);
            }
            final String tooltipText = text.replaceFirst("<body>", htmlBodyStyle.toString()).replaceFirst("</body>", "</div></body>");
            return tooltipText;
        }
    });
}
Also used : MainView(org.freeplane.view.swing.map.MainView) CssRuleBuilder(org.freeplane.core.ui.components.html.CssRuleBuilder) ModeController(org.freeplane.features.mode.ModeController) Font(java.awt.Font) NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) ITooltipProvider(org.freeplane.features.map.ITooltipProvider) Component(java.awt.Component)

Example 2 with MainView

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

the class MNodeDragListener method dragGestureRecognized.

public void dragGestureRecognized(final DragGestureEvent e) {
    final MainView mainView = (MainView) e.getComponent();
    final NodeView nodeView = mainView.getNodeView();
    final MapView mapView = nodeView.getMap();
    mapView.select();
    if (!nodeView.isSelected()) {
        nodeView.getMap().getModeController().getController().getSelection().selectAsTheOnlyOneSelected(nodeView.getModel());
    }
    Rectangle bounds = new Rectangle(0, 0, mainView.getWidth(), mainView.getHeight());
    if (!bounds.contains(e.getDragOrigin()))
        return;
    final int dragActionType = e.getDragAction();
    if (dragActionType == DnDConstants.ACTION_MOVE) {
        final NodeModel node = nodeView.getModel();
        if (node.isRoot()) {
            if (!isLinkDragEvent(e))
                return;
        }
    }
    final String dragActionName;
    Cursor cursor = getCursorByAction(dragActionType);
    if (isLinkDragEvent(e)) {
        cursor = DragSource.DefaultLinkDrop;
        dragActionName = "LINK";
    } else if ((e.getTriggerEvent().getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) {
        cursor = DragSource.DefaultCopyDrop;
        dragActionName = "COPY";
    } else {
        dragActionName = "MOVE";
    }
    final Transferable t = ClipboardController.getController().copy(Controller.getCurrentController().getSelection());
    ((MindMapNodesSelection) t).setDropAction(dragActionName);
    try {
        e.startDrag(cursor, t, new DragSourceListener() {

            public void dragDropEnd(final DragSourceDropEvent dsde) {
            }

            public void dragEnter(final DragSourceDragEvent e) {
            }

            public void dragExit(final DragSourceEvent dse) {
            }

            public void dragOver(final DragSourceDragEvent dsde) {
            }

            public void dropActionChanged(final DragSourceDragEvent dsde) {
                dsde.getDragSourceContext().setCursor(getCursorByAction(dsde.getUserAction()));
            }
        });
    } catch (final InvalidDnDOperationException ex) {
    }
}
Also used : InvalidDnDOperationException(java.awt.dnd.InvalidDnDOperationException) MainView(org.freeplane.view.swing.map.MainView) DragSourceDragEvent(java.awt.dnd.DragSourceDragEvent) Rectangle(java.awt.Rectangle) Transferable(java.awt.datatransfer.Transferable) NodeView(org.freeplane.view.swing.map.NodeView) Cursor(java.awt.Cursor) DragSourceListener(java.awt.dnd.DragSourceListener) DragSourceEvent(java.awt.dnd.DragSourceEvent) NodeModel(org.freeplane.features.map.NodeModel) MapView(org.freeplane.view.swing.map.MapView) DragSourceDropEvent(java.awt.dnd.DragSourceDropEvent) MindMapNodesSelection(org.freeplane.features.clipboard.MindMapNodesSelection)

Example 3 with MainView

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

the class MNodeDropListener method supportFolding.

private void supportFolding(final DropTargetDragEvent dtde) {
    final MainView node = getNode(dtde);
    if (isInFoldingRegion(dtde)) {
        node.setMouseArea(MouseArea.FOLDING);
        startUnfoldTimer(node);
    } else {
        node.setMouseArea(MouseArea.DEFAULT);
        stopUnfoldTimer();
    }
}
Also used : MainView(org.freeplane.view.swing.map.MainView)

Example 4 with MainView

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

the class MNodeDropListener method dragExit.

public void dragExit(final DropTargetEvent e) {
    getNode(e).setMouseArea(MouseArea.OUT);
    stopUnfoldTimer();
    final MainView mainView = getNode(e);
    mainView.setDraggedOver(NodeView.DRAGGED_OVER_NO);
    mainView.repaint();
}
Also used : MainView(org.freeplane.view.swing.map.MainView)

Example 5 with MainView

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

the class MNodeMotionListener method mouseMoved.

@Override
public void mouseMoved(final MouseEvent e) {
    if (isDragActive())
        return;
    final MainView v = (MainView) e.getSource();
    if (v.isInDragRegion(e.getPoint())) {
        v.setMouseArea(MouseArea.MOTION);
        v.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
        return;
    }
    super.mouseMoved(e);
}
Also used : MainView(org.freeplane.view.swing.map.MainView)

Aggregations

MainView (org.freeplane.view.swing.map.MainView)26 NodeView (org.freeplane.view.swing.map.NodeView)13 NodeModel (org.freeplane.features.map.NodeModel)11 ModeController (org.freeplane.features.mode.ModeController)9 MapView (org.freeplane.view.swing.map.MapView)7 MapController (org.freeplane.features.map.MapController)6 Component (java.awt.Component)5 Controller (org.freeplane.features.mode.Controller)5 Point (java.awt.Point)4 ResourceController (org.freeplane.core.resources.ResourceController)4 MMapController (org.freeplane.features.map.mindmapmode.MMapController)4 Cursor (java.awt.Cursor)2 Font (java.awt.Font)2 Rectangle (java.awt.Rectangle)2 Transferable (java.awt.datatransfer.Transferable)2 JPopupMenu (javax.swing.JPopupMenu)2 LengthUnits (org.freeplane.core.ui.LengthUnits)2 IconController (org.freeplane.features.icon.IconController)2 LinkController (org.freeplane.features.link.LinkController)2 IMapSelection (org.freeplane.features.map.IMapSelection)2