Component Factory
Every FlexGantt Gantt chart is a container, which contains several other components (tree table, timeline, layer container, ...). The Gantt chart uses a factory for creating these components. This design allows an application developer to replace the default component factory with a custom one, which then can create custom components. A custom component factory needs to be passed to the constructor of a Gantt chart as it is needed early on when the chart gets created.
Example
The following code shows a custom component factory, which returns a custom layer container. This layer container is custom because it uses its own layer factory.
/**
* Copyright 2006, 2007
* Dirk Lemmermann Software & Consulting
* http://www.dlsc.com
*/
package com.dlsc.flexgantt.manual;
import com.dlsc.flexgantt.model.gantt.IGanttChartModel;
import com.dlsc.flexgantt.swing.AbstractGanttChart;
import com.dlsc.flexgantt.swing.DefaultComponentFactory;
import com.dlsc.flexgantt.swing.layer.LayerContainer;
import com.dlsc.flexgantt.swing.treetable.TreeTable;
public class WatermarkComponentFactory extends DefaultComponentFactory {
/**
* Creates a layer container that uses the watermark layer factory.
*/
@Override
public LayerContainer createLayerContainer(AbstractGanttChart gc,
TreeTable table, IGanttChartModel model) {
return new LayerContainer(gc, model, table, WatermarkLayerFactory
.getInstance());
}
}
