function preFilter() { $this->panelBg->setStyle($this->getStyle()); $this->panelBg->setSubStyle($this->getSubStyle()); $this->setStyle(null); $this->setSubStyle(null); $this->titleBg->setSizeX($this->sizeX); $this->title->setSizeX($this->sizeX - 6); $this->panelBg->setSize($this->sizeX - 4, $this->sizeY - $this->titleBg->getSizeY() - 4.5); $this->panelBg->setPosY(-$this->titleBg->getSizeY() - 4.5); }
function onNewMemoryValue($newValue) { $lastValue = end($this->memoryStats); $this->memoryStats[] = $newValue; if (count($this->memoryStats) > 10) { array_shift($this->memoryStats); $bar = array_shift($this->bars); $this->barsFrame->removeComponent($bar); } else { $bar = new Quad(); $bar->setSizeX(($this->sizeX - 2) / 10); $bar->setValign('bottom'); } if ($lastValue === false || $lastValue == $newValue) { $bar->setBgcolor('999'); } else { if ($lastValue < $newValue) { $bar->setBgcolor('a00'); } else { $bar->setBgcolor('0a0'); } } $this->barsFrame->addComponent($bar); $this->bars[] = $bar; $heightFactor = 2 * ($this->sizeY - 6) / ceil(3 * max($this->memoryStats)); foreach ($this->bars as $i => $bar) { $bar->setSizeY($this->memoryStats[$i] * $heightFactor); } $i = 1; $step = round(37.5 * max($this->memoryStats) / $this->memoryLimit, 2); foreach ($this->lines as $line) { $line[1]->setText('$fff' . $i++ * $step . '% of total'); } $this->redraw(); }
function onNewNetworkValue($newValue) { $this->networkSums[] = $newValue[0] + $newValue[1]; $this->networkStats[] = $newValue; if (count($this->networkSums) > 10) { array_shift($this->networkSums); array_shift($this->networkStats); $bars = array_shift($this->bars); $this->barsFrame->removeComponent($bars[2]); } else { $frame = new Frame(); $frame->setSizeX(($this->sizeX - 2) / 10); $sentBar = new Quad(); $sentBar->setSizeX(($this->sizeX - 2) / 10); $sentBar->setBgcolor('a00'); $sentBar->setValign('bottom'); $frame->addComponent($sentBar); $receivedBar = new Quad(); $receivedBar->setSizeX(($this->sizeX - 2) / 10); $receivedBar->setBgcolor('0a0'); $receivedBar->setValign('bottom'); $frame->addComponent($receivedBar); $bars = array($sentBar, $receivedBar, $frame); } $this->barsFrame->addComponent($bars[2]); $this->bars[] = $bars; $heightFactor = ($this->sizeY - 6) / max(51200, 1.2 * max($this->networkSums)); foreach ($this->bars as $i => $bars) { $bars[0]->setSizeY($this->networkStats[$i][1] * $heightFactor); $bars[1]->setSizeY($this->networkStats[$i][0] * $heightFactor); $bars[1]->setPosY($bars[0]->getRealSizeY()); } $i = 1; $step = max(51200, 1.2 * max($this->networkSums)) / 4096; foreach ($this->lines as $line) { $line[1]->setText('$fff' . round($i++ * $step) . ' kb/s'); } $this->redraw(); }
function onNewCpuValue($newValue) { $this->cpuStats[] = $newValue; if (count($this->cpuStats) > 10) { array_shift($this->cpuStats); $bar = array_shift($this->bars); $this->barsFrame->removeComponent($bar); } else { $bar = new Quad(); $bar->setSizeX(($this->sizeX - 2) / 10); $bar->setValign('bottom'); } $this->barsFrame->addComponent($bar); $this->bars[] = $bar; $iColor = 0; $heightFactor = ($this->sizeY - 6) / max(self::RESPONSE_OPTIMAL, max($this->cpuStats)); foreach ($this->bars as $i => $bar) { $color = dechex($iColor++); $bar->setBgcolor($color . $color . $color); $bar->setSizeY($this->cpuStats[$i] * $heightFactor); } $this->redraw(); }