Grid Components
A feature often found in Gantt charts is the ability to perform editing operations based on a virtual / invisible grid. This way timeline objects can be dragged and dropped in such a way that their start and / or end times always line up with the beginning or end of a day, an hour or a minute.
In FlexGantt this feature is supported via the IGridComponent interface. The eventline and the layer container both implement this interface. Grid components support setting a granularity, which will be used in combination with the grid policy. The policy bases its rounding operations on the currently set granularity. Grid components also support an automatic granularity, which means that no granularity needs to be set on the component but instead the component will use the (minor) granularity currently shown in the dateline. If the dateline shows days then the grid will be based on days. If weeks are shown then the grid will be based on weeks.
A grid component also needs to support grid component listeners so that the user interface can react and display the currently used grid granularity (e.g. the grid control).
Grid Control
It is important to note that
each grid component can have its own grid policy referenced
in its own policy provider object. This is the reason why
the IGridComponent interface defines a method for
retrieving a grid policy from the grid component.
public interface IGridComponent {
/**
* Specifies a new granularity to be used by the grid component. This
* granularity will be used by the {@link IGridPolicy} to calculate grid
* locations. It will not be used if the automatic grid feature is turned
* on.
*/
void setGridGranularity(IGranularity granularity);
/**
* Returns the granularity used by the grid component.
*/
IGranularity getGridGranularity();
/**
* Specifies whether the component is using an automatic grid. A grid is
* automatic if it is not based on the grid granularity but on some other
* granularity of various origin. The dateline, for example, displays a
* major and a minor time (granularity). The minor granularity can be used
* for calculating grid locations.
*/
void setGridAutomatic(boolean b);
/**
* Determines whether the component is using an automatic grid. A grid is
* automatic if it is not based on the grid granularity but on some other
* granularity of various origin. The dateline, for example, displays a
* major and a minor time (granularity). The minor granularity can be used
* for calculating grid locations.
*/
boolean isGridAutomatic();
/**
* Returns the grid policy used by the grid component. Each component can
* have its own grid policy, which is used to determine which granularities
* are supported by the component.
*/
IGridPolicy getGridPolicy();
/**
* Returns the name of the grid component. This is useful for displaying a
* grid control so that the controls used for the different grid components
* can be distinguished from each other.
*/
String getGridComponentName();
/**
* Adds a listener to the grid component. The listener will be informed
* whenever the grid granularity used by the component gets changed.
*/
void addGridComponentListener(IGridComponentListener l);
/**
* Removes a listener from the grid component.
*/
void removeGridComponentListener(IGridComponentListener l);
}