Constructs a new graphics view and initializes the following:
Return the filter function, which determines if an activity will be rendered or not. An activity will be drawn if the function returns "true".
the predicate / the filter function for activities
Returns the list of calendars that are registered with the graphics view. Calendars are used to render static information in the background of each row. One example are the days that are considered weekend days (e.g. saturday and sunday). They will be drawn with a gray background.
the calendars drawn by the graphics view
Gets the value of the property dragAndDropFeedback.
Returns the current drag and drop information
Returns a callback that will return the layer on which a dragged activity will be placed once the drop operation has finished.
Calculates and returns the earliest time used by all rows in the model.
the earliest time used by the graphics view
Returns the currently active editing mode, e.g. "changing start time", "changing end time", "dragging horizontally", "dragging vertically", etc... The property is read-only as it can not be set from the outside. It is being updated when the user moves the pointer cursor on top of an activity. The edit mode depends on the location of the cursor (left or right edge, center). See setActivityEditingCallback(Class, Callback) for mapping pointer events to editing operations.
the currently active edit mode
Instruct the graphics view to query the activity repositories also for activities that are ending right in front of the visible area or starting right after the visible area. Querying the extra pixels is important for activities that have negative bounds (e.g. milestones: they would only become visible if their time is inside the visible area, but their diamond shape might actually already reach into the area).
the number of extra pixels added to the visible area
Returns fixed cell size for controls that are based on the virtual flow control. This value is not used by all subclasses of this class. Using a fixed cell size can result in a performance gain.
the fixed cell size (default is -1)
Returns a set that is used to store the currently highighted activities. An activity added to this set will start blinking and draw the attention of the user to it.
the set of highlighted activities
Returns a set that is used to store the currently highlighted rows. A row added to this set will start blinking and draw the attention of the user to it.
the set of highlighted rows
A property used to store the currently used lasso selection behaviour. This value of this property controls when an activity is actually considered selected by the lasso: does it need to be completely inside the lasso bounds or is it enough when it gets touched by the lasso?
the currently used lasso selection behaviour
Calculates and returns the latest time used by all rows in the model.
the latest time used by the graphics view
Returns the list that is used to store all layers of the model.
a list of layers
Returns the x coordinate for the given time.
the time for which to lookup a coordinate
the x coordinate for the given time
A property used to store the number of grid levels that the user wants to see in the graphics view. The value of this property must be between 1 and 5. The grid level depends on the number of scales shown by the dateline (see Dateline.getScaleResolutions()). If the dateline is currently showing two scales (e.g. days and weeks) then the graphics view and the GridLinesLayer can also display two different grid lines, for example a light gray one for days and a dark gray one for weeks.
Returns a callback that will be invoked when the user drags an activity over a row of the given type. The callback implementation then determines if a drop would be accepted in the given row.
A property used to store a callback for creating the header placed to the left of each row in the graphics view.
the row header callback property
Width of the so-called "row headers". These are placed in front of every row inside the graphics area. For proper layout the width of all row headers has to be the same.
the width in pixels used for all row headers
Returns the list that is used to store all rows of the model.
a list of rows
Returns the list of currently selected activities.
the list of selected activities
A property used to store the currently supported selection mode. The graphics view supports single, multiple, and none.
the currently used selection mode (single, all, none)
Returns the time at the given location.
the x-coordinate for which to retrieve the time
the time at the given location
Returns the timeline control above the graphics
the timeline control above the graphics
A property used to enable / disable the autogrid mode. The autogrid mode will cause activities to snap to times based on the currently shown granularity of the dateline. If the dateline is showing "days" then the activities will snap to the beginning and / or end of a day. If the dateline is showing hours then the activities will snap to full hours.
true if the autogrid mode is enabled
Controls whether the marked time interval property of the Eventline will be automatically set when the user performs certain editing operations (e.g. move an activity horizontally). The default is "true".
true if the marked time interval gets updated automatically
Returns if the graphics will be redrawn whenever the data in any of the activity repository changes. The default value is true. Applications can use this property to disable the redrawing when they know that they have to add a lot of activities but do not want the chart to perform a lot of redraws. The graphics will be redrawn right away when the value of this property changes from true to false or vice versa.
true if automatic redrawing will be performed (default)
Returns true if any kind of grid support is enabled.
true if any kind of grid support is enabled
Returns a flag value used to toggle the highlighting effect
a flag value used to toggle the highlighting effect
Determines whether the user can perform a horizontal drag with a pointer drag.
true if the user can perform horizontal scrolling
Returns whether the lasso selection tool is currently in use or not.
true if the user is currently performing a lasso selection operation.
Returns whether the user can use the lasso for selecting multiple activities at once.
true if the user can use the lasso
Returns whether the lasso selection tool is using the currently active grid settings.
true if the lasso is obeying the current virtual grid settings
A property used to control whether a horizontal cursor line will be shown by the graphics view. The line will always follow the location of the pointer cursor.
true if the cursor will be shown
A property used to control whether vertical lines will be shown for a marked time interval (e.g. while dragging the marked interval will display the new location of the dragged activity).
true if the marker lines will be shown
Returns if the row headers will be shown to the user or not.
true if the row headers will be visible
A property used to control whether a vertical cursor line will be shown by the graphics view. The line will always follow the location of the pointer cursor.
true if the cursor will be shown
Registers a callback used to determine if a given editing operation can be used for a given activity.
the type of the activity for which to use the callback
the callback
Sets filter function, which determines if an activity will be rendered or not. An activity will be drawn if the function returns "true".
the filter function
Sets if true the autogrid mode is enabled.
if true the autogrid mode is enabled
Sets the value of autoMarkedTimeIntervalProperty().
if true the marked time interval will be updated automatically
Sets the graphics redraw after every repository change event.
true if then the graphics redraw after every repository change event
Sets the value of the property dragAndDropFeedback.
Sets the current drag and drop information
Sets a callback that will return the layer on which a dragged activity will be placed once the drop operation has finished.
Sets the number of extra pixels added to the visible area
the number of extra pixels added to the visible area
Sets the fixed cell size.
the fixed cell size, -1 to disable fixed cell size
Sets if the user can perform horizontal scrolling.
if true the user can perform horizontal scrolling
Sets the value of lassoEnabledProperty().
if true the lasso will be usable by the user
Sets the lasso selection behaviour to use.
the lasso selection behaviour to use
Sets whether the lasso selection tool is using the currently active grid settings.
if true the lasso will obey the grid
Sets the maximum number of grid levels.
the maximum number of grid levels, a value between 1 and 5
Sets a callback that will be invoked when the user drags an activity over a row of the given type. The callback implementation then determines if a drop would be accepted in the given row.
Sets the factory used for creating the row header.
the factory used for creating the row header nodes
Width of the so-called "row headers". These are placed in front of every row inside the graphics area. For proper layout the width of all row headers has to be the same.
Sets the value of the rowsProperty().
the new rows to display
Sets the selection mode.
the new selection mode
Sets if true a horizontal cursor line will be shown.
if true a horizontal cursor line will be shown
Sets if the marker lines will be shown.
if true marker lines will be drawn for the currently marked time interval
Sets if teh row headers will be shown to the user or not.
Sets if the vertical cursor will be shown
if true a vertical cursor line will be shown
Sets the timeline control above the graphics.
the timeline control above the graphics
Makes the Timeline show a time range starting with the earliest time used and ending with the latest time used by all currently loaded rows.
Makes the Timeline start with the earliest time used by the currently loaded rows.
Makes the Timeline show the latest time used by the currently loaded rows.
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. 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. ScheduleJs 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 ScheduleJs. 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 callingSystemLayer.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 pointer event / pointer location to a 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 callingsetActivityEditingCallback(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 / EventsEvents 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 viaaddEventHandler(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 / Hit point Detection
The graphics view provides support for finding out information about a given position. Activities can be found by calling
getActivityBoundsAt(double, double)
orgetActivityRefAt(double, double)
. The time at an x-coordinate can be looked up by callinggetTimeAt(double)
. The opposite direction is also available: a location can be found for a given time by callinggetLocation(Instant)
.Context Menu
Context menus can be set on any control but due to the complexity 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.1.0