Class GraphicsBase<R extends Row<?,​?,​?>>

Type Parameters:
R - the type of the rows shown by the graphics
All Implemented Interfaces:
Styleable, EventTarget, Skinnable
Direct Known Subclasses:
ListViewGraphics, SingleRowGraphics, SplitPaneGraphics, VBoxGraphics

public abstract class GraphicsBase<R extends Row<?,​?,​?>>
extends FlexGanttFXControl
The graphics view control is responsible for the rendering of activities and system layers, the editing of activities, the event notifications, the hit detection, system layer management, and for context menu support.

Rendering

The graphics view uses the canvas API of JavaFX. This is due to the complex nature of a Gantt chart and due to the large data volumes often observed in Gantt charts. Directly rendering large quantities of activities into a bitmap is much faster than constantly updating the scene graph and reapplying CSS styling. FlexGanttFX implements a pluggable renderer architecture where renderer instances can be mapped to activity types, very similar to the way Swing was doing it. The following code is an example of how to register a custom renderer for a given "Flight" activity type. Please note that the graphics view is capable of displaying activities in three different layouts, hence the layout type must also be passed to the method.

setActivityRenderer(Flight.class, GanttLayout.class, new FlightRenderer());

System Layers

Activities are not the only thing that need to be rendered. There are also the current time ("now"), grid lines, inner lines, agenda / chart lines, etc... All of these things are rendered by so-called system layers (see SystemLayer). The graphics view manages two lists of these layers. One list for background layers (getBackgroundSystemLayers()) and one list for foreground layers (getForegroundSystemLayers()).
Background layers are drawn "behind" activities, foreground layers are drawn "in front of" activities. Each one of these lists are already pre-populated but can be changed by the application. For more information on the available system layers, please refer to their individual documentation.
System layers can be turned on and off directly via the API of GraphicsBase. There is a boolean property for each layer that ships with FlexGanttFX. The value of these properties can be set by calling the methods that follow the pattern setShowXYZLayer. System layers that are controlled like this will appear and disappear with a fade in / fade out animation, while calling SystemLayer.setVisible(boolean) directly will be without any animation.

Editing Customization

Two different callbacks are used to control the editing behaviour of activities. The first maps a mouse event / mouse location to an GraphicsBase.EditMode and can be registered by calling setEditModeCallback(Class, Class, Callback). The second callback is used to determine whether a given editing mode / operation can be applied to an activity at all. This callback is registered by calling setActivityEditingCallback(Class, Callback). Most applications will only need to work with the second callback and keep the defaults for the edit mode locations (for example: right edge used to change end time, left edge used to change start time).

Notifications / Events

Events of type ActivityEvent are sent whenever the user performs a change inside the graphics view. Applications that want to receive these events can either call any one of the setOnActivityXYZEvent() methods or by adding an event handler directly via addEventHandler(ActionEvent.ACTIVITY_XYZ, ...). Events are fired while the change is being performed and once it has been completed. For this the ActivityEvent class lists event types with the two different endings CHANGING and CHANGED.

Filtering

The data displayed by the graphics control can be filtered in two ways: first by showing / hiding rows, second by showing / hiding activities. Row filtering is done by the parent GanttChart controls while activity filtering is done by the graphics control via an activity filter predicate:

setActivityFilter(Predicate<Activity> filter);

Finding / Lookup / Hitpoint Detection

The graphics view provides support for finding out information about a given position. Activities can be found by calling getActivityBoundsAt(double, double) or getActivityRefAt(double, double). The time at an x-coordinate can be looked up by calling getTimeAt(double). The opposite direction is also available: a location can be found for a given time by calling getLocation(Instant).

Context Menu

Context menus can be set on any control in JavaFX but due to the complexitiy of the graphics view it does make sense to provide additional built-in support. By calling setContextMenuCallback(Callback) a context menu specific callback can be registered with the graphics control. This callback will be invoked when the user triggers the context menu. A callback parameter object (see GraphicsBase.ContextMenuParameter) will be passed to the callback already populated with the most important values that might be relevant for building a context menu.
Since:
1.0