Search in sources :

Example 1 with MapViewLayout

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;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) MapViewLayout(org.freeplane.features.styles.MapViewLayout) Vector(java.util.Vector)

Example 2 with MapViewLayout

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;
}
Also used : MapViewLayout(org.freeplane.features.styles.MapViewLayout)

Example 3 with MapViewLayout

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;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) ArrayList(java.util.ArrayList) MapViewLayout(org.freeplane.features.styles.MapViewLayout)

Aggregations

MapViewLayout (org.freeplane.features.styles.MapViewLayout)3 NodeModel (org.freeplane.features.map.NodeModel)2 MapStyleModel (org.freeplane.features.styles.MapStyleModel)2 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1