Search in sources :

Example 6 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class PresentationPngExporter method exportSlide.

private void exportSlide(File presentationDirectory, Slide slide) {
    final NodeModel placedNode = slide.getCurrentPlacedNode();
    if (placedNode != null)
        slide.apply(presentationZoomFactor);
    else
        slide.apply(1f);
    mapViewComponent.validate();
    mapViewComponent.setSize(mapViewComponent.getPreferredSize());
    File exportFile = new File(presentationDirectory, FileUtils.validFileNameOf(slide.getName()) + ".png");
    final ExportToImage exporter = ExportToImage.toPNG();
    final Controller controller = Controller.getCurrentController();
    final MapModel map = controller.getMap();
    if (placedNode != null) {
        final Dimension slideSize;
        if (ResourceController.getResourceController().getBooleanProperty(SWITCH_TO_FULL_SCREEN_PROPERTY))
            slideSize = mapViewComponent.getGraphicsConfiguration().getBounds().getSize();
        else
            slideSize = SwingUtilities.getWindowAncestor(mapViewComponent).getSize();
        exporter.export(map, slideSize, placedNode, slide.getPlacedNodePosition(), exportFile);
    } else
        exporter.export(map, exportFile);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) ExportToImage(org.freeplane.features.export.mindmapmode.ExportToImage) MapModel(org.freeplane.features.map.MapModel) Dimension(java.awt.Dimension) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) ResourceController(org.freeplane.core.resources.ResourceController) File(java.io.File)

Example 7 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class Slide method getSelectedNodes.

private ArrayList<NodeModel> getSelectedNodes(boolean onlyVisible) {
    MapModel map = getMap();
    ArrayList<NodeModel> selectedNodes = new ArrayList<>(selectedNodeIds.size());
    for (String id : selectedNodeIds) {
        NodeModel node = map.getNodeForID(id);
        if (node != null && (!onlyVisible || node.isVisible()))
            selectedNodes.add(node);
    }
    return selectedNodes;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) ArrayList(java.util.ArrayList) MapModel(org.freeplane.features.map.MapModel)

Example 8 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class SlideEditorController method createPlacesSelectedNodeToggleButton.

private JToggleButton createPlacesSelectedNodeToggleButton() {
    final JToggleButton checkBoxOnlySpecificNodes = createToggleButtonWithIconAndLabel("PlaceSelectedNodeOnSlide.icon", "slide.placenode");
    checkBoxOnlySpecificNodes.setAlignmentX(Component.CENTER_ALIGNMENT);
    checkBoxOnlySpecificNodes.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final String centeredNodeId = slide.getPlacedNodeId();
            final IMapSelection selection = Controller.getCurrentController().getSelection();
            if (centeredNodeId == null) {
                final NodeModel selected = selection.getSelected();
                if (selected != null) {
                    UndoableSlide.of(slide).setPlacedNodeId(selected.getID());
                    setNodePlacementControlsEnabled(true, slide.getPlacedNodePosition());
                } else {
                    UndoableSlide.of(slide).setPlacedNodeId(null);
                    setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
                }
            } else {
                UndoableSlide.of(slide).setPlacedNodeId(null);
                setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
                final MapModel map = Controller.getCurrentController().getMap();
                final NodeModel node = map.getNodeForID(centeredNodeId);
                if (node != null)
                    selection.selectAsTheOnlyOneSelected(node);
            }
            checkBoxOnlySpecificNodes.setSelected(slide.getPlacedNodeId() != null);
        }
    });
    return checkBoxOnlySpecificNodes;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) IMapSelection(org.freeplane.features.map.IMapSelection) MapModel(org.freeplane.features.map.MapModel)

Example 9 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class PresentationController method addMapSelectionListener.

private void addMapSelectionListener() {
    IMapSelectionListener mapSelectionListener = new IMapSelectionListener() {

        @Override
        public void beforeMapChange(MapModel oldMap, MapModel newMap) {
        }

        @Override
        public void afterMapChange(MapModel oldMap, MapModel newMap) {
            presentationState.stopPresentation();
            if (newMap != null && Controller.getCurrentModeController() == modeController)
                presentationEditorController.setPresentations(getPresentations(newMap).presentations);
            else
                presentationEditorController.setPresentations(null);
        }
    };
    modeController.getController().getMapViewManager().addMapSelectionListener(mapSelectionListener);
}
Also used : IMapSelectionListener(org.freeplane.features.map.IMapSelectionListener) MapModel(org.freeplane.features.map.MapModel)

Example 10 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class UrlManager method loadOtherURI.

private void loadOtherURI(URI uri, final boolean hasFreeplaneFileExtension) {
    try {
        if (!uri.isAbsolute()) {
            URI absoluteUri = getAbsoluteUri(uri);
            if (absoluteUri == null) {
                final MapModel map = Controller.getCurrentController().getMap();
                if (map.getURL() == null)
                    UITools.errorMessage(TextUtils.getText("map_not_saved"));
                else
                    UITools.errorMessage(TextUtils.format("link_not_found", String.valueOf(uri)));
                return;
            }
            uri = absoluteUri;
        }
        // DOCEAR: mindmaps can be linked in a mindmap --> therefore project-relative-paths are possible
        if (!asList(FILE_SCHEME, SMB_SCHEME, FREEPLANE_SCHEME).contains(uri.getScheme())) {
            try {
                uri = uri.toURL().openConnection().getURL().toURI().normalize();
            } catch (Exception e) {
            // ignore all exceptions due to unknown protocols
            }
        }
        try {
            if (hasFreeplaneFileExtension) {
                FreeplaneUriConverter freeplaneUriConverter = new FreeplaneUriConverter();
                final URL url = freeplaneUriConverter.freeplaneUrl(uri);
                final ModeController modeController = Controller.getCurrentModeController();
                modeController.getMapController().newMap(url);
                return;
            }
            Controller.getCurrentController().getViewController().openDocument(uri);
        } catch (final Exception e) {
            LogUtils.warn("link " + uri + " not found", e);
            UITools.errorMessage(TextUtils.format("link_not_found", uri.toString()));
        }
        return;
    } catch (final MalformedURLException ex) {
        LogUtils.warn("URL " + uri + " not found", ex);
        UITools.errorMessage(TextUtils.format("link_not_found", uri));
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController) URI(java.net.URI) XMLParseException(org.freeplane.n3.nanoxml.XMLParseException) XMLException(org.freeplane.n3.nanoxml.XMLException) URISyntaxException(java.net.URISyntaxException) HeadlessException(java.awt.HeadlessException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) URL(java.net.URL)

Aggregations

MapModel (org.freeplane.features.map.MapModel)161 NodeModel (org.freeplane.features.map.NodeModel)53 ModeController (org.freeplane.features.mode.ModeController)42 Controller (org.freeplane.features.mode.Controller)34 IActor (org.freeplane.core.undo.IActor)31 File (java.io.File)18 AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)17 MMapModel (org.freeplane.features.map.mindmapmode.MMapModel)17 IUndoHandler (org.freeplane.core.undo.IUndoHandler)16 URL (java.net.URL)14 MMapController (org.freeplane.features.map.mindmapmode.MMapController)14 IStyle (org.freeplane.features.styles.IStyle)14 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)14 MapController (org.freeplane.features.map.MapController)12 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)12 IMapViewManager (org.freeplane.features.ui.IMapViewManager)12 MapStyleModel (org.freeplane.features.styles.MapStyleModel)10 IOException (java.io.IOException)9 MalformedURLException (java.net.MalformedURLException)9 URI (java.net.URI)9