Bus topology is well known in network
management and telecommunications fields. The Bus Layout class can
display these topologies nicely. It represents the “bus” as a
“serpent” polyline. The width of the “serpent” is user-defined (via
the width of the layout region parameter) and the height is
computed so that enough space is available for all the nodes.
BL - CSS Sample
BL example
In CSS
Below is a sample CSS specification using the Bus Layout
algorithm. Since the Bus Layout places nodes and reshapes the
links, it is usually not necessary to specify an additional
link layout in CSS. The CSS specification can be loaded as a
style file into an application that uses the IlvDiagrammer class (see Graph layout in Rogue Wave JViews Diagrammer.
SDM { GraphLayout : "true"; LinkLayout : "false"; } GraphLayout { graphLayout : "Bus"; flowDirection : "LEFT_TO_RIGHT"; nodeComparator: "DESCENDING_HEIGHT"; }
To be laid out by the Bus Layout, the graph needs to contain a
bus node connected with links to several other nodes. When you
specify the Bus Layout in CSS, the data model must respect
this condition. Moreover, the CSS statements of the graphic
objects used for the nodes must specify a graphic object
implementing the IlvPolyPointsInterface to allow the Bus
Layout to discover the bus node automatically when it is not
explicitly specified (for details, see Bus node (BL)). Typically, you can do
this by specifying a node rule in which the selector uses an
attribute of the node in the data model that identifies the
bus node.
In Java™
The following code sample uses the IlvBusLayout class. This code sample
shows how to perform a Bus Layout on a grapher directly
without using a diagram component or any style sheet:
... import ilog.views.*; import ilog.views.graphic.*; import ilog.views.graphlayout.*; import ilog.views.graphlayout.bus.*; ... IlvGrapher grapher = new IlvGrapher(); IlvManagerView view = new IlvManagerView(grapher); ... /* Fill in the grapher with nodes and links here */ /* Create the bus node; the number of points and the coordinates are not important */ IlvPoint[] points = {new IlvPoint(10, 10)}; IlvPolyline bus = new IlvPolyline(points); grapher.addNode(bus, false); ... /* Fill in the grapher with links between each node and the bus here */ IlvBusLayout layout = new IlvBusLayout(); layout.attach(grapher); /* Specify the bus node */ layout.setBus(bus); try { IlvGraphLayoutReport layoutReport = layout.performLayout(); int code = layoutReport.getCode(); System.out.println("Layout completed (" + layoutReport.codeToString(code) + ")"); } catch (IlvGraphLayoutException e) { System.err.println(e.getMessage()); }