Class Row<P extends Row<?,​?,​?>,​C extends Row<?,​?,​?>,​A extends Activity>

  • 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 the isLeaf() 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
    • Method Detail

      • getProperties

        public final ObservableMap<Object,​Object> 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

        public final P 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

        public final ReadOnlyObjectProperty<P> 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
      • getPath

        public final Row[] getPath()
        Returns the path to this row, for example [ROOT, Parent1, Parent2, this].
        Returns:
        the path to this row
        Since:
        1.0
      • getChildren

        public final ObservableList<C> getChildren()
        Returns the list of children of this row.
        Returns:
        the children
        Since:
        1.0
      • hasChildren

        public boolean hasChildren​(Predicate predicate)
        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

        public final ReadOnlyBooleanProperty 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
      • expandedProperty

        public final BooleanProperty 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
      • setExpanded

        public final void setExpanded​(boolean expanded)
        Sets the value of the expandedProperty().
        Parameters:
        expanded - the new value of the expanded property
        Since:
        1.0
      • isExpanded

        public final boolean isExpanded()
        Returns the value of the expandedProperty().
        Returns:
        true if the row is expanded
        Since:
        1.0
      • showingProperty

        public final ReadOnlyBooleanProperty 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
      • isShowing

        public final boolean isShowing()
        Returns the value of showingProperty().
        Returns:
        true if the row is currently showing in the UI
        Since:
        1.0
      • layoutProperty

        public final 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).
        Returns:
        the row layer property
        Since:
        1.0
        See Also:
        getLineLayout(int)
      • getLayout

        public final Layout getLayout()
        Returns the value of the layoutProperty().
        Returns:
        the layout of the row
        Since:
        1.0
      • setLayout

        public final void setLayout​(Layout layout)
        Sets the value of the layoutProperty().
        Parameters:
        layout - the new row layout
        Since:
        1.0
      • repositoryProperty

        public final ObjectProperty<ActivityRepository<A>> 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
      • getEarliestTimeUsed

        public final Instant getEarliestTimeUsed()
        Returns the earliest time used by the row. This is a convenience method delegating to ActivityRepository.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

        public final Instant getLatestTimeUsed()
        Returns the latest time used by the row. This is a convenience method delegating to ActivityRepository.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

        public final StringProperty nameProperty()
        The property used to store the name of the row.
        Returns:
        the name property
        Since:
        1.0
      • getName

        public final String getName()
        Returns the value of the nameProperty().
        Returns:
        the name of the row
        Since:
        1.0
      • setName

        public final void setName​(String name)
        Sets the value of the nameProperty().
        Parameters:
        name - the new name of the row
        Since:
        1.0
      • heightProperty

        public final DoubleProperty heightProperty()
        The property used to store the height of the row.
        Returns:
        the row height property
        Since:
        1.0
      • setHeight

        public final void setHeight​(double height)
        Sets the value of the heightProperty().
        Parameters:
        height - the new height of the row
        Since:
        1.0
      • getHeight

        public final double getHeight()
        Returns the value of the heightProperty().
        Returns:
        the value of the height property
        Since:
        1.0
      • minHeightProperty

        public final DoubleProperty 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
      • setMinHeight

        public final void setMinHeight​(double height)
        Sets a new value for the minHeightProperty().
        Parameters:
        height - the new minimum height
        Since:
        1.0
      • getMinHeight

        public final double getMinHeight()
        Returns the value of the minHeightProperty().
        Returns:
        the minimum height of the row
        Since:
        1.0
      • maxHeightProperty

        public final DoubleProperty 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
      • setMaxHeight

        public final void setMaxHeight​(double height)
        Sets the value of the maxHeightProperty().
        Parameters:
        height - the maximum height of the row
        Since:
        1.0
      • getMaxHeight

        public final double getMaxHeight()
        Returns the value of maxHeightProperty().
        Returns:
        the maximum height of the row
        Since:
        1.0
      • userObjectProperty

        public final ObjectProperty<Object> userObjectProperty()
        The property used to store a row-specific user object.
        Returns:
        the user object property
        Since:
        1.0
      • getUserObject

        public final Object getUserObject()
        Returns the value of userObjectProperty().
        Returns:
        the user object associated with this row
        Since:
        1.0
      • setUserObject

        public final void setUserObject​(Object obj)
        Sets the value of userObjectProperty().
        Parameters:
        obj - the new user object
        Since:
        1.0
      • linesManagerProperty

        public final ObjectProperty<LinesManager<A>> linesManagerProperty()
        The property used to store the LinesManager 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
      • setLinesManager

        public final void setLinesManager​(LinesManager<A> manager)
        Sets the value of linesManagerProperty().
        Parameters:
        manager - the new lines manager
        Since:
        1.0
      • zoneIdProperty

        public final ObjectProperty<ZoneId> 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
      • getZoneId

        public final ZoneId getZoneId()
        Returns the value of the zoneIdProperty().
        Returns:
        the zone ID of this row
        Since:
        1.0
      • setZoneId

        public final void setZoneId​(ZoneId zoneId)
        Sets the value of the zoneIdProperty().
        Parameters:
        zoneId - the new zone ID for this row
        Since:
        1.0
      • getCalendars

        public final ObservableList<Calendar<?>> 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

        public final IntegerProperty 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
      • setLineCount

        public final void setLineCount​(int count)
        Sets the value of the lineCountProperty().
        Parameters:
        count - the new line count for the row
        Since:
        1.0
      • getLineCount

        public final int getLineCount()
        Returns the value of the lineCountProperty().
        Returns:
        the line count of the row
        Since:
        1.0
      • removeActivity

        public final void removeActivity​(Layer layer,
                                         A activity)
        Removes the given activity from the given layer from this row.
        Parameters:
        layer - the layer from which to remove the activity
        activity - the activity to remove
        Since:
        1.0
        See Also:
        MutableActivityRepository.removeActivity(ActivityRef)
      • getLineIndex

        public final int getLineIndex​(A activity)
        Returns the line index for the given activity. This is a convenience method delegating to LinesManager.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 and getHeight().
        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 and getHeight().
        Parameters:
        lineIndex - the index of the line for which to return a height
        Returns:
        the height of the line
        Since:
        1.0
      • getLineLayout

        public final Layout getLineLayout​(int lineIndex)
        Returns a line-specific layout for the given line.
        Parameters:
        lineIndex - the index of the line
        Returns:
        the line layout
        Since:
        1.0