org.nocrala.tools.texttablefmt
Class CellStyle

java.lang.Object
  extended by org.nocrala.tools.texttablefmt.CellStyle

public class CellStyle
extends java.lang.Object

Defines how the content of a cell is rendered.

It allows to specify the text alignment, the abbreviation mode and rendering of null values.

Author:
valarcon

Nested Class Summary
static class CellStyle.AbbreviationStyle
          This enumeration is used to specify how to reduce a text to fit it in a small cell.
static class CellStyle.HorizontalAlign
          This enumeration is used to specify how a text is horizontally aligned in a cell.
static class CellStyle.NullStyle
          This enumeration is used to specify how to display cell with null values.
 
Constructor Summary
CellStyle()
          Default style that assumes HorizontalAlign.left, AbbreviationStyle.dots and NullStyle.emptyString.
CellStyle(CellStyle.HorizontalAlign horAlign)
          Style with a specified horizontal alignment, that assumes AbbreviationStyle.dots and NullStyle.emptyString.
CellStyle(CellStyle.HorizontalAlign horAlign, CellStyle.AbbreviationStyle abbStyle)
          Style with a specified horizontal alignment and abbreviation style, that assumes NullStyle.emptyString.
CellStyle(CellStyle.HorizontalAlign horAlign, CellStyle.AbbreviationStyle abbStyle, CellStyle.NullStyle nullStyle)
          Full constructor, that specifies all characteristics.
 
Method Summary
 int getWidth(java.lang.String txt)
          Returns the width of a rendered text, based on the cell content and style.
 java.lang.String render(java.lang.String txt, int width)
          Renders a text based on the cell content, style and specified width.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellStyle

public CellStyle()

Default style that assumes HorizontalAlign.left, AbbreviationStyle.dots and NullStyle.emptyString.


CellStyle

public CellStyle(CellStyle.HorizontalAlign horAlign)

Style with a specified horizontal alignment, that assumes AbbreviationStyle.dots and NullStyle.emptyString.


CellStyle

public CellStyle(CellStyle.HorizontalAlign horAlign,
                 CellStyle.AbbreviationStyle abbStyle)

Style with a specified horizontal alignment and abbreviation style, that assumes NullStyle.emptyString.


CellStyle

public CellStyle(CellStyle.HorizontalAlign horAlign,
                 CellStyle.AbbreviationStyle abbStyle,
                 CellStyle.NullStyle nullStyle)
Full constructor, that specifies all characteristics.

Parameters:
horAlign - Horizontal alignment.
abbStyle - Abbreviation style.
nullStyle - Null style.
Method Detail

getWidth

public int getWidth(java.lang.String txt)
Returns the width of a rendered text, based on the cell content and style.

Parameters:
txt - Text to render.
Returns:
width of a rendered text, based on the cell style.

render

public java.lang.String render(java.lang.String txt,
                               int width)
Renders a text based on the cell content, style and specified width.

Parameters:
txt - Text to render.
width - Fixed width to accommodate the test to.
Returns:
Rendered text based on the cell style and the specified width.


Nocrala tools.