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;
}
}
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);
}
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;
}
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();
}
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);
}
Aggregations