Zend Framework  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AbstractObject Class Reference

Class for generate Barcode. More...

Public Member Functions

 __construct ($options=null)
 Constructor.
 
 setOptions ($options)
 Set barcode state from options array.
 
 setBarcodeNamespace ($namespace)
 Set barcode namespace for autoloading.
 
 getBarcodeNamespace ()
 Retrieve barcode namespace.
 
 getType ()
 Retrieve type of barcode.
 
 setBarHeight ($value)
 Set height of the barcode bar.
 
 getBarHeight ()
 Get height of the barcode bar.
 
 setBarThinWidth ($value)
 Set thickness of thin bar.
 
 getBarThinWidth ()
 Get thickness of thin bar.
 
 setBarThickWidth ($value)
 Set thickness of thick bar.
 
 getBarThickWidth ()
 Get thickness of thick bar.
 
 setFactor ($value)
 Set factor applying to thinBarWidth - thickBarWidth - barHeight - fontSize.
 
 getFactor ()
 Get factor applying to thinBarWidth - thickBarWidth - barHeight - fontSize.
 
 setForeColor ($value)
 Set color of the barcode and text.
 
 getForeColor ()
 Retrieve color of the barcode and text.
 
 setBackgroundColor ($value)
 Set the color of the background.
 
 getBackgroundColor ()
 Retrieve background color of the image.
 
 setWithBorder ($value)
 Activate/deactivate drawing of the bar.
 
 getWithBorder ()
 Retrieve if border are draw or not.
 
 setWithQuietZones ($value)
 Activate/deactivate drawing of the quiet zones.
 
 getWithQuietZones ()
 Retrieve if quiet zones are draw or not.
 
 setReverseColor ()
 Allow fast inversion of font/bars color and background color.
 
 setOrientation ($value)
 Set orientation of barcode and text.
 
 getOrientation ()
 Retrieve orientation of barcode and text.
 
 setText ($value)
 Set text to encode.
 
 getText ()
 Retrieve text to encode.
 
 getRawText ()
 Retrieve text to encode.
 
 getTextToDisplay ()
 Retrieve text to display.
 
 setDrawText ($value)
 Activate/deactivate drawing of text to encode.
 
 getDrawText ()
 Retrieve if drawing of text to encode is enabled.
 
 setStretchText ($value)
 Activate/deactivate the adjustment of the position of the characters to the position of the bars.
 
 getStretchText ()
 Retrieve if the adjustment of the position of the characters to the position of the bars is enabled.
 
 setWithChecksum ($value)
 Activate/deactivate the automatic generation of the checksum character added to the barcode text.
 
 getWithChecksum ()
 Retrieve if the checksum character is automatically added to the barcode text.
 
 setWithChecksumInText ($value)
 Activate/deactivate the automatic generation of the checksum character added to the barcode text.
 
 getWithChecksumInText ()
 Retrieve if the checksum character is automatically added to the barcode text.
 
 setFont ($value)
 Set the font:
 
 getFont ()
 Retrieve the font.
 
 setFontSize ($value)
 Set the size of the font in case of TTF.
 
 getFontSize ()
 Retrieve the size of the font in case of TTF.
 
 getQuietZone ()
 Quiet zone before first bar and after the last bar.
 
 getInstructions ()
 Retrieve the set of drawing instructions.
 
 checkParams ()
 Checking of parameters after all settings.
 
 getHeight ($recalculate=false)
 Get height of the result object.
 
 getWidth ($recalculate=false)
 Get width of the result object.
 
 getOffsetLeft ($recalculate=false)
 Calculate the offset from the left of the object if an orientation is activated.
 
 getOffsetTop ($recalculate=false)
 Calculate the offset from the top of the object if an orientation is activated.
 
 draw ()
 Complete drawing of the barcode.
 
 validateText ($value)
 Check for invalid characters.
 

Protected Member Functions

 getDefaultOptions ()
 Set default options for particular object.
 
 addLeadingZeros ($text, $withoutChecksum=false)
 Automatically add leading zeros if barcode length is fixed.
 
 addInstruction (array $instruction)
 Add an instruction in the array of instructions.
 
 addPolygon (array $points, $color=null, $filled=true)
 Add a polygon drawing instruction in the set of instructions.
 
 addText ($text, $size, $position, $font, $color, $alignment= 'center', $orientation=0)
 Add a text drawing instruction in the set of instructions.
 
 checkText ($value=null)
 Check if a text is really provided to barcode.
 
 checkRatio ($min=2, $max=3)
 Check the ratio between the thick and the thin bar.
 
 checkFontAndOrientation ()
 Drawing with an angle is just allow TTF font.
 
 calculateWidth ()
 Width of the result image (before any rotation)
 
 calculateBarcodeWidth ()
 Calculate the width of the barcode.
 
 calculateHeight ()
 Height of the result object.
 
 calculateBarcodeHeight ()
 Height of the barcode.
 
 rotate ($x1, $y1)
 Apply rotation on a point in X/Y dimensions.
 
 drawBarcode ()
 Draw the barcode.
 
 drawBorder ()
 Partial function to draw border.
 
 drawText ()
 Partial function to draw text.
 
 validateSpecificText ($value, $options=[])
 Standard validation for most of barcode objects.
 
 prepareBarcode ()
 Each child must prepare the barcode and return a table like array( 0 => array( 0 => int (visible(black) or not(white)) 1 => int (width of the bar) 2 => float (0->1 position from the top of the beginning of the bar in %) 3 => float (0->1 position from the top of the end of the bar in %) ), 1 => ...
 
 checkSpecificParams ()
 Checking of parameters after all settings.
 
 preDrawBarcode ()
 Allow each child to draw something else.
 
 postDrawBarcode ()
 Allow each child to draw something else (ex: bearer bars in interleaved 2 of 5 code)
 

Protected Attributes

 $barcodeNamespace = 'Zend\Barcode\Object'
 
 $instructions = []
 
 $type = null
 
 $height = null
 
 $width = null
 
 $barHeight = 50
 
 $barThinWidth = 1
 
 $barThickWidth = 3
 
 $factor = 1
 
 $foreColor = 0x000000
 
 $backgroundColor = 0xFFFFFF
 
 $withBorder = false
 
 $withQuietZones = true
 
 $mandatoryQuietZones = false
 
 $orientation = 0
 
 $offsetTop = null
 
 $offsetLeft = null
 
 $text = null
 
 $drawText = true
 
 $stretchText = false
 
 $font = null
 
 $fontSize = 10
 
 $withChecksum = false
 
 $withChecksumInText = false
 
 $barcodeLength = null
 
 $addLeadingZeros = true
 
 $mandatoryChecksum = false
 
 $substituteChecksumCharacter = 0
 

Detailed Description

Class for generate Barcode.

Constructor & Destructor Documentation

__construct (   $options = null)

Constructor.

Parameters
array | Traversable$options

Implements ObjectInterface.

Member Function Documentation

addInstruction ( array  $instruction)
protected

Add an instruction in the array of instructions.

Parameters
array$instruction
addLeadingZeros (   $text,
  $withoutChecksum = false 
)
protected

Automatically add leading zeros if barcode length is fixed.

Parameters
string$text
bool$withoutChecksum
Returns
string
addPolygon ( array  $points,
  $color = null,
  $filled = true 
)
protected

Add a polygon drawing instruction in the set of instructions.

Parameters
array$points
int$color
bool$filled
addText (   $text,
  $size,
  $position,
  $font,
  $color,
  $alignment = 'center',
  $orientation = 0 
)
protected

Add a text drawing instruction in the set of instructions.

Parameters
string$text
float$size
int[]$position
string$font
int$color
string$alignment
float | int$orientation
calculateBarcodeHeight ( )
protected

Height of the barcode.

Returns
int
calculateBarcodeWidth ( )
abstractprotected

Calculate the width of the barcode.

Returns
int
calculateHeight ( )
protected

Height of the result object.

Returns
int
calculateWidth ( )
protected

Width of the result image (before any rotation)

Returns
int
checkFontAndOrientation ( )
protected

Drawing with an angle is just allow TTF font.

Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface
checkParams ( )

Checking of parameters after all settings.

Returns
bool

Implements ObjectInterface.

checkRatio (   $min = 2,
  $max = 3 
)
protected

Check the ratio between the thick and the thin bar.

Parameters
int$min
int$max
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface
checkSpecificParams ( )
abstractprotected

Checking of parameters after all settings.

checkText (   $value = null)
protected

Check if a text is really provided to barcode.

Parameters
string | null$value
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface
draw ( )

Complete drawing of the barcode.

Returns
array Table of instructions

Implements ObjectInterface.

drawBarcode ( )
protected

Draw the barcode.

drawBorder ( )
protected

Partial function to draw border.

drawText ( )
protected

Partial function to draw text.

getBackgroundColor ( )

Retrieve background color of the image.

Returns
int

Implements ObjectInterface.

getBarcodeNamespace ( )

Retrieve barcode namespace.

Returns
string

Implements ObjectInterface.

getBarHeight ( )

Get height of the barcode bar.

Returns
int

Implements ObjectInterface.

getBarThickWidth ( )

Get thickness of thick bar.

Returns
int

Implements ObjectInterface.

getBarThinWidth ( )

Get thickness of thin bar.

Returns
int

Implements ObjectInterface.

getDefaultOptions ( )
protected

Set default options for particular object.

getDrawText ( )

Retrieve if drawing of text to encode is enabled.

Returns
bool

Implements ObjectInterface.

getFactor ( )

Get factor applying to thinBarWidth - thickBarWidth - barHeight - fontSize.

Returns
int

Implements ObjectInterface.

getFont ( )

Retrieve the font.

Returns
int|string

Implements ObjectInterface.

getFontSize ( )

Retrieve the size of the font in case of TTF.

Returns
float

Implements ObjectInterface.

getForeColor ( )

Retrieve color of the barcode and text.

Returns
int

Implements ObjectInterface.

getHeight (   $recalculate = false)

Get height of the result object.

Parameters
bool$recalculate
Returns
int

Implements ObjectInterface.

getInstructions ( )

Retrieve the set of drawing instructions.

Returns
array

Implements ObjectInterface.

getOffsetLeft (   $recalculate = false)

Calculate the offset from the left of the object if an orientation is activated.

Parameters
bool$recalculate
Returns
float

Implements ObjectInterface.

getOffsetTop (   $recalculate = false)

Calculate the offset from the top of the object if an orientation is activated.

Parameters
bool$recalculate
Returns
float

Implements ObjectInterface.

getOrientation ( )

Retrieve orientation of barcode and text.

Returns
float

Implements ObjectInterface.

getQuietZone ( )

Quiet zone before first bar and after the last bar.

Returns
int

Implements ObjectInterface.

getRawText ( )

Retrieve text to encode.

Returns
string

Implements ObjectInterface.

getStretchText ( )

Retrieve if the adjustment of the position of the characters to the position of the bars is enabled.

Returns
bool

Implements ObjectInterface.

getText ( )

Retrieve text to encode.

Returns
string

Implements ObjectInterface.

getTextToDisplay ( )

Retrieve text to display.

Returns
string

Implements ObjectInterface.

getType ( )

Retrieve type of barcode.

Returns
string

Implements ObjectInterface.

getWidth (   $recalculate = false)

Get width of the result object.

Parameters
bool$recalculate
Returns
int

Implements ObjectInterface.

getWithBorder ( )

Retrieve if border are draw or not.

Returns
bool

Implements ObjectInterface.

getWithChecksum ( )

Retrieve if the checksum character is automatically added to the barcode text.

Returns
bool

Implements ObjectInterface.

getWithChecksumInText ( )

Retrieve if the checksum character is automatically added to the barcode text.

Returns
bool

Implements ObjectInterface.

getWithQuietZones ( )

Retrieve if quiet zones are draw or not.

Returns
bool
postDrawBarcode ( )
protected

Allow each child to draw something else (ex: bearer bars in interleaved 2 of 5 code)

preDrawBarcode ( )
protected

Allow each child to draw something else.

prepareBarcode ( )
abstractprotected

Each child must prepare the barcode and return a table like array( 0 => array( 0 => int (visible(black) or not(white)) 1 => int (width of the bar) 2 => float (0->1 position from the top of the beginning of the bar in %) 3 => float (0->1 position from the top of the end of the bar in %) ), 1 => ...

)

Returns
array
rotate (   $x1,
  $y1 
)
protected

Apply rotation on a point in X/Y dimensions.

Parameters
float$x1x-position before rotation
float$y1y-position before rotation
Returns
array Array of two elements corresponding to the new XY point
setBackgroundColor (   $value)

Set the color of the background.

Parameters
int$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setBarcodeNamespace (   $namespace)

Set barcode namespace for autoloading.

Parameters
string$namespace
Returns

Implements ObjectInterface.

setBarHeight (   $value)

Set height of the barcode bar.

Parameters
int$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setBarThickWidth (   $value)

Set thickness of thick bar.

Parameters
int$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setBarThinWidth (   $value)

Set thickness of thin bar.

Parameters
int$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setDrawText (   $value)

Activate/deactivate drawing of text to encode.

Parameters
bool$value
Returns

Implements ObjectInterface.

setFactor (   $value)

Set factor applying to thinBarWidth - thickBarWidth - barHeight - fontSize.

Parameters
int | float | string | bool$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setFont (   $value)

Set the font:

  • if integer between 1 and 5, use gd built-in fonts
  • if string, $value is assumed to be the path to a TTF font
Parameters
int | string$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setFontSize (   $value)

Set the size of the font in case of TTF.

Parameters
float$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setForeColor (   $value)

Set color of the barcode and text.

Parameters
string$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setOptions (   $options)

Set barcode state from options array.

Parameters
array$options
Returns

Implements ObjectInterface.

setOrientation (   $value)

Set orientation of barcode and text.

Parameters
int | float | string | bool$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setReverseColor ( )

Allow fast inversion of font/bars color and background color.

Returns

Implements ObjectInterface.

setStretchText (   $value)

Activate/deactivate the adjustment of the position of the characters to the position of the bars.

Parameters
bool$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setText (   $value)

Set text to encode.

Parameters
string$value
Returns

Implements ObjectInterface.

setWithBorder (   $value)

Activate/deactivate drawing of the bar.

Parameters
bool$value
Returns

Implements ObjectInterface.

setWithChecksum (   $value)

Activate/deactivate the automatic generation of the checksum character added to the barcode text.

Parameters
bool$value
Returns

Implements ObjectInterface.

setWithChecksumInText (   $value)

Activate/deactivate the automatic generation of the checksum character added to the barcode text.

Parameters
bool$value
Returns
Exceptions
\Zend\Barcode\Object\Exception\ExceptionInterface

Implements ObjectInterface.

setWithQuietZones (   $value)

Activate/deactivate drawing of the quiet zones.

Parameters
bool$value
Returns
AbstractObject
validateSpecificText (   $value,
  $options = [] 
)
protected

Standard validation for most of barcode objects.

Parameters
string$value
array$options
validateText (   $value)

Check for invalid characters.

Parameters
string$valueText to be checked

Implements ObjectInterface.

Member Data Documentation

$addLeadingZeros = true
protected
$backgroundColor = 0xFFFFFF
protected
$barcodeLength = null
protected
$barcodeNamespace = 'Zend\Barcode\Object'
protected
$barHeight = 50
protected
$barThickWidth = 3
protected
$barThinWidth = 1
protected
$drawText = true
protected
$factor = 1
protected
$font = null
protected
$fontSize = 10
protected
$foreColor = 0x000000
protected
$height = null
protected
$instructions = []
protected
$mandatoryChecksum = false
protected
$mandatoryQuietZones = false
protected
$offsetLeft = null
protected
$offsetTop = null
protected
$orientation = 0
protected
$stretchText = false
protected
$substituteChecksumCharacter = 0
protected
$text = null
protected
$type = null
protected
$width = null
protected
$withBorder = false
protected
$withChecksum = false
protected
$withChecksumInText = false
protected
$withQuietZones = true
protected