Search in sources :

Example 6 with NodeModel

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

the class ClipboardController method duplicate.

public NodeModel duplicate(final NodeModel source, boolean withChildren) {
    try {
        final StringWriter writer = new StringWriter();
        ModeController modeController = Controller.getCurrentModeController();
        modeController.getMapController().getMapWriter().writeNodeAsXml(writer, source, Mode.CLIPBOARD, true, withChildren, false);
        final String result = writer.toString();
        final NodeModel copy = modeController.getMapController().getMapReader().createNodeTreeFromXml(source.getMap(), new StringReader(result), Mode.CLIPBOARD);
        copy.setFolded(false);
        return copy;
    } catch (final Exception e) {
        LogUtils.severe(e);
        return null;
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) StringWriter(java.io.StringWriter) StringReader(java.io.StringReader) ModeController(org.freeplane.features.mode.ModeController) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException)

Example 7 with NodeModel

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

the class ClipboardController method copySingle.

public Transferable copySingle(final Collection<NodeModel> source) {
    final int size = source.size();
    final Vector<NodeModel> target = new Vector<NodeModel>(size);
    target.setSize(size);
    int i = 0;
    for (NodeModel node : source) {
        target.set(i, new SingleCopySource(node));
        i++;
    }
    return copy(target, false);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) Vector(java.util.Vector)

Example 8 with NodeModel

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

the class MindMapHTMLWriter method writeHTML.

private int writeHTML(final NodeModel model, final String parentID, int lastChildNumber, final boolean isRoot, final boolean treatAsParagraph, final int depth) throws IOException {
    if (!model.hasVisibleContent()) {
        for (final NodeModel child : mapController.childrenUnfolded(model)) {
            lastChildNumber = writeHTML(child, parentID, lastChildNumber, false, false, depth);
        }
        return lastChildNumber;
    }
    boolean createFolding = false;
    if (writeFoldingCode) {
        createFolding = mapController.isFolded(model);
        if (getProperty("html_export_folding").equals("html_export_fold_all")) {
            createFolding = mapController.hasChildren(model);
        }
        if (getProperty("html_export_folding").equals("html_export_no_folding") || basedOnHeadings || isRoot) {
            createFolding = false;
        }
    }
    final TextController textController = TextController.getController();
    final Object userObject = model.getUserObject();
    final String text = textController.getTransformedTextNoThrow(userObject, model, userObject);
    final boolean hasHtml = text.startsWith("<html>");
    final boolean heading = basedOnHeadings && !hasHtml && mapController.hasChildren(model) && depth <= 6;
    if (!treatAsParagraph && !basedOnHeadings) {
        fileout.write("<li>");
    } else {
        if (heading) {
            fileout.write(lf + "<h" + depth + ">");
        } else if (!hasHtml) {
            fileout.write("<p>");
        }
    }
    String localParentID = parentID;
    if (createFolding) {
        lastChildNumber++;
        localParentID = parentID + "_" + lastChildNumber;
        writeFoldingButtons(localParentID);
    }
    final String fontStyle = fontStyle(nodeStyleController.getColor(model), nodeStyleController.getFont(model));
    boolean shouldOutputFontStyle = !fontStyle.equals("");
    if (shouldOutputFontStyle) {
        fileout.write("<span style=\"" + fontStyle + "\">");
    }
    String link = NodeLinks.getLinkAsString(model);
    if (link != null) {
        if (link.endsWith(UrlManager.FREEPLANE_FILE_EXTENSION)) {
            link += ".html";
        }
        fileout.write("<a href=\"" + link + "\" target=\"_blank\">");
    }
    if (ResourceController.getResourceController().getBooleanProperty("export_icons_in_html")) {
        writeIcons(model);
    }
    writeModelContent(text);
    if (link != null) {
        fileout.write("</a>" + lf);
    }
    if (shouldOutputFontStyle) {
        fileout.write("</span>");
    }
    final String detailText = DetailTextModel.getDetailTextText(model);
    if (detailText != null) {
        writeModelContent(detailText);
    }
    final String noteContent = NoteModel.getNoteText(model);
    if (noteContent != null) {
        writeModelContent(noteContent);
    }
    if (heading) {
        fileout.write("</h" + depth + ">" + lf);
    }
    if (getProperty("html_export_folding").equals("html_export_based_on_headings")) {
        for (final NodeModel child : mapController.childrenUnfolded(model)) {
            lastChildNumber = writeHTML(child, parentID, lastChildNumber, /*isRoot=*/
            false, false, depth + 1);
        }
        return lastChildNumber;
    }
    if (mapController.hasChildren(model)) {
        if (getProperty("html_export_folding").equals("html_export_based_on_headings")) {
            for (final NodeModel child : mapController.childrenUnfolded(model)) {
                lastChildNumber = writeHTML(child, parentID, lastChildNumber, /*isRoot=*/
                false, false, depth + 1);
            }
        } else if (createFolding) {
            fileout.write(lf + "<ul id=\"fold" + localParentID + "\" style=\"POSITION: relative; VISIBILITY: visible;\">" + lf);
            int localLastChildNumber = 0;
            for (final NodeModel child : mapController.childrenUnfolded(model)) {
                localLastChildNumber = writeHTML(child, localParentID, localLastChildNumber, /* isRoot=*/
                false, false, depth + 1);
            }
        } else {
            fileout.write(lf + "<ul>" + lf);
            for (final NodeModel child : mapController.childrenUnfolded(model)) {
                lastChildNumber = writeHTML(child, parentID, lastChildNumber, /* isRoot= */
                false, false, depth + 1);
            }
        }
        fileout.write("</ul>" + lf);
    }
    if (!treatAsParagraph) {
        fileout.write("</li>" + lf);
    }
    return lastChildNumber;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) TextController(org.freeplane.features.text.TextController)

Example 9 with NodeModel

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

the class MindMapHTMLWriter method writeHTML.

void writeHTML(final Collection<NodeModel> selectedNodes) throws IOException {
    fileout.write("<html>" + lf + "<head>" + lf);
    if (!selectedNodes.isEmpty()) {
        final MapModel map = selectedNodes.iterator().next().getMap();
        setDefaultsFrom(map);
        writeStyle();
    }
    fileout.write(lf + "</head>" + lf + "<body>" + lf);
    for (NodeModel node : selectedNodes) {
        writeHTML(node, "1", 0, /* isRoot */
        true, true, /* depth */
        1);
    }
    fileout.write("</body>" + lf);
    fileout.write("</html>" + lf);
    fileout.close();
    resetDefaults();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapModel(org.freeplane.features.map.MapModel)

Example 10 with NodeModel

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

the class CloneAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final MClipboardController clipboardController = (MClipboardController) ClipboardController.getController();
    final NodeModel parent = Controller.getCurrentController().getSelection().getSelected();
    clipboardController.addClone(clipboardController.getClipboardContents(), parent);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Aggregations

NodeModel (org.freeplane.features.map.NodeModel)408 ModeController (org.freeplane.features.mode.ModeController)89 MapModel (org.freeplane.features.map.MapModel)47 Controller (org.freeplane.features.mode.Controller)44 MapStyleModel (org.freeplane.features.styles.MapStyleModel)39 IMapSelection (org.freeplane.features.map.IMapSelection)34 MapController (org.freeplane.features.map.MapController)33 Point (java.awt.Point)32 MMapController (org.freeplane.features.map.mindmapmode.MMapController)31 IStyle (org.freeplane.features.styles.IStyle)31 IActor (org.freeplane.core.undo.IActor)30 NodeView (org.freeplane.view.swing.map.NodeView)22 ArrayList (java.util.ArrayList)20 Color (java.awt.Color)16 URI (java.net.URI)16 ResourceController (org.freeplane.core.resources.ResourceController)16 Component (java.awt.Component)15 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)15 File (java.io.File)14