Search in sources :

Example 21 with MapView

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

the class ExportSvg method export.

public void export(MapModel map, File chosenFile) {
    if (!ExportController.getContoller().checkCurrentMap(map)) {
        return;
    }
    try {
        final MapView view = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
        if (view == null) {
            return;
        }
        Controller.getCurrentController().getViewController().setWaitingCursor(true);
        final SVGGraphics2D g2d = fillSVGGraphics2D(view);
        final FileOutputStream bos = new FileOutputStream(chosenFile);
        final BufferedOutputStream bufStream = new BufferedOutputStream(bos);
        final OutputStreamWriter osw = new OutputStreamWriter(bufStream, "UTF-8");
        g2d.stream(osw);
        osw.flush();
        bos.flush();
        bos.close();
    } catch (final Exception ex) {
        org.freeplane.core.util.LogUtils.warn(ex);
        UITools.errorMessage(ex.getLocalizedMessage());
    } finally {
        Controller.getCurrentController().getViewController().setWaitingCursor(false);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) MapView(org.freeplane.view.swing.map.MapView) SVGGraphics2D(org.apache.batik.svggen.SVGGraphics2D) OutputStreamWriter(java.io.OutputStreamWriter) BufferedOutputStream(java.io.BufferedOutputStream)

Example 22 with MapView

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

the class LastOpenedList method updateLastVisitedNodeId.

private void updateLastVisitedNodeId(final Component mapView) {
    if (!(mapView instanceof MapView))
        return;
    final NodeView selected = ((MapView) mapView).getSelected();
    final RecentFile recentFile = findRecentFileByMapModel(getMapModel(mapView));
    if (selected != null && recentFile != null) {
        NodeModel selectedNode = selected.getModel();
        // if a map has never been visited restoration of the selection has not yet taken place
        if (!selectedNode.isRoot())
            recentFile.lastVisitedNodeId = selectedNode.getID();
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapView(org.freeplane.view.swing.map.MapView) NodeView(org.freeplane.view.swing.map.NodeView)

Example 23 with MapView

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

the class AttributeTable method updateComponentFontAndColors.

private void updateComponentFontAndColors(final JComponent c) {
    final NodeView nodeView = attributeView.getNodeView();
    final MapView mapView = nodeView.getMap();
    final ModeController modeController = mapView.getModeController();
    final NodeStyleController style = (NodeStyleController) modeController.getExtension(NodeStyleController.class);
    final MapStyleModel model = MapStyleModel.getExtension(mapView.getModel());
    final NodeModel attributeStyleNode = model.getStyleNodeSafe(MapStyleModel.ATTRIBUTE_STYLE);
    final Font font = style.getFont(attributeStyleNode);
    c.setFont(font.deriveFont(UITools.FONT_SCALE_FACTOR * font.getSize2D()));
    if (!SwingUtilities.isDescendingFrom(this, nodeView)) {
        return;
    }
    final Color backgroundColor = NodeStyleModel.getBackgroundColor(attributeStyleNode);
    if (backgroundColor != null) {
        c.setOpaque(true);
        c.setBackground(backgroundColor);
    } else {
        c.setBackground(nodeView.getBackgroundColor());
        c.setOpaque(false);
    }
    c.setForeground(style.getColor(attributeStyleNode));
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView) Font(java.awt.Font)

Example 24 with MapView

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

the class AttributeTable method updateGridColor.

private void updateGridColor() {
    final NodeView nodeView = attributeView.getNodeView();
    if (!SwingUtilities.isDescendingFrom(this, nodeView))
        return;
    final MapView mapView = nodeView.getMap();
    final MapStyleModel model = MapStyleModel.getExtension(mapView.getModel());
    final NodeModel attributeStyleNode = model.getStyleNodeSafe(MapStyleModel.ATTRIBUTE_STYLE);
    final EdgeModel edge = EdgeModel.getModel(attributeStyleNode);
    if (edge != null) {
        final Color edgeColor = edge.getColor();
        setGridAndBorderColor(edgeColor);
    } else
        this.gridColor = null;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapView(org.freeplane.view.swing.map.MapView) NodeView(org.freeplane.view.swing.map.NodeView) EdgeModel(org.freeplane.features.edge.EdgeModel)

Example 25 with MapView

use of org.freeplane.view.swing.map.MapView 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)

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