use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class EdgeColorsConfigurationFactory method create.
public EdgeColorConfiguration create(MapModel map) {
MapStyleModel mapStyle = MapStyleModel.getExtension(map);
final String configurationString = mapStyle.getProperty(EDGE_COLOR_CONFIGURATION_PROPERTY);
if (configurationString != null)
return load(configurationString);
else {
final EdgeColorConfiguration newConfiguration = createNewConfiguration(map);
String newConfigurationString = save(newConfiguration);
mapStyle.setProperty(EDGE_COLOR_CONFIGURATION_PROPERTY, newConfigurationString);
configurations.put(newConfigurationString, newConfiguration);
return newConfiguration;
}
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class EdgeController method getStyleDash.
private DashVariant getStyleDash(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 DashVariant dash = styleModel.getDash();
if (dash == null) {
continue;
}
return dash;
}
return null;
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class EdgeController method getStyleEdgeColorRule.
private ObjectRule<Color, Rules> getStyleEdgeColorRule(NodeModel node) {
MapModel map = node.getMap();
Collection<IStyle> collection = LogicalStyleController.getController(modeController).getStyles(node);
final MapStyleModel styles = MapStyleModel.getExtension(map);
for (IStyle styleKey : collection) {
final NodeModel styleNode = styles.getStyleNode(styleKey);
if (styleNode == null) {
continue;
}
if (node != styleNode && map.getRootNode().containsExtension(AutomaticEdgeColor.class)) {
AutomaticLayoutController automaticLayoutController = modeController.getExtension(AutomaticLayoutController.class);
if (automaticLayoutController != null && automaticLayoutController.isAutomaticLevelStyle(styleNode)) {
continue;
}
}
ObjectRule<Color, Rules> nodeColor = getNodeColorRule(styleNode);
if (nodeColor != null)
return nodeColor;
}
return null;
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class EdgeController method getStyleWidth.
private Integer getStyleWidth(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 int width = styleModel.getWidth();
if (width == EdgeModel.DEFAULT_WIDTH) {
continue;
}
return width;
}
return null;
}
use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.
the class MMapController method getSiblingsSortedOnSide.
/**
* Sorts nodes by their left/right status. The left are first.
*/
private List<NodeModel> getSiblingsSortedOnSide(final NodeModel node) {
final ArrayList<NodeModel> nodes = new ArrayList<NodeModel>(node.getChildCount());
for (final NodeModel child : Controller.getCurrentModeController().getMapController().childrenUnfolded(node)) {
nodes.add(child);
}
if (!node.isRoot()) {
return nodes;
}
final MapStyleModel mapStyleModel = MapStyleModel.getExtension(node.getMap());
MapViewLayout layoutType = mapStyleModel.getMapViewLayout();
if (layoutType.equals(MapViewLayout.OUTLINE)) {
return nodes;
}
Collections.sort(nodes, new Comparator<Object>() {
public int compare(final Object o1, final Object o2) {
if (o1 instanceof NodeModel) {
final NodeModel n1 = (NodeModel) o1;
if (o2 instanceof NodeModel) {
final NodeModel n2 = (NodeModel) o2;
final int b1 = n1.isLeft() ? 0 : 1;
final int b2 = n2.isLeft() ? 0 : 1;
return b1 - b2;
}
}
throw new IllegalArgumentException("Elements in LeftRightComparator are not comparable.");
}
});
return nodes;
}
Aggregations