### Run Groovy Script at Startup Source: https://github.com/p/freemind/code/blob/1.1.0/freemind/history.txt Execute a Groovy script when FreeMind starts. Useful for automating tasks like exporting maps from the command line. ```bash java -Dstartup_groovy_script=accessories/ExportToPdf.groovy -jar lib/freemind.jar ``` -------------------------------- ### FreeMind XML Structure Source: https://context7.com/p/freemind/llms.txt Example of a .mm file structure including rich content, styling, attributes, and node hooks. ```xml

Project Planning

Main project overview

Detailed requirements documentation:

  • Feature A specifications
  • Feature B specifications
``` -------------------------------- ### HTML Header Example Source: https://github.com/p/freemind/code/blob/1.1.0/freemind/history.txt An example of a strange HTML header that was fixed in FreeMind 0.9.0 RC 13. This issue affected the conversion of notes. ```html ``` -------------------------------- ### Export Map with XSLT Transformation in Java Source: https://context7.com/p/freemind/llms.txt This example demonstrates how to export a FreeMind map to various formats using XSLT transformations. It shows how to get the map as XML and then transform it using a specified XSLT file. FreeMind includes several XSLT files for different export formats like HTML, Word ML, and OPML. ```java import accessories.plugins.util.xslt.XmlExporter; import freemind.extensions.ExportHook; import java.io.File; import java.io.StringWriter; public class XsltExportExample extends ExportHook { public void exportWithXslt() { // Get map as XML StringWriter xmlWriter = new StringWriter(); try { getController().getModel().getXml(xmlWriter); String mapXml = xmlWriter.toString(); // Transform using XSLT (HTML export example) // FreeMind includes several XSLT files: // - mm2xbel.xsl (Bookmarks) // - mm2twiki.xsl (TWiki format) // - mm2wordml_utf8.xsl (Word ML) // - mm2opml.xsl (OPML) // - mm2oowriter.xsl (OpenOffice Writer) // - freemind2html.xsl (HTML) } catch (Exception e) { e.printStackTrace(); } } } ``` -------------------------------- ### Access FreeMind Application Context with FreeMindMain Source: https://context7.com/p/freemind/llms.txt Demonstrates how to access the main controller, current map view, and application properties using the FreeMindMain interface. It also shows how to set custom properties, retrieve localized resources, open documents, display status messages, and get the FreeMind directory path. ```java import freemind.main.FreeMindMain; import freemind.controller.Controller; import freemind.view.mindmapview.MapView; import java.util.Properties; import java.net.URL; // Access the main application context public class FreeMindExample { private FreeMindMain freemindMain; public void demonstrateFreeMindMain() { // Get the main controller Controller controller = freemindMain.getController(); // Access the current map view MapView currentView = freemindMain.getView(); // Get application properties Properties props = freemindMain.getProperties(); String lookAndFeel = freemindMain.getProperty("lookandfeel"); int wheelVelocity = freemindMain.getIntProperty("wheel_velocity", 80); // Set custom properties freemindMain.setProperty("custom_setting", "value"); freemindMain.saveProperties(false); // Get localized resources String text = freemindMain.getResourceString("menu_file"); String withDefault = freemindMain.getResourceString("missing_key", "Default Value"); // Open a document in browser try { URL docUrl = new URL("http://freemind.sourceforge.net"); freemindMain.openDocument(docUrl); } catch (Exception e) { freemindMain.err("Failed to open document: " + e.getMessage()); } // Show status messages freemindMain.out("Operation completed successfully"); // Get FreeMind directory path String freemindDir = freemindMain.getFreemindDirectory(); // Returns: ~/.freemind/ on Linux, or equivalent on other OS } } ``` -------------------------------- ### Configure default browser command Source: https://github.com/p/freemind/code/blob/1.1.0/admin/faq.html Set the path to the preferred web browser in the user.properties file using the {0} placeholder for the URL. ```properties default_browser_command_windows_nt = C:\Program Files\Internet Explorer\iexplore.exe "{0}" ``` -------------------------------- ### Enable Latex Support in Build Source: https://github.com/p/freemind/code/blob/1.1.0/freemind/history.txt To re-enable HotEqn (Latex) support, which was removed due to poor integration, modify the build.xml file to set include_latex to true. This feature may not be fully supported. ```xml ``` -------------------------------- ### Traverse and Process All Nodes with Groovy Source: https://context7.com/p/freemind/llms.txt Recursively traverses all nodes in the mind map starting from the root, printing each node's text with indentation based on its depth. ```groovy // Example 3: Traverse and process all nodes def processNode(n, depth = 0) { println(" " * depth + n.getText()) n.childrenUnfolded().each { child -> processNode(child, depth + 1) } } processNode(c.getMap().getRootNode()) ``` -------------------------------- ### Configure Legacy Browser Parameters Source: https://github.com/p/freemind/code/blob/1.1.0/flash/source/readme.txt Legacy configuration method for Internet Explorer and other browsers using param and embed tags. ```html For iexplorer For others Bold text"); // Set rich text // Note operations (attached notes to nodes) String noteText = node.getNoteText(); // Get note content String xmlNoteText = node.getXmlNoteText(); // Get XML-formatted note node.setNoteText("This is a detailed note for the node"); node.setXmlNoteText("Rich note"); // Node styling String style = node.getStyle(); // "bubble", "fork", "combined", "as_parent" node.setStyle(MindMapNode.STYLE_BUBBLE); node.setStyle(MindMapNode.STYLE_FORK); Color textColor = node.getColor(); Font nodeFont = node.getFont(); String fontFamily = node.getFontFamilyName(); String fontSize = node.getFontSize(); boolean isBold = node.isBold(); boolean isItalic = node.isItalic(); boolean isUnderlined = node.isUnderlined(); boolean isStrikethrough = node.isStrikethrough(); // Hyperlink String link = node.getLink(); // Get hyperlink URL // Links are set via MindMapActions interface // Edge (connection line) properties MindMapEdge edge = node.getEdge(); Color edgeColor = edge.getColor(); String edgeStyle = edge.getStyle(); // "linear", "bezier", "sharp_linear", "sharp_bezier" int edgeWidth = edge.getWidth(); // Tree navigation MindMapNode parent = node.getParentNode(); List children = node.getChildren(); boolean hasChildren = node.hasChildren(); int level = node.getNodeLevel(); // 0 for root // Iterate children (folded state aware) ListIterator foldedIter = node.childrenFolded(); while (foldedIter.hasNext()) { MindMapNode child = foldedIter.next(); // Process visible children } // Iterate all children (ignoring fold state) ListIterator allIter = node.childrenUnfolded(); while (allIter.hasNext()) { MindMapNode child = allIter.next(); // Process all children } // Get sorted children (left then right) ListIterator sortedIter = node.sortedChildrenUnfolded(); // Folding state boolean isFolded = node.isFolded(); // Position (for root children) boolean isLeft = node.isLeft(); // Left side of root // Tree relationships boolean isDescendant = node.isDescendantOf(parent); int childPosition = parent.getChildPosition(node); } } ``` -------------------------------- ### Manage MindMap Document Operations in Java Source: https://context7.com/p/freemind/llms.txt Demonstrates accessing the root node, performing file operations, exporting to various formats, and handling node change notifications. ```java import freemind.modes.MindMap; import freemind.modes.MindMapNode; import freemind.controller.filter.Filter; import java.io.File; import java.io.StringWriter; import java.io.FileWriter; import java.net.URL; import java.util.List; import java.util.Arrays; public class MindMapExample { public void demonstrateMindMap(MindMap mindMap) throws Exception { // Get root node MindMapNode rootNode = mindMap.getRootNode(); // Map file operations File mapFile = mindMap.getFile(); URL mapUrl = mindMap.getURL(); // Check map state boolean isReadOnly = mindMap.isReadOnly(); boolean isSaved = mindMap.isSaved(); mindMap.setReadOnly(true); mindMap.setSaved(false); // Mark as dirty // Save map mindMap.save(new File("/path/to/output.mm")); // Export to XML string StringWriter xmlWriter = new StringWriter(); mindMap.getXml(xmlWriter); String xmlContent = xmlWriter.toString(); // Export filtered content only StringWriter filteredWriter = new StringWriter(); mindMap.getFilteredXml(filteredWriter); // Export to different formats List nodesToExport = Arrays.asList(rootNode); String plainText = mindMap.getAsPlainText(nodesToExport); String rtfText = mindMap.getAsRTF(nodesToExport); String htmlText = mindMap.getAsHTML(nodesToExport); // Filtering Filter filter = mindMap.getFilter(); mindMap.setFilter(filter); // Node change notifications mindMap.nodeChanged(rootNode); // Notify view of change mindMap.nodeRefresh(rootNode); // Force refresh mindMap.nodeStructureChanged(rootNode); // Structure changed // Change root node MindMapNode newRoot = rootNode.getChildren().get(0); mindMap.changeRoot(newRoot); // File change monitoring mindMap.registerMapSourceChangedObserver( new MindMap.MapSourceChangedObserver() { @Override public boolean mapSourceChanged(MindMap map) throws Exception { System.out.println("Map file changed on disk!"); return true; // Return true to continue monitoring } }, 0 ); // Get restorable string (for session restoration) String restorable = mindMap.getRestorable(); // Clean up when done mindMap.destroy(); } } ``` -------------------------------- ### Embed Image using Relative Path in FreeMind Source: https://github.com/p/freemind/code/blob/1.1.0/admin/docs/HTML User Guide/pixhtml.htm Use this method to embed an image using a relative path within a FreeMind node. Ensure the node content starts with '' and includes a space before the tag to prevent rendering issues. ```html ``` -------------------------------- ### Create Mind Maps Programmatically Source: https://context7.com/p/freemind/llms.txt Demonstrates exporting a MindMap model to XML and saving it to a file using Java. ```java import freemind.modes.mindmapmode.MindMapMapModel; import freemind.modes.mindmapmode.MindMapNodeModel; import freemind.modes.MindMapNode; import freemind.modes.MindMap; import java.io.File; import java.io.FileWriter; import java.io.StringWriter; public class MapCreationExample { public void createMapProgrammatically() throws Exception { // The typical approach is through MindMapController // which handles proper model/view coordination // Export existing map to XML string MindMap map = /* get from controller */; StringWriter writer = new StringWriter(); map.getXml(writer); String xmlOutput = writer.toString(); // Save to file File outputFile = new File("output.mm"); FileWriter fileWriter = new FileWriter(outputFile); map.getXml(fileWriter); fileWriter.close(); } } ```