Developing with the SDK > Using and Adding Renderers > Predefined Renderers > The GraphLayout Renderer

Note
Graph layout features are available only if you purchased a full JViews Diagrammer license.

The GraphLayout renderer lets you apply an automatic layout algorithm to the nodes of the graph. The layout algorithm can be any of the algorithms made available by the Graph Layout capability.

The graph layout algorithm will be applied once when the data model is loaded, and also every time a new object is dynamically added to the model. The algorithm can be temporarily disabled and then re-enabled.

Table 4.6 lists the properties of the GraphLayout renderer.

Table 4.6 Global Properties of the GraphLayout Renderer 
Property 
Type 
Default 
Description 
connectingLinksToShape 
boolean 
false 
Specifies whether the links should be connected to the shape of the node or to the bounding box of the node (including the label). Connection to the shape is possible if the node is an IlvGeneralNode object, and does not take the label into account if it is outside the shape.  
enabled 
boolean 
true 
Enables/disables the graph layout algorithm. 
graphLayout 
IlvGraphLayout 
null 
Specifies which algorithm to apply. You can use the full class name, for example: 
or an abbreviated name (for example, Hierarchical). 
incrementalLayout 
boolean 
false 
partialLayout 
boolean 
false 
Tells the renderer to lay out only the selected objects. Objects that are not selected are marked as fixed before the layout. 
savingNodePositions 
boolean 
false 
Specifies whether the new positions of the nodes must be saved to the data model after the layout is applied. 

Setting Properties of IlvGraphLayout Objects

You can set any property of the IlvGraphLayout subclass corresponding to the selected layout algorithm. Code Sample 4.14 shows an example of some typical rules.

SDM {
    GraphLayout : "Hierarchical";
}

GraphLayout {
    enabled         : "false";
    globalLinkStyle : "ORTHOGONAL_LINKS";
    flowDirection   : "Bottom";
}

Code Sample 4.14 Typical Graph Layout Rules

In this example, enabled is a property of the GraphLayout renderer itself, but globalLinkStyle and flowDirection are properties of the IlvHierarchicalLayout object used by the renderer.

The properties of each layout algorithm are fully explained in the Using Graph Layout Algorithms. The properties of the IlvGraphLayout subclasses conform to the JavaBeans conventions: if a class has a pair of methods called setMyProp (with a single parameter) and getMyProp (without parameters), then you can set the property myProp in the style sheet.

Note
If the value of the property is an enumeration of integer values defined by static member variables of the class, you can use the name of the variable alone, or the variable name prefixed by the class name alone, or the variable name prefixed by the fully qualified class name. For example, these declarations are all valid:

globalLinkStyle : "ORTHOGONAL_LINKS";

globalLinkStyle : "ORTHOGONAL_LINKS";

globalLinkStyle : "IlvHierarchicalLayout.ORTHOGONAL_LINKS";

globalLinkStyle : "ilog.views.graphlayout.hierarchical.IlvHierarchicalLayout.ORTHOGONAL_LINKS";

Table 4.7 lists the per-object rendering properties of the GraphLayout renderer:

Table 4.7 Per-Object Properties of the GraphLayout Renderer 
Property 
Type 
Default 
Description 
GraphLayout 
IlvGraphLayout 
null 
Lets you define a different graph layout algorithm for each subgraph. If one is not specified, the same algorithm is applied recursively to all subgraphs. 
LayoutCluster 
String 
n/a 
Deprecated, replaced by ClusterId 
LayoutFixed 
String 
false 
Deprecated, replaced by Fixed. 
LayoutGroup 
String 
null 
Lets you apply the algorithm to different groups of objects, one group after the other. 
LayoutIgnored 
boolean 
false 
If true, the object is ignored by the layout. 
LayoutStarCenter 
boolean 
false 
Deprecated, replaced by StarCenter. 
ClusterId 
String 
n/a 
For Circular Layout only: A list of cluster identifiers (at least one) to which a node belongs. For example, the ClusterId value "cluster3" means that the node belongs to the cluster with this identifier; the ClusterId value "cluster3,2" means that the node belongs to the cluster cluster3 and has the order index "2"; the ClusterId value "cluster3,2;cluster5,3" means that the node belongs to two clusters, cluster3 and cluster5, and has the order index "2" on the first cluster and the order index "3" on the second cluster. 
It is mandatory to specify a value for the node to be managed by the circular layout. 
StarCenter 
boolean 
false 
For Circular Layout only: If true, the object is placed at the center of a star configuration. 
Fixed 
boolean 
false 
If true, the node is not moved by the graph layout (for links, the link is not reshaped).  

Setting Node or Link Parameters on Graph Layout Objects

You can set any parameter of a graph layout algorithm that applies to a particular node or link in the style sheet. Such a parameter is defined by a method of the form:

setMyParam(Object node, <type> value);

or

setMyParam(Object link, <type> value);

Node or link parameters are set in the style sheet as follows:

node {
    MyParam : "value";
}

The name of the property is the name of the method, without the set prefix. Note that node and link parameters are capitalized, unlike Bean properties.

For example, the hierarchical layout defines a setFromPortSide method that lets you choose which side of the origin node a given link will be connected to. The signature of the method is:

    setFromPortSide(Object link, int side);

In the style sheet, you can set this parameter as follows:

link {
    FromPortSide : "WEST";
}

The value of the property can be any simple type (integer, String, float), or it can be the name of a public constant defined by the graph layout class, for example, WEST , which is defined in the class IlvHierarchicalLayout.