A halo is an outline of constant width that is drawn around a shape or label. It is typically drawn in a color that contrasts with that of the haloed object itself, to make the object clearly visible on all backgrounds.

halo
Figure 1. Halos improve label visibility

The following painters have built-in support for halos:

You can enable halos on other painters using the class TLcdGXYHaloPainter. This class wraps around an existing ILcdGXYPainter and adds a halo to anything drawn by the wrapped painter.

All halo-enabled painters share a common set of methods to configure the halo effect:

  • setHaloEnabled specifies whether or not to draw halos.

  • setHaloThickness sets the thickness (in pixels) of the halo. Note that higher values result in reduced performance. A value of 1 or 2 pixels is recommended.

  • setHaloColor sets the color of the halo. Choose this such that it contrasts well with the color of the shape or label to which the halo is added.

  • setUseImageCache specifies whether or not the painter should cache image representations of the haloed objects. Enabling this can compensate for the performance overhead associated with enabling halos. When caching is off, the painter must redraw the halo for every repaint. When caching is enabled, the painter can paint the object and its halo once and draw the cached image on the view for subsequent repaints.

  • clearImageCache removes objects from the image cache. There may be situations in which an object or its label changes, without the painter knowing about it. In that case, any image that the painter may have already cached for this object becomes invalid and should thus be recreated. By calling clearImageCache, applications can force this behavior whenever necessary. Two versions of clearImageCache exist: one with an Object parameter, which removes only the image cached for that particular object, and one without parameters, which removes all currently cached images.