Class Grid

All Implemented Interfaces:
Serializable

public class Grid extends AbstractSequenceContent
A grid represents a whole table that can have single and multi cells.
See Also:
  • Constructor Details

    • Grid

      public Grid(GridCellDim dim, IncludeSpec includeSpec)
      Create a grid of given size
      Parameters:
      dim - size of the grid
  • Method Details

    • getNestedContents

      public Iterable<Content> getNestedContents()
      Specified by:
      getNestedContents in class Content
      Returns:
      the set of contents nested in this content. Nested contents can be list items in a List, elements in a Sequence, elements in a Grid, elements in a Paragraph, and so on. If this is a leaf content, the returned set is empty.
    • getCells

      public Iterable<GridCell> getCells()
      Returns:
      a list of all cells. The list will not reflect any subsequent changes to the grid.
    • getContents

      public Iterable<Content> getContents()
      Returns:
      a list of all contents. The list will not reflect any subsequent changes to the grid.
    • setSingleCell

      public void setSingleCell(GridCellPos pos, Content content, GridCellType type, GridCellAlignment align, GridCellShowMode showMode, Double brightness, GridCellWidth width, GridCellPadding padding, String id)
      add a single cell to the grid
      Parameters:
      pos - position
      content - content
      type - type (header or normal)
      align - alignment (left, center, right)
      showMode -
      brightness -
      width -
      padding -
      id -
    • setMultiCell

      public void setMultiCell(GridCellPos pos, GridCellDim dim, Content content, GridCellType type, GridCellAlignment align, GridCellShowMode showMode, Double brightness, GridCellWidth width, GridCellPadding padding, String id)
      add a cell spanning multiple rows or columns to the grid
      Parameters:
      pos - position
      dim - region of spanned cells
      content - content
      type - type (header or normal)
      align - alignment
      showMode -
      brightness -
      width -
      padding -
      id -
    • setCell

      public void setCell(GridCell cell)
      add a cell (single or multi) to the grid.
      Parameters:
      cell - the cell to be inserted.
    • validate

      public void validate() throws AssertionError
      checks, that there are no overlapping cells and no duplicate ids. Otherwise throws an AssertionError.
      Throws:
      AssertionError
    • getRows

      public int getRows()
      Returns:
      height
    • getCols

      public int getCols()
      Returns:
      width
    • getDim

      public GridCellDim getDim()
      Returns:
      dim
    • getCell

      public GridCell getCell(GridCellPos pos)
      Parameters:
      pos - query position
      Returns:
      cell at given position or null, if there is no cell. If the position is spanned by a multicell and pos is not the upper left corner of the multi cell, null is returned.
    • getContent

      public Content getContent(GridCellPos pos)
      Parameters:
      pos - query position
      Returns:
      cell content at given position or null, if there is no cell or no content. If the position is spanned by a multicell and pos is not the upper left corner of the multi cell, null is returned.
    • findCellSpanning

      public GridCell findCellSpanning(GridCellPos pos)
      Parameters:
      pos - query position
      Returns:
      the cell (single or multi) containing the given position
    • hashCode

      public int hashCode()
      implements the contract of Object.hashCode().
      Overrides:
      hashCode in class Content
      See Also:
    • equals

      public boolean equals(Object obj)
      implements the contract of Object.equals(Object).
      Overrides:
      equals in class Content
    • toString

      public String toString(String prefix)
      Description copied from class: Content
      This method is for debugging purposes.
      Overrides:
      toString in class Content
      Parameters:
      prefix - If the output has multiple lines, prefix specifies the indentation of the subsequent lines.
      Returns:
      a string representation of the content and it's internal structure.
      See Also:
    • renderHtmlImpl

      public void renderHtmlImpl(StringBuilder sb, IncludeInfo includeInfo, RenderContext ctx, boolean useJavascript)
      Description copied from class: Content
      render content to HTML. This method is meant to be overriden by subclasses.
      Specified by:
      renderHtmlImpl in class Content
      Parameters:
      sb - HTML code result
      includeInfo - controls, which content to be rendered.
      ctx - render context
      useJavascript - if true, the generated HTML code will contain Javascript
      See Also:
      • de.hsh.graja.util.comment.Content#renderHtml(StringBuilder, IncludeInfo, RenderContext)
    • hideRow

      public Action hideRow(int row)
      Parameters:
      row - index of original row. When rendering, the original row will be mapped to a "printed" row.
      Returns:
    • showRow

      public Action showRow(int row)
    • observeRowHidden

      public void observeRowHidden(int row, CallableAction<IfThenElseCompositeConditionedAction> action)
    • observeRowShowing

      public void observeRowShowing(int row, CallableAction<IfThenElseCompositeConditionedAction> action)
    • onHideRow

      public Grid onHideRow(int row, Action action)
    • onShowRow

      public Grid onShowRow(int row, Action action)
    • renderPlainImpl

      public void renderPlainImpl(StringBuilder appender, IncludeInfo includeInfo, RenderContext ctx)
      Description copied from class: Content
      render content to plain text. This method is meant to be overriden by subclasses.
      Specified by:
      renderPlainImpl in class Content
      Parameters:
      appender - plain text result
      includeInfo - controls, which content to be rendered.
      ctx - render context (unused).
      See Also: