Search in sources :

Example 1 with MapView

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

the class PrintController method print.

public void print(Printable mapView, boolean showDlg) throws PrinterException {
    if (!acquirePrinterJobAndPageFormat(showDlg)) {
        return;
    }
    getPrinterJob().setPrintable(mapView, getPageFormat());
    if (!showDlg || printDialog()) {
        if (mapView instanceof MapView)
            ((MapView) mapView).preparePrinting();
        try {
            final PrinterJob printerJob = getPrinterJob();
            if (mapView instanceof Component) {
                final String name = ((Component) mapView).getName();
                if (name != null)
                    printerJob.setJobName(name);
            }
            printerJob.print();
        } catch (PrinterException ex) {
            LogUtils.warn(ex);
        } finally {
            if (mapView instanceof MapView)
                ((MapView) mapView).endPrinting();
        }
    }
}
Also used : MapView(org.freeplane.view.swing.map.MapView) PrinterException(java.awt.print.PrinterException) Component(java.awt.Component) PrinterJob(java.awt.print.PrinterJob)

Example 2 with MapView

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

the class Preview method paint.

@Override
public void paint(final Graphics g) {
    try {
        final Graphics2D g2d = (Graphics2D) g;
        final PageFormat format = getPageFormat();
        paintPaper(g, format);
        if (previewPageImage == null) {
            previewPageImage = (BufferedImage) createImage(getPageWidth(format) - 1, getPageHeight(format) - 1);
            imageGraphics = previewPageImage.createGraphics();
            imageGraphics.scale(zoom, zoom);
            if (view instanceof MapView)
                ((MapView) view).preparePrinting();
            while (Printable.NO_SUCH_PAGE == view.print(imageGraphics, format, index) && index > 0) {
                index--;
            }
            if (view instanceof MapView)
                ((MapView) view).endPrinting();
        }
        g2d.drawImage(previewPageImage, 0, 0, this);
    } catch (final PrinterException e) {
        LogUtils.severe(e);
    }
}
Also used : PageFormat(java.awt.print.PageFormat) MapView(org.freeplane.view.swing.map.MapView) PrinterException(java.awt.print.PrinterException) Graphics2D(java.awt.Graphics2D)

Example 3 with MapView

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

the class DefaultMouseWheelListener method mouseWheelMoved.

/*
	 * (non-Javadoc)
	 * @see
	 * freeplane.modes.ModeController.MouseWheelEventHandler#handleMouseWheelEvent
	 * (java.awt.event.MouseWheelEvent)
	 */
public void mouseWheelMoved(final MouseWheelEvent e) {
    final MapView mapView = (MapView) e.getSource();
    final ModeController mController = mapView.getModeController();
    if (mController.isBlocked()) {
        return;
    }
    final Set<IMouseWheelEventHandler> registeredMouseWheelEventHandler = mController.getUserInputListenerFactory().getMouseWheelEventHandlers();
    for (final IMouseWheelEventHandler handler : registeredMouseWheelEventHandler) {
        final boolean result = handler.handleMouseWheelEvent(e);
        if (result) {
            return;
        }
    }
    if ((e.getModifiers() & DefaultMouseWheelListener.ZOOM_MASK) != 0) {
        float newZoomFactor = 1f + Math.abs((float) e.getWheelRotation()) / 10f;
        if (e.getWheelRotation() < 0) {
            newZoomFactor = 1 / newZoomFactor;
        }
        final float oldZoom = ((MapView) e.getComponent()).getZoom();
        float newZoom = oldZoom / newZoomFactor;
        newZoom = (float) Math.rint(newZoom * 1000f) / 1000f;
        newZoom = Math.max(1f / 32f, newZoom);
        newZoom = Math.min(32f, newZoom);
        if (newZoom != oldZoom) {
            Controller.getCurrentController().getMapViewManager().setZoom(newZoom);
        }
    } else if ((e.getModifiers() & DefaultMouseWheelListener.HORIZONTAL_SCROLL_MASK) != 0) {
        ((MapView) e.getComponent()).scrollBy(DefaultMouseWheelListener.SCROLL_SKIPS * e.getWheelRotation(), 0);
    } else {
        ((MapView) e.getComponent()).scrollBy(0, DefaultMouseWheelListener.SCROLL_SKIPS * e.getWheelRotation());
    }
}
Also used : IMouseWheelEventHandler(org.freeplane.core.ui.IMouseWheelEventHandler) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController)

Example 4 with MapView

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

the class DefaultNodeMouseMotionListener method mousePressed.

public void mousePressed(final MouseEvent e) {
    final MapView mapView = MapView.getMapView(e.getComponent());
    mapView.select();
    doubleClickTimer.cancel();
    showPopupMenu(e);
}
Also used : MapView(org.freeplane.view.swing.map.MapView)

Example 5 with MapView

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

the class UserInputListenerFactory method updateMapList.

private void updateMapList(final String mapsMenuPosition) {
    if (!getMenuBuilder(MenuBuilder.class).contains(mapsMenuPosition))
        return;
    getMenuBuilder(MenuBuilder.class).removeChildElements(mapsMenuPosition);
    final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
    final List<? extends Component> mapViewVector = mapViewManager.getMapViewVector();
    if (mapViewVector == null) {
        return;
    }
    final ButtonGroup group = new ButtonGroup();
    int i = 0;
    for (final Component mapView : mapViewVector) {
        final String displayName = mapView.getName();
        final JRadioButtonMenuItem newItem = new JRadioButtonMenuItem(displayName);
        newItem.setSelected(false);
        group.add(newItem);
        newItem.addActionListener(mapsMenuActionListener);
        if (displayName.length() > 0) {
            newItem.setMnemonic(displayName.charAt(0));
        }
        final MapView currentMapView = (MapView) mapViewManager.getMapViewComponent();
        if (currentMapView != null) {
            if (mapView == currentMapView) {
                newItem.setSelected(true);
            }
        }
        getMenuBuilder(MenuBuilder.class).addMenuItem(mapsMenuPosition, newItem, mapsMenuPosition + '-' + i++, UIBuilder.AS_CHILD);
    }
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) MapView(org.freeplane.view.swing.map.MapView) JComponent(javax.swing.JComponent) Component(java.awt.Component) MenuBuilder(org.freeplane.core.ui.MenuBuilder)

Aggregations

MapView (org.freeplane.view.swing.map.MapView)55 NodeView (org.freeplane.view.swing.map.NodeView)20 ModeController (org.freeplane.features.mode.ModeController)19 Point (java.awt.Point)15 NodeModel (org.freeplane.features.map.NodeModel)13 Controller (org.freeplane.features.mode.Controller)11 Component (java.awt.Component)9 MainView (org.freeplane.view.swing.map.MainView)9 Dimension (java.awt.Dimension)8 JComponent (javax.swing.JComponent)8 MMapController (org.freeplane.features.map.mindmapmode.MMapController)7 ResourceController (org.freeplane.core.resources.ResourceController)6 MapController (org.freeplane.features.map.MapController)6 MTextController (org.freeplane.features.text.mindmapmode.MTextController)5 IMapViewManager (org.freeplane.features.ui.IMapViewManager)5 Color (java.awt.Color)4 Rectangle (java.awt.Rectangle)4 LocationController (org.freeplane.features.nodelocation.LocationController)4 MLocationController (org.freeplane.features.nodelocation.mindmapmode.MLocationController)4 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)4