ilog.views.graphlayout.tree
Class IlvTreeLayout

java.lang.Object
  extended by ilog.views.graphlayout.IlvGraphLayout
      extended by ilog.views.graphlayout.tree.IlvTreeLayout
All Implemented Interfaces:
GraphModelListener, Serializable, EventListener

public class IlvTreeLayout
extends IlvGraphLayout

The main class for the Tree Layout algorithm.

The Tree Layout algorithm places the nodes of a tree starting from the root of the tree to the leaves. If the graph has parts that are disconnected, it arranges each connected component as an individual tree. The Tree Layout algorithm is primarily designed for a forest of pure trees. In a tree, each node except the root has a parent node. All the nodes that have the same parent are called children with respect to the parent and siblings with respect to each other. The Tree Layout algorithm can also be used for non-trees (for example, cyclic graphs). In this case, the layout algorithm ignores those links that violate the tree structure and takes only the spanning tree of the graph into account.

The algorithm has several layout modes:

To simplify the explanations of the layout parameters, we use the compass directions north, south, east, and west. The center of the root node of a tree is the north pole. If the root node is placed at the top border, north is always upwards, south towards the bottom, west towards the left, and east towards the right side of the layout. If the root node is placed at the left border, north is left and south is right. In radial mode, the root is placed in the center, and so the notation of north and south depends on where a node is placed relative to the root. The north side of any node is the side that is closer to the root and the south side is the side that is farther away from the root.

Several alignment options are provided. In particular, the free layout mode allows the tip-over alignment, which means that subtrees are arranged serially rather than in parallel. If the subtrees starting at one node are normally arranged horizontally, the tip-over alignment arranges them vertically. The tree layout provides layout modes that automatically adapt the tip-over alignment to best fit the layout to a given aspect ratio.

The following sample drawings are produced by the Tree Layout algorithm. The left drawing uses the level layout mode. The flow direction of the links is towards the bottom, and the nodes are south-justified (that is, they are aligned to the bottom) within each level. The right drawing is the same tree in free layout mode (which always uses north level alignment):

Click on the image to see it in normal size.

Here is another sample drawing in free layout mode with the tip-over alignment at some leaf nodes:

Click on the image to see it in normal size.

The following are two sample drawings in the two radial layout modes. The normal radial mode in the left drawing places the nodes of the same level on a circle around the root node. The alternating radial mode in the right drawing places the nodes of the same level alternating on two circles around the root node. This results in better usage of the space.

Click on the image to see it in normal size.

In nonradial layout modes, the Tree Layout algorithm supports different styles of links in the same drawing. The following sample drawing shows orthogonal and straight-line links. It also shows nodes that are aligned to the center (see the red nodes), to the east (green), and to the west (blue) of their children. The drawing was created by the free layout mode with the link flow direction to the right, and so north is to the left.

Click on the image to see it in normal size.

The Tree Layout algorithm supports node neighboring in all modes. The following sample drawing shows a tree layout with the flow direction towards the top. Some nodes are not placed as children but rather as neighbors at the same level as the corresponding parent node. The red links, which are perpendicular to the flow direction, are between nodes that were specified as neighbored.

Click on the image to see it in normal size.

See the corresponding chapter of the User's Manual for details on the algorithm, the types of graphs for which this algorithm can be used, the features and limitations, code samples, and so on.

Note the following points:

See Also:
Serialized Form

Field Summary
static int ALTERNATING_RADIAL
          Alternating radial layout mode.
static int AUTOMATIC_PINS
          Automatic connector pin option.
static int BORDER_CENTER
          Border center alignment option.
static int CENTER
          Center alignment option.
static int CENTERED_PINS
          Centered connector pin option.
static int CLIPPED_PINS
          Clipped connector pin option.
static int EAST
          East alignment option.
static int EVENLY_SPACED_PINS
          Evenly spaced connector pin option.
static int FREE
          Free layout mode.
static int LEVEL
          Level layout mode.
static int MIXED
          Mixed alignment option.
static int MIXED_STYLE
          Mixed link shape option.
static int NO_RESHAPE_STYLE
          No reshape option.
static int NORTH
          North alignment option.
static int ORTHOGONAL_STYLE
          Orthogonal link shape option.
static int RADIAL
          Radial layout mode.
static int SOUTH
          South alignment option.
static int STRAIGHT_LINE_STYLE
          Straight-line link shape option.
static int TIP_LEAVES_OVER
          Tip-over layout mode.
static int TIP_OVER
          Tip-over alignment option.
static int TIP_OVER_BOTH_SIDES
          Tip-over to both sides alignment option.
static int TIP_ROOTS_AND_LEAVES_OVER
          Tip-over layout mode.
static int TIP_ROOTS_OVER
          Tip-over layout mode.
static int WEST
          West alignment option.
 
Fields inherited from class ilog.views.graphlayout.IlvGraphLayout
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
 
Constructor Summary
IlvTreeLayout()
          Creates a new instance of the Tree Layout algorithm.
IlvTreeLayout(IlvTreeLayout source)
          Creates a new layout instance by copying an existing one.
 
Method Summary
 int checkAppropriateLink(Object link)
          Checks whether the input link is appropriate for this layout.
 void cleanLink(IlvGraphModel graphModel, Object link)
          Cleans a link.
 void cleanNode(IlvGraphModel graphModel, Object node)
          Cleans a node.
 IlvGraphLayout copy()
          Copies the layout instance.
 void copyParameters(IlvGraphLayout source)
          Copies the parameters from a given layout instance.
protected  IlvGraphLayoutGrapherProperty createLayoutGrapherProperty(String name, boolean withDefaults)
          Returns a new instance of IlvTreeLayoutGrapherProperty that stores the parameter settings of this layout class.
protected  IlvGraphLayoutLinkProperty createLayoutLinkProperty(String name, IlvGraphic link, boolean withDefaults)
          Returns a new instance of IlvTreeLayoutLinkProperty that stores the parameter settings of this layout class for links.
protected  IlvGraphLayoutNodeProperty createLayoutNodeProperty(String name, IlvGraphic node, boolean withDefaults)
          Returns a new instance of IlvTreeLayoutNodeProperty that stores the parameter settings of this layout class for nodes.
 void detach()
          Detaches the graph model from the layout instance.
 int getAlignment(Object node)
          Returns the local alignment option of the node.
 float getAspectRatio()
          Returns the aspect ratio specified for the layout.
 float getBranchOffset()
          Returns the minimal offset between neighbor nodes that belong to different branches in the tree.
 Enumeration getCalcBackwardTreeLinks()
          Returns the backward links that were used in the reverse direction as part of the spanning tree during layout.
 Enumeration getCalcForwardTreeLinks()
          Returns the forward links that were used as part of the spanning tree during the layout.
 Enumeration getCalcNonTreeLinks()
          Returns the links that were neither forward nor backward links in the spanning tree during layout.
 Enumeration getCalcRoots()
          Returns the nodes that were used as roots during layout.
 int getConnectorStyle()
          Returns the style of the connectors.
 Object getEastNeighbor(Object node)
          Returns the specified east neighbor node of the input node, or null if none was specified.
 int getFlowDirection()
          Returns the current direction of the flow.
 int getGlobalAlignment()
          Returns the global alignment option.
 int getGlobalLinkStyle()
          Returns the global style of the shapes of links.
 int getLayoutMode()
          Returns the current layout mode.
 int getLevelAlignment()
          Returns the current alignment within the levels.
 int getLinkStyle(Object link)
          Returns the style of the shape of an individual link.
 int getMaxChildrenAngle()
          Returns the maximal angle for children that are placed in radial mode.
 IlvGraphicVector getMovingNodes()
          Returns the vector of nodes being moved by the graph layout algorithm.
 float getOrthForkPercentage()
          Returns the percentage of the parent-child offset that determines the location where the orthogonal link routing places the bends in order to fork the routing towards the children.
 float getOverlapPercentage()
          Returns the percentage for which a node is considered smaller in the flow direction.
 float getParentChildOffset()
          Returns the minimal offset between a parent and its children.
 IlvPoint getPosition()
          Returns the specified position of the layout.
 int getRootPreference(Object node)
          Returns the specified preference of the node to become root node.
 float getSiblingOffset()
          Returns the minimal offset between siblings.
 Enumeration getSpecRoots()
          Returns the nodes that were specified as root.
 float getTipOverBranchOffset()
          Returns the minimal offset in the flow direction between neighbor nodes that belong to different branches in the tree.
 Object getWestNeighbor(Object node)
          Returns the specified west neighbor node of the input node, or null if none was specified.
protected  void init()
          Initializes instance variables.
 boolean isAllLevelsAlternating()
          Returns true if at all levels, nodes are forced into alternating circular layers.
 boolean isCalcRoot(Object node)
          Returns true if the input node was used as root during layout.
 boolean isCategorizingLinks()
          Returns true if the layout algorithm stores the categorization of links into forward, backward, and non-tree links.
 boolean isFirstCircleEvenlySpacing()
          Returns true if the nodes on the first circle must be evenly spaced in radial mode.
 boolean isIncrementalMode()
          Returns true if the incremental mode is enabled.
 boolean isInvisibleRootUsed()
          Returns true if an invisible root is used to combine components that are disconnected from each other.
 boolean isNonTreeLinksStraight()
          Returns true if all non-tree links that don't have the no-reshape link style and that are not fixed and are not incident to fixed nodes are reshaped to be straight.
 boolean isRespectNodeSizes()
          Returns true if the algorithm tries to respect the size of the nodes, and false otherwise.
 boolean isRootPosition()
          Returns true if the specified position means the position of the root node.
 boolean isSpecRoot(Object node)
          Returns true if the input node was specified as root.
protected  void layout(boolean redraw)
          Computes the layout using the Tree Layout algorithm.
 void layoutStepPerformed()
          This method can be called by the layout classes when a step of the layout algorithm has been performed.
 void setAlignment(Object node, int alignment)
          Sets the alignment option of an individual node.
 void setAllLevelsAlternating(boolean enable)
          Sets whether at all levels, nodes are forced into alternating circular layers.
 void setAspectRatio(float aspectRatio)
          Sets the aspect ratio for the layout.
 void setAspectRatio(IlvManagerView view)
          Sets the aspect ratio for the layout from a given view.
 void setAspectRatio(IlvRect rect)
          Sets the aspect ratio for the layout from a given rectangle.
 void setBranchOffset(float offset)
          Sets the minimal offset between neighbor nodes that belong to different branches in the tree.
 void setCategorizingLinks(boolean flag)
          Sets whether the layout algorithm stores the categorization of links into forward, backward, and non-tree links.
 void setConnectorStyle(int style)
          Sets the style of the connectors.
 void setEastWestNeighboring(Object eastNode, Object westNode)
          Creates an east-west neighboring of two nodes.
 void setFirstCircleEvenlySpacing(boolean enable)
          Sets whether the nodes on the first circle must be evenly spaced in radial mode.
 void setFlowDirection(int direction)
          Sets the direction of the flow.
 void setGlobalAlignment(int alignment)
          Sets the global alignment option.
 void setGlobalLinkStyle(int style)
          Sets the global style of the shapes of links.
 void setIncrementalMode(boolean enable)
          Sets the incremental mode.
 void setInvisibleRootUsed(boolean flag)
          Sets whether an invisible root is used to combine components that are disconnected from each other.
 void setLayoutMode(int mode)
          Sets the layout mode.
 void setLevelAlignment(int alignment)
          Sets the alignment within the levels.
 void setLinkStyle(Object link, int style)
          Sets the style of the shape of an individual link.
 void setMaxChildrenAngle(int angle)
          Sets the maximal angle for children that are placed in radial mode.
 void setNonTreeLinksStraight(boolean enable)
          Sets whether all non-tree links that don't have the no-reshape link style and that are not fixed and are not incident to fixed nodes are reshaped to be straight.
 void setOrthForkPercentage(float percentage)
          Sets the percentage of the parent-child offset that determines the location where the orthogonal link routing places the bends in order to fork the routing towards the children.
 void setOverlapPercentage(float percentage)
          Sets the percentage for which a node is considered smaller in the flow direction.
 void setParentChildOffset(float offset)
          Sets the minimal offset between a parent and its children.
 void setPosition(IlvPoint point)
          Sets the position of the layout.
 void setPosition(IlvPoint point, boolean isRootPosition)
          Sets the position of the layout.
 void setRespectNodeSizes(boolean respect)
          Sets whether the algorithm must try to respect the size of the nodes.
 void setRoot(Object node)
          Allows you to specify the root(s) of the tree.
 void setRootPosition(boolean isRootPosition)
          Sets the meaning of the specified position.
 void setRootPreference(Object node, int preference)
          Specifies the preference of the node to become root node.
 void setSiblingOffset(float offset)
          Sets the minimal offset between siblings, that is, between nodes that have the same parent in the tree structure.
 void setTipOverBranchOffset(float offset)
          Sets the minimal offset in the flow direction between neighbor nodes that belong to different branches in the tree.
 void setWestEastNeighboring(Object westNode, Object eastNode)
          Creates an east-west neighboring of two nodes.
 boolean stopImmediately()
          Stops the running layout algorithm as soon as possible.
 boolean supportsAllowedTime()
          Indicates that this layout class can stop the layout computation in a proper manner when the user-defined allowed time is exceeded.
 boolean supportsLayoutOfConnectedComponents()
          Indicates that this layout class can use the generic connected component layout mechanism of the IlvGraphLayout base class.
 boolean supportsLinkClipping()
          Indicates that this layout class can use a link clip interface to clip the end points of a link.
 boolean supportsLinkConnectionBox()
          Indicates that this layout class can use a link connection box interface to calculate the end points of links.
 boolean supportsPercentageComplete()
          Indicates that this layout class can estimate the percentage of completion during the run of the layout.
 boolean supportsPreserveFixedLinks()
          Indicates that this layout class allows the user to specify fixed links.
 boolean supportsPreserveFixedNodes()
          Indicates that this layout class allows the user to specify fixed nodes.
 boolean supportsSaveParametersToNamedProperties()
          Indicates that this layout class can transfer the layout parameters to named properties.
 boolean supportsSplineRouting()
          Tests if this class supports the generic optimization of spline control points.
 boolean supportsStopImmediately()
          Indicates that this layout class can interrupt the current run of the layout immediately in a controlled way.
 
Methods inherited from class ilog.views.graphlayout.IlvGraphLayout
addGraphLayoutEventListener, addGraphLayoutParameterEventListener, afterLayoutOfSubgraph, attach, attach, beforeLayout, beforeLayoutOfSubgraph, callLayoutStepPerformedIfNeeded, checkAppropriateLinks, cleanGraphModel, clipAllLinks, clipLink, contentsChanged, createLayoutReport, getAllowedTime, getAutoLayoutHandler, getBalanceSplineCurveThreshold, getCalcLayoutRegion, getCoordinatesMode, getGrapher, getGraphModel, getInstanceId, getLayout, getLayoutOfConnectedComponents, getLayoutOfConnectedComponentsReport, getLayoutRegion, getLayoutReport, getLayouts, getLinkClipInterface, getLinkConnectionBoxInterface, getMaxSplineCurveSize, getMinBusyTime, getMinSplineCurveSize, getParentLayout, getProperty, getProperty, getRecursiveLayout, getRemainingAllowedTime, getSeedValueForRandomGenerator, getSpecLayoutRegion, getSplineLinkFilter, increasePercentageComplete, isAnimate, isAutoLayout, isFitToView, isFixed, isGeometryUpToDate, isInputCheckEnabled, isLayoutNeeded, isLayoutOfConnectedComponentsEnabled, isLayoutOfConnectedComponentsEnabledByDefault, isLayoutRunning, isLayoutTimeElapsed, isMemorySavings, isParametersUpToDate, isPreserveFixedLinks, isPreserveFixedNodes, isSplineRoutingEnabled, isStoppedImmediately, isStructureUpToDate, isUseDefaultParameters, isUseSeedValueForRandomGenerator, onParameterChanged, onParameterChanged, performAutoLayout, performLayout, performLayout, performLayout, PerformLayout, performSublayout, removeGraphLayoutEventListener, removeGraphLayoutParameterEventListener, setAllowedTime, setAnimate, setAutoLayout, setAutoLayoutHandler, setBalanceSplineCurveThreshold, setCoordinatesMode, setFixed, setGeometryUpToDate, setGrapher, setGraphModel, setInputCheckEnabled, setLayoutOfConnectedComponents, setLayoutOfConnectedComponentsEnabled, setLayoutRegion, setLayoutRegion, setLayoutRegion, setLayoutReport, setLinkClipInterface, setLinkConnectionBoxInterface, setMaxSplineCurveSize, setMemorySavings, setMinBusyTime, setMinSplineCurveSize, setParametersUpToDate, setParentLayout, setPreserveFixedLinks, setPreserveFixedNodes, setProperty, setProperty, setSeedValueForRandomGenerator, setSplineLinkFilter, setSplineRoutingEnabled, setStructureUpToDate, setUseDefaultParameters, setUseSeedValueForRandomGenerator, supportsAnimation, supportsLayoutRegion, supportsMemorySavings, supportsRandomGenerator, unfixAllLinks, unfixAllNodes, useAnimateRedraw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_RESHAPE_STYLE

public static final int NO_RESHAPE_STYLE
No reshape option. When used as the argument of the method setGlobalLinkStyle(int), none of the links are reshaped. To specify the shape of an individual link, use this option as the argument of the method setLinkStyle(Object, int).

See Also:
Constant Field Values

STRAIGHT_LINE_STYLE

public static final int STRAIGHT_LINE_STYLE
Straight-line link shape option. When used as the argument of the method setGlobalLinkStyle(int), all links that are part of the spanning tree get a straight-line shape. To specify the shape of an individual link, use this option as the argument of the method setLinkStyle(Object, int).

See Also:
Constant Field Values

ORTHOGONAL_STYLE

public static final int ORTHOGONAL_STYLE
Orthogonal link shape option. When used as the argument of the method setGlobalLinkStyle(int), all links that are part of the spanning tree get a shape consisting of a sequence of orthogonal line segments. To specify the shape of an individual link, use this option as the argument of the method setLinkStyle(Object, int).

See Also:
Constant Field Values

MIXED_STYLE

public static final int MIXED_STYLE
Mixed link shape option. When used as the argument of the method setGlobalLinkStyle(int), each link can have a different shape. The shape of an individual link can be set by setLinkStyle(Object, int).

Since:
JViews 3.5
See Also:
Constant Field Values

AUTOMATIC_PINS

public static final int AUTOMATIC_PINS
Automatic connector pin option. When used as the argument of the method setConnectorStyle(int), the connector style is automatically selected depending on the global link style.

Since:
JViews 5.0
See Also:
setGlobalLinkStyle(int), Constant Field Values

CENTERED_PINS

public static final int CENTERED_PINS
Centered connector pin option. When used as the argument of the method setConnectorStyle(int), the connector pins of links are placed at the center of the border to which the link is attached.

Since:
JViews 5.0
See Also:
Constant Field Values

CLIPPED_PINS

public static final int CLIPPED_PINS
Clipped connector pin option. When used as the argument of the method setConnectorStyle(int), the connector pins of links are placed such that the link pointing toward the node center is clipped at the node border.

Since:
JViews 5.0
See Also:
Constant Field Values

EVENLY_SPACED_PINS

public static final int EVENLY_SPACED_PINS
Evenly spaced connector pin option. When used as the argument of the method setConnectorStyle(int), the connector pins of links are evenly spaced along the border to which the link is attached.

Since:
JViews 5.0
See Also:
Constant Field Values

EAST

public static final int EAST
East alignment option. When used as the argument of the method setGlobalAlignment(int), all parent nodes are aligned to the east border of their children. The alignment of an individual node can be set by setAlignment(Object, int).

Since:
JViews 3.5
See Also:
Constant Field Values

WEST

public static final int WEST
West alignment option. When used as the argument of the method setGlobalAlignment(int), all parent nodes are aligned to the west border of their children. The alignment of an individual node can be set by setAlignment(Object, int).

Since:
JViews 3.5
See Also:
Constant Field Values

NORTH

public static final int NORTH
North alignment option. When used in level layout mode as the argument of the method setLevelAlignment(int), the nodes of the same level are justified to the north side (towards the root).

Since:
JViews 3.5
See Also:
Constant Field Values

SOUTH

public static final int SOUTH
South alignment option. When used in level layout mode as the argument of the method setLevelAlignment(int), the nodes of the same level are justified to the south side (away from the root).

Since:
JViews 3.5
See Also:
Constant Field Values

CENTER

public static final int CENTER
Center alignment option. When used as the argument of the method setGlobalAlignment(int), all parent nodes are centered with respect to their children. The alignment of an individual node can be set by setAlignment(Object, int).

When used in level layout mode as the argument of the method setLevelAlignment(int), the nodes of the same level are justified to their centers.

See Also:
Constant Field Values

BORDER_CENTER

public static final int BORDER_CENTER
Border center alignment option. When used as the argument of the method setGlobalAlignment(int), all parent nodes are centered with respect to the border of their children. The alignment of an individual node can be set by setAlignment(Object, int).

Since:
JViews 3.5
See Also:
Constant Field Values

TIP_OVER

public static final int TIP_OVER
Tip-over alignment option.

When used as the argument of the method setGlobalAlignment(int), the children are arranged serially rather than in parallel. For instance, if the children are normally arranged horizontally below each parent node, the tip-over alignment arranges them vertically below the parent node. The alignment of an individual parent node can be set by setAlignment(Object, int).

When used as the argument of the method setLayoutMode(int), all links flow roughly in the flow direction. In this layout mode, the algorithm tries to optimize the layout to automatically fit best to the specified aspect ratio by calculating which individual nodes need tip-over alignment and which nodes can use the specified alignment. The layout algorithm uses a fast heuristic.

Since:
JViews 3.5
See Also:
Constant Field Values

TIP_OVER_BOTH_SIDES

public static final int TIP_OVER_BOTH_SIDES
Tip-over to both sides alignment option.

When used as the argument of the method setGlobalAlignment(int), the children are arranged in pairs serially rather than in parallel. While the TIP_OVER option arranges all children at the same side of the parent, this alignment arranges the children in pairs at both sides of the parent. The alignment of an individual parent node can be set by setAlignment(Object, int).

Since:
JViews 5.0
See Also:
Constant Field Values

MIXED

public static final int MIXED
Mixed alignment option. When used as the argument of the method setGlobalAlignment(int), each node can have a different alignment. The alignment of an individual node can be set by setAlignment(Object, int).

Since:
JViews 3.5
See Also:
Constant Field Values

FREE

public static final int FREE
Free layout mode. When used as the argument of the method setLayoutMode(int), all links flow roughly in the flow direction. Parents and sibling nodes are aligned according to the specified alignment option, but nodes of different tree branches are not justified with each other,

Since:
JViews 3.5
See Also:
Constant Field Values

LEVEL

public static final int LEVEL
Level layout mode. When used as the argument of the method setLayoutMode(int), all links flow roughly in the flow direction. All nodes are organized in levels and are justified to their borders or centered according to the level alignment option. Tip-over node alignment is not possible; all other alignment options are possible.

Since:
JViews 3.5
See Also:
Constant Field Values

RADIAL

public static final int RADIAL
Radial layout mode. When used as the argument of the method setLayoutMode(int), the root node is in the center and the links flow radially away from the center. The nodes are placed in circular layers around the root node.

Since:
JViews 3.5
See Also:
Constant Field Values

ALTERNATING_RADIAL

public static final int ALTERNATING_RADIAL
Alternating radial layout mode. When used as the argument of the method setLayoutMode(int), the root node is in the center and the links flow radially away from the center. The nodes are placed in circular layers around the root node. To optimize space, siblings may be placed alternating in two different circular layers. The alternating radial mode differs only from the radial mode if the alternating placement produces smaller circles.

Since:
JViews 3.5
See Also:
Constant Field Values

TIP_LEAVES_OVER

public static final int TIP_LEAVES_OVER
Tip-over layout mode. When used as the argument of the method setLayoutMode(int), all links flow roughly in the flow direction. The algorithm tries to optimize the layout to automatically fit best to the specified aspect ratio by calculating which individual nodes need tip-over alignment and which nodes can use the specified alignment. The layout algorithm uses a heuristic that checks whether leaf nodes (and their immediate parent nodes) should be tipped over. It checks only the alignment mode TIP_OVER, but not TIP_OVER_BOTH_SIDES.

Since:
JViews 3.5
See Also:
Constant Field Values

TIP_ROOTS_OVER

public static final int TIP_ROOTS_OVER
Tip-over layout mode. When used as the argument of the method setLayoutMode(int), all links flow roughly in the flow direction. The algorithm tries to optimize the layout to automatically fit best to the specified aspect ratio by calculating which individual nodes need tip-over alignment and which nodes can use the specified alignment. The layout algorithm uses a heuristic that checks whether root nodes (and their immediate children nodes) should be tipped over. It checks only the alignment mode TIP_OVER, but not TIP_OVER_BOTH_SIDES.

Since:
JViews 3.5
See Also:
Constant Field Values

TIP_ROOTS_AND_LEAVES_OVER

public static final int TIP_ROOTS_AND_LEAVES_OVER
Tip-over layout mode. When used as the argument of the method setLayoutMode(int), all links flow roughly in the flow direction. The algorithm tries to optimize the layout to automatically fit best to the specified aspect ratio by calculating which individual nodes need tip-over alignment and which nodes can use the specified alignment. The layout algorithm uses a heuristic that checks whether root nodes and leaf nodes should be tipped over. It checks only the alignment mode TIP_OVER, but not TIP_OVER_BOTH_SIDES.

Since:
JViews 3.5
See Also:
Constant Field Values
Constructor Detail

IlvTreeLayout

public IlvTreeLayout()
Creates a new instance of the Tree Layout algorithm.
To indicate the grapher you want to lay out, use the method IlvGraphLayout.attach(IlvGrapher).
To indicate the graph model you want to lay out, use the method IlvGraphLayout.attach(IlvGraphModel).
To perform the layout, use the method IlvGraphLayout.performLayout().
To modify the layout parameters, use the different methods provided in this class and its superclass.

See Also:
IlvGraphLayout.attach(IlvGrapher), IlvGraphLayout.attach(IlvGraphModel), IlvGraphLayout.performLayout()

IlvTreeLayout

public IlvTreeLayout(IlvTreeLayout source)
Creates a new layout instance by copying an existing one. This constructor is used by the copy() method. Any subclass should provide a copy constructor.

The parameters of the source layout are copied using the method copyParameters(ilog.views.graphlayout.IlvGraphLayout).

Parameters:
source - The layout instance that is copied.
Since:
JViews 5.0
See Also:
copy(), copyParameters(ilog.views.graphlayout.IlvGraphLayout)
Method Detail

init

protected void init()
Initializes instance variables.

You should not call this method directly. The method is called internally by the constructor without arguments and by the copy constructor. The method must be overridden by subclasses that need to initialize additional instance variables.

Overrides:
init in class IlvGraphLayout
Since:
JViews 5.0

copy

public IlvGraphLayout copy()
Copies the layout instance.

This method copies the layout instance by calling the copy constructor.

When performing a recursive layout of a nested graph, this method is used by IlvLayoutProvider to "clone" the layout instance of a parent graph. Note that the parameters which are specific to a node or a link are not copied. Only the global parameters are copied. The layout position is not copied.

Specified by:
copy in class IlvGraphLayout
Returns:
A copy of the layout instance.
Since:
JViews 5.0
See Also:
copyParameters(ilog.views.graphlayout.IlvGraphLayout), setPosition(IlvPoint), setPosition(IlvPoint, boolean)

copyParameters

public void copyParameters(IlvGraphLayout source)
Copies the parameters from a given layout instance.

Note that the parameters which are specific to a node or a link are not copied. Only the global parameters are copied. The layout position is not copied.

Overrides:
copyParameters in class IlvGraphLayout
Parameters:
source - The layout instance from which the parameters are copied.
Since:
JViews 5.0
See Also:
copy(), setPosition(IlvPoint), setPosition(IlvPoint, boolean)

layout

protected void layout(boolean redraw)
               throws IlvGraphLayoutException
Computes the layout using the Tree Layout algorithm. To start the layout, call the method IlvGraphLayout.performLayout().

Specified by:
layout in class IlvGraphLayout
Parameters:
redraw - If true, the attached graph model will be asked to redraw the graph after layout. When the layout algorithm moves the nodes and reshapes the links, it is required to pass the value of the redraw argument to the methods IlvGraphModel.moveNode(java.lang.Object, float, float, boolean) and IlvGraphModel.reshapeLink(java.lang.Object, ilog.views.IlvPoint, ilog.views.IlvPoint[], int, int, ilog.views.IlvPoint, boolean).
Throws:
IlvGraphLayoutException - If an unusual situation occurs. WARNING: this method can throw one of the subclasses of IlvGraphLayoutException. Specifically, it can throw an IlvInappropriateGraphException. It can also throw an IlvInappropriateLinkException when inappropriate types of links and/or link connectors are used in an IlvGrapher. For details, refer to the documentation of these exception classes.
See Also:
IlvGraphLayout.performLayout()

detach

public void detach()
Detaches the graph model from the layout instance. When you attach a new graph model to the layout instance, you do not need to detach the old graph model because this is done automatically when you call IlvGraphLayout.attach(IlvGraphModel). The detach method performs cleaning operations on the graph model. In addition to the cleaning operations in the base class, the Tree Layout removes the alignment, root preference, and node neighboring specifications of individual nodes, and the link style specifications of individual links.

Note that you must call this method when you no longer need the layout instance. Otherwise, some objects may not be garbage collected.

Overrides:
detach in class IlvGraphLayout
See Also:
IlvGraphLayout.attach(IlvGrapher), setAlignment(Object, int), setRootPreference(Object, int), setLinkStyle(Object, int), setEastWestNeighboring(Object, Object)

cleanNode

public void cleanNode(IlvGraphModel graphModel,
                      Object node)
Cleans a node. This method removes any data that has been stored by the layout algorithm on a node. In addition to the cleaning operations in the base class, Tree Layout removes the root node preference and the alignment and east/west attachment settings from the nodes.

Subclasses can override this method to remove additional information stored in the nodes.

Overrides:
cleanNode in class IlvGraphLayout
Parameters:
graphModel - The graph model to which node belongs.
node - The node to be cleaned.
Since:
JViews 5.0
See Also:
detach()

cleanLink

public void cleanLink(IlvGraphModel graphModel,
                      Object link)
Cleans a link. This method removes any data that has been stored by the layout algorithm on a link. In addition to the cleaning operations in the base class, Tree Layout removes the link style settings from the nodes.

Subclasses can override this method to remove additional information stored in the links.

Overrides:
cleanLink in class IlvGraphLayout
Parameters:
graphModel - The graph model to which link belongs.
link - The link to be cleaned.
Since:
JViews 5.0
See Also:
detach()

supportsPreserveFixedNodes

public final boolean supportsPreserveFixedNodes()
Indicates that this layout class allows the user to specify fixed nodes. Fixed nodes are not moved during the layout if the method IlvGraphLayout.setPreserveFixedNodes(boolean) is called with a true argument. Links that are incident to fixed nodes are not reshaped during the layout. Fixed nodes are ignored by the Tree Layout algorithm, which may lead to node overlaps. The effect is very similar to the effect when the node is filtered during layout.

Overrides:
supportsPreserveFixedNodes in class IlvGraphLayout
Returns:
Always true.
Since:
JViews 3.5
See Also:
IlvGrapherAdapter.setFilter(IlvLayoutGraphicFilter), IlvGraphLayout.setPreserveFixedNodes(boolean), IlvGraphLayout.isPreserveFixedNodes()

supportsPreserveFixedLinks

public final boolean supportsPreserveFixedLinks()
Indicates that this layout class allows the user to specify fixed links. Fixed links are not reshaped during the layout if the method IlvGraphLayout.setPreserveFixedLinks(boolean) is called with a true argument. Fixed links are ignored by the Tree Layout algorithm, which may lead to overlaps. The effect is very similar to the effect when the link is filtered during layout.

Overrides:
supportsPreserveFixedLinks in class IlvGraphLayout
Returns:
Always true.
See Also:
IlvGrapherAdapter.setFilter(IlvLayoutGraphicFilter), IlvGraphLayout.setPreserveFixedLinks(boolean), IlvGraphLayout.isPreserveFixedLinks(), setGlobalLinkStyle(int), setLinkStyle(Object, int)

supportsAllowedTime

public final boolean supportsAllowedTime()
Indicates that this layout class can stop the layout computation in a proper manner when the user-defined allowed time is exceeded. If the allowed time elapses before termination of the Tree Layout algorithm, the nodes and links are not moved and remain at the same position as before the start of the algorithm. The result code in the layout report is IlvGraphLayoutReport.STOPPED_AND_INVALID in this case.

Overrides:
supportsAllowedTime in class IlvGraphLayout
Returns:
Always true.
Since:
JViews 3.5
See Also:
IlvGraphLayout.setAllowedTime(long), IlvGraphLayout.getAllowedTime(), IlvGraphLayoutReport.getCode()

supportsStopImmediately

public final boolean supportsStopImmediately()
Indicates that this layout class can interrupt the current run of the layout immediately in a controlled way. If the algorithm is stopped before termination of the Tree Layout algorithm, the nodes and links are not moved and remain at the same position as before the start of the algorithm. The result code in the layout report is IlvGraphLayoutReport.STOPPED_AND_INVALID in this case.

Overrides:
<