| Graphic Components > Network Component > Network Component Services > Label Layout |
Label Layout |
INDEX
PREVIOUS
NEXT
|
JViews TGO allows you to place labels in a network automatically to make them easier to read. This placement overrides the default placement of labels in JViews TGO, namely:
Label layout allows you to reduce overlap between labels and other objects in the current view. Therefore, it is particularly useful for positioning labels on links. Figure 2.2 shows labels positioned by default. Figure 2.3 shows the same links with customized positioning of the labels through label layout.
Label layout in JViews TGO uses the label layout of ILOG JViews. See the ILOG JViews Diagrammer Using Graph Layout Algorithms documentation for more details on label layout.
JViews TGO provides the IltAnnealingLabelLayout class (a subclass of IlvAnnealingLabelLayout) that moves the labels of the nodes and the links so that they do not overlap. If it is impossible to prevent some overlap, this class will minimize the overlap between different labels.
The class IlpNetworkView provides the following method for handling label layout:
void setLabelLayout (IltAnnealingLabelLayout layout);
This method sets the given layout for the specified view. This method is also available from the class IlpNetwork, for convenience.
Unlike node layout and link layout, label layout is not performed automatically when the content of the network changes. You need to call labelLayout.performLayout() explicitly. There is a toolbar button for triggering label layout computation. See the class IlpNetworkLabelLayoutButton.
Here is a typical example of how to use label layout.
IlpNetwork network = new IlpNetwork(); // fill the network with your elements IltAnnealingLabelLayout labelLayout = new IltAnnealingLabelLayout(); network.setLabelLayout(labelLayout); labelLayout.performLayout(); network.setLabelLayout(null);
In this example you:
Label layout positions only the labels of links by default. You can choose to apply the layout to other types of object through the following methods:
void setObjects (IltLabelLayoutConstants[] types) void setObjects (int index, IltLabelLayoutConstants type) IltLabelLayoutConstants[] getObjects() IltLabelLayoutConstants getObjects (int index)
or through the following convenience methods:
setUsesOthers(boolean flag) setUsesLinks(boolean flag) setUsesNetworkElements(boolean flag) setUsesBTS(boolean flag) setUsesLinearGroups(boolean flag) setUsesPolyGroups(boolean flag) setUsesRectGroups(boolean flag)
IltAnnealingLabelLayout labelLayout = new IltAnnealingLabelLayout(); labelLayout.setObjects(0, IltLabelLayoutConstants.NETWORK_ELEMENTS); network.setLabelLayout(labelLayout); network.performLabelLayout(); network.setLabelLayout(null);
The method setObjects indicates whether a certain type of object will have its label placed by the label layout. In this example, only Network Elements will have their labels placed by the label layout.
Network {
labelLayout: true;
}
LabelLayout {
class: 'ilog.tgo.graphic.graphlayout.labellayout.IltAnnealingLabelLayout";
objects[0]: NETWORK_ELEMENTS;
}
The property objects indicates whether a certain type of object will have its label placed by the label layout. In this example, only network elements will have their labels placed by the label layout.
The label layout positions the labels of the objects by taking into account the obstacles that are in the network view. By default, all objects are considered as obstacles, but you can configure this behavior in CSS or through the API:
Network {
labelLayout: true;
}
LabelLayout {
class:
'ilog.tgo.graphic.graphlayout.labellayout.IltAnnealingLabelLayout';
obstacles[0]: NETWORK_ELEMENTS;
obstacles[1]: LINKS;
}
void setObstacles (IltLabelLayoutConstants[] types) void setObstacles (int index, IltLabelLayoutConstants type) IltLabelLayoutConstants[] getObstacles() IltLabelLayoutConstants getObstacles (int index)
The following constraints exist for label layout:
performLayout() whenever any object with a label changes. The ILOG JViews algorithm for annealing label layout used in JViews TGO consumes a lot of resources. Therefore, it is not recommend to call the method performLayout() often. Note also that the layout does not always find the same position for the labels. See the ILOG JViews Diagrammer User's Documentation for more information.
Please note that you can configure the label layout in a CSS file through the labelLayout property. For more information, see The LabelLayout Rule.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |