TrackManiaControl/libs/FML/Controls/Graph.php

105 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2017-03-25 18:40:15 +01:00
<?php
namespace FML\Controls;
use FML\Script\Features\GraphCurve;
2017-06-21 19:43:38 +02:00
use FML\Script\Features\GraphSettings;
2017-03-25 18:40:15 +01:00
/**
* Graph Control
* (CMlGraph)
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Graph extends Control {
2017-03-25 18:40:15 +01:00
/**
* @var GraphSettings $graphSettings Graph settings
*/
protected $graphSettings = null;
2017-06-21 19:43:38 +02:00
/**
* @var GraphCurve[] $curves Curves
*/
protected $curves = array();
2017-03-25 18:40:15 +01:00
/**
* Get the graph settings
*
* @api
* @return GraphSettings
*/
public function getSettings() {
if (!$this->graphSettings) {
$this->createSettings();
}
return $this->graphSettings;
}
2017-06-21 19:43:38 +02:00
/**
* Create new graph settings
*
* @return GraphSettings
*/
protected function createSettings() {
$this->graphSettings = new GraphSettings($this);
$this->addScriptFeature($this->graphSettings);
return $this->graphSettings;
}
2017-06-21 19:43:38 +02:00
/**
* Get curves
*
* @api
* @return GraphCurve[]
*/
public function getCurves() {
return $this->curves;
}
2017-03-25 18:40:15 +01:00
/**
* Add curve
*
* @api
* @param GraphCurve $curve Curve
* @return static
*/
public function addCurve(GraphCurve $curve) {
$curve->setGraph($this);
$this->addScriptFeature($curve);
array_push($this->curves, $curve);
return $this;
}
2017-03-25 18:40:15 +01:00
/**
* Add curves
*
* @api
* @param GraphCurve[] $curves Curves
* @return static
*/
public function addCurves(array $curves) {
foreach ($curves as $curve) {
$this->addCurve($curve);
}
return $this;
}
2017-03-25 18:40:15 +01:00
/**
* @see Control::getTagName()
*/
public function getTagName() {
return "graph";
}
2017-03-25 18:40:15 +01:00
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass() {
return "CMlGraph";
}
2017-03-25 18:40:15 +01:00
}