Class: I2CE TextTable (Development): Difference between revisions

From IHRIS Wiki
No edit summary
No edit summary
 
Line 2: Line 2:
This article describes the class ''I2CE_TextTable'' .
This article describes the class ''I2CE_TextTable'' .
*Extends the class: [[Class: I2CE_TextCell (Development) | I2CE_TextCell]].
*Extends the class: [[Class: I2CE_TextCell (Development) | I2CE_TextCell]].
*Location: Part of the module [[TextLayout Tools Module List (Development)#textlayout|textlayout]] in the package [https://launchpad.net/textlayout TextLayout Tools] 4.0-dev
*Location: Part of the module [[TextLayout Tools Module List (Development)#textlayout|textlayout]] in the package [https://launchpad.net/textlayout TextLayout Tools] 4.1-dev
*Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L20 lib/I2CE_TextTable.php] on line 20
*Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L20 lib/I2CE_TextTable.php] on line 20
*Author: Carl Leitner <litlfred@ibiblio.org>
*Author: Carl Leitner <litlfred@ibiblio.org>
A word-wrapping text tabke class.  Uses the i2ce_hyphen class.
A word-wrapping text tabke class.  Uses the i2ce_hyphen class.
Line 9: Line 9:
===$font_metric===
===$font_metric===
protected @var I2CE_FontMetric $font_metric
protected @var I2CE_FontMetric $font_metric
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L52 textlayout/lib/I2CE_TextTable.php] on line 52
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L52 textlayout/lib/I2CE_TextTable.php] on line 52
*Type: protected $font_metric
*Type: protected $font_metric


===$encoding===
===$encoding===
protected @var I2CE_Encoding $encoding
protected @var I2CE_Encoding $encoding
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L57 textlayout/lib/I2CE_TextTable.php] on line 57
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L57 textlayout/lib/I2CE_TextTable.php] on line 57
*Type: protected $encoding
*Type: protected $encoding


===$widths===
===$widths===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L62 textlayout/lib/I2CE_TextTable.php] on line 62
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L62 textlayout/lib/I2CE_TextTable.php] on line 62
*Type: protected $widths
*Type: protected $widths


===$col_spacing===
===$col_spacing===
protected @var numeric $col_spacing -- the spacing between columns
protected @var numeric $col_spacing -- the spacing between columns
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L67 textlayout/lib/I2CE_TextTable.php] on line 67
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L67 textlayout/lib/I2CE_TextTable.php] on line 67
*Type: protected $col_spacing
*Type: protected $col_spacing


===$max_table_width===
===$max_table_width===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L72 textlayout/lib/I2CE_TextTable.php] on line 72
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L72 textlayout/lib/I2CE_TextTable.php] on line 72
*Type: protected $max_table_width
*Type: protected $max_table_width


===$min_cell_width===
===$min_cell_width===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L77 textlayout/lib/I2CE_TextTable.php] on line 77
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L77 textlayout/lib/I2CE_TextTable.php] on line 77
*Type: protected $min_cell_width
*Type: protected $min_cell_width


===$widthstyle===
===$widthstyle===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L82 textlayout/lib/I2CE_TextTable.php] on line 82
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L82 textlayout/lib/I2CE_TextTable.php] on line 82
*Type: protected $widthstyle
*Type: protected $widthstyle


==Methods==
==Methods==
===Visualize()===
===Visualize()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L401 textlayout/lib/I2CE_TextTable.php] on line 401
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L401 textlayout/lib/I2CE_TextTable.php] on line 401
*Signature: public function Visualize($table_data,$font_size)
*Signature: public function Visualize($table_data,$font_size)
*Parameters:
*Parameters:
Line 47: Line 47:
===__construct()===
===__construct()===
Construct a text table object @param numeric $max_width -- the maximum width of the table
Construct a text table object @param numeric $max_width -- the maximum width of the table
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L32 textlayout/lib/I2CE_TextTable.php] on line 32
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L32 textlayout/lib/I2CE_TextTable.php] on line 32
*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:
Line 63: Line 63:
===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
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L245 textlayout/lib/I2CE_TextTable.php] on line 245
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L245 textlayout/lib/I2CE_TextTable.php] on line 245
*Signature: protected function adjustDesiredWidths($desired_widths,$width)
*Signature: protected function adjustDesiredWidths($desired_widths,$width)
*Parameters:
*Parameters:
Line 69: Line 69:
**$width  
**$width  
===getColSpacing()===
===getColSpacing()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L132 textlayout/lib/I2CE_TextTable.php] on line 132
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L132 textlayout/lib/I2CE_TextTable.php] on line 132
*Signature: public function getColSpacing()
*Signature: public function getColSpacing()
===getFontMetric()===
===getFontMetric()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L97 textlayout/lib/I2CE_TextTable.php] on line 97
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L97 textlayout/lib/I2CE_TextTable.php] on line 97
*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 to determine the widths, it will be set to the widths used in the generation of the last text table
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
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L153 textlayout/lib/I2CE_TextTable.php] on line 153
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L153 textlayout/lib/I2CE_TextTable.php] on line 153
*Signature: public function getWidths()
*Signature: public function getWidths()
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of numeric
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of numeric
===getWidthsFromAllCells()===
===getWidthsFromAllCells()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L351 textlayout/lib/I2CE_TextTable.php] on line 351
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L351 textlayout/lib/I2CE_TextTable.php] on line 351
*Signature: protected function getWidthsFromAllCells($table_data,$font_sizes)
*Signature: protected function getWidthsFromAllCells($table_data,$font_sizes)
*Parameters:
*Parameters:
Line 86: Line 86:
**$font_sizes  
**$font_sizes  
===getWidthsFromHeader()===
===getWidthsFromHeader()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L303 textlayout/lib/I2CE_TextTable.php] on line 303
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L303 textlayout/lib/I2CE_TextTable.php] on line 303
*Signature: protected function getWidthsFromHeader($row_data,$font_sizes)
*Signature: protected function getWidthsFromHeader($row_data,$font_sizes)
*Parameters:
*Parameters:
Line 92: Line 92:
**$font_sizes  
**$font_sizes  
===setColSpacing()===
===setColSpacing()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L124 textlayout/lib/I2CE_TextTable.php] on line 124
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L124 textlayout/lib/I2CE_TextTable.php] on line 124
*Signature: public function setColSpacing($col_spacing)
*Signature: public function setColSpacing($col_spacing)
*Parameters:
*Parameters:
**$col_spacing  
**$col_spacing  
===setFontMetric()===
===setFontMetric()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L89 textlayout/lib/I2CE_TextTable.php] on line 89
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L89 textlayout/lib/I2CE_TextTable.php] on line 89
*Signature: public function setFontMetric($fm)
*Signature: public function setFontMetric($fm)
*Parameters:
*Parameters:
**$fm  
**$fm  
===setMaxTableWidth()===
===setMaxTableWidth()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L107 textlayout/lib/I2CE_TextTable.php] on line 107
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L107 textlayout/lib/I2CE_TextTable.php] on line 107
*Signature: public function setMaxTableWidth($table_width)
*Signature: public function setMaxTableWidth($table_width)
*Parameters:
*Parameters:
**$table_width  
**$table_width  
===setMinCellWidth()===
===setMinCellWidth()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L116 textlayout/lib/I2CE_TextTable.php] on line 116
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L116 textlayout/lib/I2CE_TextTable.php] on line 116
*Signature: public function setMinCellWidth($width)
*Signature: public function setMinCellWidth($width)
*Parameters:
*Parameters:
Line 114: Line 114:
===setWidthStyle()===
===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.
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.
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L143 textlayout/lib/I2CE_TextTable.php] on line 143
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L143 textlayout/lib/I2CE_TextTable.php] on line 143
*Signature: public function setWidthStyle($widthstyle)
*Signature: public function setWidthStyle($widthstyle)
*Parameters:
*Parameters:
**$widthstyle  
**$widthstyle  
===setWidths()===
===setWidths()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L160 textlayout/lib/I2CE_TextTable.php] on line 160
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L160 textlayout/lib/I2CE_TextTable.php] on line 160
*Signature: public function setWidths($widths)
*Signature: public function setWidths($widths)
*Parameters:
*Parameters:
Line 125: Line 125:
===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
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0-dev/annotate/head:/lib/I2CE_TextTable.php#L178 textlayout/lib/I2CE_TextTable.php] on line 178
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextTable.php#L178 textlayout/lib/I2CE_TextTable.php] on line 178
*Signature: public function wordWrapTable($table_data,$font_size,$pad_cell_height)
*Signature: public function wordWrapTable($table_data,$font_size,$pad_cell_height)
*Parameters:
*Parameters:

Latest revision as of 08:20, 6 May 2015


This article describes the class I2CE_TextTable .

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

Variables

$font_metric

protected @var I2CE_FontMetric $font_metric

$encoding

protected @var I2CE_Encoding $encoding

$widths

$col_spacing

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

$max_table_width

$min_cell_width

$widthstyle

Methods

Visualize()

__construct()

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

  • Defined in textlayout/lib/I2CE_TextTable.php on line 32
  • 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

  • Defined in textlayout/lib/I2CE_TextTable.php on line 245
  • Signature: protected function adjustDesiredWidths($desired_widths,$width)
  • Parameters:
    • $desired_widths
    • $width

getColSpacing()

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

getWidthsFromAllCells()

  • Defined in textlayout/lib/I2CE_TextTable.php on line 351
  • Signature: protected function getWidthsFromAllCells($table_data,$font_sizes)
  • Parameters:
    • $table_data
    • $font_sizes

getWidthsFromHeader()

setColSpacing()

setFontMetric()

setMaxTableWidth()

setMinCellWidth()

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.

setWidths()

wordWrapTable()

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

  • Defined in textlayout/lib/I2CE_TextTable.php on line 178
  • 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 Methods

getEncoding()

This public method is inherited from I2CE_TextCell->getEncoding()

getHyphenDictionary()

This public method is inherited from I2CE_TextCell->getHyphenDictionary()

getLineBreaks()

This public method is inherited from I2CE_TextCell->getLineBreaks()

getParagraphs()

This public method is inherited from I2CE_TextCell->getParagraphs()

getWidth()

This public method is inherited from I2CE_TextCell->getWidth()

getWords()

This public method is inherited from I2CE_TextCell->getWords()

setEncoding()

This public method is inherited from I2CE_TextCell->setEncoding()

setHyphenationDictionary()

This public method is inherited from I2CE_TextCell->setHyphenationDictionary()

setWidth()

This public method is inherited from I2CE_TextCell->setWidth()

setWordWrapAlgorithm()

This public method is inherited from I2CE_TextCell->setWordWrapAlgorithm()

Greedy()

This protected method is inherited from I2CE_TextCell->Greedy()

Knuth()

This protected method is inherited from I2CE_TextCell->Knuth()

Truncate()

This protected method is inherited from I2CE_TextCell->Truncate()

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