Class TreeLayer

    • Constructor Detail

      • TreeLayer

        public TreeLayer​(IUniqueIndexLayer underlyingLayer,
                         ITreeRowModel<?> treeRowModel)
        Creates a TreeLayer instance based on the given information. Will use a default IndentedTreeImagePainter that uses 10 pixels for indentation and simple + and - icons for expand/collapse icons. It also uses the DefaultTreeLayerConfiguration.
        Parameters:
        underlyingLayer - The underlying layer on whose top this layer will be set.
        treeRowModel - The ITreeRowModelListener that is used to get information about the tree structure.
      • TreeLayer

        public TreeLayer​(IUniqueIndexLayer underlyingLayer,
                         ITreeRowModel<?> treeRowModel,
                         IndentedTreeImagePainter indentedTreeImagePainter)
        Creates a TreeLayer instance based on the given information. Allows to specify the IndentedTreeImagePainter while using the DefaultTreeLayerConfiguration.
        Parameters:
        underlyingLayer - The underlying layer on whose top this layer will be set.
        treeRowModel - The ITreeRowModelListener that is used to get information about the tree structure.
        indentedTreeImagePainter - The IndentedTreeImagePainter that paints indentation to the left of the configured base painter and icons for expand/collapse if possible, to render tree structure accordingly.
      • TreeLayer

        public TreeLayer​(IUniqueIndexLayer underlyingLayer,
                         ITreeRowModel<?> treeRowModel,
                         boolean useDefaultConfiguration)
        Creates a TreeLayer instance based on the given information. Will use a default IndentedTreeImagePainter that uses 10 pixels for indentation and simple + and - icons for expand/collapse icons.
        Parameters:
        underlyingLayer - The underlying layer on whose top this layer will be set.
        treeRowModel - The ITreeRowModelListener that is used to get information about the tree structure.
        useDefaultConfiguration - true to use the DefaultTreeLayerConfiguration, false if you want to specify your own configuration.
      • TreeLayer

        public TreeLayer​(IUniqueIndexLayer underlyingLayer,
                         ITreeRowModel<?> treeRowModel,
                         IndentedTreeImagePainter indentedTreeImagePainter,
                         boolean useDefaultConfiguration)
        Creates a TreeLayer instance based on the given information.
        Parameters:
        underlyingLayer - The underlying layer on whose top this layer will be set.
        treeRowModel - The ITreeRowModelListener that is used to get information about the tree structure.
        indentedTreeImagePainter - The IndentedTreeImagePainter that paints indentation to the left of the configured base painter and icons for expand/collapse if possible, to render tree structure accordingly.
        useDefaultConfiguration - true to use the DefaultTreeLayerConfiguration, false if you want to specify your own configuration.
    • Method Detail

      • getConfigLabelsByPosition

        public LabelStack getConfigLabelsByPosition​(int columnPosition,
                                                    int rowPosition)
        Description copied from interface: ILayer
        Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of the IConfigRegistry.
        Specified by:
        getConfigLabelsByPosition in interface ILayer
        Overrides:
        getConfigLabelsByPosition in class AbstractLayerTransform
        Parameters:
        columnPosition - The column position of the cell.
        rowPosition - The row position of the cell.
        Returns:
        The LabelStack with the config labels for the cell at the given coordinates.
      • getModel

        public ITreeRowModel<?> getModel()
        Returns:
        The ITreeRowModelListener that is used to get information about the tree structure.
      • isTreeColumn

        protected boolean isTreeColumn​(int columnPosition)
        Parameters:
        columnPosition - The column position to check.
        Returns:
        true if the given column position is the tree column, false if not.
        Since:
        1.6
      • isRowIndexHidden

        public boolean isRowIndexHidden​(int rowIndex)
        Description copied from class: AbstractRowHideShowLayer
        Will check if the row at the specified index is hidden or not. Checks this layer and also the sublayers for the visibility.
        Specified by:
        isRowIndexHidden in class AbstractRowHideShowLayer
        Parameters:
        rowIndex - The row index of the row whose visibility state should be checked.
        Returns:
        true if the row at the specified index is hidden, false if it is visible.
      • getHiddenRowIndexes

        public Collection<Integer> getHiddenRowIndexes()
        Description copied from class: AbstractRowHideShowLayer
        Will collect and return all indexes of the rows that are hidden in this layer.

        Note: It is not intended that it also collects the row indexes of underlying layers. This would cause issues on calculating positions, as every layer is responsible for those calculations itself.

        Since 2.0 it is recommended to use AbstractRowHideShowLayer.getHiddenRowIndexesArray() to avoid unnecessary autoboxing operations.

        Specified by:
        getHiddenRowIndexes in class AbstractRowHideShowLayer
        Returns:
        Collection of all row indexes that are hidden in this layer.
      • getHiddenRowIndexesArray

        public int[] getHiddenRowIndexesArray()
        Description copied from class: AbstractRowHideShowLayer
        Will collect and return all indexes of the rows that are hidden in this layer.

        Note: It is not intended that it also collects the row indexes of underlying layers. This would cause issues on calculating positions, as every layer is responsible for those calculations itself.

        Specified by:
        getHiddenRowIndexesArray in class AbstractRowHideShowLayer
        Returns:
        All row indexes that are hidden in this layer.
      • expandOrCollapseIndex

        public void expandOrCollapseIndex​(int parentIndex)
        Performs an expand/collapse action dependent on the current state of the tree node at the given row index.
        Parameters:
        parentIndex - The index of the row that shows the tree node for which the expand/collapse action should be performed.
      • collapseTreeRow

        public void collapseTreeRow​(int parentIndex)
        Collapses the tree node for the given row index.
        Parameters:
        parentIndex - The index of the row that shows the node that should be collapsed
      • collapseAll

        public void collapseAll()
        Collapses all tree nodes in the tree.
      • expandTreeRow

        public void expandTreeRow​(int parentIndex)
        Expands the tree node for the given row index.
        Parameters:
        parentIndex - The index of the row that shows the node that should be expanded
      • expandTreeRowToLevel

        public void expandTreeRowToLevel​(int parentIndex,
                                         int level)
        Expands the tree node for the given row index in the tree to a certain level.
        Parameters:
        parentIndex - The index of the row that shows the node that should be expanded
        level - The level to which the tree node should be expanded.
      • expandAll

        public void expandAll()
        Expands all tree nodes in the tree.
      • expandAllToLevel

        public void expandAllToLevel​(int level)
        Expands all tree nodes in the tree to a certain level.
        Parameters:
        level - The level to which the tree node should be expanded.
      • doCommand

        public boolean doCommand​(ILayerCommand command)
        Description copied from interface: ILayer
        Opportunity to respond to a command as it flows down the stack. If the layer is not interested in the command it should allow the command to keep traveling down the stack.

        Note: Before the layer can process a command it must convert the command to its local coordinates using ILayerCommand.convertToTargetLayer(ILayer)

        Specified by:
        doCommand in interface ILayer
        Overrides:
        doCommand in class AbstractLayerTransform
        Parameters:
        command - The command to execute.
        Returns:
        true if the command has been handled and was therefore consumed, false otherwise.
      • handleRowHideCommand

        protected boolean handleRowHideCommand​(RowHideCommand command)
        Checks if the given command tries to hide a row that is a node that is not collapsed and has children. In that case also the child rows need to be hidden.
        Parameters:
        command - The RowHideCommand to process
        Returns:
        true if the command has been handled, false otherwise
      • handleMultiRowHideCommand

        protected boolean handleMultiRowHideCommand​(MultiRowHideCommand command)
        Checks if the given command tries to hide rows that are nodes that are not collapsed and have children. In that case also the child rows need to be hidden.
        Parameters:
        command - The MultiRowHideCommand to process
        Returns:
        true if the command has been handled, false otherwise
      • isUseTreeColumnIndex

        public boolean isUseTreeColumnIndex()
        Returns:
        true if the column index is used to determine the tree column, false if the column position is used. Default is false.
      • setUseTreeColumnIndex

        public void setUseTreeColumnIndex​(boolean useTreeColumnIndex)
        Configure whether (column index == 0) or (column position == 0) should be performed to identify the tree column.
        Parameters:
        useTreeColumnIndex - true if the column index should be used to determine the tree column, false if the column position should be used.