<?php
/******************************************************************************
* File : $RCSfile: class.coordinateobject.php,v $
* Project : pdfDOM
* Description : Coordinate helper class
* Author : Timo A. Hummel <hide@address.com>
* Created : 28.01.2003
* Modified : $Date: 2005/06/23 11:31:04 $
*
* This file is part of the pdfDOM project.
*
* More information:
* http://www.pdfdom.org
* http://www.sf.net/projects/pdfdom
*
* © four for business AG, www.4fb.de
*
* $Id: class.coordinateobject.php,v 1.2 2005/06/23 11:31:04 timo_h Exp $
******************************************************************************/
class pdCoordinateObject
{
// Attributes
/**
* x coordinate
*/
var $_x;
/**
* y coordinate
*/
var $_y;
/**
* width
*/
var $_width;
/**
* height
*/
var $_height;
/**
* x1
*/
var $_x1;
/**
* y1
*/
var $_y1;
/**
* Constructor
* Initializes all variables to float
* @param none
* @return none
*/
function pdCoordinateObject ()
{
settype($this->_x, "float");
settype($this->_y, "float");
settype($this->_width, "float");
settype($this->_height, "float");
settype($this->_x1, "float");
settype($this->_y1, "float");
}
// Operations
/**
* sets the X coordinate of the object
* @param x the x coordinate of the object
*/
function setX($x)
{
$this->_x = $x;
} // end operation setX
/**
* sets the y coordinate
* @param y
*/
function setY($y)
{
$this->_y = $y;
} // end operation setY
/**
* sets the width of the object
* @param w
*/
function setWidth($w)
{
$this->_width = $w;
$this->_x1 = $this->_x + $this->_width;
} // end operation setWidth
/**
* sets the height of the object
* @param h
*/
function setHeight($h)
{
$this->_height = $h;
$this->_y1 = $this->_y + $this->_height;
} // end operation setHeight
/**
* sets the x and y coordinates
* @param x
* @param y
*/
function setXY($x, $y)
{
$this->setX($x);
$this->setY($y);
} // end operation setXY
/**
* sets the x and y coordinates as well as the width and height
* @param x
* @param y
* @param w
* @param h
*/
function setXYWH($x, $y, $w, $h)
{
$this->setX($x);
$this->setY($y);
$this->setWidth($w);
$this->setHeight($h);
} // end operation setXYWH
/**
* sets the x1 coordinate
* @param x1
*/
function setX1($x1)
{
$this->_x1 = $x1;
$this->_width = $this->_x1 - $this->_x;
} // end operation setX1
/**
* sets the y1 coordinate
* @param y1
*/
function setY1($y1)
{
$this->_y1 = $y1;
$this->_height = $this->_y1 - $this->_y;
} // end operation setY1
/**
* sets the x1 and y1 coordinates
* @param x1
* @param y1
*/
function setX1Y1($x1, $y1)
{
$this->setX1($x1);
$this->setY1($y1);
} // end operation setX1Y1
function moveY ($y)
{
$offset = $this->getHeight();
$this->setY($y);
$this->setHeight($offset);
}
function moveX ($x)
{
$offset = $this->getWidth();
$this->setX($x);
$this->setWidth($offset);
}
/**
* sets the x, y, x1 and y1 coordinates
* @param x
* @param y
* @param x1
* @param y1
*/
function setXYX1Y1($x, $y, $x1, $y1)
{
$this->setX($x);
$this->setY($y);
$this->setX1($x1);
$this->setY1($y1);
} // end operation set_XYX1Y1
/**
* returns the x coordinate
*/
function getX()
{
return ($this->_x);
} // end operation getX
/**
* returns the y coordinate
*/
function getY()
{
return ($this->_y);
} // end operation getY
/**
* returns the width of the object
*/
function getWidth()
{
return ($this->_width);
} // end operation getWidth
/**
* returns the height of the object
*/
function getHeight()
{
return ($this->_height);
} // end operation getHeight
/**
* returns the x1 coordinate
*/
function getX1()
{
return ($this->_x1);
} // end operation getX1
/**
* Does ...
*/
function getY1()
{
return ($this->_y1);
} // end operation getY1
function getXYX1Y1 ()
{
return (array(
$this->getX(),
$this->getY(),
$this->getX1(),
$this->getY1()));
}
function getXYWH ()
{
return (array(
$this->getX(),
$this->getY(),
$this->getWidth(),
$this->getHeight()));
}
} // end class pdCoordinateObject
?>