Source for file TextShape.php
Documentation is available at TextShape.php
* Description: Base class for Chart shape elements with text
* @copyright (c) 1995-2010 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
private $DEFAULTROUNDSIZE = 16;
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
$this->textFormat = TextFormatted::$NORMAL;
if ($this->font != null) {
$this->font->setChart($this->chart);
* Shape may be rectagular or rounded rectangular in shape. <br>
* Default value: TextShapeStyle.Rectangle
return $this->shapeStyle;
* Shape may be rectagular or rounded rectangular in shape. <br>
* Default value: TextShapeStyle.Rectangle
* @param value TextShapeStyle
if ($this->shapeStyle != $value) {
$this->shapeStyle = $value;
* Determines if Text is drawn as Normal or HTML styles.
* Default value: TextFormatted::$Normal
return $this->textFormat;
if ($this->textFormat != $value)
$this->textFormat = $value;
* Obsolete. Please use Shadow.<!-- -->Size.
* Obsolete. Please use Shadow.<!-- -->Size.
return ($this->lines == null) ? 0 : count($this->lines);
static private function stringJoin($separator, $source) {
for ($t = 0; $t < sizeof($source); $t++ ) {
$result = $result . $source[$t] . $separator;
* Displays customized strings inside Shapes. <br>
* You can use Font and Aligment to control Text display. <br><br>
* Note: You would maybe need to change Shape Font size to a different
* value when creating metafiles or when zooming Charts.
/* TODO correct line, temp code added
return ($this->getLinesLength() == 0) ? "" : $this->stringJoin($Language->getString("crlf"), $this->lines);
* Displays customized strings inside Shapes. <br>
One separator can be single char, so use a trick and replace \r\n with \n
$istr = $value->replaceAll($Language->getString("crlf"), $Language->getString("LineSeparator"));
$this->lines = $StringFormat->split($istr, $Language->getString("LineSeparator"));
* Accesses the array of Text lines.<br>
* Use lines to add multiline text to TeeChart's text objects
* (TeeChart Header, TeeChart Axis Titles etc.). <br>
* Accesses the array of Text lines.<br>
* Determines the font attributes used to output
* ShapeSeries.<!-- -->Text Strings.
if ($this->font == null) {
* Assign all properties from a TextShape to another.
$this->getFont()->assign($s->font);
$this->lines = $s->lines;
$this->shapeStyle = $s->shapeStyle;
* Paints the TextShape object on the Chart Canvas.
public function paint() {
* Paints the TextShape object on the Chart Canvas.
public function _paint($gd, $rect, $animations= null) {
if ($this->drawText && ($this->lines != null)) {
$gd->setFont($this->font);
$tmpW = $gd->textWidth($tmpText);
$rect->height = $gd->textHeight($tmpText);
$rect->x = (($rect->x + $x) / 2) - $tmpW;
//CDI Fix for TextShapeStyle
if ($this->shapeStyle == TextShapeStyle::$RECTANGLE) {
if ($this->shapeStyle == TextShapeStyle::$ROUNDRECTANGLE) {
// super.paint(g, rect); Not valid here !!!
if ($this->drawText && ($this->lines != null)) {
$gd->textOut($rect->x, $rect->y + 2, 0, $tmpText);
private function internalDrawShape($gd, $aRect, $defaultRoundSize, $angle, $aZ,$animations= null) {
$gd->polygonZ($aZ, $gd->rotateRectangle($aRect, $angle));
if ($gd->getSupportsFullRotation()) {
$gd->rectangleWithZ($aRect, $aZ);
$gd->rectangle($aRect); // $animations
$gd->roundRectangle($aRect,$defaultRoundSize,$defaultRoundSize);
* Draws the Shape rectangle rotated by Angle degrees.
public function drawRectRotated($gd, $rect, $angle, $aZ, $animations= null) {
if (!$gd->getSupportsFullRotation()) {
$this->shadow->draw($gd, $rect, $angle, $aZ); // internaldrawshape !
// if (($this->getGradient()->getVisible()) && ($angle == 0)) {
// $this->getGradient()->fill($gd->img,
// $this->getGradient()->getDirection(),
// $this->getGradient()->getStartColor(),
// $this->getGradient()->getEndColor());
// $gd->getBrush()->setVisible(false);
$this->internalDrawShape($gd, $rect, $this->DEFAULTROUNDSIZE, $angle, $aZ, $animations);
$this->bBevel->draw($gd, $rect);
|