Search in sources :

Example 6 with NodeView

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

the class MNodeMouseWheelListener method mouseWheelMoved.

@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    if (!e.isAltDown()) {
        super.mouseWheelMoved(e);
        return;
    }
    final MainView view = (MainView) e.getComponent();
    final MapView map = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, view);
    if (map.usesLayoutSpecificMaxNodeWidth())
        return;
    final int wheelRotation = e.getWheelRotation();
    final NodeView nodeView = view.getNodeView();
    if (!nodeView.isSelected())
        map.selectAsTheOnlyOneSelected(nodeView);
    final double factor = e.isControlDown() ? 1 : 6 * LengthUnits.pt.factor();
    double newZoomedWidth = Math.max((view.getWidth() - wheelRotation * factor) / map.getZoom(), 0);
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    Quantity<LengthUnits> newZoomedWidthQuantity = LengthUnits.pixelsInPt(newZoomedWidth);
    final ModeController modeController = map.getModeController();
    final MNodeStyleController styleController = (MNodeStyleController) modeController.getExtension(NodeStyleController.class);
    selection.keepNodePosition(nodeView.getModel(), 0f, 0f);
    for (final NodeModel node : selection.getSelection()) {
        styleController.setMinNodeWidth(node, newZoomedWidthQuantity);
        styleController.setMaxNodeWidth(node, newZoomedWidthQuantity);
    }
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) NodeModel(org.freeplane.features.map.NodeModel) MainView(org.freeplane.view.swing.map.MainView) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) IMapSelection(org.freeplane.features.map.IMapSelection) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView)

Example 7 with NodeView

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

the class ViewerController method onViewCreated.

public void onViewCreated(final Container container) {
    final NodeView nodeView = (NodeView) container;
    final ExternalResource previewUri = nodeView.getModel().getExtension(ExternalResource.class);
    if (previewUri == null) {
        return;
    }
    createViewer(previewUri, nodeView);
}
Also used : INodeView(org.freeplane.features.map.INodeView) NodeView(org.freeplane.view.swing.map.NodeView)

Example 8 with NodeView

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

the class MExternalImageDropListener method drop.

public void drop(final DropTargetDropEvent ev) {
    try {
        int dropAction = ev.getDropAction();
        if (dropAction == DnDConstants.ACTION_MOVE && ev.isDataFlavorSupported(MindMapNodesSelection.fileListFlavor)) {
            try {
                ev.acceptDrop(ev.getDropAction());
                @SuppressWarnings("unchecked") final List<File> transferData = (List<File>) ev.getTransferable().getTransferData(MindMapNodesSelection.fileListFlavor);
                if (transferData.size() != 1)
                    return;
                final Component target = ev.getDropTargetContext().getComponent();
                NodeView nodeView = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, target);
                final File file = transferData.get(0);
                final ViewerController vc = (Controller.getCurrentController().getModeController().getExtension(ViewerController.class));
                final NodeModel node = nodeView.getModel();
                vc.paste(file.toURI(), node, node.isLeft());
            } catch (Exception e) {
                LogUtils.warn(e);
            }
        }
    } catch (final Exception e) {
        LogUtils.severe("Drop exception:", e);
        ev.dropComplete(false);
        return;
    }
    ev.dropComplete(true);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) List(java.util.List) Component(java.awt.Component) NodeView(org.freeplane.view.swing.map.NodeView) File(java.io.File)

Example 9 with NodeView

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

the class MMapViewController method createEditor.

private EditNodeBase createEditor(final NodeModel node, final EditedComponent parent, final String text, final IEditControl editControl) {
    final ZoomableLabel parentComponent;
    final MainView mainView = (MainView) getComponent(node);
    final NodeView nodeView = mainView.getNodeView();
    if (EditedComponent.TEXT.equals(parent))
        parentComponent = mainView;
    else if (EditedComponent.DETAIL.equals(parent)) {
        final JComponent component = nodeView.getContent(NodeView.DETAIL_VIEWER_POSITION);
        if (component instanceof ZoomableLabel)
            parentComponent = (ZoomableLabel) component;
        else
            parentComponent = null;
    } else
        parentComponent = null;
    if (parentComponent == null || !parentComponent.isVisible()) {
        return null;
    }
    final EditNodeTextField textField = new EditNodeTextField(node, (ZoomableLabel) parentComponent, text, editControl);
    if (EditedComponent.TEXT.equals(parent))
        textField.setBackground(nodeView.getTextBackground());
    else if (EditedComponent.DETAIL.equals(parent))
        textField.setBackground(nodeView.getDetailBackground());
    return textField;
}
Also used : MainView(org.freeplane.view.swing.map.MainView) JComponent(javax.swing.JComponent) ZoomableLabel(org.freeplane.view.swing.map.ZoomableLabel) NodeView(org.freeplane.view.swing.map.NodeView)

Example 10 with NodeView

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

the class MMapMouseListener method mouseDragged.

public void mouseDragged(final MouseEvent e) {
    final MapView mapView = (MapView) e.getComponent();
    if (draggedLink != null && mapView.getLayoutType().equals(MapViewLayout.MAP)) {
        final int deltaX = (int) ((e.getX() - originX) / mapView.getZoom());
        final int deltaY = (int) ((e.getY() - originY) / mapView.getZoom());
        double distSqToTarget = 0;
        double distSqToSource = 0;
        final NodeModel target = draggedLink.getTarget();
        final NodeView targetView = mapView.getNodeView(target);
        final NodeView sourceView = mapView.getNodeView(draggedLink.getSource());
        if (targetView != null && sourceView != null) {
            final Point targetLinkPoint = targetView.getLinkPoint(draggedLink.getEndInclination());
            final Point sourceLinkPoint = sourceView.getLinkPoint(draggedLink.getStartInclination());
            distSqToTarget = targetLinkPoint.distanceSq(originX, originY);
            distSqToSource = sourceLinkPoint.distanceSq(originX, originY);
        }
        if ((targetView == null || sourceView != null) && distSqToSource <= distSqToTarget * 2.25) {
            final Point changedInclination = draggedLink.getStartInclination();
            draggedLink.changeInclination(deltaX, deltaY, draggedLink.getSource(), changedInclination);
            draggedLink.setStartInclination(changedInclination);
        }
        if ((sourceView == null || targetView != null) && distSqToTarget <= distSqToSource * 2.25) {
            final Point changedInclination = draggedLink.getEndInclination();
            draggedLink.changeInclination(deltaX, deltaY, target, changedInclination);
            draggedLink.setEndInclination(changedInclination);
        }
        originX = e.getX();
        originY = e.getY();
        mapView.repaintVisible();
    } else {
        super.mouseDragged(e);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapView(org.freeplane.view.swing.map.MapView) Point(java.awt.Point) NodeView(org.freeplane.view.swing.map.NodeView) Point(java.awt.Point)

Aggregations

NodeView (org.freeplane.view.swing.map.NodeView)43 NodeModel (org.freeplane.features.map.NodeModel)20 MapView (org.freeplane.view.swing.map.MapView)17 ModeController (org.freeplane.features.mode.ModeController)14 MainView (org.freeplane.view.swing.map.MainView)11 Point (java.awt.Point)8 INodeView (org.freeplane.features.map.INodeView)8 Controller (org.freeplane.features.mode.Controller)6 JPopupMenu (javax.swing.JPopupMenu)5 ResourceController (org.freeplane.core.resources.ResourceController)5 MapController (org.freeplane.features.map.MapController)5 MMapController (org.freeplane.features.map.mindmapmode.MMapController)5 Dimension (java.awt.Dimension)4 MTextController (org.freeplane.features.text.mindmapmode.MTextController)4 Color (java.awt.Color)3 Component (java.awt.Component)3 JComponent (javax.swing.JComponent)3 IMapSelection (org.freeplane.features.map.IMapSelection)3 LocationController (org.freeplane.features.nodelocation.LocationController)3 MLocationController (org.freeplane.features.nodelocation.mindmapmode.MLocationController)3