The default labeling model is suitable only if the underlying data
structure is an IlvManager. The case may arise when an
application uses its own classes and when, for some reason, you do
not want to replace these classes with Rogue Wave® JViews classes
such as
IlvManager
and IlvLabel. Here, you cannot use the default
labeling model. To enable the label layout algorithms to work with
these data structures, you must write a custom labeling model (that
is, a subclass of
IlvLabelingModel
).
The custom labeling model must implement all the abstract methods of the
IlvLabelingModel
class. The nonabstract methods of this class have a default
implementation that is functional. However, they may not be optimal
because they do not take advantage of the characteristics of the
underlying graph implementation. In this case, they can be
overridden as well. The efficiency of the layout algorithm depends
directly on the efficiency of the implementation of the labeling
model and the underlying data structure.
The following minimum set of methods must be
implemented:
abstract Enumeration getLabels()
abstract boolean isLabel(Object obj)
abstract void moveLabel(Object label, float x, float y, boolean redraw)
abstract double getLabelOverlap(Object label1, IlvRect bbox1, Object label2, IlvRect bbox2, float minDist)
abstract Enumeration getObstacles()
abstract boolean isObstacle(Object obj)
abstract double getObstacleOverlap(Object label, IlvRect labelBBox, Object obstacle, IlvRect obstacleBBox, float minDist)
abstract IlvRect boundingBox(Object labelOrObstacle)
These methods are described in The IlvLabelingModel Class.
If the label layout algorithm is to support rotated labels, the new
labeling model must additionally implement the interface IlvLabelingModelWithRotation.