Package de.hsh.graja.util.comment.grid
Class Grid
- java.lang.Object
-
- de.hsh.graja.util.comment.Content
-
- de.hsh.graja.util.comment.AbstractSequenceContent
-
- de.hsh.graja.util.comment.grid.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Grid.Filter<T>
-
Field Summary
-
Fields inherited from class de.hsh.graja.util.comment.Content
EXCLUSIVE, renderUuid
-
-
Constructor Summary
Constructors Constructor Description Grid(GridCellDim dim, IncludeSpec includeSpec)
Create a grid of given size
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
implements the contract ofObject.equals(Object)
.GridCell
findCellSpanning(GridCellPos pos)
GridCell
getCell(GridCellPos pos)
Iterable<GridCell>
getCells()
int
getCols()
Content
getContent(GridCellPos pos)
Iterable<Content>
getContents()
GridCellDim
getDim()
Iterable<Content>
getNestedContents()
int
getRows()
int
hashCode()
implements the contract ofObject.hashCode()
.Action
hideRow(int row)
void
observeRowHidden(int row, CallableAction<IfThenElseCompositeConditionedAction> action)
void
observeRowShowing(int row, CallableAction<IfThenElseCompositeConditionedAction> action)
Grid
onHideRow(int row, Action action)
Grid
onShowRow(int row, Action action)
void
renderHtmlImpl(StringBuilder sb, IncludeInfo includeInfo, RenderContext ctx, boolean useJavascript)
render content to HTML.void
renderPlainImpl(StringBuilder appender, IncludeInfo includeInfo, RenderContext ctx)
render content to plain text.void
setCell(GridCell cell)
add a cell (single or multi) to the grid.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 gridvoid
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 gridAction
showRow(int row)
String
toString(String prefix)
This method is for debugging purposes.void
validate()
checks, that there are no overlapping cells and no duplicate ids.-
Methods inherited from class de.hsh.graja.util.comment.Content
click, disableCallerStacktraceRecording, enableCallerStacktraceRecording, excludeGlobally, getIncludeSpec, getRenderUuid, getStackdump, hide, include, isCallerStacktraceRecordingEnabled, isHidden, isShowing, onClick, onClick, onHide, onHide, onLoad, onLoad, onShow, onShow, registerCallable, renderHtml, renderHtml, renderIdAttribute, renderJavascriptOncePerClass, renderOnClickAttribute, renderPlain, renderPlain, setGlobalIncludeInfo, setHref, setIncludeSpec, show, toString
-
-
-
-
Constructor Detail
-
Grid
public Grid(GridCellDim dim, IncludeSpec includeSpec)
Create a grid of given size- Parameters:
dim
- size of the grid
-
-
Method Detail
-
getNestedContents
public Iterable<Content> getNestedContents()
- Specified by:
getNestedContents
in classContent
- 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
- positioncontent
- contenttype
- 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
- positiondim
- region of spanned cellscontent
- contenttype
- type (header or normal)align
- alignmentshowMode
-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 ofObject.hashCode()
.- Overrides:
hashCode
in classContent
- See Also:
Object.hashCode()
-
equals
public boolean equals(Object obj)
implements the contract ofObject.equals(Object)
.
-
toString
public String toString(String prefix)
Description copied from class:Content
This method is for debugging purposes.- Overrides:
toString
in classContent
- 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:
Content.toString(String)
-
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 classContent
- Parameters:
sb
- HTML code resultincludeInfo
- controls, which content to be rendered.ctx
- render contextuseJavascript
- 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)
-
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 classContent
- Parameters:
appender
- plain text resultincludeInfo
- controls, which content to be rendered.ctx
- render context (unused).- See Also:
Content.renderPlainImpl(StringBuilder, IncludeInfo, RenderContext)
-
-