Set the stacking order for Gantt activities

Article ID: 2255
Last updated: 29 May, 2018
Article ID: 2255
Last updated: 29 May, 2018
Revision: 3
Views: 526
Posted: 28 Mar, 2007
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How do I set the stacking order for Gantt activities?

Answer

The customization of the activity layout algorithms is possible and this is the recommended approach to control the stacking order of the

activity graphics within a row. Do this by creating a customized IlvActivityLayout and then calling the new IlvScheduleChart.setActivityLayout() method with an instance of the custom layout. The easiest approach is to subclass IlvActivitySimpleLayout and override the two arrange() methods like this:

public void arrange(IlvGanttRow row, IlvActivityGraphic[] graphics) {

// IlvSimpleActivityLayout arranges graphics within row, but does not

// guarantee z-ordering.

super.arrange(row, graphics);

// Reorder graphics within the array to match desired z-ordering.

// After this method exits, the Gantt uses the array ordering to

// set the activity graphic indices.

Arrays.sort(graphics, new Comparator() {

public int compare(IlvActivityGraphic o1, IlvActivityGraphic o2) {

Date start1 = o1.getActivity().getStartTime();

Date start2 = o2.getActivity().getStartTime();

return start1.compareTo(start2);

}

});

}

// This method is typically only called when a single reservation

// is added to the data model.

public void arrange(IlvGanttRow row, IlvActivityGraphic graphic) {

// IlvSimpleActivityLayout does not guarantee z-order, so we perform

// a layout of the entire row.

arrange(row, row.getActivityGraphics());

}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2255
Last updated: 29 May, 2018
Revision: 3
Views: 526
Posted: 28 Mar, 2007 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Also listed in


Others in this category