documentationfor yFiles for HTML 3.0.0.1

Tree Layout

This chapter describes the major API changes to the TreeLayout introduced with yFiles for HTML 3.0 and how to migrate from the older version.

As with all major layout algorithms, the TreeLayout no longer inherits from MultiStageLayout, but instead implements ILayoutAlgorithm directly. The layout stages are now managed by a LayoutStageStack, which can be obtained via the layoutStages property; see the migration chapter Layout Stages and Multi-Stage Layouts for more details.

Renamed, Moved, and Removed Classes and Members

The following table contains the renamed, moved, and removed classes and members of the major classes of the TreeLayout.

Renamed, moved, and removed members of classes related to the TreeLayout (classes are bold)
yFiles for HTML 2.6 yFiles for HTML 3.0 Remarks
TreeLayoutclass name unchanged
Properties in class TreeLayout
componentLayoutEnabledcomponentLayout.enabled
considerNodeLabelsnodeLabelPlacementThe enum now allows you to choose between considering the node labels and the GenericLabeling algorithm.
defaultLeafPlacerremovedThe defaultSubtreePlacer is now used for leaves. Subtree placers for individual nodes can be specified via TreeLayoutData.subtreePlacers property.
defaultNodePlacerdefaultSubtreePlacer
defaultOutEdgeComparerremovedUse TreeLayoutData.childOrder instead.
defaultPortAssignmentdefaultPortAssigner
groupingSupportedremovedGroups are always supported now.
hideGroupsStageremovedThe TreeLayout is able to handle group nodes itself.
hideGroupsStageEnabled
integratedEdgeLabelingedgeLabelPlacementThe enum now allows you to choose between integrated labeling and the GenericLabeling algorithm.
labelingremovedTo influence the labeling, use the nodeLabelPlacement and edgeLabelPlacement properties.
labelingEnabled
multiParentAllowedallowMultiParent
orientationLayoutremovedUse layoutOrientation to set the desired layout orientation.
orientationLayoutEnabled
parallelEdgeRouterEnabledparallelEdgeRouter.enabled
selfLoopRouterEnabledselfLoopRouter.enabled
sourceGroupDataAcceptorremoved
sourcePortConstraintDataAcceptorremoved
subgraphLayoutremovedIf necessary, the SubgraphLayoutStage can be accessed and enabled via method get<T> of property layoutStages, but this may lead to overlaps.
subgraphLayoutEnabled
targetGroupDataAcceptorremoved
targetPortConstraintDataAcceptorremoved
TreeLayoutDataTreeLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>
Properties in class TreeLayoutData
abortHandlerremovedA LayoutAbortController is exposed by the LayoutExecutor; see Section Maximum Duration and Aborting of Algorithms for more details.
delegatingNodePlacerPrimaryNodessingleSplitSubtreePlacerPrimaryNodes
edgeLabelPreferredPlacementedgeLabelPreferredPlacements
gridNodePlacerRowIndicesmultiLayerSubtreePlacerLayerIndices
nodeHalosnodeMargins
nodePlacerssubtreePlacers
outEdgeComparerschildOrder
portAssignmentsportAssigners
sourcePortConstraintsports.sourcePortCandidatesMoved to sub-data ports. See also migration chapter about Ports.
targetPortConstraintsports.targetPortCandidates
ITreeLayoutNodePlacerISubtreePlacer
IFromSketchNodePlacerIFromSketchSubtreePlacer
NodePlacerBaseremoved
RotatableNodePlacerBaseremoved
AspectRatioNodePlacerAspectRatioSubtreePlacer
AssistantNodePlacerAssistantSubtreePlacer
BusNodePlacerBusSubtreePlacer
CompactNodePlacerCompactSubtreePlacer
DefaultNodePlacerSingleLayerSubtreePlacer
DelegatingNodePlacerSingleSplitSubtreePlacer
DendrogramNodePlacerDendrogramSubtreePlacer
DoubleLineNodePlacerDoubleLayerSubtreePlacer
FreeNodePlacerFixedSubtreePlacer
GridNodePlacerMultiLayerSubtreePlacer
GroupedNodePlacerMultiSplitSubtreePlacer
LayeredNodePlacerLevelAlignedSubtreePlacer
LeafNodePlacerremovedUse SingleLayerSubtreePlacer instead.
LeftRightNodePlacerLeftRightSubtreePlacer
SimpleNodePlacerremovedUse SingleLayerSubtreePlacer instead.
RootAlignmentMultiLayerSubtreePlacerRootAlignmentFor MultiLayerSubtreePlacer.
SingleLayerSubtreePlacerRootAlignmentFor SingleLayerSubtreePlacer.
SubtreeRootAlignmentFor DoubleLayerSubtreePlacer and LevelAlignedSubtreePlacer.
Constants in RootAlignment
CENTER_OVER_CHILDRENCENTER_OF_CHILDREN
LEADINGLEFT
LEADING_OFFSETLEADING
TRAILINGRIGHT
TRAILING_OFFSETTRAILING
LayeredRoutingStyleLevelAlignedSubtreePlacerRoutingStyle
Constants in enum LevelAlignedSubtreePlacerRoutingStyle
STRAIGHTSTRAIGHT_LINE
MultiParentRoutingStyleenum name unchanged
Constants in enum MultiParentRoutingStyle
STRAIGHTSTRAIGHT_LINE
TreeLayoutEdgeRoutingStyleSingleLayerSubtreePlacerRoutingStyle
Constants in enum SingleLayerSubtreePlacerRoutingStyle
FORKORTHOGONAL
FORK_AT_ROOTORTHOGONAL_AT_ROOT
POLYLINESTRAIGHT_LINE_TO_CHILD_CONNECTOR
STRAIGHTSTRAIGHT_LINE
TreeLayoutPortAssignmentModeenum name unchanged
Constants in enum MultiParentRoutingStyle
DISTRIBUTED_EASTDISTRIBUTEDSee section Changed Default Values and Behavior Changes.
DISTRIBUTED_NORTH
DISTRIBUTED_SOUTH
DISTRIBUTED_WEST
NONECENTER
portConstraintremovedSee section Changed Default Values and Behavior Changes.
RotatableNodePlacerMatrixSubtreeTransform
Constants in enum SubtreeTransform
DEFAULTNONE
MIR_HORFLIP_Y
MIR_VERTFLIP_X
ROT90ROTATE_LEFT
ROT180ROTATE_180
ROT270ROTATE_RIGHT
MIR_VERT_ROT90ROTATE_RIGHT_FLIP_Y
MIR_HOR_ROT90ROTATE_LEFT_FLIP_Y
TreeReductionStageclass name unchanged
Properties in class TreeReductionStage
multiParentAllowedallowMultiParent
nonTreeEdgeLabelSelectionKeyremovedTransferring the scope between stages is now handled automatically; see section Scope and Affected Items.
nonTreeEdgeLabelingAlgorithmnonTreeEdgeLabeling
nonTreeEdgeSelectionKeyremovedTransferring the scope between stages is now handled automatically; see section Scope and Affected Items.
AspectRatioTreeLayoutremovedUse TreeLayout with AspectRatioSubtreePlacer instead. See section Aspect Ratio Tree Layout for more details.
ClassicTreeLayoutremovedUse TreeLayout instead. See section Classic Tree Layout for more details.
FamilyTreeLayoutremovedUse TreeLayout instead.

Changed Default Values and Behavior Changes

If non-tree graphs are given as input, they are now temporarily reduced to trees by applying the TreeReductionStage before applying the layout algorithm. The non-tree edges are then routed using the router specified via the TreeReductionStage.nonTreeEdgeRouter. The TreeReductionStage that is used by the TreeLayout is available via the property TreeLayout.treeReductionStage.

Node labels are now considered by default. To change this behavior, set the nodeLabelPlacement property to the desired value. It is now also easier to place the node labels with GenericLabeling by setting the value to GENERIC.

Edge labels are now placed using an integrated edge labeling algorithm. To change this behavior, set the edgeLabelPlacement property to the desired value. It is now also easier to place the edge labels with GenericLabeling by setting the value to GENERIC.

The port assignment modes specified via the property TreeLayoutPortAssigner.mode have been reduced. Port candidates are now always considered. It is no longer necessary to set it to PORT_CONSTRAINT. The distributed values for the four sides of the node have been combined as DISTRIBUTED. The side can be specified by defining a free port candidate on the desired side via the properties on TreeLayoutData.ports. See also section Ports for more information.

The MultiLayerSubtreePlacer (formerly GridNodePlacer) now automatically considers custom layers defined via the property multiLayerSubtreePlacerLayerIndices. It is no longer necessary to set the property automaticRowAssignment, which has consequently been removed.

Classic Tree Layout

The ClassicTreeLayout has been superseded by the TreeLayout. To obtain similar results within a similar time frame, the following configuration may be used.

Fast setting for TreeLayout that emulates the ClassicTreeLayout
const subtreePlacer = new LevelAlignedSubtreePlacer()
subtreePlacer.alignPorts = false // required (default)
subtreePlacer.busAlignment = 0.6 // can be changed freely
subtreePlacer.dendrogramStyle = false // required (default)
subtreePlacer.layerSpacing = layerDistance // can be changed freely
subtreePlacer.polylineLabeling = false // required (default)
subtreePlacer.rootAlignment = SubtreeRootAlignment.CENTER_OF_PORTS // required
subtreePlacer.edgeRoutingStyle =
  LevelAlignedSubtreePlacerRoutingStyle.ORTHOGONAL // or StraightLine
subtreePlacer.spacing = nodeDistance // should be at most BusAlignment * LayerSpacing
subtreePlacer.verticalAlignment = 0.5 // required (default)

const treeLayout = new TreeLayout({
  defaultSubtreePlacer: subtreePlacer
})

Aspect Ratio Tree Layout

The AspectRatioTreeLayout has been superseded by the TreeLayout with the AspectRatioSubtreePlacer. To obtain similar results, use the following configuration, which depends on the previous value of the rootPlacement.

RootPlacement childArrangementrootPlacement
CornerAUTOMATICCORNER_COMPACT
CornerTopHORIZONTALCORNER_COMPACT
CornerSideVERTICALCORNER_COMPACT
TopHORIZONTALCENTER
Setting for TreeLayout that emulates the AspectRatioTreeLayout
const subtreePlacer = new AspectRatioSubtreePlacer({
  childArrangement: childArrangement,
  rootPlacement: rootPlacement
})

const treeLayout = new TreeLayout({
  defaultSubtreePlacer: subtreePlacer
})

Major Changes to Expert API

The changes described in this chapter only affect developers who work directly with the LayoutGraph API, such as those writing custom layout algorithms.

Several protected methods of the TreeLayout class have been removed. In many case, these protected methods allowed for customizations that are better handled by setting appropriate values through the appropriate TreeLayoutData properties. The remaining methods still allow extensive customization of the layout process.