Source for file ChartBrush.php
Documentation is available at ChartBrush.php
* Description: Common Chart Brush (pattern) used to fill polygons and
* @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
private $foregroundColor;
private $imageTransparent;
private $wrapTile = true;
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
public function ChartBrush($c, $aColor= null, $startVisible= true) {
$aColor= new Color(255,255,255);
$this->style= HatchStyle::$BACKWARDDIAGONAL;
$this->foregroundColor = new Color (220,220,220); // Silver
public function reset() {
private function bufferedFrom($image) {
$this->hatchImage = $this->bufferedFrom($this->style->getImage(($this->getChart()->getParent())));
$r = new Rectangle(0, 0, $this->hatchImage->getWidth(null),
$this->hatchImage->getHeight(null));
return new TexturePaint($this->hatchImage, $r);
if ($this->imageMode != ImageMode::$STRETCH) {
return new TexturePaint($this->bufferedFrom($image), $tileRect);
$this->foregroundColor = $b->foregroundColor;
$this->color = $b->color;
$this->style = $b->style;
$this->image = $b->image;
$this->imageTransparent = $b->imageTransparent;
$this->solid = $b->solid;
$this->wrapTile = $b->wrapTile;
$this->imageMode = $b->imageMode;
//CDI chart cannot be null
if($this->chart == null) {
$this->chart = $b->chart;
// chart = b.chart; <-- problem, when assigning brush from another chart
if ($b->gradient != null) {
private function setNullHandle() {
if ($this->chart != null) {
$this->chart->doChangedBrush($this);
if ($this->gradient != null) {
$this->gradient->setChart($this->chart);
* The Transparency level from 0 to 100%.<br>
* Transparency is a value between 0 and 100 which sets the transparency
* percentage with respect to foreground versus background.<br>
* Sets Transparency level from 0 to 100%.<br>
if ($this->gradient != null) {
$this->gradient->setTransparency($value);
* Fills using Color only. Does not use Foreground color.<br>
* Fills using Color only. Does not use Foreground color.<br>
* The Brush image will be Transparent when true.<br>
return $this->imageTransparent;
* Sets the Brush image to Transparent.<br>
return ($this->gradient != null) && $this->gradient->visible;
* Gradient specifies the colors used to fill a zone.
* The zone is filled using these three colors: StartColor, MidColor and
* EndColor. You can control the drawing output by setting
* Gradient.Direction.<br>
* Use the Visible property to show / hide filling. <br>
if ($this->gradient == null) {
* Sets the Gradient fill.<br>
* Use invalidate when the entire canvas needs to be repainted.<br>
* When more than one region within the canvas needs repainting, Invalidate
* will cause the entire window to be repainted in a single pass, aing
* flicker caused by redundant repaints. There is no performance penalty
* for calling Invalidate multiple times before the control is actually
* Drawing Brush Image Style.<br>
* Drawing Brush Image Style.<br>
if ($this->imageMode != $value) {
$this->imageMode = $value;
if ($this->image != null) {
return new Rectangle(0,0, $this->image->getWidth(null), $this->image->getHeight(null));
* Drawing Brush Image Style.<br>
* Drawing Brush Image Style.<br>
if ($this->wrapTile != $value) {
$this->wrapTile = $value;
* Color to fill inner portions of Brush, when Solid is false.<br>
return $this->foregroundColor;
* Specifies the Color to fill inner portions of Brush, when Solid is false.
$this->foregroundColor = $this->setColorProperty($this->foregroundColor, $value);
$this->color = $this->color->applyDark($quantity);
* Determines the color used to fill a zone.
* Specifies the color used to fill a zone.
* Determines if the brush will draw lines or not.
* Determines if the brush will draw lines or not.
* Determines the style in which the zone is filled or patterned using both
* Color and ForegroundColor.<br>
* Default value: HatchStyle.BackwardDiagonal
* Determines the style in which the zone is filled or patterned using both
* Color and ForegroundColor.<br>
* Default value: HatchStyle.BackwardDiagonal
* @param value HatchStyle
if ($this->style != $value) {
$this->hatchImage = null;
* Image to use for fill.<br>
* Image to use for fill.<br>
$this->solid = $this->image == null;
* Loads a bitmap into a ChartBrush element from the specified path.
* Loads a bitmap into a ChartBrush element from the specified URL.
/* todo public function loadImage($location) {
$this->setImage(ImageUtils->getImage($location, ($this->getChart()->getParent())));
* Clears the ChartBrush element from all associated bitmap images.
/* todo private function writeObject($stream) {
$stream->defaultWriteObject();
$gd= ($this->chart==null) ? null : $this->chart->getGraphics3D();
ImageUtils->writeImage($stream, $this->image, $gd);
ImageUtils->writeImage($stream, $this->hatchImage, $gd);
private readObject($stream) {
$stream->defaultReadObject();
$tmp = ImageUtils->readImage($stream);
$tmp2 = ImageUtils->readImage($stream);
$this->hatchImage = $tmp2;
|