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
Properties Type Property Description BooleanProperty
expanded
The property used to store the expansion state of the row.DoubleProperty
height
The property used to store the height of the row.ObjectProperty<Layout>
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).ReadOnlyBooleanProperty
leaf
Represents the TreeItem leaf property, which is true if the TreeItem has no children.IntegerProperty
lineCount
The property used to keep track of the number of inner lines shown by the row.ObjectProperty<LinesManager<A>>
linesManager
The property used to store theLinesManager
instance for this row.DoubleProperty
maxHeight
The property used to store the maximum height of the row.DoubleProperty
minHeight
The property used to store the minimum height of the row.StringProperty
name
The property used to store the name of the row.ReadOnlyObjectProperty<P>
parent
Returns a read-only property used to store the parent row of this row.ObjectProperty<ActivityRepository<A>>
repository
The property used to store the activity repository for the row.ReadOnlyBooleanProperty
showing
The property used to express whether a row is currently showing in the view or not.ObjectProperty<Object>
userObject
The property used to store a row-specific user object.ObjectProperty<ZoneId>
zoneId
The property used to store the zone ID for this row. -
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_ROW_HEIGHT
The default height of a row (24 pixels). -
Constructor Summary
Constructors Constructor Description Row()
Constructs a new row with anIntervalTreeActivityRepository
and anEqualLinesManager
.Row(String name)
Constructs a new row with anIntervalTreeActivityRepository
and anEqualLinesManager
and the given name. -
Method Summary
Modifier and Type Method Description void
addActivity(Layer layer, A activity)
Adds the given activity for the given layer to this row.void
clearActivities()
Removes all activities from the row.void
clearActivities(Layer layer)
Removes all activities on the given layer from the row.BooleanProperty
expandedProperty()
The property used to store the expansion state of the row.ObservableList<Calendar<?>>
getCalendars()
Returns a list of calendars attached to this row.ObservableList<C>
getChildren()
Returns the list of children of this row.Instant
getEarliestTimeUsed()
Returns the earliest time used by the row.double
getHeight()
Returns the value of theheightProperty()
.Instant
getLatestTimeUsed()
Returns the latest time used by the row.Layout
getLayout()
Returns the value of thelayoutProperty()
.int
getLineCount()
Returns the value of thelineCountProperty()
.double
getLineHeight(int lineIndex)
Returns the height of the given inner line.int
getLineIndex(A activity)
Returns the line index for the given activity.Layout
getLineLayout(int lineIndex)
Returns a line-specific layout for the given line.double
getLineLocation(int lineIndex)
Returns the location of the given inner line.LinesManager<A>
getLinesManager()
Returns the value oflinesManagerProperty()
.double
getMaxHeight()
Returns the value ofmaxHeightProperty()
.double
getMinHeight()
Returns the value of theminHeightProperty()
.String
getName()
Returns the value of thenameProperty()
.P
getParent()
The parent of this row.Row[]
getPath()
Returns the path to this row, for example [ROOT, Parent1, Parent2, this].ObservableMap<Object,Object>
getProperties()
Returns an observable map of properties on this row.ActivityRepository<A>
getRepository()
Returns the value of therepositoryProperty()
.Object
getUserObject()
Returns the value ofuserObjectProperty()
.ZoneId
getZoneId()
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.boolean
hasProperties()
Tests if the row has properties.DoubleProperty
heightProperty()
The property used to store the height of the row.boolean
isExpanded()
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.boolean
isShowing()
Returns the value ofshowingProperty()
.ObjectProperty<Layout>
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).ReadOnlyBooleanProperty
leafProperty()
Represents the TreeItem leaf property, which is true if the TreeItem has no children.IntegerProperty
lineCountProperty()
The property used to keep track of the number of inner lines shown by the row.ObjectProperty<LinesManager<A>>
linesManagerProperty()
The property used to store theLinesManager
instance for this row.DoubleProperty
maxHeightProperty()
The property used to store the maximum height of the row.DoubleProperty
minHeightProperty()
The property used to store the minimum height of the row.StringProperty
nameProperty()
The property used to store the name of the row.ReadOnlyObjectProperty<P>
parentProperty()
Returns a read-only property used to store the parent row of this row.void
removeActivity(Layer layer, A activity)
Removes the given activity from the given layer from this row.ObjectProperty<ActivityRepository<A>>
repositoryProperty()
The property used to store the activity repository for the row.void
setExpanded(boolean expanded)
Sets the value of theexpandedProperty()
.void
setHeight(double height)
Sets the value of theheightProperty()
.void
setLayout(Layout layout)
Sets the value of thelayoutProperty()
.void
setLineCount(int count)
Sets the value of thelineCountProperty()
.void
setLinesManager(LinesManager<A> manager)
Sets the value oflinesManagerProperty()
.void
setMaxHeight(double height)
Sets the value of themaxHeightProperty()
.void
setMinHeight(double height)
Sets a new value for theminHeightProperty()
.void
setName(String name)
Sets the value of thenameProperty()
.void
setRepository(ActivityRepository<A> repository)
Sets the value of therepositoryProperty()
.void
setUserObject(Object obj)
Sets the value ofuserObjectProperty()
.void
setZoneId(ZoneId zoneId)
Sets the value of thezoneIdProperty()
.ReadOnlyBooleanProperty
showingProperty()
The property used to express whether a row is currently showing in the view or not.String
toString()
ObjectProperty<Object>
userObjectProperty()
The property used to store a row-specific user object.ObjectProperty<ZoneId>
zoneIdProperty()
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:
getParent()
-
leaf
Represents the TreeItem leaf property, which is true if the TreeItem has no children.- Since:
- 1.3
- See Also:
isLeaf()
-
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:
isExpanded()
,setExpanded(boolean)
-
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:
isShowing()
-
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:
getLayout()
,setLayout(Layout)
-
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:
getRepository()
,setRepository(ActivityRepository)
-
name
The property used to store the name of the row.- Since:
- 1.0
- See Also:
getName()
,setName(String)
-
height
The property used to store the height of the row.- Since:
- 1.0
- See Also:
getHeight()
,setHeight(double)
-
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:
getMinHeight()
,setMinHeight(double)
-
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:
getMaxHeight()
,setMaxHeight(double)
-
userObject
The property used to store a row-specific user object.- Since:
- 1.0
- See Also:
getUserObject()
,setUserObject(Object)
-
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:
getLinesManager()
,setLinesManager(LinesManager)
-
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:
getZoneId()
,setZoneId(ZoneId)
-
lineCount
The property used to keep track of the number of inner lines shown by the row.- Since:
- 1.0
- See Also:
getLineCount()
,setLineCount(int)
-
-
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.- Since:
- 1.0
- See Also:
getParent()
-
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.- Since:
- 1.3
- See Also:
isLeaf()
-
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.- Since:
- 1.0
- See Also:
isExpanded()
,setExpanded(boolean)
-
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.- Since:
- 1.0
- See Also:
isShowing()
-
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).- Since:
- 1.0
- See Also:
getLayout()
,setLayout(Layout)
-
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.- Since:
- 1.0
- See Also:
getRepository()
,setRepository(ActivityRepository)
-
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.- Since:
- 1.0
- See Also:
getName()
,setName(String)
-
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.- Since:
- 1.0
- See Also:
getHeight()
,setHeight(double)
-
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.- Since:
- 1.0
- See Also:
getMinHeight()
,setMinHeight(double)
-
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.- Since:
- 1.0
- See Also:
getMaxHeight()
,setMaxHeight(double)
-
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.- Since:
- 1.0
- See Also:
getUserObject()
,setUserObject(Object)
-
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.- Since:
- 1.0
- See Also:
getLinesManager()
,setLinesManager(LinesManager)
-
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.- Since:
- 1.0
- See Also:
getZoneId()
,setZoneId(ZoneId)
-
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.- Since:
- 1.0
- See Also:
getLineCount()
,setLineCount(int)
-
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:
MutableActivityRepository.addActivity(ActivityRef)
-
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:
MutableActivityRepository.removeActivity(ActivityRef)
-
clearActivities
public final void clearActivities()Removes all activities from the row.- Since:
- 1.0
- See Also:
MutableActivityRepository.clearActivities()
-
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:
MutableActivityRepository.clearActivities(Layer)
-
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
-