Source for file Zoom.php
Documentation is available at Zoom.php
* <p>Title: Zoom class</p>
* <p>Description: Used at tChart1.Zoom property, determines mouse
* <p>Copyright (c) 2005-2010 by Steema Software SL. All Rights Reserved.</p>
* <p>Company: Steema Software</p>
private $animatedSteps = 8;
private $direction = 2; // ZoomDirections::$BOTH;
private $mouseButton = 0; // MouseEvent::$UTTON1;
* Controls the animated zoom "speed" (inertia)
* Creates a new Zoom instance.
public function Zoom($c) {
* Allows runtime Zoom by dragging the mouse when true.<br>
* Allows runtime Zoom by dragging the mouse when true.<br>
* Animates Zoom in sequenced steps when true.<br>
* Animates Zoom in sequenced steps when true.<br>
$this->animated = $value;
* Brush used to fill mousedragged zoom area.
if ($this->bBrush == null) {
* The direction of the zoom on a selected area.<br><br>
* Example. Horizontal will zoom only on a horizontal plane although the
* mouse is dragged across a vertical and horizontal plane.<br>
* Sets the direction of the zoom on a selected area.<br><br>
* @param value ZoomDirections
$this->direction = $value;
* Determines the number of steps of the animated zooming sequence.<br>
* Large number of steps can delay zooming. The Animated property should be
return $this->animatedSteps;
* Sets the number of steps of the animated zooming sequence.<br>
* Large number of steps can delay zooming. The Animated property should be
$this->animatedSteps = $value;
* The keyboard button as an extra condition to initiate the zoom.<br>
* Sets a keyboard button as an extra condition to initiate the zoom.<br>
$this->keyShift = $value;
* The minimum number of pixels to actuate zoom action.<br>
* Sets minimum number of pixels to actuate zoom action.<br>
$this->minPixels = $value;
* The mousebutton to use for the zoom action.<br>
* Note that Scroll action uses the right (Right) mousebutton as
return $this->mouseButton;
* Sets the mousebutton to use for the zoom action.<br>
$this->mouseButton = $value;
* Pen used to draw surrounding rectangle of zoom area.
if ($this->pen == null) {
$this->pen = new ChartPen($this->chart, $tmpColor->BLACK, false, 1, $tmpLineCap->BEVEL, $tmpDashStyle->SOLID);
* Zooms the Chart rectangle. Units pixels.
$this->x0 = $r->getLeft();
$this->y0 = $r->getTop();
$this->x1 = $r->getRight();
$this->y1 = $r->getBottom();
$this->chart->getAxes()->doZoom($this->x0, $this->y0, $this->x1, $this->y1);
* Displays rectangle while dragging Chart for zoom operation.
$g = $this->chart->getGraphics3D();
if($this->chart->getParent()!= null) {
if ($this->bBrush != null && $this->bBrush->getVisible()) {
$brushXOR = - 1 ^ $this->bBrush->getColor()->getRGB();
$e->setXORMode($this->Color->fromArgb($brushXOR));
$e->fillRect($this->x0, $this->y0, $this->x1 - $this->x0, $this->y1 - $this->y0);
if ($this->pen!= null && $this->pen->getVisible()) {
$penXOR = - 1 ^ $this->pen->getColor()->getRGB();
$e->setXORMode($this->Color->fromArgb($penXOR));
$e->drawRect($this->x0- 1,$this->y0- 1,$this->x1+ 1- $this->x0,$this->y1+ 1- $this->y0);
else if($this->pen!= null && $this->pen->getVisible()) {
$this->chart->invalidate();
$g->getBrush()->setVisible(false);
$g->getBrush()->setVisible(true);
$this->chart->invalidate();
$g->setPen(new ChartPen($this->chart, $tmpColor->BLACK, true, 1, $tmpLineCap->BEVEL, $tmpDashStyle->DASH));
$g->getBrush()->setVisible(false);
$g->getBrush()->setVisible(true);
* Overrides base SetChart method to adjust pen and brush chart properties.
if ($this->pen != null) {
$this->pen->setChart($c);
if ($this->bBrush != null) {
$this->bBrush->setChart($c);
* Rescales the Chart Axis to their Maximum and Minimum values.
$this->chart->restoreAxisScales();
* Determines if Chart axis scales fit all Chart points or not.<br>
* It is set to true when users's apply zoom or scroll to the Chart using
* the mouse at run-time. <br>
* The Zoom.Undo method sets the Zoomed property to false and resets the
* axis scales to fit all Series points. <br>
* The default value is true, meaning no zoom or scroll has been applied
* to the chart after it has been displayed for first time. <br><br>
* Set the Chart axis scales to fit all Chart points when true.<br>
if (($this->chart->getParent() != null) && (!$this->zoomed)) {
$this->chart->getParent()->doUnZoomed($this);
private function calcAxisScale($axis, $percentZoom) {
$axis->calcMinMax($minmax);
$tmpDelta = ($minmax->min - $minmax->max) * $percentZoom;
return new PointDouble($minmax->min + $tmpDelta, $minmax->max - $tmpDelta);
* Applies the specified PercentZoom Zoom In/Out to the current Axis
* When PercentZoom is greater than 100%, Zoom Out is performed. <br>
* When PercentZoom is lower than 100%, Zoom In is performed.<br>
* The Animated property controls if Zoom is done directly in only o
* ne step or by multiple zooms thus giving an animation effect.
* @param percentZoom double
$percentZoom = ($percentZoom - 100.0) * 0.01;
$left = $this->calcAxisScale($this->chart->getAxes()->getLeft(), $percentZoom);
$right = $this->calcAxisScale($this->chart->getAxes()->getRight(), $percentZoom);
$top = $this->calcAxisScale($this->chart->getAxes()->getTop(), $percentZoom);
$bottom = $this->calcAxisScale($this->chart->getAxes()->getBottom(), $percentZoom);
$this->chart->doZoom($top, $bottom, $left, $right);
|