Rogue Wave JViews Diagrammer Code Example: Rotated Label Layout


Description

This sample illustrates the Annealing Label Layout provided by the JViews Label Layout module. It shows how to automatically place labels close to polyline links of a grapher. It also shows how annealing label layout handles rotated labels.

How to Use the Code Example

How to Run the Code Example as an Application

This code example can also be run as an application. The installation directory contains an executable JAR file, rotated-label-layout.jar, that allows you to execute the code example with a double click from a file browser. Note that if you are using Internet Explorer, you can open the installation directory and execute the JAR file from the browser. This technique may not work in other Web browsers.

Alternatively, you can run the code example application from the command line. First check that the Ant utility is properly configured. If not, see the instructions on how to configure Ant for Rogue Wave JViews.

Then, go to the installation directory of the code example and type:

ant run

Topics Covered

Detailed Description

This applet illustrates how to automatically place labels close to polyline links of a grapher. The same mechanism can be used to place labels close to any polylines, e.g., it can be used to label the roads of a map: each label is placed close to the polyline object that represents the road. The label layout algorithm used in this sample is based on Simulated Annealing.
It tries to place labels such that the overlaps among labels, and between labels and obstacles are small. Overlaps are avoided in order to keep labels readable.
Simulated annealing is a quality controlled, randomized iterative heuristic. The labels are placed according to a temperature scheme, and the quality of the placement increases when the temperature decreases. The quality is defined by the amount of overlaps between pairs of labels and between labels and obstacles. The fewer overlaps the higher the quality. Simulated annealing, as randomized algorithm, does not guarantee a placement of the labels without overlaps. However, it produces a quality layout with a high probability.

Notes about this Applet



Installation Directory

The Rotated Label Layout code example is installed here.

Classes Involved

Source Files

Copyright © Rogue Wave Software, Inc. 1997, 2015. All rights reserved. Legal terms.