Search in sources :

Example 36 with NodeView

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

the class ExternalResource method setZoom.

public void setZoom(final float r) {
    zoom = r;
    for (final NodeView nodeView : viewers) {
        final JComponent viewer = nodeView.getContent(ViewerController.VIEWER_POSITION);
        final MapView mapView = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, viewer);
        final Dimension preferredSize = ((ScalableComponent) viewer).getOriginalSize();
        preferredSize.width = (int) (preferredSize.width * r);
        preferredSize.height = (int) (preferredSize.height * r);
        preferredSize.width = mapView.getZoomed(preferredSize.width);
        preferredSize.height = mapView.getZoomed(preferredSize.height);
        ((ScalableComponent) viewer).setFinalViewerSize(preferredSize);
        viewer.revalidate();
    }
}
Also used : JComponent(javax.swing.JComponent) MapView(org.freeplane.view.swing.map.MapView) Dimension(java.awt.Dimension) NodeView(org.freeplane.view.swing.map.NodeView)

Example 37 with NodeView

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

the class ViewerController method createViewer.

void createViewer(final ExternalResource model, final NodeView view) {
    final JComponent viewer = createViewer(view.getMap().getModel(), model);
    if (imagePopupMenu == null) {
        imagePopupMenu = new ExternalImagePopupMenu();
    }
    viewer.setBorder(new MatteBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_COLOR));
    final Set<NodeView> viewers = model.getViewers();
    viewers.add(view);
    viewer.setBounds(viewer.getX() - 5, viewer.getY() - 5, viewer.getWidth() + 15, viewer.getHeight() + 15);
    view.addContent(viewer, VIEWER_POSITION);
    if (view.getMap().getModeController().canEdit()) {
        final DropTarget dropTarget = new DropTarget(viewer, DTL);
        dropTarget.setActive(true);
    }
    if (view.isShortened())
        viewer.setVisible(false);
    else {
        viewer.revalidate();
        viewer.repaint();
    }
}
Also used : MatteBorder(javax.swing.border.MatteBorder) JComponent(javax.swing.JComponent) DropTarget(java.awt.dnd.DropTarget) INodeView(org.freeplane.features.map.INodeView) NodeView(org.freeplane.view.swing.map.NodeView)

Example 38 with NodeView

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

the class ViewerController method add.

@Override
protected void add(final NodeModel node, final IExtension extension) {
    final ExternalResource preview = (ExternalResource) extension;
    for (NodeModel nodeClone : node.clones()) {
        for (final INodeView iNodeView : nodeClone.getViewers()) {
            final NodeView view = (NodeView) iNodeView;
            createViewer(preview, view);
        }
    }
    super.add(node, extension);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) INodeView(org.freeplane.features.map.INodeView) NodeView(org.freeplane.view.swing.map.NodeView) INodeView(org.freeplane.features.map.INodeView)

Example 39 with NodeView

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

the class ViewerController method onViewRemoved.

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

Example 40 with NodeView

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

the class ExternalImagePopupMenu method getRemove.

/**
 * @return Returns the delete menu item.
 */
private JMenuItem getRemove() {
    final ProgressUtilities progUtil = new ProgressUtilities();
    if (remove == null) {
        remove = new JMenuItem(TextUtils.getText("ExternalImage_popupMenu_Remove"));
        remove.addActionListener(new ActionListener() {

            public void actionPerformed(final ActionEvent e) {
                final ExternalResource extRes = node.getExtension(ExternalResource.class);
                if (progUtil.hasExternalResource(node) && !progUtil.hasExtendedProgressIcon(node)) {
                    viewer.remove(node, extRes);
                    NodeView nv = null;
                    final Collection<INodeView> invs = Controller.getCurrentController().getModeController().getMapController().getSelectedNode().getViewers();
                    for (final INodeView inv : invs) {
                        if (inv instanceof NodeView) {
                            nv = (NodeView) inv;
                            break;
                        }
                    }
                    viewer.deleteViewer(extRes, nv);
                    viewer.undoableDeactivateHook(node);
                    Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.UNKNOWN_PROPERTY, null, null);
                }
            }
        });
    }
    return remove;
}
Also used : ActionListener(java.awt.event.ActionListener) ProgressUtilities(org.freeplane.view.swing.features.progress.mindmapmode.ProgressUtilities) ActionEvent(java.awt.event.ActionEvent) Collection(java.util.Collection) JMenuItem(javax.swing.JMenuItem) INodeView(org.freeplane.features.map.INodeView) NodeView(org.freeplane.view.swing.map.NodeView) INodeView(org.freeplane.features.map.INodeView)

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