Source for file Annotation.php
Documentation is available at Annotation.php
* Description: Annotation tool
* @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
public function Annotation($c = null , $text = "")
$this->textAlign = Array(StringAlignment::$HORIZONTAL_LEFT_ALIGN);
// TODO $this->cursor = Cursors::$DEFAULT;
$this->shape->getShadow()->setVisible(true);
$this->listenerList->add($this->ToolMouseListener->class , $l);
$this->listenerList->remove($this->ToolMouseListener->class , $l);
if($this->callout == null)
* The Cursor type for when the user moves the mouse over the
* Annotation bounds. <br>
* Selects the Cursor type for when the user moves the mouse over the
* Annotation bounds. <br>
* Horizontal alignment of displayed text.<br>
* Default value: StringAlignment.Near
* @return StringAlignment
* Sets the horizontal alignment of displayed text.<br>
* Default value: StringAlignment.Near
* @param value StringAlignment
if($this->textAlign != $value)
$this->textAlign = $value;
//private boolean ShouldSerializeLeft() {
// return shape.getCustomPosition();
* The horizontal displacement in pixels of text box from Chart's left
return $this->shape->getLeft();
* Sets horizontal displacement in pixels of text box from Chart's left
$this->shape->setLeft($value);
$this->shape->setCustomPosition(true);
* The vertical displacement in pixels of text box from Chart's top edge.
return $this->shape->getTop();
* Sets vertical displacement in pixels of text box from Chart's top edge.
public function setTop($value)
$this->shape->setTop($value);
$this->shape->setCustomPosition(true);
* The default position for the Annotation Tool text box and text.
* Default value: AnnotationPosition.LeftTop
* @return AnnotationPosition
* Defines a default position for the Annotation Tool text box and text.
* Default value: AnnotationPosition.LeftTop
* @param value AnnotationPosition
if($this->position != $value)
$this->position = $value;
$this->shape->setCustomPosition(false);
* The characteristics of the Annotation Tool text and text box Shape.
* @return TextShapePosition
return $this->shape->getText();
* The text for the Annotation Tool.<br>
* Defines the text for the Annotation Tool.<br>
* Gets detailed descriptive text.
* Returns the annotation height in pixels
return $this->shape->getHeight();
* Sets the annotation height in pixels
$this->shape->setHeight($value);
* Returns the annotation width in pixels
return $this->shape->getWidth();
* Sets the annotation width in pixels
$this->shape->setWidth($value);
/// Set to true to permit custom sizing of TextShape.
return $this->customSize;
$this->customSize = $value;
private function drawText()
$g = $this->chart->getGraphics3D();
$g->setFont($this->shape->getFont());
$tmpHeight = $this->shape->getFont()->getSize();
$m = $this->chart->multiLineTextWidth($tmp);
$tmpW = $m->width- $tmpHeight;
$tmpH = $tmpN * $tmpHeight;
if($this->shape->getCustomPosition())
$x = $this->shape->getShapeBounds()->getLeft() + 4;
$y = $this->shape->getShapeBounds()->getTop() + 4;
$tmpX = $this->chart->getWidth() - $tmpW - 8;
$tmpY = $this->chart->getHeight() - $tmpH - 8;
$this->shape->setShapeBounds(new Rectangle($x - 4, $y - 4, $tmpW + 4,
4 + ($tmpHeight * 1.20) + 4));
if($this->shape->getVisible())
$oldname = TChart::$controlName;
TChart::$controlName = 'Annotation';
TChart::$controlName= $oldname;
$g->getBrush()->setVisible(false);
$g->setTextAlign($this->textAlign);
if($this->textAlign == StringAlignment::$CENTER)
(($this->shape->getShapeBounds()->x + $this->shape->getShapeBounds()->getRight()) /
if($this->textAlign == StringAlignment::$FAR)
$x = $this->shape->getShapeBounds()->getRight() - 2;
$s = Array();// Array of String
for($t = 1; $t <= $tmpN; $t++ )
$g->textOut($x, $y + ($t * $tmpHeight),0, $s[$t - 1]);
if($this->getCallout()->getVisible() || $this->callout->getArrow()->getVisible())
$tmpTo = new TeePoint($this->callout->getXPosition(),
$this->callout->getYPosition());
$tmpFrom = $this->callout->closerPoint($this->shape->getShapeBounds(), $tmpTo);
if($this->callout->getDistance() != 0)
$this->callout->getDistance());
$this->callout->draw(Color::EMPTYCOLOR() , $tmpTo, $tmpFrom, $this->callout->getZPosition());
//$tmpChartDrawEvent = new ChartDrawEvent();
if(/*($e->getID() == ChartDrawEvent::$PAINTED) &&*/ ($e->getDrawPart() == ChartDrawEvent::$CHART))
* Returns true is point parameter is inside annotation bounds
return $this->getShape()->getShapeBounds()->contains($p);
$tmpMouseEvent = new MouseEvent();
if($e->getID() == $tmpMouseEvent->MOUSE_PRESSED)
if(($e->getID() == $tmpMouseEvent->MOUSE_MOVED) &&
($this->cursor != $this->Cursor->getDefaultCursor()))
|