Class: I2CE TextTable: Difference between revisions

From IHRIS Wiki
No edit summary
No edit summary
Line 33: Line 33:
===Visualize()===
===Visualize()===
*Signature: public function Visualize($table_data,$font_size)
*Signature: public function Visualize($table_data,$font_size)
Parameters:
*Parameters:
*$table_data  
*$table_data  
*$font_size  
*$font_size  
===__construct()===
===__construct()===
Construct a text table object
Construct a text table object @param numeric $max_width -- the maximum width of the table
@param numeric $max_width -- the maximum width of the table
@param I2CE_Encoding encoding -- the encoding we want to use
*Signature: public function __construct($max_table_width,$font_metric,$hyphen,$encoding,$col_spacing,$widthstyle,$algorithm)
*Signature: public function __construct($max_table_width,$font_metric,$hyphen,$encoding,$col_spacing,$widthstyle,$algorithm)
Parameters:
*Parameters:
*$max_table_width  
*$max_table_width  
* [[Class: I2CE_FontMetric | I2CE_FontMetric]] $font_metric
** [[Class: I2CE_FontMetric | I2CE_FontMetric]] $font_metric
* [[Class: I2CE_Hyphen | I2CE_Hyphen]] $hyphen<br/>default is null
** [[Class: I2CE_Hyphen | I2CE_Hyphen]] $hyphen <br/>default is null
**Default Value: null
***Default Value: null
*&$encoding  
**&$encoding  
* [http://www.php.net/manual/en/language.pseudo-types.php numeric ] $col_spacing<br/>the spacing used between the columns. Default to 0
** [http://www.php.net/manual/en/language.pseudo-types.php numeric ] $col_spacing <br/>the spacing used between the columns. Default to 0
**Default Value: 0
***Default Value: 0
* [http://www.php.net/manual/en/language.types.string.php string ] $widthstyle<br/>how we determine the width  of the columns.  Defaults to 'Header'
** [http://www.php.net/manual/en/language.types.string.php string ] $widthstyle <br/>how we determine the width  of the columns.  Defaults to 'Header'
**Default Value: 'Header'
***Default Value: 'Header'
* [http://www.php.net/manual/en/language.types.integer.php int ] $algorithm<br/>the word wrapping algorithm: default = 'Greedy'
** [http://www.php.net/manual/en/language.types.integer.php int ] $algorithm <br/>the word wrapping algorithm: default = 'Greedy' @param I2CE_Encoding encoding -- the encoding we want to use
**Default Value: 'Greedy'
***Default Value: 'Greedy'
===adjustDesiredWidths()===
===adjustDesiredWidths()===
helper function to adjust the desired width of a column to those allowable by the maxium size
helper function to adjust the desired width of a column to those allowable by the maxium size
*Signature: protected function adjustDesiredWidths($desired_widths,$width)
*Signature: protected function adjustDesiredWidths($desired_widths,$width)
Parameters:
*Parameters:
*$desired_widths  
*$desired_widths  
*$width  
*$width  
Line 64: Line 62:
*Signature: public function getFontMetric()
*Signature: public function getFontMetric()
===getWidths()===
===getWidths()===
Get the currently set width of the columns. If we are using one of the algorithms
Get the currently set width of the columns. If we are using one of the algorithms to determine the widths, it will be set to the widths used in the generation of the last text table
to determine the widths, it will be set to the widths used in the generation of the last
text table
*Signature: public function getWidths()
*Signature: public function getWidths()
*Returns: [http://www.php.net/manual/en/language.types.array.php array ] of numeric
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of numeric
===getWidthsFromAllCells()===
===getWidthsFromAllCells()===
*Signature: protected function getWidthsFromAllCells($table_data,$font_sizes)
*Signature: protected function getWidthsFromAllCells($table_data,$font_sizes)
Parameters:
*Parameters:
*$table_data  
*$table_data  
*$font_sizes  
*$font_sizes  
===getWidthsFromHeader()===
===getWidthsFromHeader()===
*Signature: protected function getWidthsFromHeader($row_data,$font_sizes)
*Signature: protected function getWidthsFromHeader($row_data,$font_sizes)
Parameters:
*Parameters:
*$row_data  
*$row_data  
*$font_sizes  
*$font_sizes  
===setColSpacing()===
===setColSpacing()===
*Signature: public function setColSpacing($col_spacing)
*Signature: public function setColSpacing($col_spacing)
Parameters:
*Parameters:
*$col_spacing  
*$col_spacing  
===setFontMetric()===
===setFontMetric()===
*Signature: public function setFontMetric($fm)
*Signature: public function setFontMetric($fm)
Parameters:
*Parameters:
*$fm  
*$fm  
===setMaxTableWidth()===
===setMaxTableWidth()===
*Signature: public function setMaxTableWidth($table_width)
*Signature: public function setMaxTableWidth($table_width)
Parameters:
*Parameters:
*$table_width  
*$table_width  
===setMinCellWidth()===
===setMinCellWidth()===
*Signature: public function setMinCellWidth($width)
*Signature: public function setMinCellWidth($width)
Parameters:
*Parameters:
*$width  
*$width  
**Default Value: 0
***Default Value: 0
===setWidthStyle()===
===setWidthStyle()===
Set the table's column widths
Set the table's column widths @param sting $widthsstyle.  Possible values are 'Explicit' the user sets the widths via setWidths(). 'Header' --n we try to guess good widths by looking at the first row of the table. 'All' then we try to guess good widths by examining all rows.
@param sting $widthsstyle.  Possible values are 'Explicit' the user sets the widths via setWidths().
'Header' --n we try to guess good widths
by looking at the first row of the table. 'All' then we try to guess good widths
by examining all rows.
*Signature: public function setWidthStyle($widthstyle)
*Signature: public function setWidthStyle($widthstyle)
Parameters:
*Parameters:
*$widthstyle  
*$widthstyle  
===setWidths()===
===setWidths()===
*Signature: public function setWidths($widths)
*Signature: public function setWidths($widths)
Parameters:
*Parameters:
*$widths  
*$widths  
===wordWrapTable()===
===wordWrapTable()===
@param array of array of string $table_data a row/col array of the text we want in the table
@param array of array of string $table_data a row/col array of the text we want in the table
if $font_size[$i] describe the font_size to be used for row $i.  if $font_size[$i] is numeric
then the font size applies to the whole row $i.  othwise, if it is an array of numeric, the font_size[$i][$j]
is the font size of cell $i,$j.
the same number of rows of text per cell
*Signature: public function wordWrapTable($table_data,$font_size,$pad_cell_height)
*Signature: public function wordWrapTable($table_data,$font_size,$pad_cell_height)
*Returns: a row/col indexed array of arrays.  each text cell becomes an array of strings, each element of which
*Parameters:
is a row of text of that cell.
Parameters:
*$table_data  
*$table_data  
* [http://www.php.net/manual/en/language.types.array.php array ] $font_size
** [http://www.php.net/manual/en/language.types.array.php array ] $font_size if $font_size[$i] describe the font_size to be used for row $i.  if $font_size[$i] is numeric then the font size applies to the whole row $i.  othwise, if it is an array of numeric, the font_size[$i][$j] is the font size of cell $i,$j.
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $pad_cell_height<br/>(Default true) whether or not we should ensure that for each table row, we have
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $pad_cell_height <br/>(Default true) whether or not we should ensure that for each table row, we have the same number of rows of text per cell
**Default Value: true
***Default Value: true
*Returns: a<br/>row/col indexed array of arrays.  each text cell becomes an array of strings, each element of which is a row of text of that cell.
==Inherited Variables==
==Inherited Variables==
===$font_metric===
===$font_metric===

Revision as of 23:43, 16 October 2009

This article desrcibes the class I2CE_TextTable.

A word-wrapping text tabke class. Uses the i2ce_hyphen class.

Variables

$font_metric

protected @var I2CE_FontMetric $font_metric

  • Type: protected $font_metric

$encoding

protected @var I2CE_Encoding $encoding

  • Type: protected $encoding

$widths

  • Type: protected $widths

$col_spacing

protected @var numeric $col_spacing -- the spacing between columns

  • Type: protected $col_spacing

$max_table_width

  • Type: protected $max_table_width

$min_cell_width

  • Type: protected $min_cell_width

$widthstyle

  • Type: protected $widthstyle

Methods

Visualize()

  • Signature: public function Visualize($table_data,$font_size)
  • Parameters:
  • $table_data
  • $font_size

__construct()

Construct a text table object @param numeric $max_width -- the maximum width of the table

  • Signature: public function __construct($max_table_width,$font_metric,$hyphen,$encoding,$col_spacing,$widthstyle,$algorithm)
  • Parameters:
  • $max_table_width
    • I2CE_FontMetric $font_metric
    • I2CE_Hyphen $hyphen
      default is null
      • Default Value: null
    • &$encoding
    • numeric $col_spacing
      the spacing used between the columns. Default to 0
      • Default Value: 0
    • string $widthstyle
      how we determine the width of the columns. Defaults to 'Header'
      • Default Value: 'Header'
    • int $algorithm
      the word wrapping algorithm: default = 'Greedy' @param I2CE_Encoding encoding -- the encoding we want to use
      • Default Value: 'Greedy'

adjustDesiredWidths()

helper function to adjust the desired width of a column to those allowable by the maxium size

  • Signature: protected function adjustDesiredWidths($desired_widths,$width)
  • Parameters:
  • $desired_widths
  • $width

getColSpacing()

  • Signature: public function getColSpacing()

getFontMetric()

  • Signature: public function getFontMetric()

getWidths()

Get the currently set width of the columns. If we are using one of the algorithms to determine the widths, it will be set to the widths used in the generation of the last text table

  • Signature: public function getWidths()
  • Returns: array
    of numeric

getWidthsFromAllCells()

  • Signature: protected function getWidthsFromAllCells($table_data,$font_sizes)
  • Parameters:
  • $table_data
  • $font_sizes

getWidthsFromHeader()

  • Signature: protected function getWidthsFromHeader($row_data,$font_sizes)
  • Parameters:
  • $row_data
  • $font_sizes

setColSpacing()

  • Signature: public function setColSpacing($col_spacing)
  • Parameters:
  • $col_spacing

setFontMetric()

  • Signature: public function setFontMetric($fm)
  • Parameters:
  • $fm

setMaxTableWidth()

  • Signature: public function setMaxTableWidth($table_width)
  • Parameters:
  • $table_width

setMinCellWidth()

  • Signature: public function setMinCellWidth($width)
  • Parameters:
  • $width
      • Default Value: 0

setWidthStyle()

Set the table's column widths @param sting $widthsstyle. Possible values are 'Explicit' the user sets the widths via setWidths(). 'Header' --n we try to guess good widths by looking at the first row of the table. 'All' then we try to guess good widths by examining all rows.

  • Signature: public function setWidthStyle($widthstyle)
  • Parameters:
  • $widthstyle

setWidths()

  • Signature: public function setWidths($widths)
  • Parameters:
  • $widths

wordWrapTable()

@param array of array of string $table_data a row/col array of the text we want in the table

  • Signature: public function wordWrapTable($table_data,$font_size,$pad_cell_height)
  • Parameters:
  • $table_data
    • array $font_size if $font_size[$i] describe the font_size to be used for row $i. if $font_size[$i] is numeric then the font size applies to the whole row $i. othwise, if it is an array of numeric, the font_size[$i][$j] is the font size of cell $i,$j.
    • boolean $pad_cell_height
      (Default true) whether or not we should ensure that for each table row, we have the same number of rows of text per cell
      • Default Value: true
  • Returns: a
    row/col indexed array of arrays. each text cell becomes an array of strings, each element of which is a row of text of that cell.

Inherited Variables

$font_metric

Theis protected variable is inherited from I2CE_TextCell->$font_metric

$encoding

Theis protected variable is inherited from I2CE_TextCell->$encoding

$space_char

Theis protected variable is inherited from I2CE_TextCell->$space_char

$hyphen_char

Theis protected variable is inherited from I2CE_TextCell->$hyphen_char

$width

Theis protected variable is inherited from I2CE_TextCell->$width

$hyphen

Theis protected variable is inherited from I2CE_TextCell->$hyphen