use of org.freeplane.features.styles.IStyle in project freeplane by freeplane.
the class MUIFactory method updateMapStyles.
private void updateMapStyles(final MapModel newMap) {
ignoreChangeEvent = true;
styles.removeAllElements();
if (newMap == null) {
return;
}
final Collection<IStyle> styleObjects = MapStyleModel.getExtension(newMap).getStyles();
for (final IStyle style : styleObjects) {
styles.addElement(style);
}
ignoreChangeEvent = false;
}
use of org.freeplane.features.styles.IStyle 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.IStyle in project freeplane by freeplane.
the class IconController method getIconSize.
public Quantity<LengthUnits> getIconSize(NodeModel node) {
final MapModel map = node.getMap();
final ModeController modeController = Controller.getCurrentModeController();
final LogicalStyleController styleController = LogicalStyleController.getController(modeController);
final Collection<IStyle> styles = styleController.getStyles(node);
final Quantity<LengthUnits> size = getStyleIconSize(map, styles);
return size;
}
use of org.freeplane.features.styles.IStyle 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);
}
use of org.freeplane.features.styles.IStyle 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);
}
Aggregations