CODE STYLE class.pmGauge.php

This commit is contained in:
Fernando Ontiveros
2012-10-09 12:57:01 -04:00
parent eba4b6e7d7
commit 409bbdf07c

View File

@@ -1,61 +1,64 @@
<?php
class pmGauge {
class pmGauge
{
/**
width
* width
*/
var $w = 610;
/**
height
* height
*/
var $h = 300;
/**
value of gauge
* value of gauge
*/
var $value = 50;
/**
maxValue
* maxValue
*/
var $maxValue = 100;
/**
redFrom
* redFrom
*/
var $redFrom = 80;
/**
redTo
* redTo
*/
var $redTo = 100;
/**
yellowFrom
* yellowFrom
*/
var $yellowFrom = 60;
/**
yellowTo
* yellowTo
*/
var $yellowTo = 80;
/**
greenFrom
* greenFrom
*/
var $greenFrom = 0;
/**
greenTo
* greenTo
*/
var $greenTo = 60;
/**
centerLabel, the label in the middle of the gauge
* centerLabel, the label in the middle of the gauge
*/
var $centerLabel = '';
function render () {
function render ()
{
$this->h = $this->w / 2;
$im = imagecreatetruecolor( $this->w, $this->h );
$width = $this->w;
@@ -107,7 +110,8 @@
}
function renderGauge($im, $cX, $cY, $diameter) {
function renderGauge ($im, $cX, $cY, $diameter)
{
//gauge color
$bgcolor = ImageColorAllocate( $im, 247, 247, 247 );
$extRing = ImageColorAllocate( $im, 214, 214, 214 );
@@ -141,12 +145,18 @@
imagefilledellipse( $im, $cX, $cY, $dXRing, $dYRing, $bgcolor );
//drawing the red arc
if ( $this->redFrom > $this->maxValue ) $this->redFrom = $this->maxValue;
if ( $this->redTo > $this->maxValue ) $this->redTo = $this->maxValue;
if ( $this->yellowFrom > $this->maxValue ) $this->yellowFrom = $this->maxValue;
if ( $this->yellowTo > $this->maxValue ) $this->yellowTo = $this->maxValue;
if ( $this->greenFrom > $this->maxValue ) $this->greenFrom = $this->maxValue;
if ( $this->greenTo > $this->maxValue ) $this->greenTo = $this->maxValue;
if ($this->redFrom > $this->maxValue)
$this->redFrom = $this->maxValue;
if ($this->redTo > $this->maxValue)
$this->redTo = $this->maxValue;
if ($this->yellowFrom > $this->maxValue)
$this->yellowFrom = $this->maxValue;
if ($this->yellowTo > $this->maxValue)
$this->yellowTo = $this->maxValue;
if ($this->greenFrom > $this->maxValue)
$this->greenFrom = $this->maxValue;
if ($this->greenTo > $this->maxValue)
$this->greenTo = $this->maxValue;
$redFrom = $this->redFrom / $this->maxValue * 300 - 240;
$redTo = $this->redTo / $this->maxValue * 300 - 240;
@@ -184,7 +194,6 @@
ImageLine( $im, $x1, $y1, $x2, $y2, $black );
if ($min % 5 == 0) {
$textToDisplay = sprintf( "%d", (55 - $min) * $this->maxValue / 50 );
$bbox = imagettfbbox( 8, 0, $fontArial, $textToDisplay );
@@ -206,7 +215,6 @@
imagettftext( $im, 9, 0, $cX * 0.60, $cY * 1.8, $gray, $fontArial, $this->open );
imagettftext( $im, 9, 0, $cX * 1.40, $cY * 1.8, $gray, $fontArial, $this->completed );
//drawing the arrow, simple way
$radiusX = intval( $dX * 0.35 );
$radiusY = intval( $dY * 0.35 );
@@ -264,7 +272,6 @@
$centerY = $cY + $dYRing / 2 + 3 - abs( $bbox[5] );
imagettftext( $im, 9, 0, $centerX, $centerY, $black, $fontArial, $textToDisplay );
}
}