use of org.freeplane.features.styles.MapStyleModel 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.MapStyleModel in project freeplane by freeplane.
the class MapProxy method getBackgroundColor.
// MapRO: R
public Color getBackgroundColor() {
// see MapBackgroundColorAction
final MapStyle mapStyle = (MapStyle) Controller.getCurrentModeController().getExtension(MapStyle.class);
final MapStyleModel model = (MapStyleModel) mapStyle.getMapHook(getDelegate());
if (model != null) {
return model.getBackgroundColor();
} else {
final String colorPropertyString = ResourceController.getResourceController().getProperty(MapStyle.RESOURCES_BACKGROUND_COLOR);
final Color defaultBgColor = ColorUtils.stringToColor(colorPropertyString);
return defaultBgColor;
}
}
use of org.freeplane.features.styles.MapStyleModel 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.MapStyleModel 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);
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class LocationController method getStyleChildGap.
private Quantity<LengthUnits> getStyleChildGap(final MapModel map, final Collection<IStyle> styleKeys) {
final MapStyleModel model = MapStyleModel.getExtension(map);
for (IStyle styleKey : styleKeys) {
final NodeModel styleNode = model.getStyleNode(styleKey);
if (styleNode == null) {
continue;
}
final LocationModel styleModel = styleNode.getExtension(LocationModel.class);
if (styleModel == null) {
continue;
}
Quantity<LengthUnits> vGap = styleModel.getVGap();
if (vGap == LocationModel.DEFAULT_VGAP) {
continue;
}
return vGap;
}
return null;
}
Aggregations