Module com.flexganttfx.model
Package com.flexganttfx.model
Class Row<P extends Row<?,?,?>,C extends Row<?,?,?>,A extends Activity>
java.lang.Object
com.flexganttfx.model.Row<P,C,A>
- Type Parameters:
P
- the type of the parent row (example: row is of type "Building" and parent type is "Factory" to express that the factory consists of several buildings).C
- the type of the children rows (example: row is of type "Building" and children type is "Machine" to express that the building houses several machines).A
- the type of the activities shown in this row (example: row is of type "Building", activities are "ProductionOrders" that are executed in this building).
public abstract class Row<P extends Row<?,?,?>,C extends Row<?,?,?>,A extends Activity>
extends Object
A row object is used to store the activities found on a row of the Gantt
chart. These activities are not stored directly on the row but in an activity
repository (see
getRepository()
). The default repository is of type
IntervalTreeActivityRepository
and can be replaced by calling
setRepository(ActivityRepository)
. Activities can be placed on lines
within the row. The row delegates this work to a LinesManager
. The
default manager is of type EqualLinesManager
. To replace the manager
simply call setLinesManager(LinesManager)
.
Code Example
public class Aircraft extends Row<Fleet, CrewMember, Flight> { }This now allows you to call:
Aircraft aircraft = new Aircraft(); ... Fleet fleet = aircraft.getParent(); List<CrewMember> crew = aircraft.getChildren();
Lazy Loading
Simply override theisLeaf()
method to control
whether a row is a parent row or not. Then listen to changes of the expanded
property to load the children when the user toggles the expansion state.
static class HelloLazyRow extends Row<HelloLazyRow, HelloLazyRow, Activity> { public HelloLazyRow(String name) { super(name); expandedProperty().addListener(it -> loadChildrenLazily()); } @Override public boolean isLeaf() { return false; } private void loadChildrenLazily() { getChildren().add(new HelloLazyRow("Child 1")); getChildren().add(new HelloLazyRow("Child 2")); ... getChildren().add(new HelloLazyRow("Child N")); } }
- Since:
- 1.0
-
Property Summary
PropertiesTypePropertyDescriptionfinal BooleanProperty
The property used to store the expansion state of the row.final DoubleProperty
The property used to store the height of the row.final ObjectProperty<Layout>
The property used to store the layout used for laying out the activities that are directly associated with the row (and not on an inner line).final ReadOnlyBooleanProperty
Represents the TreeItem leaf property, which is true if the TreeItem has no children.final IntegerProperty
The property used to keep track of the number of inner lines shown by the row.final ObjectProperty<LinesManager<A>>
The property used to store theLinesManager
instance for this row.final DoubleProperty
The property used to store the maximum height of the row.final DoubleProperty
The property used to store the minimum height of the row.final StringProperty
The property used to store the name of the row.final ReadOnlyObjectProperty<P>
Returns a read-only property used to store the parent row of this row.final ObjectProperty<ActivityRepository<A>>
The property used to store the activity repository for the row.final ReadOnlyBooleanProperty
The property used to express whether a row is currently showing in the view or not.final ObjectProperty<Object>
The property used to store a row-specific user object.final ObjectProperty<ZoneId>
The property used to store the zone ID for this row. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
The default height of a row (24 pixels). -
Constructor Summary
ConstructorsConstructorDescriptionRow()
Constructs a new row with anIntervalTreeActivityRepository
and anEqualLinesManager
.Constructs a new row with anIntervalTreeActivityRepository
and anEqualLinesManager
and the given name. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addActivity
(Layer layer, A activity) Adds the given activity for the given layer to this row.final void
Removes all activities from the row.final void
clearActivities
(Layer layer) Removes all activities on the given layer from the row.final BooleanProperty
The property used to store the expansion state of the row.final ObservableList<Calendar<?>>
Returns a list of calendars attached to this row.final ObservableList<C>
Returns the list of children of this row.final Instant
Returns the earliest time used by the row.final double
Returns the value of theheightProperty()
.final Instant
Returns the latest time used by the row.final Layout
Returns the value of thelayoutProperty()
.final int
Returns the value of thelineCountProperty()
.final double
getLineHeight
(int lineIndex) Returns the height of the given inner line.final int
getLineIndex
(A activity) Returns the line index for the given activity.final Layout
getLineLayout
(int lineIndex) Returns a line-specific layout for the given line.final double
getLineLocation
(int lineIndex) Returns the location of the given inner line.final LinesManager<A>
Returns the value oflinesManagerProperty()
.final double
Returns the value ofmaxHeightProperty()
.final double
Returns the value of theminHeightProperty()
.final String
getName()
Returns the value of thenameProperty()
.final P
The parent of this row.final Row[]
getPath()
Returns the path to this row, for example [ROOT, Parent1, Parent2, this].final ObservableMap<Object,
Object> Returns an observable map of properties on this row.final ActivityRepository<A>
Returns the value of therepositoryProperty()
.final Object
Returns the value ofuserObjectProperty()
.final ZoneId
Returns the value of thezoneIdProperty()
.boolean
hasChildren
(Predicate predicate) Checks whether the given row has any child rows (no matter how deep) that fulfill the given predicate.final boolean
Tests if the row has properties.final DoubleProperty
The property used to store the height of the row.final boolean
Returns the value of theexpandedProperty()
.boolean
isLeaf()
A row is a leaf in the tree table view on the left-hand side of the Gantt chart if it has no children.final boolean
Returns the value ofshowingProperty()
.final ObjectProperty<Layout>
The property used to store the layout used for laying out the activities that are directly associated with the row (and not on an inner line).final ReadOnlyBooleanProperty
Represents the TreeItem leaf property, which is true if the TreeItem has no children.final IntegerProperty
The property used to keep track of the number of inner lines shown by the row.final ObjectProperty<LinesManager<A>>
The property used to store theLinesManager
instance for this row.final DoubleProperty
The property used to store the maximum height of the row.final DoubleProperty
The property used to store the minimum height of the row.final StringProperty
The property used to store the name of the row.final ReadOnlyObjectProperty<P>
Returns a read-only property used to store the parent row of this row.final void
removeActivity
(Layer layer, A activity) Removes the given activity from the given layer from this row.final ObjectProperty<ActivityRepository<A>>
The property used to store the activity repository for the row.final void
setExpanded
(boolean expanded) Sets the value of theexpandedProperty()
.final void
setHeight
(double height) Sets the value of theheightProperty()
.final void
Sets the value of thelayoutProperty()
.final void
setLineCount
(int count) Sets the value of thelineCountProperty()
.final void
setLinesManager
(LinesManager<A> manager) Sets the value oflinesManagerProperty()
.final void
setMaxHeight
(double height) Sets the value of themaxHeightProperty()
.final void
setMinHeight
(double height) Sets a new value for theminHeightProperty()
.final void
Sets the value of thenameProperty()
.final void
setRepository
(ActivityRepository<A> repository) Sets the value of therepositoryProperty()
.final void
setUserObject
(Object obj) Sets the value ofuserObjectProperty()
.final void
Sets the value of thezoneIdProperty()
.final ReadOnlyBooleanProperty
The property used to express whether a row is currently showing in the view or not.toString()
final ObjectProperty<Object>
The property used to store a row-specific user object.final ObjectProperty<ZoneId>
The property used to store the zone ID for this row.
-
Property Details
-
parent
Returns a read-only property used to store the parent row of this row.- Since:
- 1.0
- See Also:
-
leaf
Represents the TreeItem leaf property, which is true if the TreeItem has no children.- Since:
- 1.3
- See Also:
-
expanded
The property used to store the expansion state of the row. The value of this property is needed for controlling the state of the tree items that will be created for the tree table view control on the left-hand side of the Gantt chart.- Since:
- 1.0
- See Also:
-
showing
The property used to express whether a row is currently showing in the view or not. This information can be useful when deciding whether a row needs to update its activities or not, for example in a lazy-loading scenario.- Since:
- 1.0
- See Also:
-
layout
The property used to store the layout used for laying out the activities that are directly associated with the row (and not on an inner line).- Since:
- 1.0
- See Also:
-
repository
The property used to store the activity repository for the row. A repository is used to lookup the activities for a given time interval that needs to be shown on the row.- Since:
- 1.0
- See Also:
-
name
The property used to store the name of the row.- Since:
- 1.0
- See Also:
-
height
The property used to store the height of the row.- Since:
- 1.0
- See Also:
-
minHeight
The property used to store the minimum height of the row. The user will not be able to resize the row to anything smaller than the value of this property.- Since:
- 1.0
- See Also:
-
maxHeight
The property used to store the maximum height of the row. The user will not be able to resize the row to anything larger than the value of this property.- Since:
- 1.0
- See Also:
-
userObject
The property used to store a row-specific user object.- Since:
- 1.0
- See Also:
-
linesManager
The property used to store theLinesManager
instance for this row. The lines manager is used to control the layout of inner lines and the placement of activities on these lines.- Since:
- 1.0
- See Also:
-
zoneId
The property used to store the zone ID for this row. Each row can be placed in a different time zone.- Since:
- 1.0
- See Also:
-
lineCount
The property used to keep track of the number of inner lines shown by the row.- Since:
- 1.0
- See Also:
-
-
Field Details
-
DEFAULT_ROW_HEIGHT
public static final double DEFAULT_ROW_HEIGHTThe default height of a row (24 pixels).
-
-
Constructor Details
-
Row
public Row()Constructs a new row with anIntervalTreeActivityRepository
and anEqualLinesManager
.- Since:
- 1.0
-
Row
Constructs a new row with anIntervalTreeActivityRepository
and anEqualLinesManager
and the given name.- Parameters:
name
- the name of the row (e.g. "Building 1")- Since:
- 1.0
-
-
Method Details
-
getProperties
Returns an observable map of properties on this row.- Returns:
- an observable map of properties on this row
-
hasProperties
public final boolean hasProperties()Tests if the row has properties.- Returns:
- true if node has properties.
-
getParent
The parent of this row. Each row can have only one parent. If a row has no parent, it represents a root in the tree model.- Returns:
- the parent of this row, or null if the row has no parent.
- Since:
- 1.0
-
parentProperty
Returns a read-only property used to store the parent row of this row.- Returns:
- the property used for storing the parent row
- Since:
- 1.0
- See Also:
-
getPath
Returns the path to this row, for example [ROOT, Parent1, Parent2, this].- Returns:
- the path to this row
- Since:
- 1.0
-
getChildren
Returns the list of children of this row.- Returns:
- the children
- Since:
- 1.0
-
hasChildren
Checks whether the given row has any child rows (no matter how deep) that fulfill the given predicate.- Parameters:
predicate
- the test to perform- Returns:
- true if the row has any children where the predicate returns true
-
isLeaf
public boolean isLeaf()A row is a leaf in the tree table view on the left-hand side of the Gantt chart if it has no children. This method may of course be overridden by subclasses to support alternate means of defining how a row may be a leaf, but the general premise is the same: a leaf can not be expanded by the user, and as such will not show a disclosure node or respond to expansion requests.- Returns:
- true if the row is a leaf (has no children rows)
- Since:
- 1.3
-
leafProperty
Represents the TreeItem leaf property, which is true if the TreeItem has no children.- Returns:
- a property for determining if the row is a leaf row
- Since:
- 1.3
- See Also:
-
expandedProperty
The property used to store the expansion state of the row. The value of this property is needed for controlling the state of the tree items that will be created for the tree table view control on the left-hand side of the Gantt chart.- Returns:
- the expanded property
- Since:
- 1.0
- See Also:
-
setExpanded
public final void setExpanded(boolean expanded) Sets the value of theexpandedProperty()
.- Parameters:
expanded
- the new value of the expanded property- Since:
- 1.0
-
isExpanded
public final boolean isExpanded()Returns the value of theexpandedProperty()
.- Returns:
- true if the row is expanded
- Since:
- 1.0
-
showingProperty
The property used to express whether a row is currently showing in the view or not. This information can be useful when deciding whether a row needs to update its activities or not, for example in a lazy-loading scenario.- Returns:
- the showing property
- Since:
- 1.0
- See Also:
-
isShowing
public final boolean isShowing()Returns the value ofshowingProperty()
.- Returns:
- true if the row is currently showing in the UI
- Since:
- 1.0
-
layoutProperty
The property used to store the layout used for laying out the activities that are directly associated with the row (and not on an inner line).- Returns:
- the row layer property
- Since:
- 1.0
- See Also:
-
getLayout
Returns the value of thelayoutProperty()
.- Returns:
- the layout of the row
- Since:
- 1.0
-
setLayout
Sets the value of thelayoutProperty()
.- Parameters:
layout
- the new row layout- Since:
- 1.0
-
repositoryProperty
The property used to store the activity repository for the row. A repository is used to lookup the activities for a given time interval that needs to be shown on the row.- Returns:
- the repository property
- Since:
- 1.0
- See Also:
-
getRepository
Returns the value of therepositoryProperty()
.- Returns:
- the activity repository of the row
- Since:
- 1.0
-
setRepository
Sets the value of therepositoryProperty()
.- Parameters:
repository
- the new repository to use- Since:
- 1.0
-
getEarliestTimeUsed
Returns the earliest time used by the row. This is a convenience method delegating toActivityRepository.getEarliestTimeUsed()
.- Returns:
- the earliest time used by the row / by the activities of the row / earliest start time of any activity on the row
- Since:
getLatestTimeUsed()
, 1.0
-
getLatestTimeUsed
Returns the latest time used by the row. This is a convenience method delegating toActivityRepository.getLatestTimeUsed()
.- Returns:
- the latest time used by the row / by the activities of the row / earliest start time of any activity on the row
- Since:
getEarliestTimeUsed()
, 1.0
-
nameProperty
The property used to store the name of the row.- Returns:
- the name property
- Since:
- 1.0
- See Also:
-
getName
Returns the value of thenameProperty()
.- Returns:
- the name of the row
- Since:
- 1.0
-
setName
Sets the value of thenameProperty()
.- Parameters:
name
- the new name of the row- Since:
- 1.0
-
heightProperty
The property used to store the height of the row.- Returns:
- the row height property
- Since:
- 1.0
- See Also:
-
setHeight
public final void setHeight(double height) Sets the value of theheightProperty()
.- Parameters:
height
- the new height of the row- Since:
- 1.0
-
getHeight
public final double getHeight()Returns the value of theheightProperty()
.- Returns:
- the value of the height property
- Since:
- 1.0
-
minHeightProperty
The property used to store the minimum height of the row. The user will not be able to resize the row to anything smaller than the value of this property.- Returns:
- the minimum height property
- Since:
- 1.0
- See Also:
-
setMinHeight
public final void setMinHeight(double height) Sets a new value for theminHeightProperty()
.- Parameters:
height
- the new minimum height- Since:
- 1.0
-
getMinHeight
public final double getMinHeight()Returns the value of theminHeightProperty()
.- Returns:
- the minimum height of the row
- Since:
- 1.0
-
maxHeightProperty
The property used to store the maximum height of the row. The user will not be able to resize the row to anything larger than the value of this property.- Returns:
- the maximum height property
- Since:
- 1.0
- See Also:
-
setMaxHeight
public final void setMaxHeight(double height) Sets the value of themaxHeightProperty()
.- Parameters:
height
- the maximum height of the row- Since:
- 1.0
-
getMaxHeight
public final double getMaxHeight()Returns the value ofmaxHeightProperty()
.- Returns:
- the maximum height of the row
- Since:
- 1.0
-
userObjectProperty
The property used to store a row-specific user object.- Returns:
- the user object property
- Since:
- 1.0
- See Also:
-
getUserObject
Returns the value ofuserObjectProperty()
.- Returns:
- the user object associated with this row
- Since:
- 1.0
-
setUserObject
Sets the value ofuserObjectProperty()
.- Parameters:
obj
- the new user object- Since:
- 1.0
-
linesManagerProperty
The property used to store theLinesManager
instance for this row. The lines manager is used to control the layout of inner lines and the placement of activities on these lines.- Returns:
- the lines manager property
- Since:
- 1.0
- See Also:
-
getLinesManager
Returns the value oflinesManagerProperty()
.- Returns:
- the lines manager for this row
- Since:
- 1.0
-
setLinesManager
Sets the value oflinesManagerProperty()
.- Parameters:
manager
- the new lines manager- Since:
- 1.0
-
zoneIdProperty
The property used to store the zone ID for this row. Each row can be placed in a different time zone.- Returns:
- the zone ID property
- Since:
- 1.0
- See Also:
-
getZoneId
Returns the value of thezoneIdProperty()
.- Returns:
- the zone ID of this row
- Since:
- 1.0
-
setZoneId
Sets the value of thezoneIdProperty()
.- Parameters:
zoneId
- the new zone ID for this row- Since:
- 1.0
-
getCalendars
Returns a list of calendars attached to this row. Calendars directly attached to a row can be used to visualize row-specific information, for example "resource availability".- Returns:
- a list of row-specific calendars
- Since:
- 1.0
-
lineCountProperty
The property used to keep track of the number of inner lines shown by the row.- Returns:
- the line count property
- Since:
- 1.0
- See Also:
-
setLineCount
public final void setLineCount(int count) Sets the value of thelineCountProperty()
.- Parameters:
count
- the new line count for the row- Since:
- 1.0
-
getLineCount
public final int getLineCount()Returns the value of thelineCountProperty()
.- Returns:
- the line count of the row
- Since:
- 1.0
-
addActivity
Adds the given activity for the given layer to this row. This method delegates toMutableActivityRepository.addActivity(ActivityRef)
.- Parameters:
layer
- the layer where the activity will be displayedactivity
- the activity that will be added- Since:
- 1.0
- See Also:
-
removeActivity
Removes the given activity from the given layer from this row.- Parameters:
layer
- the layer from which to remove the activityactivity
- the activity to remove- Since:
- 1.0
- See Also:
-
clearActivities
public final void clearActivities()Removes all activities from the row.- Since:
- 1.0
- See Also:
-
clearActivities
Removes all activities on the given layer from the row.- Parameters:
layer
- the layer from which to remove all activities- Since:
- 1.0
- See Also:
-
getLineIndex
Returns the line index for the given activity. This is a convenience method delegating toLinesManager.getLineIndex(Activity)
.- Parameters:
activity
- the activity for which to return a line index- Returns:
- the line index for the given activity
- Since:
- 1.0
-
getLineLocation
public final double getLineLocation(int lineIndex) Returns the location of the given inner line. The value returned is usually between 0 andgetHeight()
.- Parameters:
lineIndex
- the index of the line for which to return a location- Returns:
- the line location y-coordinate
- Since:
- 1.0
-
getLineHeight
public final double getLineHeight(int lineIndex) Returns the height of the given inner line. The value returned is usually between 0 andgetHeight()
.- Parameters:
lineIndex
- the index of the line for which to return a height- Returns:
- the height of the line
- Since:
- 1.0
-
getLineLayout
Returns a line-specific layout for the given line.- Parameters:
lineIndex
- the index of the line- Returns:
- the line layout
- Since:
- 1.0
-
toString
-