Restrições de Extremidade (HL)

Para forçar um nó para o primeiro nível, é possível especificar:
layout.setSpecNodeLevelIndex(node, 0);
However, you cannot specify a level index for the last level because it is unknown at the beginning of layout how many levels are created. Não é recomendável especificar:
layout.setSpecNodeLevelIndex(node, Number.MAX_VALUE);
because it creates many empty levels between the levels used and the last one. Even though these empty levels are removed in postprocessing steps, it influences the speed and quality of the layout. (In fact, the algorithm runs out of memory if you set the specified level index unreasonably high.)
Usando restrições, é possível obter o mesmo efeito de forma mais eficiente.
Para forçar um nó para o primeiro nível:
Chamada:
layout.addConstraint(new ibm_ilog.graphlayout.hierarchical.HierarchicalExtremityConstraint(node, ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.NORTH));
Para forçar um nó para o último nível:
Chame:
layout.addConstraint(
    new ibm_ilog.graphlayout.hierarchical.HierarchicalExtremityConstraint(node, ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.SOUTH));
Com direções da bússola como uma referência conveniente (consulte Parâmetro de Lados da Porta (HL)), o primeiro nível indica o polo norte e o último nível indica o polo sul. Também é possível especificar restrições de extremidade para os lados leste e oeste:
layout.addConstraint(
    new ibm_ilog.graphlayout.hierarchical.HierarchicalExtremityConstraint(node1, ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.EAST));
layout.addConstraint(
    new ibm_ilog.graphlayout.hierarchical.HierarchicalExtremityConstraint(node2, ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.WEST));
A restrição de extremidade oeste força o nó para o índice de posição mais baixo em seu nível, e a restrição de extremidade leste força o nó para o índice de posição mais alto em seu nível. Os índices de posição especificam a posição relativa dentro do nível. For instance, a node with west extremity constraint is the leftmost node within its level, if the flow direction is towards the bottom. However, it does not affect other levels; there can be a node in another level that is still placed farther to the left.
A figura a seguir ilustra algumas restrições de extremidade.
layout-Hierarchical-extrconst107.gif
Esboço de Restrições de Extremidade