use of org.freeplane.features.styles.IStyle 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.IStyle 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;
}
use of org.freeplane.features.styles.IStyle in project freeplane by freeplane.
the class EdgeController method getStyleStyle.
private EdgeStyle getStyleStyle(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 EdgeModel styleModel = EdgeModel.getModel(styleNode);
if (styleModel == null) {
continue;
}
final EdgeStyle style = styleModel.getStyle();
if (style == null) {
continue;
}
return style;
}
return null;
}
use of org.freeplane.features.styles.IStyle in project freeplane by freeplane.
the class NodeStyleProxy method setName.
public void setName(String styleName) {
if (styleName == null) {
setStyle(null);
} else {
final MapStyleModel mapStyleModel = MapStyleModel.getExtension(getDelegate().getMap());
// actually styles is a HashSet so lookup is fast
final Set<IStyle> styles = mapStyleModel.getStyles();
// search for user defined styles
final IStyle styleString = StyleFactory.create(styleName);
if (styles.contains(styleString)) {
setStyle(styleString);
return;
}
// search for predefined styles by key
final IStyle styleNamedObject = StyleFactory.create(new TranslatedObject(styleName));
if (styles.contains(styleNamedObject)) {
setStyle(styleNamedObject);
return;
}
// search for predefined styles by their translated name (style.toString())
for (IStyle style : styles) {
if (style.toString().equals(styleName)) {
setStyle(style);
return;
}
}
throw new IllegalArgumentException("style '" + styleName + "' not found");
}
}
use of org.freeplane.features.styles.IStyle in project freeplane by freeplane.
the class DeleteLevelStyleAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final SModeController modeController = (SModeController) Controller.getCurrentModeController();
final MapModel map = Controller.getCurrentController().getMap();
final MapStyleModel styleModel = MapStyleModel.getExtension(map);
NodeModel levelStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_AUTOMATIC_LAYOUT);
final int childNumber = levelStyleParentNode.getChildCount() - 1;
if (childNumber < 1) {
UITools.errorMessage(TextUtils.getText("can_not_delete_root_style"));
return;
}
final String styleName = "AutomaticLayout.level," + childNumber;
final IStyle styleObject = StyleFactory.create(TranslatedObject.format(styleName));
final MMapController mapController = (MMapController) modeController.getMapController();
final NodeModel node = styleModel.getStyleNode(styleObject);
mapController.deleteNode(node);
final IActor actor = new IActor() {
public void undo() {
styleModel.addStyleNode(node);
}
public String getDescription() {
return "DeleteStyle";
}
public void act() {
styleModel.removeStyleNode(node);
}
};
Controller.getCurrentModeController().execute(actor, map);
}
Aggregations