Drawing the activity name on top of the activity bar

Article ID: 2380
Last updated: 29 May, 2018
Article ID: 2380
Last updated: 29 May, 2018
Revision: 3
Views: 664
Posted: 15 Nov, 2010
by Dean J.
Updated: 29 May, 2018
by Gargani A.


I have activities with long names, and often, the activity name in the bar is truncated. How can I force the drawing of my activity labels so that they are displayed entirely?


You can use the IlvActivityCompositeRenderer for that.

In the bottom part, use a IlvActivityGraphicRenderer in which you simply draw a IlvRectangle.
In the top part, you can use the IlvActivityLabel, but you need to override its getBounds() method to make sure the label is being drawn at the right place.


// Get the default activity renderer for the Gantt chart
IlvDefaultActivityRendererFactory rendererFactory =

// Create a composite Renderer
IlvActivityCompositeRenderer compositeRenderer = new IlvActivityCompositeRenderer();

// Draw the bar:
// a red rectangle...
IlvRectangle rectangle = new IlvRectangle(new IlvRect(0, 0, 100, 100), true, true);
// Add this rectangle in a IlvActivityGraphicRenderer
IlvActivityGraphicRenderer bar = new IlvActivityGraphicRenderer(rectangle);
// Now add this renderer for the bar to the renderer factory

// Make sure the bar does not fill all the space
// So leave the top half for the label...

// Now create the label
IlvActivityLabel label = new IlvActivityLabel(bar) {
  // we need to change the getBounds of this label, 
  public IlvRect getBounds(IlvActivityGraphic ag, IlvTransformer t) {
    IlvLabelInterface label = (IlvLabelInterface)getGraphic();
    // make sure we've set the string to the label
    IlvStringProperty property = getDisplayedProperty();
    if (property != null) {
    IlvRect refBox;
    if (getMainRenderer() != null) {
      refBox = getMainRenderer().getBounds(ag, t);
    } else {
      refBox = ag.getDefinitionRect(t);
    // We have computed the correct position where we want to draw the label
    IlvRect labelBox = label.getLabelBBox(null);
    labelBox.x = refBox.x + getOffset();
    labelBox.y = refBox.y - labelBox.height;
    return labelBox;
// Now add this label renderer to the composite renderer
// and to finish, add this composite renderer to the renderer factory

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2380
Last updated: 29 May, 2018
Revision: 3
Views: 664
Posted: 15 Nov, 2010 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Also listed in

Others in this category