Package de.hsh.graja.util.comment.grid
Class GridCell
- java.lang.Object
-
- de.hsh.graja.util.comment.grid.GridCell
-
- All Implemented Interfaces:
Serializable
,Comparable<GridCell>
- Direct Known Subclasses:
GridCellMulti
,GridCellSingle
public abstract class GridCell extends Object implements Comparable<GridCell>, Serializable
A cell of a grid. Columns and rows, that consist of empty cells only, are hidden automatically.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GridCell.PosProcessor
A helper interface to execute a method for each position of the cell.
-
Constructor Summary
Constructors Constructor Description GridCell(GridCellPos pos, Content content, GridCellType type, GridCellAlignment align, GridCellShowMode showMode, Double brightness, GridCellWidth width, GridCellPadding padding, String id)
Create a cell of the grid.
-
Method Summary
-
-
-
Constructor Detail
-
GridCell
public GridCell(GridCellPos pos, Content content, GridCellType type, GridCellAlignment align, GridCellShowMode showMode, Double brightness, GridCellWidth width, GridCellPadding padding, String id)
Create a cell of the grid.- Parameters:
pos
- the upper left corner (0-based index)content
- the cell content (may be null, if there is no content)type
- header or notalign
- alignmentshowMode
- show modebrightness
- background brightness. 1 means white, 0 means black. null means: transparent.width
- the widthpadding
- paddingid
- id (used as postfix of CSS id)
-
-
Method Detail
-
toString
public String toString(String prefix)
- See Also:
Content.toString(java.lang.String)
-
getPos
public GridCellPos getPos()
- Returns:
- the upper left corner (0-based index)
-
getContent
public Content getContent()
- Returns:
- the content
-
getType
public GridCellType getType()
- Returns:
- the type of the cell (header, normal).
-
getAlign
public GridCellAlignment getAlign()
- Returns:
- the alignment of the cell (left, center, ...)
-
getDim
public abstract GridCellDim getDim()
- Returns:
- the dimensions (width and height). Single cells always return (1,1).
-
colsSet
public Set<Integer> colsSet(IntPredicate filter)
- Parameters:
filter
- if null, nothing is filtered- Returns:
- a set of integers with the range of columns spanned by this cell
-
hasColsPassing
public boolean hasColsPassing(IntPredicate filter)
- Parameters:
filter
- if null, nothing is filtered- Returns:
- true, if this cell spans at least one column whose index passes the given filter. If filter is null, the answer is always true.
-
rowsSet
public Set<Integer> rowsSet(IntPredicate filter)
- Parameters:
filter
- if null, nothing is filtered- Returns:
- a set of integers with the range of rows spanned by this cell
-
hasRowsPassing
public boolean hasRowsPassing(IntPredicate filter)
- Parameters:
filter
- if null, nothing is filtered- Returns:
- true, if this cell spans at least one row whose index passes the given filter. If filter is null, the answer is always true.
-
hasColsInExcept
public boolean hasColsInExcept(Collection<Integer> inCollection, int except)
- Returns:
- true, if this cell spans at least one column whose index is contained in
inCollection
but is not equal toexcept
.
-
hasRowsInExcept
public boolean hasRowsInExcept(Collection<Integer> inCollection, int except)
- Returns:
- true, if this cell spans at least one row whose index is contained in
inCollection
but is not equal toexcept
.
-
getShowMode
public GridCellShowMode getShowMode()
- Returns:
- the show mode of the cell (empty? defensive?)
-
getBrightness
public Double getBrightness()
- Returns:
- the background brightness. 1 means white, 0 means black, null means transparent.
-
setBrightness
public void setBrightness(Double brightness)
Set the background brightness- Parameters:
brightness
- 1 means white, 0 means black, 0 means transparent.
-
getShrinkWidthMode
public GridCellWidth getShrinkWidthMode()
- Returns:
- the width of the cell
-
setShrinkWidthMode
public void setShrinkWidthMode(GridCellWidth width)
Set the width of the cell.- Parameters:
width
- The new value.
-
getPadding
public GridCellPadding getPadding()
- Returns:
- the padding of the cell
-
getId
public String getId()
- Returns:
- the CSS id of the cell
-
setId
public void setId(String id)
Set the id- Parameters:
id
- id
-
forEach
public abstract void forEach(GridCell.PosProcessor p)
Execute a method for each position- Parameters:
p
- the processor
-
compareTo
public int compareTo(GridCell other)
- Specified by:
compareTo
in interfaceComparable<GridCell>
-
hashCode
public int hashCode()
implements the contract ofObject.hashCode()
.
-
equals
public boolean equals(Object obj)
implements the contract ofObject.equals(Object)
.
-
-