The right-hand side of every Gantt chart is a layer container. This container gets created by the component factory of the Gantt chart. The following image depicts the structure of the layer container and shows how the container is composed of a stack of layers. The layer container manages three different types of layers that are supported by the framework: system layers, timeline object layers, and custom layers.

Layer Stack
System layers are non-optional layers required by the framework. They provide the various features supported by the Gantt chart. Timeline object layers are responsible for rendering activities and events (the data). Custom layers are used to extend the feature list to meet application-specific requirements.
Model vs. UI Layer
When reading about layers and the layer container it is important to understand the difference between model layers and user interface (UI) layers. Model layers are provided by the Gantt chart model. The IGanttChartModel interface defines a method called getLayers(). This method returns an iterator over ILayer instances. Each one of these ILayer instances will result in the creation of a timeline object layer, which is a UI layer that will be added to the layer container. UI layers have graphical attributes while model layers only carry data and features requests.
Layer Ordering
The layers approach found in FlexGantt is very similar to the one used in graphics applications. These applications have many things in common but the one thing that can always be found is different ways of changing the order of layers. It is only logical that FlexGantt supports the same feature. The following table lists the available operations:
| Method | Description |
|---|---|
| void moveBack(ILayer) | Moves the given layer behind the layer that is currently shown below it. |
| void moveForward(ILayer) | Moves the given layer in front of the layer that is currently shown above it. |
| void moveToBack(ILayer) | Moves the given layer all the way to the back. All other layers will be drawn on top. |
| void moveToFront(ILayer) | Moves the given layer all the way to the front. All other layers will be drawn below. |
| void hideLayer(ILayer) | Hides the given layer. The layer becomes invisible. |
| void showLayer(ILayer) | Shows the given layer. The layer becomes visible. |
It should be noted that these operations are only available for timeline object and for custom layers. System layers appear in a fixed order, which gets determined by two protected methods of LayerContainer. This default order can be changed by overriding these methods. For more information on this topic, please refer to the chapter called „System Layers“.
Layer Lookup
Layers are not „manually“ added to or removed from the layer container. Instead the LayerContainer class manages the life-cycle of layers. For the layer creation it delegates to a layer factory. After the layers have been created the container owns them. The following methods are available for layer access:
| Method | Description |
|---|---|
| T getSystemLayer(ClasslayerType) | Returns the system layer instance that was created for the given system layer type. |
| TimelineObjectLayer getTimelineObjectLayer(ILayer) | Returns the timeline object layer instance that was created for the given model layer instance. |
| AbstractCustomLayer getCustomLayer(ILayer) | Returns the custom layer instance that was created for the given model layer instance. This method will only work if the model layer is a custom model layer. |
| boolean ILayer.isCustomLayer() | It is important to know that the LayerContainer recreates its layer stack after certain events have occurred on the Gantt chart model. Hence, applications should not keep references to the layers for a longer period of time. |
Layer Selector Support
The layer container stores an icon map used to retrieve icons for layers. These icons can then be used in other FlexGantt components like the LayerPalette / LayerSelector. The ILayer class can not provide an icon by itself, since the model and the UI are supposed to be in different classes.

Layer Selector / Layer Palette
| Method | Description |
|---|---|
| Icon getLayerIcon(ILayer) void setLayerIcon(ILayer, Icon) |
Sets / gets an icon for the given layer. FlexGantt registers a default icon, which gets retrieved from the IconRegistry via the key IconID.LAYER. |
Overview / Radar Selector Support
The overview selector implements a radar-like feature, which provides an overview over the entire data currently stored in the Gantt chart model. Each timeline object gets shown as a thin line or a small dot. To add a little bit more meaning to this kind of representation the application developer can map different colors and icons to so-called „status“ objects. A good example for a status object is the value of an enumerator, which lists the different states that a timeline object can
be in.
public enum Status {
NEW,
PLANNED,
EXECUTED,
ARCHIVED
}
The values of this enumerator can then be used to register the colors and icons:
layerContainer.setTimelineObjectStatusColor(Status.NEW, Color.WHITE);
layerContainer.setTimelineObjectStatusColor(Status.PLANNED, Color.RED);
layerContainer.setTimelineObjectStatusColor(Status.EXECUTED, Color.GREEN);
layerContainer.setTimelineObjectStatusColor(Status.ARCHIVED, Color.GRAY);
//
// Only display an icon for new timeline objects.
//
layerContainer.setTimelineObjectStatusColor(Status.NEW, new NewIcon());
The status objects can then be set on the timeline objects:
DefaultTimelineObject tlo = new DefaultTimelineObject();
tlo.setStatusObject(Status.NEW);
These settings will cause the overview selector to display the timeline objects in four different colors depending on their state. Those timeline objects that are new will also show an icon, which will make it easy for the user to navigate to them and to perform some kind of scheduling action on them.
| Method | Description |
|---|---|
| Icon getTimelineObjectStatusIcon(Object) void setTimelineObjectStatusIcon(Object, Icon) |
Gets or sets an icon for the given status object. |
| Color getTimelineObjectStatusColor(Object) void setTimelineObjectStatusColor(Object) |
Gets or sets a color for the given status object. |
Highlighting
An extremely helpful feature provided by the LayerContainer is its ability to highlight timeline objects. Highlighting means that one or more timeline objects will be drawn in two different ways, which will cause them to blink. Making them blink will force the userʻs attention on them. Highlighting is implemented as a specialized thread (inner class HighlightThread), which periodically puts the layer container into two different states and then calls its repaint() method. The two states are passed to the timeline object renderers. This way the renderers can draw the highlight feedback. The default renderer implementations simply use different colors for the two states. This is sufficient to make then blink. The following code fragment is taken from the DefaultTimelineObjectRenderer class. The method paints the content of an activity (bar):
/**
* Renders the timeline object if it is an activity (different start and end
* time = duration).
*/
protected void paintActivityContent(Graphics g) {
int w = getWidth() - 1;
int h = getHeight() - 1;
Graphics2D g2d = (Graphics2D) g;
if (highlighted) {
g2d.setPaint(new GradientPaint(0, 0, highlightFillColor1, 0, h / 2, highlightFillColor2));
} else if (selected) {
g2d.setPaint(new GradientPaint(0, 0, selectionFillColor1, 0, h / 2, selectionFillColor2));
} else {
g2d.setPaint(new GradientPaint(0, 0, activityFillColor1, 0, h / 2, activityFillColor2));
}
... more drawing going on here
}
The „highlighted“ flag was set in the getTimelineObjectRendererComponent() method of the renderer. The following table lists the methods related to highlighting:
| Method | Description |
|---|---|
| void addHighlightedObject(TimelineObjectPath path) | Adds a timeline object path to the list of highlighted objects. The layer container will automatically start the highlighting thread. |
| void addHighlightedObjects(Collection paths) | Adds several timeline object paths at the same time. The layer container will automatically start the highlighting thread. |
| void removeHighlightedObjects(Collection paths) | Removes a timeline object path from the list of highlighted objects. The layer container automatically stops the highlighting thread if the list is now empty. |
| void clearHighlightedObjects() | Clears the list of highlighted timeline objects. The highlighting thread will be stopped automatically. |
| boolean isHighlighted(TimelineObjectPath path) | Determines if the given timeline object is a member of the list of highlighted objects. |
| void setHighlighting(boolean b) | Turns highlighting on and off. This method gets called by the highlight thread with the alternating values „true“ and „false“. |
| boolean isHighlighting() | Determines if the layer container is currently in the second mode „highlight“. |
| long getHighlightingDelay(); setHighlightingDelay(long delay) |
Gets / sets the delay between two calls of the highlighting thread to setHighlighting(boolean). The lower this value, the higher the blink frequency. |
Some notes:
- The layer container automatically starts or stops the highlight thread whenever a timeline object path gets added to or removed from the list of highlighted paths.
- The highlight feature is used by the Gantt chart when it tries to show a „message context“. If the message is of type TimelineObjectPathMessage then the timeline object path stored in the message object will be passed to the layer container's addHighlightedObject(TimelineObjectPath) method.
- Highlighting will only be visible if the renderers support it. Please make sure that your renderers make use of the „highlighted“ flag passed to them.
Selection Models
The layer container manages the selection models used for the timeline object layers. This is due to the fact that the UI layers for the model layers are very volatile. They can be created and deleted after model changes but the selections should remain the same. This is why the layer container manages a map of selection models where the model layers are used as the key.
| Method | Description |
|---|---|
| ITimelineObjectLayerSelectionModel getSelectionModel(ILayer layer) void setSelectionModel(ILayer, ITimelineObjectLayerSelectionModel) |
Gets / sets the selection model for the given layer. |


