Ignore:
Timestamp:
Mar 1, 2015, 12:43:56 PM (10 years ago)
Author:
chronos
Message:
  • Moved trunk as mvc branch.
Location:
branches/mvc
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/mvc/Application/View/Graph.php

    r47 r59  
    66class GraphView extends View
    77{
     8  var $FontSize;
     9  var $FontFileName;
     10  var $ValueToImageHeigthCoefficient;
    811  var $DefaultWidth;
    912  var $DefaultHeight;
     
    1417    $this->DefaultWidth = 800;
    1518    $this->DefaultHeight = 200;
     19    $this->FontSize = 10;
     20    $this->FontFileName = 'Arial.ttf';
     21    $this->ValueToImageHeigthCoefficient = 0.9;
    1622  }
    1723
     
    3541    if(!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];
    3642      else $Differential = addslashes($_GET['Differential']);
    37     $VerticalLinesCount = round($Height / ($this->Config['Application']['FontSize'] + 4));
    38 
     43    $VerticalLinesCount = round($Height / ($this->FontSize + 4));
     44
     45    $PrefixMultiplier = new PrefixMultiplier();
    3946    $StopWatchStart = $this->System->GetMicrotime();
    4047
     
    5057    $MeasureMethod = $DbResult2->fetch_assoc();
    5158
    52     $FontSize = $this->Config['Application']['FontSize'];
    53     $FontFile = dirname(__FILE__).'/../Style/'.$this->Config['System']['Style'].'/'.$this->Config['Application']['FontFileName'];
     59    $FontSize = $this->FontSize;
     60    $FontFile = dirname(__FILE__).'/../Style/'.$this->Config['System']['Style'].'/'.$this->FontFileName;
    5461
    5562    $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1;
     
    9299      {
    93100        $PointsMin[] = $Index * $Width / $Measure->DivisionCount;
    94         $PointsMin[] = $Height - 1 - ($Points[$Index]['Min'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
     101        $PointsMin[] = $Height - 1 - ($Points[$Index]['Min'] - $MinValue) /
     102          ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient;
    95103        $PointsAvg[] = $Index * $Width / $Measure->DivisionCount;
    96         $PointsAvg[] = $Height - 1 - ($Points[$Index]['Avg'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
     104        $PointsAvg[] = $Height - 1 - ($Points[$Index]['Avg'] - $MinValue) /
     105          ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient;
    97106        $PointsMax[] = $Index * $Width / $Measure->DivisionCount;
    98         $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
     107        $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) /
     108          ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient;
    99109        //echo($Index.' - '.$Item.' '.$Points[$Index].'<br/>');
    100110      }
     
    113123    $PointsMax[] = $Height - 1;
    114124
    115 
    116125    //array_unshift($Points, $Height - 1);
    117126    //array_unshift($Points, 0);
    118127    //$Points[] = $Width - 1;
    119128    //$Points[] = $Height - 1;      echo('sds');
    120 
    121 
    122129    //print_r($PointsMax);
    123130
     
    179186        {
    180187          for($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
    181           imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,  $Height - 2, $Black, $FontFile, $Text);
     188          imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,
     189            $Height - 2, $Black, $FontFile, $Text);
    182190          $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2;
    183191        }
     
    190198        $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    191199        //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $this->Config['Application']['ValueToImageHeigthCoefficient'] * $Height);
    192         $Text = $this->System->AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $this->Config['Application']['ValueToImageHeigthCoefficient'] * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3);
     200        $Text = $PrefixMultiplier->Add(round(($I * $VerticalLinesDistance /
     201          $Height / $this->ValueToImageHeigthCoefficient * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3);
    193202        $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    194203        if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
     
    198207
    199208      $Left = $Width - 10;
    200       $Text = '    Max. '.$this->System->AddPrefixMultipliers($MaxValue, $MeasureMethod['Unit']);
     209      $Text = '    Max. '.$PrefixMultiplier->Add($MaxValue, $MeasureMethod['Unit']);
    201210      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    202211      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    203212      imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text);
    204213
    205       $Text = '    Avg.  '.$this->System->AddPrefixMultipliers($AvgValue, $MeasureMethod['Unit']);
     214      $Text = '    Avg.  '.$PrefixMultiplier->Add($AvgValue, $MeasureMethod['Unit']);
    206215      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    207216      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    208217      imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text);
    209218
    210       $Text = '    Min.  '.$this->System->AddPrefixMultipliers($MinValue, $MeasureMethod['Unit']);
     219      $Text = '    Min.  '.$PrefixMultiplier->Add($MinValue, $MeasureMethod['Unit']);
    211220      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    212221      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
Note: See TracChangeset for help on using the changeset viewer.