use of org.freeplane.features.styles.MapViewLayout in project freeplane by freeplane.
the class MMapController method getSortedSiblings.
/**
* Sorts nodes by their left/right status. The left are first.
*/
private Vector<NodeModel> getSortedSiblings(final NodeModel node) {
final Vector<NodeModel> nodes = new Vector<NodeModel>();
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;
}
use of org.freeplane.features.styles.MapViewLayout in project freeplane by freeplane.
the class SelectableLayout method getLayout.
private INodeViewLayout getLayout(final Container parent) {
final NodeView view = (NodeView) parent;
MapView map = view.getMap();
final MapViewLayout layoutType = map.getLayoutType();
if (layoutType == MapViewLayout.OUTLINE) {
return OutlineLayout.getInstance();
}
final NodeViewLayoutAdapter layout;
if (view.isRoot()) {
layout = VerticalRootNodeViewLayout.getInstance();
} else {
if (view.isLeft()) {
layout = LeftNodeViewLayout.getInstance();
} else {
layout = RightNodeViewLayout.getInstance();
}
}
return layout;
}
use of org.freeplane.features.styles.MapViewLayout 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