use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class NewUserStyleAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final String styleName = JOptionPane.showInputDialog(TextUtils.getText("enter_new_style_name"));
if (styleName == null) {
return;
}
final Controller controller = Controller.getCurrentController();
final NodeModel selectedNode = controller.getSelection().getSelected();
final MapModel map = controller.getMap();
final MapStyleModel styleModel = MapStyleModel.getExtension(map);
final IStyle style = StyleFactory.create(styleName);
if (null != styleModel.getStyleNode(style)) {
UITools.errorMessage(TextUtils.getText("style_already_exists"));
return;
}
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
final NodeModel newNode = new NodeModel(map);
newNode.setUserObject(style);
Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, selectedNode, newNode);
Controller.getCurrentModeController().copyExtensions(Keys.ICONS, selectedNode, newNode);
NodeModel userStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_USER_DEFINED);
if (userStyleParentNode == null) {
userStyleParentNode = new NodeModel(map);
userStyleParentNode.setUserObject(new StyleTranslatedObject(MapStyleModel.STYLES_USER_DEFINED));
mapController.insertNode(userStyleParentNode, map.getRootNode(), false, false, true);
}
mapController.insertNode(newNode, userStyleParentNode, false, false, true);
mapController.select(newNode);
final IActor actor = new IActor() {
public void undo() {
styleModel.removeStyleNode(newNode);
}
public String getDescription() {
return "NewStyle";
}
public void act() {
styleModel.addStyleNode(newNode);
}
};
Controller.getCurrentModeController().execute(actor, map);
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class MindMapHTMLWriter method writeHTML.
void writeHTML(final NodeModel rootNodeOfBranch) throws IOException {
setDefaultsFrom(rootNodeOfBranch.getMap());
final String htmlExportFoldingOption = getProperty("html_export_folding");
writeFoldingCode = (htmlExportFoldingOption.equals("html_export_fold_currently_folded") && mapController.hasFoldedStrictDescendant(rootNodeOfBranch)) || htmlExportFoldingOption.equals("html_export_fold_all");
ResourceController.getResourceController().getBooleanProperty("export_icons_in_html");
fileout.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" + lf + "<html>" + lf + "<head>" + lf);
fileout.write("<title>" + MindMapHTMLWriter.writeHTML_escapeUnicodeAndSpecialCharacters(TextController.getController().getPlainTransformedTextWithoutNodeNumber(rootNodeOfBranch).replace('\n', ' ')) + "</title>" + lf);
writeStyle();
fileout.write(lf + "</head>" + lf + "<body");
final MapStyleModel style = MapStyleModel.getExtension(rootNodeOfBranch.getMap());
final Color background = style != null ? style.getBackgroundColor() : null;
if (background != null) {
fileout.write(" bgcolor=" + ColorUtils.colorToString(background));
}
fileout.write(">" + lf);
if (writeFoldingCode) {
writeBodyWithFolding(rootNodeOfBranch);
} else {
writeHTML(rootNodeOfBranch, "1", 0, /* isRoot */
true, true, /* depth */
1);
}
fileout.write("</body>" + lf);
fileout.write("</html>" + lf);
fileout.close();
resetDefaults();
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class MindMapHTMLWriter method setDefaultsFrom.
private void setDefaultsFrom(MapModel map) {
final MapStyleModel model = MapStyleModel.getExtension(map);
final NodeModel styleNode = model.getStyleNodeSafe(MapStyleModel.DEFAULT_STYLE);
defaultFont = nodeStyleController.getFont(styleNode);
defaultColor = nodeStyleController.getColor(styleNode);
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class AddStyleAttributes method getAttributes.
private NodeModel getAttributes(final NodeModel node) {
final IStyle style = LogicalStyleController.getController().getFirstStyle(node);
final MapStyleModel extension = MapStyleModel.getExtension(node.getMap());
final NodeModel styleNode = extension.getStyleNode(style);
return styleNode;
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class CloudController method getStyleCloud.
protected CloudModel getStyleCloud(final MapModel map, final Collection<IStyle> collection) {
final MapStyleModel model = MapStyleModel.getExtension(map);
for (IStyle styleKey : collection) {
final NodeModel styleNode = model.getStyleNode(styleKey);
if (styleNode == null) {
continue;
}
final CloudModel styleModel = CloudModel.getModel(styleNode);
if (styleModel != null) {
return styleModel;
}
}
return null;
}
Aggregations