Skip to content

Instantly share code, notes, and snippets.

@plewin
Last active February 17, 2017 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plewin/1480ebf6e13def55c4da5cf155eb7351 to your computer and use it in GitHub Desktop.
Save plewin/1480ebf6e13def55c4da5cf155eb7351 to your computer and use it in GitHub Desktop.
Minimal code to generate freeplane mm files
import org.freeplane.features.map.IMapSelection;
import org.freeplane.features.map.MapModel;
import org.freeplane.features.map.NodeModel;
import org.freeplane.features.mode.Controller;
import org.freeplane.features.url.mindmapmode.MFileManager;
import org.freeplane.main.application.FreeplaneStarter;
import org.freeplane.main.headlessmode.FreeplaneHeadlessStarter;
import org.freeplane.main.headlessmode.HeadlessMapViewController;
import java.io.File;
import java.io.IOException;
// hack to prevent an unsupported method exception
class Stub extends HeadlessMapViewController {
@Override
public IMapSelection getMapSelection() {
return null;
}
}
public class Test {
public static void main(String[] args) throws IOException {
FreeplaneStarter s = new FreeplaneHeadlessStarter();
Controller e = s.createController();
e.setMapViewManager(new Stub());
s.createModeControllers(e);
MFileManager mFileManager = new MFileManager();
MapModel map = new MapModel();
map.setRoot(new NodeModel("hi", map));
// load data from neo4j
// create the freeplane model
mFileManager.writeToFile(map, new File("...tmp.."));
// send the file content as a http response
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment