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 within its layer (0 means top-aligned with respect to the
      // drawing direction).
      layouter.getNodeLayoutDescriptor().setLayerAlignment(0);
    }
  }
Creates graph layouter objects that are used to layout ZyGraphs.
java/zylib/src/main/java/com/google/security/zynamics/zylib/yfileswrap/gui/zygraph/layouters/ZyGraphLayouter.java