Source for file Border.class.php
Documentation is available at Border.class.php
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
require_once dirname(__FILE__ ). "/../Graph.class.php";
* @package linea21.externals
* @param awColor $color Border color
* @param int $style Border style
public function __construct($color = NULL, $style = awLine::SOLID) {
* This method automatically shows the border if it is hidden
public function setColor(awColor $color) {
$this->style = (int) $style;
public function hide($hide = TRUE) {
$this->hide = (bool) $hide;
public function show($show = TRUE) {
$this->hide = (bool) !$show;
* Is the border visible ?
* Draw border as a rectangle
* @param awDriver $driver
* @param awPoint $p1 Top-left corner
* @param awPoint $p2 Bottom-right corner
public function rectangle(awDriver $driver, awPoint $p1, awPoint $p2) {
$line->setStyle($this->style);
$line->setLocation($p1, $p2);
$driver->rectangle($this->color, $line);
* Draw border as an ellipse
* @param awDriver $driver
* @param awPoint $center Ellipse center
* @param int $width Ellipse width
* @param int $height Ellipse height
public function ellipse(awDriver $driver, awPoint $center, $width, $height) {
$driver->ellipse($this->color, $center, $width, $height);
awImage::drawError("Class Border: Dashed and dotted borders and not yet implemented on ellipses.");
* Draw border as a polygon
* @param awDriver $driver A Driver object
* @param awPolygon $polygon A Polygon object
public function polygon(awDriver $driver, awPolygon $polygon) {
$polygon->setStyle($this->style);
$driver->polygon($this->color, $polygon);
// In case of Line::SOLID, Driver::polygon() uses imagepolygon()
// which automatically closes the shape. In any other case,
// we have to do it manually here.
if($this->style !== Line::SOLID) {
$this->closePolygon($driver, $polygon);
* Draws the last line of a Polygon, between the first and last point
* @param awDriver $driver A Driver object
* @param awPolygon $polygon The polygon object to close
private function closePolygon(awDriver $driver, awPolygon $polygon) {
$first = $polygon->get(0);
$last = $polygon->get($polygon->count() - 1);
$line = new awLine($first, $last, $this->style, $polygon->getThickness());
$driver->line($this->color, $line);
|