Search in sources :

Example 1 with HierarchicLayouter

use of y.layout.hierarchic.HierarchicLayouter in project binnavi by google.

the class ZyGraphLayouter method alignNodesToTopLayer.

public static void alignNodesToTopLayer(final Graph2D graph, final CanonicMultiStageLayouter multiStageLayouter) {
    if (multiStageLayouter instanceof HierarchicLayouter) {
        final HierarchicLayouter layouter = (HierarchicLayouter) multiStageLayouter;
        layouter.setLayeringStrategy(HierarchicLayouter.LAYERING_HIERARCHICAL_OPTIMAL);
        final OrientationLayouter ol = (OrientationLayouter) layouter.getOrientationLayouter();
        layouter.setDrawer(new AlignmentDrawer(layouter.getDrawer()));
        graph.addDataProvider(AlignmentDrawer.NODE_ALIGNMENT_POINT_DPKEY, ol.getOrientation() == OrientationLayouter.TOP_TO_BOTTOM ? new AlignmentDrawer.TopAlignmentDataProvider() : new AlignmentDrawer.LeftAlignmentDataProvider());
    } else if (multiStageLayouter instanceof IncrementalHierarchicLayouter) {
        final IncrementalHierarchicLayouter layouter = (IncrementalHierarchicLayouter) multiStageLayouter;
        layouter.setFromScratchLayeringStrategy(IncrementalHierarchicLayouter.LAYERING_STRATEGY_HIERARCHICAL_OPTIMAL);
        // sets the alignment of the node
        layouter.getNodeLayoutDescriptor().setLayerAlignment(0);
    // within its layer (0 means top
    // aligned with respect to the
    // drawing direction).
    }
}
Also used : IncrementalHierarchicLayouter(y.layout.hierarchic.IncrementalHierarchicLayouter) OrientationLayouter(y.layout.OrientationLayouter) IncrementalHierarchicLayouter(y.layout.hierarchic.IncrementalHierarchicLayouter) HierarchicLayouter(y.layout.hierarchic.HierarchicLayouter) AlignmentDrawer(y.layout.hierarchic.AlignmentDrawer)

Aggregations

OrientationLayouter (y.layout.OrientationLayouter)1 AlignmentDrawer (y.layout.hierarchic.AlignmentDrawer)1 HierarchicLayouter (y.layout.hierarchic.HierarchicLayouter)1 IncrementalHierarchicLayouter (y.layout.hierarchic.IncrementalHierarchicLayouter)1