Parâmetro de Alinhamento

A opção de alinhamento controla como um pai é posicionado em relação a seus nós-filhos. O alinhamento pode ser configurado globalmente, neste caso, todos os nós são alinhados da mesma maneira, ou localmente em cada nó, com o resultado de que ocorrem alinhamentos diferentes no mesmo desenho.
Series
of tree layouts showing center alignment, west alignment, border center
alignment, and east alignment.
Opções de alinhamento

Alinhamento Global

Para configurar o alinhamento global:
treeLayout.setGlobalAlignment(ibm_ilog.graphlayout.tree.TreeLayout.WEST);
Os valores válidos para o alinhamento global são:
  • ibm_ilog.graphlayout.tree.TreeLayout.CENTER (o padrão)
    O pai é centralizado sobre seus nós-filhos, considerando o centro dos nós-filhos.
  • ibm_ilog.graphlayout.tree.TreeLayout.BORDER_CENTER
    O pai é centralizado sobre seus nós-filhos, considerando a borda dos nós-filhos. Se o tamanho do primeiro e do último filhos variar, o alinhamento do centro da borda posicionará o pai mais próximo do maior filho do que do alinhamento do centro padrão.
  • ibm_ilog.graphlayout.tree.TreeLayout.EAST
    O pai é alinhado com a borda de seu filho mais ao leste. Por exemplo, se a direção do fluxo for para a parte inferior, leste será a direção à direita. Se a direção do fluxo for para a parte superior, leste será a direção à esquerda. Consulte Usando Direções da Bússola para Parâmetros de Layout Posicionais (TL) para obter detalhes.
  • ibm_ilog.graphlayout.tree.TreeLayout.WEST
    O pai é alinhado com a borda de seu filho mais ao oeste. Por exemplo, se a direção do fluxo for para a parte inferior, oeste será a direção à esquerda. Se a direção do fluxo for para a direita, oeste será a direção para a parte inferior. Consulte Usando Direções da Bússola para Parâmetros de Layout Posicionais (TL) para obter detalhes.
  • ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_EAST
    The child nodes are arranged sequentially instead of in parallel and the parent node is placed with an offset to the child nodes. The child nodes are to the east of the parent node. Para obter detalhes, consulte Alinhamento invertido.
  • ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_WEST
    The child nodes are arranged sequentially instead of in parallel and the parent node is placed with an offset to the child nodes. The child nodes are to the west of the parent node. Para obter detalhes, consulte Alinhamento invertido.
  • ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_EAST_WEST
    The child nodes are arranged sequentially instead of in parallel and the parent node is placed with an offset to the child nodes. The child nodes are arranged on both sides of the parent node. The first child node is placed to the east. Subsequent child nodes are placed to the east or the west, such that the space used on both sides is roughly the same; that is, the sum of the heights of the subtrees to the east is approximately the same as that of the subtrees to the west. Para obter detalhes, consulte Alinhamento invertido.
  • ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_BOTH_SIDES
    Os nós-filhos são organizados de forma sequencial em vez de paralela. Whereas the alignment TIP_OVER arranges all child nodes on the same side of the parent, this alignment arranges the child nodes on both sides of the parent. Unlike TIP_OVER_EAST_WEST alignment, this style does not try to optimize the space used on both sides, but always places the odd-numbered child nodes on the west and the even-numbered on the east. Each pair of child nodes, one on the west and one on the east, has its odd and even nodes aligned with each other. Para obter detalhes, consulte Alinhamento invertido.
  • ibm_ilog.graphlayout.tree.TreeLayout.MIXED
    Cada nó-pai pode ter um alinhamento diferente. O alinhamento de cada nó individual pode ser configurado com o resultado de que podem ocorrer alinhamentos diferentes no mesmo gráfico.

Alinhamento de Nós Individuais

Todos os nós possuem o mesmo alinhamento, a menos que o alinhamento global esteja configurado como MIXED. Apenas quando o alinhamento global estiver configurado como MIXED, cada nó poderá ter um estilo de alinhamento individual.
Um gráfico de amostra
com diferentes alinhamentos em cada subárvore
Diferentes alinhamentos combinados no mesmo desenho
Para especificar o alinhamento de um nó individual:
Use os métodos:
treeLayout.setGlobalAlignment(ibm_ilog.graphlayout.tree.TreeLayout.MIXED);
treeLayout.setAlignment(graph.children[1], ibm_ilog.graphlayout.tree.TreeLayout.EAST);  
Os valores válidos para alignment são:
  • ibm_ilog.graphlayout.tree.TreeLayout.CENTER (the default value)
  • ibm_ilog.graphlayout.tree.TreeLayout.BORDER_CENTER
  • ibm_ilog.graphlayout.tree.TreeLayout.EAST
  • ibm_ilog.graphlayout.tree.TreeLayout.WEST
  • ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_EAST
  • ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_WEST
  • ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_EAST_WEST
  • ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_BOTH_SIDES

Alinhamento invertido

Normalmente, os nós-filhos de um nó são posicionados em uma organização paralela, com irmãos como vizinhos diretos uns dos outros. Tip-over alignments mean a sequential arrangement of the child nodes instead.
A sample
graph shown first with normal alignment and then with tip-over east
alignment
Normal alignment and a tip-over alignment
O alinhamento invertido é útil quando a árvore possui muitas folhas. With normal alignment, a tree with many leaves would result in the layout being wide. If the global alignment style is set to tip-over, the drawing is tall rather than wide. Para balancear a largura e altura do desenho, é possível configurar o alinhamento global como combinado.
Por exemplo:
treeLayout.setGlobalAlignment(ibm_ilog.graphlayout.tree.TreeLayout.MIXED);
Além disso, é possível configurar o alinhamento individual como invertido para alguns pais com um alto número de nós-filhos, da seguinte forma:
treeLayout.setAlignment(parent, ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_EAST); 
Tip-over alignments can be specified explicitly for some or all of the nodes. Tree Layout offers layout modes that automatically determine when to tip over, giving a drawing that fits into a specified aspect ratio. Estes modos de layout são descritos em Modos de Layout Invertidos.
Tip-over-east alignment arranges the nodes on the east side of the center line that starts at the parent node. The tip-over-west alignment arranges the nodes on the west side of that line. There are also two variants that distribute the subtrees on both sides of that line. You can specify these variants at a parent node with a high number of child nodes by the following code:
treeLayout.setAlignment(parent, ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_EAST_WEST);
or:
treeLayout.setAlignment(parent, ibm_ilog.graphlayout.tree.TreeLayout.TIP_OVER_BOTH_SIDES);
The following figures show the difference between Tip-over-east-west and tip-over-both-sides alignments.
Graph
with five child nodes arranged in tip-over-east-west alignment.
Graph
with five child nodes arranged in tip-over-both-sides alignment.
Tip-over-east-west alignment Tip-over-both-sides alignment
Tip-over alignment works well with the orthogonal link style; see Estilo de Link (TL). The following figure shows the difference between tip over on one side and tip over on two sides. Tip-over alignments are specified for the red nodes; the blue nodes have center alignment.
Tree
layouts showing tip-over alignment options for east and both sides
at red nodes.
Tip-over alignments

Child alignments

Global alignment is valid for all nodes. The alignment specified at a node is valid for all child nodes of that node. Additionally, you can specify exceptions for certain nodes that are aligned differently than all other child nodes. This is useful for organization chart displays. In an organization chart that shows a management hierarchy, some of the people shown do not belong to the hierarchy. Instead, they are associated with a particular member of the hierarchy. An example could be a secretary associated with a manager of a company. In an organization chart tree, the node representing the secretary is normally displayed close to the node of the manager, but is not mixed with the child nodes that represent the normal workers who report to that manager.
To set the child alignment of a specific node:
Use os métodos:
treeLayout.setChildAlignment(node, alignment);
treeLayout.getChildAlignment(node);
The following values are valid for child alignment:
In the following figures, the yellow nodes have child alignments EAST_NEIGHBOR or WEST_NEIGHBOR, and the red nodes have child alignments TIP_OVER_ASSOCIATE_EAST or TIP_OVER_ASSOCIATE_BOTH_SIDES. The green nodes have unspecified child alignments, that is, they are aligned with the global alignment style.
Child
node alignments: yellow east neighbor, red tip over associate east,
green center.
Child
node alignments: yellow east neighbor, red tip over associate east,
green tip over both sides.
Alignments shown are for yellow node: east neighbor, for red nodes: tip over associate east, and for green nodes: center Alignments shown are for yellow node: east neighbor, for red nodes: tip over associate east, and for green nodes: tip over both sides
Child
node alignments: yellow west neighbor, red tip over associate both
sides, green center.
Child
node alignments: yellow west neighbor, red tip over associate both
sides, green tip over both sides.
Alignments shown are for yellow node: west neighbor, for red nodes: tip over associate both sides, and for green nodes: center Alignments shown are for yellow node: west neighbor, for red nodes: tip over associate both sides, and for green nodes: tip over both sides