use of y.layout.OrientationLayouter 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).
}
}
use of y.layout.OrientationLayouter in project binnavi by google.
the class ZyGraphLayouter method createOrthoLayouter.
public static CanonicMultiStageLayouter createOrthoLayouter(final OrthogonalStyle style, final long gridSize, final boolean isVerticalOrientation) {
Preconditions.checkArgument(gridSize > 0, "Internal Error: Grid size can not be 0 or lower.");
Preconditions.checkNotNull(style, "Internal Error: Layout style can't be null");
final OrthogonalLayouter layouter = new OrthogonalLayouter();
layouter.setLayoutStyle(style == OrthogonalStyle.NORMAL ? OrthogonalLayouter.NORMAL_STYLE : OrthogonalLayouter.NORMAL_TREE_STYLE);
final OrientationLayouter ol = (OrientationLayouter) layouter.getOrientationLayouter();
ol.setOrientation(isVerticalOrientation ? OrientationLayouter.TOP_TO_BOTTOM : OrientationLayouter.LEFT_TO_RIGHT);
layouter.setGrid((int) gridSize);
return layouter;
}
use of y.layout.OrientationLayouter in project binnavi by google.
the class ZyGraphLayouter method createIncrementalHierarchicalLayouter.
public static CanonicMultiStageLayouter createIncrementalHierarchicalLayouter(final boolean orthogonalEdgeRooting, final long minLayerDist, final long minNodeDist, final HierarchicOrientation orientation) {
final IncrementalHierarchicLayouter layouter = new IncrementalHierarchicLayouter();
final OrientationLayouter ol = (OrientationLayouter) layouter.getOrientationLayouter();
ol.setOrientation(orientation == HierarchicOrientation.HORIZONTAL ? OrientationLayouter.TOP_TO_BOTTOM : OrientationLayouter.LEFT_TO_RIGHT);
layouter.setMinimumLayerDistance(minLayerDist);
layouter.setNodeToNodeDistance(minNodeDist);
layouter.setEdgeToEdgeDistance(25);
layouter.setNodeToEdgeDistance(25);
layouter.setBackloopRoutingEnabled(true);
layouter.setSelfLoopLayouterEnabled(true);
// layouter.setParallelEdgeLayouterEnabled(true);
layouter.setOrthogonallyRouted(orthogonalEdgeRooting);
return layouter;
}
Aggregations