use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class MLogicalStyleController method copyStyleExtensions.
public void copyStyleExtensions(final IStyle style, final NodeModel target) {
final MTextController textController = MTextController.getController();
final MapStyleModel extension = MapStyleModel.getExtension(target.getMap());
final NodeModel styleNode = extension.getStyleNode(style);
if (styleNode != null) {
final MAttributeController attributeController = MAttributeController.getController();
attributeController.copyAttributesToNode(styleNode, target);
final String detailTextText = DetailTextModel.getDetailTextText(styleNode);
if (detailTextText != null)
textController.setDetails(target, detailTextText);
final String noteText = NoteModel.getNoteText(styleNode);
if (noteText != null) {
MNoteController noteController = (MNoteController) NoteController.getController();
noteController.setNoteText(target, noteText);
}
}
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class MapBackgroundColorAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final Controller controller = Controller.getCurrentController();
MapStyle mapStyle = (MapStyle) controller.getModeController().getExtension(MapStyle.class);
final MapStyleModel model = (MapStyleModel) mapStyle.getMapHook(controller.getMap());
final Color oldBackgroundColor;
final String colorPropertyString = ResourceController.getResourceController().getProperty(MapStyle.RESOURCES_BACKGROUND_COLOR);
final Color defaultBgColor = ColorUtils.stringToColor(colorPropertyString);
if (model != null) {
oldBackgroundColor = model.getBackgroundColor();
} else {
oldBackgroundColor = defaultBgColor;
}
final Color actionColor = ColorTracker.showCommonJColorChooserDialog(controller.getSelection().getSelected(), TextUtils.getText("choose_map_background_color"), oldBackgroundColor, defaultBgColor);
mapStyle.setBackgroundColor(model, actionColor);
}
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 MapModel styleMap = styleModel.getStyleMap();
final IStyle newStyle = StyleFactory.create(styleName);
if (null != styleModel.getStyleNode(newStyle)) {
UITools.errorMessage(TextUtils.getText("style_already_exists"));
return;
}
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
final NodeModel newNode = new NodeModel(styleMap);
newNode.setUserObject(newStyle);
final LogicalStyleController styleController = LogicalStyleController.getController();
final ArrayList<IStyle> styles = new ArrayList<IStyle>(styleController.getStyles(selectedNode));
for (int i = styles.size() - 1; i >= 0; i--) {
IStyle style = styles.get(i);
if (MapStyleModel.DEFAULT_STYLE.equals(style)) {
continue;
}
final NodeModel styleNode = styleModel.getStyleNode(style);
if (styleNode == null) {
continue;
}
Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, styleNode, newNode);
}
Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, selectedNode, newNode);
Controller.getCurrentModeController().copyExtensions(Keys.ICONS, selectedNode, newNode);
NodeModel userStyleParentNode = styleModel.getStyleNodeGroup(styleMap, MapStyleModel.STYLES_USER_DEFINED);
if (userStyleParentNode == null) {
userStyleParentNode = new NodeModel(styleMap);
userStyleParentNode.setUserObject(new StyleTranslatedObject(MapStyleModel.STYLES_USER_DEFINED));
mapController.insertNode(userStyleParentNode, styleMap.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);
styleController.refreshMap(map);
}
public String getDescription() {
return "NewStyle";
}
public void act() {
styleModel.addStyleNode(newNode);
styleController.refreshMap(map);
}
};
Controller.getCurrentModeController().execute(actor, styleMap);
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class EditStylesAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final Controller currentController = Controller.getCurrentController();
final MapModel map = currentController.getMap();
final MapStyleModel mapStyleModel = MapStyleModel.getExtension(map);
final MapModel styleMap = mapStyleModel.getStyleMap();
if (styleMap == null) {
UITools.errorMessage(TextUtils.getText("no_styles_found_in_map"));
return;
}
final IMapViewManager mapViewManager = currentController.getMapViewManager();
currentMapView = mapViewManager.getMapViewComponent();
mapViewManager.changeToMapView((Component) null);
final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
undoHandler.startTransaction();
init();
SModeController modeController = getModeController();
modeController.getMapController().newMapView(styleMap);
Controller controller = modeController.getController();
Component mapViewComponent = controller.getMapViewManager().getMapViewComponent();
((DialogController) controller.getViewController()).setMapView(mapViewComponent);
dialog.setLocationRelativeTo(currentController.getViewController().getCurrentRootComponent());
dialog.setVisible(true);
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class NewLevelStyleAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final MapModel map = Controller.getCurrentController().getMap();
final MapStyleModel styleModel = MapStyleModel.getExtension(map);
NodeModel levelStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_AUTOMATIC_LAYOUT);
final String styleName = "AutomaticLayout.level," + levelStyleParentNode.getChildCount();
final IStyle styleObject = StyleFactory.create(TranslatedObject.format(styleName));
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
final NodeModel node = new NodeModel(map);
node.setUserObject(styleObject);
mapController.insertNode(node, levelStyleParentNode, false, false, true);
mapController.select(node);
final IActor actor = new IActor() {
public void undo() {
styleModel.removeStyleNode(node);
}
public String getDescription() {
return "NewLevelStyle";
}
public void act() {
styleModel.addStyleNode(node);
}
};
Controller.getCurrentModeController().execute(actor, map);
}
Aggregations