Sgss_Graphics_Length
Represents an encapsuled length

Description

Implements:
Sgss_Graphics_Length_Interface
Author:
Matsuda Shota
Copyright:
(c) 2007-2008 Matsuda Shota
License:
http://creativecommons.org/licenses/GPL/2.0/
Located in:
/Graphics/Length.php (line 61)

Class overview

Accessors

read-only number $value

Value of this length

read-only string $type

Type of this length

Variables

protected static array $_absolutes

Definition of absolute length types

protected static array $_fixeds

Definition of fixed length types

protected int $_method

Measurement method of this length

protected Sgss_Graphics_Length_Interface|null $_ref

Reference of this length

protected static array $_relatives

Definition of relative length types

protected string $_type

Type of this length

protected static array $_types

Length type declarations

protected number $_value

Value of this length

Methods

__construct (string|number $value, [string|null $type = null])

The constructor

int compare (Sgss_Graphics_Length $length, [int $precision = -1])

Compares the measurement of this length with that of the specified length

Sgss_Graphics_Length convertTo (string $type)

Converts the type of this length to the specified type of length

boolean equals (Sgss_Graphics_Length $length, [int $precision = -1])

Determines the measurement of this length is equals to that of the specified length

Sgss_Graphics_Length getLength (string $type)

Alias of the convertTo()

string getType ()

Returns the type of this length

number getValue ([string|null $type = null])

Returns the value of this length, or converts it into the specified type of length

number pixel ()
Sgss_Graphics_Length referTo (Sgss_Graphics_Length_Interface $ref)

Sets the reference of this length to the specified value

protected boolean _contains (Sgss_Graphics_Length $ref)

Determines whether this length contains the specified length in the reference chain of this length

protected Sgss_Graphics_Length_Interface|null _findRes ()

Returns the resolution in the reference chain of this length

protected static int _methodOf (string $type)

Returns method of the specified type

protected boolean _needRef ()

Determines whether this length needs reference

mixed __get (mixed $name)
array __sleep ()
string __toString ()
void __wakeup ()

Constants

CENTIMETER = 'CENTIMETER' Type of length
EM = 'EM' Type of length
EX = 'EX' Type of length
FACTOR = 'FACTOR' Type of length
INCH = 'INCH' Type of length
METER = 'METER' Type of length
METHOD_ABSOLUTE = 1 Absolute measurement type identifier
METHOD_FIXED = 0 Fixed measurement type identifier
METHOD_RELATIVE = 2 Relative measurement type identifier
MILLIMETER = 'MILLIMETER' Type of length
PERCENT = 'PERCENT' Type of length
PERMILLE = 'PERMILLE' Type of length
PICA = 'PICA' Type of length
PIXEL = 'PIXEL' Type of length
POINT = 'POINT' Type of length

Variable detail

$_absolutes  

Definition of absolute length types

This takes the following form:

  1.  array(
  2.      name1 => zend_measure_type1
  3.      name2 => zend_measure_type2
  4.      ....
  5.      nameN => zend_measure_typeN
  6.  );

Signature:
protected static array $_absolutes = array(...)


$_fixeds  

Definition of fixed length types

This takes the following form:

  1.  array(name1name....nameN);

Signature:
protected static array $_fixeds = array(...)


$_method 

Measurement method of this length

Signature:
protected int $_method


$_ref 

Reference of this length

Signature:
protected Sgss_Graphics_Length_Interface|null $_ref = null


$_relatives  

Definition of relative length types

  1.  array(
  2.      name1 => array(multiplier1class1),
  3.      name2 => array(multiplier2class2),
  4.      ....
  5.      nameN => array(multiplierNclassN)
  6.  );

Signature:
protected static array $_relatives = array(...)


$_type 

Type of this length

Signature:
protected string $_type


$_types  

Length type declarations

This takes the following form:

  1.  array(
  2.      suffix1 => name1
  3.      suffix2 => name2
  4.      ....
  5.      suffixN => nameN
  6.  );

Signature:
protected static array $_types = array(...)


$_value 

Value of this length

Signature:
protected number $_value


Method detail

__construct

The constructor

Parameters:
  • string|number $value

    Value or expression of length

  • string|null $type

    Type of length

Throws:
  • Sgss_Graphics_Length_Exception

    When the specified type is undefined

Signature:
public __construct (string|number $value, [string|null $type = null])


compare

Compares the measurement of this length with that of the specified length

Parameters:
  • Sgss_Graphics_Length $length

    Length with which this length is to be compared

  • int $precision

    Number of decimals to be compared

Returns:
int -- Positive when the measurement of this length is larger than that of the specified length, negative when smaller, and zero when equivalent
Uses:
Sgss_Graphics_Length::getValue(), Sgss_Graphics_Length::getType()
Signature:
public int compare (Sgss_Graphics_Length $length, [int $precision = -1])


convertTo

Converts the type of this length to the specified type of length

Parameters:
  • string $type

    The type to which this length is to be converted

Returns:
Sgss_Graphics_Length -- Converted length
Uses:
Sgss_Graphics_Length::_methodOf(), Sgss_Graphics_Length::getValue()
Used by:
Sgss_Graphics_Length::getLength()
Signature:
public Sgss_Graphics_Length convertTo (string $type)


equals

Determines the measurement of this length is equals to that of the specified length

Parameters:
  • Sgss_Graphics_Length $length

    Length with which this length is to be determined

  • int $precision

    Number of decimals to be determined

Returns:
boolean -- True if the measurement of this length equals to that of the specified length
Uses:
Sgss_Graphics_Length::getValue(), Sgss_Graphics_Length::getType()
Signature:
public boolean equals (Sgss_Graphics_Length $length, [int $precision = -1])


getLength

Alias of the convertTo()

Parameters:
  • string $type

    The type to which this length is to be converted

Returns:
Sgss_Graphics_Length -- Converted length
Specified by:
Uses:
Sgss_Graphics_Length::convertTo()
Related subject:
Sgss_Graphics_Length_Interface::getLength()
Signature:
public Sgss_Graphics_Length getLength (string $type)


getType

Returns the type of this length

Returns:
string -- The type of this length
Used by:
Sgss_Graphics_Length::getValue(), Sgss_Graphics_Length::equals(), Sgss_Graphics_Length::compare()
Signature:
public string getType ()


getValue

Returns the value of this length, or converts it into the specified type of length

Parameters:
  • string|null $type

    The type into which the value of this length is to be converted

Returns:
number -- The value of this length, or converted value expressed in the specified type
Throws:
  • Sgss_Graphics_Length_Exception

    When the specified type is undefined, or unable to convert

Uses:
Sgss_Graphics_Length::_methodOf(), Sgss_Graphics_Length::getType(), Sgss_Graphics_Length::getValue(), Zend_Measure_Length
Used by:
Sgss_Graphics_Length::compare(), Sgss_Graphics_Length::convertTo(), Sgss_Graphics_Length::getValue(), Sgss_Graphics_Length::equals()
Signature:
public number getValue ([string|null $type = null])


pixel

Signature:
public number pixel ()


referTo

Sets the reference of this length to the specified value

Parameters:
Returns:
Sgss_Graphics_Length -- This object for conveniece
Throws:
  • Sgss_Graphics_Length_Exception

    When the specified reference is illegal, or attempling to refer in cyclic

Uses:
Sgss_Graphics_Length::_contains()
Signature:
public Sgss_Graphics_Length referTo (Sgss_Graphics_Length_Interface $ref)


_contains 

Determines whether this length contains the specified length in the reference chain of this length

Parameters:
Returns:
boolean -- True when this length contains the specified length in the reference chain of this length
Used by:
Sgss_Graphics_Length::referTo()
Signature:
protected boolean _contains (Sgss_Graphics_Length $ref)


_findRes 

Returns the resolution in the reference chain of this length

Returns:
Sgss_Graphics_Length_Interface|null -- Resolution in the reference chain of this length, or null if not found
Signature:
protected Sgss_Graphics_Length_Interface|null _findRes ()


_methodOf  

Returns method of the specified type

Parameters:
  • string $type

    Type to be converted

Returns:
int -- Method identifier of the specified type
Used by:
Sgss_Graphics_Length::getValue(), Sgss_Graphics_Length::convertTo()
Signature:
protected static int _methodOf (string $type)


_needRef 

Determines whether this length needs reference

Returns:
boolean -- True when this length needs reference
Signature:
protected boolean _needRef ()


__get

Parameters:
  • mixed $name
Signature:
public mixed __get (mixed $name)


__sleep

Signature:
public array __sleep ()


__toString

Signature:
public string __toString ()


__wakeup

Signature:
public void __wakeup ()


Constant detail

CENTIMETER

Type of length

Signature:
const CENTIMETER = 'CENTIMETER'


EM

Type of length

Signature:
const EM = 'EM'


EX

Type of length

Signature:
const EX = 'EX'


FACTOR

Type of length

Signature:
const FACTOR = 'FACTOR'


INCH

Type of length

Signature:
const INCH = 'INCH'


METER

Type of length

Signature:
const METER = 'METER'


METHOD_ABSOLUTE

Absolute measurement type identifier

Signature:
const METHOD_ABSOLUTE = 1


METHOD_FIXED

Fixed measurement type identifier

Signature:
const METHOD_FIXED = 0


METHOD_RELATIVE

Relative measurement type identifier

Signature:
const METHOD_RELATIVE = 2


MILLIMETER

Type of length

Signature:
const MILLIMETER = 'MILLIMETER'


PERCENT

Type of length

Signature:
const PERCENT = 'PERCENT'


PERMILLE

Type of length

Signature:
const PERMILLE = 'PERMILLE'


PICA

Type of length

Signature:
const PICA = 'PICA'


PIXEL

Type of length

Signature:
const PIXEL = 'PIXEL'


POINT

Type of length

Signature:
const POINT = 'POINT'