Source for file ShapeSeries.php
Documentation is available at ShapeSeries.php
* <p>Title: ShapeSeries class</p>
* <p>Description: Shape Series.</p>
* <p>Copyright (c) 2005-2010 by Steema Software SL. All Rights Reserved.</p>
* <p>Company: Steema Software SL</p>
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
$this->xyStyle = ShapeXYStyle::$AXIS;
$this->textVertAlign = ShapeTextVertAlign::$CENTER;
$this->textHorizAlign = ShapeTextHorizAlign::$CENTER;
$this->shape = new TextShape($c);
$this->addDefaultPoints();
if ($this->shape != null) {
$this->shape->setChart($c);
private function addDefaultPoints() {
if (parent::getChart() != null) {
$this->drawShape($g, false, $rect);
private function drawText($r) {
$g = $this->chart->getGraphics3D();
$tmpPosY = $tmpMid->getY() - MathUtils::round($tmpH * sizeof($this->getText()) / 2.0);
$tmpWidth = $g->textWidth($this->getText($t));
$tmpPosX = $tmpMid->getX() - ($tmpWidth / 2);
$tmpPosX = $r->getLeft() + $this->getPen()->getWidth() + $shapeHorizMargin;
$tmpPosX = $r->getRight() - $this->getPen()->getWidth() - $tmpWidth -
if ($this->getXYStyle() == ShapeXYStyle::$PIXELS) {
$g->textOut($tmpPosX, $tmpPosY, 0, $this->getText($t));
* Displays customized Strings inside Shapes.<br>
* You can use the Font and Aligment properties to control Text display.<br>
* <b>Note:</b> You may need to change Shape Font size to a different
* value when creating metafiles or when zooming Charts.
public function getText($index=- 1) {
$tmpx = array(); // TODO remove this line ?
$tmpx = $this->shape->getLines();
// TODO review if enter..
if ($this->shape->getLines() == null) {
$this->shape->setLines($tmpStr);
return $this->shape->getLines();
* Coordinate used to define the englobing ShapeSeries rectangle.<br>
* The values should be expressed in Axis coordinates. <br>
* You can convert from Screen pixel coordinates to values and vice-versa
* using several TChart and Series methods like XScreenToValue and
public function getX0() {
* Coordinate used to define the englobing ShapeSeries rectangle.<br>
public function setX0($value) {
* Coordinate used to define the englobing ShapeSeries rectangle.<br>
* The values should be expressed in Axis coordinates. <br>
* You can convert from Screen pixel coordinates to values and vice-versa
* using several TChart and Series methods like XScreenToValue and
public function getX1() {
* Coordinate used to define the englobing ShapeSeries rectangle.<br>
public function setX1($value) {
* Coordinate used to define the englobing ShapeSeries rectangle.<br>
* The values should be expressed in Axis coordinates. <br>
* You can convert from Screen pixel coordinates to values and vice-versa
* using several TChart and Series methods like XScreenToValue and
public function getY0() {
* Coordinate used to define the englobing ShapeSeries rectangle.<br>
public function setY0($value) {
* Coordinate used to define the englobing ShapeSeries rectangle.<br>
* The values should be expressed in Axis coordinates. <br>
* You can convert from Screen pixel coordinates to values and vice-versa
* using several TChart and Series methods like XScreenToValue and
public function getY1() {
* Coordinate used to define the englobing ShapeSeries rectangle.<br>
public function setY1($value) {
* Defines how a TChartShape component appears on a Chart.<br>
* Defines how a TChartShape component appears on a Chart.<br>
* @param value ShapeStyle
$this->chart->invalidate();
* Sets the vertical alignment of Text within a TChartShape Series shape.
* It can be Top, Center, Bottom.
* @return ShapeTextVertAlign
return $this->textVertAlign;
* Sets the vertical alignment of Text within a TChartShape Series shape.
* @param value ShapeTextVertAlign
if ($this->textVertAlign != $value) {
$this->textVertAlign = $value;
* Horizontally aligns the text.<br>
* There are three options; Centre, Left or Right.
* @return ShapeTextHorizAlign
return $this->textHorizAlign;
* Horizontally aligns the text.<br>
* @param value ShapeTextHorizAlign
if ($this->textHorizAlign != $value) {
$this->textHorizAlign = $value;
private function getShapeRectangle() {
$x0 = (int) ($this->getX0());
$y0 = (int) ($this->getY0());
$x1 = (int) ($this->getX1());
$y1 = (int) ($this->getY1());
$x1 = $x0 + (int) ($this->getX1());
$y1 = $y0 + (int) ($this->getY1());
return Rectangle::fromLTRB($x0, $y0, $x1, $y1);
private function getAdjustedRectangle() {
$r = $this->getShapeRectangle();
if ($r->y == $r->getBottom()) {
if ($r->y > $r->getBottom()) {
if ($r->x == $r->getRight()) {
if ($r->x > $r->getRight()) {
private function drawDiagonalCross2D($g, $r) {
$g->line($r->x, $r->y, $r->getRight() + 1, $r->getBottom() + 1);
$g->line($r->x, $r->getBottom(), $r->getRight() + 1, $r->y - 1);
private function drawDiagonalCross3D($g, $r) {
$g->line($r->x, $r->y, $r->getRight(), $r->getBottom(), $this->getMiddleZ());
$g->line($r->x, $r->getBottom(), $r->getRight(), $r->y, $this->getMiddleZ());
private function drawCross3D($g, $r) {
$g->verticalLine($tmpMid->x, $r->y, $r->getBottom(), $this->getMiddleZ());
$g->horizontalLine($r->x, $r->getRight(), $tmpMid->y, $this->getMiddleZ());
private function drawCross2D($g, $r) {
$g->verticalLine($tmpMid->x, $r->y, $r->getBottom() + 1);
$g->horizontalLine($r->x, $r->getRight() + 1, $tmpMid->y);
private function doGradient($is3D, $r) {
$g= $this->chart->getGraphics3D();
$tmpR = $is3D ? $g->calcRect3D($r, $this->getMiddleZ()) : $r;
$g->getBrush()->setVisible(false);
private function _drawShape($is3D, $r) {
$this->drawShape($this->chart->getGraphics3D(), $is3D, $r);
private function drawShape($g, $is3D, $r) {
$g->getBrush()->setVisible(false);
$g->getBrush()->setColor($this->getColor());
// if ( Brush.Color.isEmpty())
// g.getBrush().getVisible()=false;
// TODO assign visible brush to false if transparent is true
$this->doGradient($is3D, $r);
$this->doGradient($is3D, $r);
$g->verticalLine($tmpMid->getX(), $r->getY(), $r->getBottom(), $this->getMiddleZ());
$g->horizontalLine($r->getX(), $r->getRight(), $tmpMid->getY(), $this->getMiddleZ());
$g->triangle(new TeePoint($r->getX(), $r->getBottom()),
new TeePoint($tmpMid->getX(), $r->getY()),
$g->triangle(new TeePoint($r->getX(), $r->getY()),
new TeePoint($tmpMid->getX(), $r->getBottom()),
$g->line($r->getX(), $r->getY(), $r->getRight(), $r->getBottom(), $this->getMiddleZ());
$g->plane(new TeePoint($r->getX(), $tmpMid->getY()),
new TeePoint($tmpMid->getX(), $r->getY()),
new TeePoint($r->getRight(), $tmpMid->getY()),
$this->drawCross3D($g,$r);
$this->drawDiagonalCross3D($g,$r);
$this->drawCross3D($g,$r);
$this->drawDiagonalCross3D($g,$r);
$g->pyramid(true, $r->getX(), $r->getBottom(), $r->getRight(), $r->getY(), $this->getStartZ(),
TextShapeStyle::$ROUNDRECTANGLE) {
$tmpR = new Rectangle($r->getLeft(), $r->getTop(),
$r->height - $roundSize);
$g->roundRectangle($tmpR, $roundSize, $roundSize);
$this->doGradient($is3D, $r);
$this->doGradient($is3D, $r);
$g->verticalLine($tmpMid->getX(), $r->getY(), $r->getBottom());
$g->horizontalLine($r->getX(), $r->getRight() + 1, $tmpMid->getY());
$tmp = Array(new TeePoint($r->getX(), $r->getBottom()),
new TeePoint($tmpMid->getX(), $r->getY()),
new TeePoint($r->getRight(), $r->getBottom()));
$tmp = Array(new TeePoint($r->getX(), $r->getY()),
new TeePoint($tmpMid->getX(), $r->getBottom()),
new TeePoint($r->getRight(), $r->getY()));
$g->line($r->getX(), $r->getY(), $r->getRight(), $r->getBottom());
$tmp = Array(new TeePoint($r->getX(), $tmpMid->getY()),
new TeePoint($tmpMid->getX(), $r->getY()),
new TeePoint($r->getRight(), $tmpMid->getY()),
new TeePoint($tmpMid->getX(), $r->getBottom()));
$this->drawCross2D($g,$r);
$this->drawDiagonalCross2D($g,$r);
$this->drawCross2D($g,$r);
$this->drawDiagonalCross2D($g,$r);
* Called internally. Draws the "ValueIndex" point of the Series.
if (($this->getCount() == 2) && ($valueIndex == 0)) {
$r = $this->getAdjustedRectangle();
if ($r->intersects($this->chart->getChartRect())) {
$tmp = ($this->xyStyle == ShapeXYStyle::$PIXELS) ? false :
$this->chart->getAspect()->getView3D();
($this->style == ShapeStyle::$LINE) ? $this->getShapeRectangle() : $r);
$this->addDefaultPoints();
$this->add($r->tmpX + ($r->StepX / 8.0), $r->tmpY / 2);
$this->add($r->tmpX + $r->StepX - ($r->StepX / 8.0),
$r->tmpY + MathUtils::round($r->DifY * $r->Random()));
* Returns the ValueIndex of the "clicked" point in the Series.
if (($this->chart != null)) {
$p = $this->chart->getGraphics3D()->calculate2DPosition($x, $y, $this->getStartZ());
$r = $this->getShapeRectangle();
$tmp = GraphicsGD::pointInLineTolerance($p, $tmpMid->x, $r->y, $tmpMid->x,
} else if ($this->style== ShapeStyle::$HORIZLINE) {
$tmp = GraphicsGD::pointInLineTolerance($p, $r->x, $tmpMid->y, $r->getRight(),
$tmp = GraphicsGD::pointInLineTolerance($p, $r->x, $r->y, $r->getRight(),
$points= Array (new TeePoint($tmpMid->x, $r->y),
new TeePoint($r->getRight(), $tmpMid->y),
new TeePoint($tmpMid->x, $r->getBottom()),
$tmp = GraphicsGD::pointInTriangle($p, $r->x, $r->getRight(), $r->getBottom(), $r->y);
} else if (($this->style== ShapeStyle::$INVERTTRIANGLE) | ($this->style== ShapeStyle::$INVERTPYRAMID)) {
$tmp = GraphicsGD::pointInTriangle($p, $r->x, $r->getRight(), $r->y, $r->getBottom());
$tmp = GraphicsGD::pointInEllipse($p, $r);
$tmp = $r->contains($x, $y);
* Determines the font attributes used to output ShapeSeries.<br>
* No auto font sizing is performed, so you must specify the desired font
* size to avoid shape text from overlapping the Shape boundaries.
return $this->shape->getFont();
* Defines the brush used to fill shape background.<br>
* <pre><font face="Courier" size="4">
* shape[0] = new TeeShape(myChart.getChart());
* tmpShape.getMarks().setVisible(false);
* tmpShape.setColor(Color.WHITE);
* tmpShape.getBrush().setColor(Color.WHITE);
* tmpShape.getBrush().setImageMode(ImageMode::$TILE);
* tmpShape.getBrush().loadImage(ChartSamplePanel.class.getResource(URL_IMAGE1));
* tmpShape.setStyle(ShapeStyle::$CIRCLE);
* tmpShape.getPen().setColor(Color.RED);
* tmpShape.getPen().setWidth(2);
return $this->shape->getBrush();
* Defines pen to draw Series Shape.
return $this->shape->getPen();
* Gets Gradient fill characteristics for the ShapeSeries Shape.
return $this->shape->getGradient();
$this->shape->setLines($value);
* Allows Shape Brush attributes to fill the interior of the Shape.<br>
* When false, Shapes do not redraw their background, so charting contents
* behind Shape Series is seen inside the Shape. <br>
return $this->shape->getTransparent();
* Allows Shape Brush attributes to fill the interior of the Shape.<br>
$this->shape->setTransparent($value);
$tmpColor = new Color(255,255,255); // White
$this->getFont()->setColor($tmpColor);
$this->shape->setLines($tmpArray);
if ($this->chart->getSeriesIndexOf($this) == 1) {
$this->getBrush()->setColor($isEnabled ? $tmpColor->BLUE : $tmpColor->SILVER);
$tmp= Array(Language::getString("ShapeGallery1"));
$this->getBrush()->setColor($isEnabled ? $tmpColor->RED : $tmpColor->SILVER);
$tmp= Array(Language::getString("ShapeGallery2"));
* Can be set to:- Axis, AxisOrigin or Pixels.
* Can be set to:- Axis, AxisOrigin or Pixels.
* @param value ShapeXYStyle
if ($this->xyStyle != $value) {
* Returns false if the Value parameter is the same as Self.
return $s instanceof Shape;
parent::setSubGallery($index);
|