forked from halo-battle/game
Upgrade jpgrah to 4.3.4
This commit is contained in:
parent
7c3999c5cd
commit
b5868f05f6
72 changed files with 19157 additions and 10327 deletions
|
|
@ -1,20 +1,20 @@
|
|||
<?php
|
||||
/*=======================================================================
|
||||
// File: JPGRAPH_POLAR.PHP
|
||||
// Description: Polar plot extension for JpGraph
|
||||
// Created: 2003-02-02
|
||||
// Ver: $Id: jpgraph_polar.php 869 2007-03-24 11:19:38Z ljp $
|
||||
//
|
||||
// Copyright (c) Aditus Consulting. All rights reserved.
|
||||
//========================================================================
|
||||
*/
|
||||
// File: JPGRAPH_POLAR.PHP
|
||||
// Description: Polar plot extension for JpGraph
|
||||
// Created: 2003-02-02
|
||||
// Ver: $Id: jpgraph_polar.php 1796 2009-09-07 09:37:19Z ljp $
|
||||
//
|
||||
// Copyright (c) Asial Corporation. All rights reserved.
|
||||
//========================================================================
|
||||
*/
|
||||
|
||||
require_once('jpgraph_plotmark.inc.php');
|
||||
require_once "jpgraph_log.php";
|
||||
|
||||
|
||||
DEFINE('POLAR_360', 1);
|
||||
DEFINE('POLAR_180', 2);
|
||||
define('POLAR_360', 1);
|
||||
define('POLAR_180', 2);
|
||||
|
||||
//
|
||||
// Note. Don't attempt to make sense of this code.
|
||||
|
|
@ -38,9 +38,9 @@ class PolarPlot
|
|||
public $legendcsimtarget='';
|
||||
public $legendcsimalt='';
|
||||
public $legend="";
|
||||
public $csimtargets=array(); // Array of targets for CSIM
|
||||
public $csimareas=""; // Resultant CSIM area tags
|
||||
public $csimalts=null; // ALT:s for corresponding target
|
||||
public $csimtargets=array(); // Array of targets for CSIM
|
||||
public $csimareas=""; // Resultant CSIM area tags
|
||||
public $csimalts=null; // ALT:s for corresponding target
|
||||
public $scale=null;
|
||||
private $numpoints=0;
|
||||
private $iColor='navy';
|
||||
|
|
@ -48,7 +48,7 @@ class PolarPlot
|
|||
private $iLineWeight=1;
|
||||
private $coord=null;
|
||||
|
||||
public function PolarPlot($aData)
|
||||
public function __construct($aData)
|
||||
{
|
||||
$n = count($aData);
|
||||
if ($n & 1) {
|
||||
|
|
@ -91,13 +91,13 @@ class PolarPlot
|
|||
$this->csimtargets=$aTargets;
|
||||
$this->csimalts=$aAlts;
|
||||
}
|
||||
|
||||
|
||||
// Get all created areas
|
||||
public function GetCSIMareas()
|
||||
{
|
||||
return $this->csimareas;
|
||||
}
|
||||
|
||||
|
||||
public function SetLegend($aLegend, $aCSIM="", $aCSIMAlt="")
|
||||
{
|
||||
$this->legend = $aLegend;
|
||||
|
|
@ -143,7 +143,7 @@ class PolarPlot
|
|||
list($x1, $y1) = $scale->PTranslate($this->coord[2*$i], $this->coord[2*$i+1]);
|
||||
$p[2*$i] = $x1;
|
||||
$p[2*$i+1] = $y1;
|
||||
|
||||
|
||||
if (isset($this->csimtargets[$i])) {
|
||||
$this->mark->SetCSIMTarget($this->csimtargets[$i]);
|
||||
$this->mark->SetCSIMAlt($this->csimalts[$i]);
|
||||
|
|
@ -192,9 +192,9 @@ class PolarAxis extends Axis
|
|||
private $show_angle_tick=true;
|
||||
private $radius_tick_color='black';
|
||||
|
||||
public function PolarAxis($img, $aScale)
|
||||
public function __construct($img, $aScale)
|
||||
{
|
||||
parent::Axis($img, $aScale);
|
||||
parent::__construct($img, $aScale);
|
||||
}
|
||||
|
||||
public function ShowAngleDegreeMark($aFlg=true)
|
||||
|
|
@ -260,7 +260,7 @@ class PolarAxis extends Axis
|
|||
$this->radius_tick_color = $aRadColor;
|
||||
$this->angle_tick_color = $aAngleColor;
|
||||
}
|
||||
|
||||
|
||||
// Private methods
|
||||
public function StrokeGrid($pos)
|
||||
{
|
||||
|
|
@ -281,7 +281,7 @@ class PolarAxis extends Axis
|
|||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
$limit = max($this->img->plotwidth, $this->img->plotheight)*1.4 ;
|
||||
while ($r < $limit) {
|
||||
$off = $r;
|
||||
|
|
@ -360,7 +360,7 @@ class PolarAxis extends Axis
|
|||
if (!$this->show_angle_label) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$x0 = round($this->img->left_margin+$this->img->plotwidth/2)+1;
|
||||
|
||||
$d = max($this->img->plotwidth, $this->img->plotheight)*1.42;
|
||||
|
|
@ -381,17 +381,20 @@ class PolarAxis extends Axis
|
|||
$margin=5;
|
||||
|
||||
$tl = $this->angle_tick_len ; // Outer len
|
||||
$tl2 = $this->angle_tick_len2 ; // Interior len
|
||||
$tl2 = $this->angle_tick_len2 ; // Interior len
|
||||
|
||||
$this->img->SetColor($this->angle_tick_color);
|
||||
$this->img->SetColor($this->angle_tick_color);
|
||||
$rot90 = $this->img->a == 90 ;
|
||||
|
||||
if ($type == POLAR_360) {
|
||||
|
||||
// Corner angles of the four corners
|
||||
$ca1 = atan($h/$w)/M_PI*180;
|
||||
$ca2 = 180-$ca1;
|
||||
$ca3 = $ca1+180;
|
||||
$ca4 = 360-$ca1;
|
||||
$end = 360;
|
||||
|
||||
while ($a < $end) {
|
||||
$ca = cos($a/180*M_PI);
|
||||
$sa = sin($a/180*M_PI);
|
||||
|
|
@ -454,15 +457,20 @@ class PolarAxis extends Axis
|
|||
}
|
||||
if ($a != 0 && $a != 180) {
|
||||
$t->Align($ha, $va);
|
||||
if ($this->show_angle_mark) {
|
||||
$a .= '°';
|
||||
if ($this->scale->clockwise) {
|
||||
$t->Set(360-$a);
|
||||
} else {
|
||||
$t->Set($a);
|
||||
}
|
||||
if ($this->show_angle_mark && $t->font_family > 4) {
|
||||
$a .= SymChar::Get('degree');
|
||||
}
|
||||
$t->Set($a);
|
||||
$t->Stroke($this->img, $xt, $yt);
|
||||
if ($this->show_angle_tick) {
|
||||
$this->img->Line($x1, $y1, $x2, $y2);
|
||||
}
|
||||
}
|
||||
$a = (int) $a;
|
||||
$a += $this->angle_step;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -516,14 +524,15 @@ class PolarAxis extends Axis
|
|||
$y1=$y2=$yt;
|
||||
}
|
||||
$t->Align($ha, $va);
|
||||
if ($this->show_angle_mark) {
|
||||
$a .= '°';
|
||||
if ($this->show_angle_mark && $t->font_family > 4) {
|
||||
$a .= SymChar::Get('degree');
|
||||
}
|
||||
$t->Set($a);
|
||||
$t->Stroke($this->img, $xt, $yt);
|
||||
if ($this->show_angle_tick) {
|
||||
$this->img->Line($x1, $y1, $x2, $y2);
|
||||
}
|
||||
$a = (int) $a;
|
||||
$a += $this->angle_step;
|
||||
}
|
||||
}
|
||||
|
|
@ -547,8 +556,7 @@ class PolarAxis extends Axis
|
|||
$this->title->SetPos($this->img->width-$this->img->right_margin, $y, "right", "top");
|
||||
} elseif ($this->title_adjust=="middle" || $this->title_adjust=="center") {
|
||||
$this->title->SetPos(
|
||||
($this->img->width-$this->img->left_margin-
|
||||
$this->img->right_margin)/2+$this->img->left_margin,
|
||||
($this->img->width-$this->img->left_margin-$this->img->right_margin)/2+$this->img->left_margin,
|
||||
$y,
|
||||
"center",
|
||||
"top"
|
||||
|
|
@ -560,7 +568,7 @@ class PolarAxis extends Axis
|
|||
//('Unknown alignment specified for X-axis title. ('.$this->title_adjust.')');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!$this->hide_labels) {
|
||||
$this->StrokeLabels($pos, false);
|
||||
}
|
||||
|
|
@ -575,7 +583,7 @@ class PolarAxis extends Axis
|
|||
$i=0;
|
||||
while ($i < $n) {
|
||||
$this->scale->ticks->ticks_pos[$i] =
|
||||
$mid-$this->scale->ticks->ticks_pos[$i] ;
|
||||
$mid-$this->scale->ticks->ticks_pos[$i] ;
|
||||
++$i;
|
||||
}
|
||||
|
||||
|
|
@ -583,15 +591,15 @@ class PolarAxis extends Axis
|
|||
$i=0;
|
||||
while ($i < $n) {
|
||||
$this->scale->ticks->maj_ticks_pos[$i] =
|
||||
$mid-$this->scale->ticks->maj_ticks_pos[$i] ;
|
||||
$mid-$this->scale->ticks->maj_ticks_pos[$i] ;
|
||||
++$i;
|
||||
}
|
||||
|
||||
|
||||
$n = count($this->scale->ticks->maj_ticklabels_pos);
|
||||
$i=1;
|
||||
while ($i < $n) {
|
||||
$this->scale->ticks->maj_ticklabels_pos[$i] =
|
||||
$mid-$this->scale->ticks->maj_ticklabels_pos[$i] ;
|
||||
$mid-$this->scale->ticks->maj_ticklabels_pos[$i] ;
|
||||
++$i;
|
||||
}
|
||||
|
||||
|
|
@ -633,11 +641,18 @@ class PolarAxis extends Axis
|
|||
class PolarScale extends LinearScale
|
||||
{
|
||||
private $graph;
|
||||
public $clockwise=false;
|
||||
|
||||
public function PolarScale($aMax=0, $graph)
|
||||
public function __construct($aMax, $graph, $aClockwise)
|
||||
{
|
||||
parent::LinearScale(0, $aMax, 'x');
|
||||
parent::__construct(0, $aMax, 'x');
|
||||
$this->graph = $graph;
|
||||
$this->clockwise = $aClockwise;
|
||||
}
|
||||
|
||||
public function SetClockwise($aFlg)
|
||||
{
|
||||
$this->clockwise = $aFlg;
|
||||
}
|
||||
|
||||
public function _Translate($v)
|
||||
|
|
@ -651,8 +666,13 @@ class PolarScale extends LinearScale
|
|||
$w = $this->graph->img->plotwidth/2;
|
||||
$aRad = $aRad/$m*$w;
|
||||
|
||||
$x = cos($aAngle/180 * M_PI) * $aRad;
|
||||
$y = sin($aAngle/180 * M_PI) * $aRad;
|
||||
$a = $aAngle/180 * M_PI;
|
||||
if ($this->clockwise) {
|
||||
$a = 2*M_PI-$a;
|
||||
}
|
||||
|
||||
$x = cos($a) * $aRad;
|
||||
$y = sin($a) * $aRad;
|
||||
|
||||
$x += $this->_Translate(0);
|
||||
|
||||
|
|
@ -668,11 +688,19 @@ class PolarScale extends LinearScale
|
|||
class PolarLogScale extends LogScale
|
||||
{
|
||||
private $graph;
|
||||
public function PolarLogScale($aMax=1, $graph)
|
||||
public $clockwise=false;
|
||||
|
||||
public function __construct($aMax, $graph, $aClockwise=false)
|
||||
{
|
||||
parent::LogScale(0, $aMax, 'x');
|
||||
parent::__construct(0, $aMax, 'x');
|
||||
$this->graph = $graph;
|
||||
$this->ticks->SetLabelLogType(LOGLABELS_MAGNITUDE);
|
||||
$this->clockwise = $aClockwise;
|
||||
}
|
||||
|
||||
public function SetClockwise($aFlg)
|
||||
{
|
||||
$this->clockwise = $aFlg;
|
||||
}
|
||||
|
||||
public function PTranslate($aAngle, $aRad)
|
||||
|
|
@ -685,8 +713,13 @@ class PolarLogScale extends LogScale
|
|||
$w = $this->graph->img->plotwidth/2;
|
||||
$aRad = $aRad/$m*$w;
|
||||
|
||||
$x = cos($aAngle/180 * M_PI) * $aRad;
|
||||
$y = sin($aAngle/180 * M_PI) * $aRad;
|
||||
$a = $aAngle/180 * M_PI;
|
||||
if ($this->clockwise) {
|
||||
$a = 2*M_PI-$a;
|
||||
}
|
||||
|
||||
$x = cos($a) * $aRad;
|
||||
$y = sin($a) * $aRad;
|
||||
|
||||
$x += $w+$this->graph->img->left_margin;//$this->_Translate(0);
|
||||
if ($this->graph->iType == POLAR_360) {
|
||||
|
|
@ -703,10 +736,11 @@ class PolarGraph extends Graph
|
|||
public $scale;
|
||||
public $axis;
|
||||
public $iType=POLAR_360;
|
||||
|
||||
public function PolarGraph($aWidth=300, $aHeight=200, $aCachedName="", $aTimeOut=0, $aInline=true)
|
||||
private $iClockwise=false;
|
||||
|
||||
public function __construct($aWidth=300, $aHeight=200, $aCachedName="", $aTimeOut=0, $aInline=true)
|
||||
{
|
||||
parent::Graph($aWidth, $aHeight, $aCachedName, $aTimeOut, $aInline) ;
|
||||
parent::__construct($aWidth, $aHeight, $aCachedName, $aTimeOut, $aInline) ;
|
||||
$this->SetDensity(TICKD_DENSE);
|
||||
$this->SetBox();
|
||||
$this->SetMarginColor('white');
|
||||
|
|
@ -717,22 +751,29 @@ class PolarGraph extends Graph
|
|||
$this->SetTickDensity(TICKD_NORMAL, $aDense);
|
||||
}
|
||||
|
||||
public function SetClockwise($aFlg)
|
||||
{
|
||||
$this->scale->SetClockwise($aFlg);
|
||||
}
|
||||
|
||||
public function Set90AndMargin($lm=0, $rm=0, $tm=0, $bm=0)
|
||||
{
|
||||
$adj = ($this->img->height - $this->img->width)/2;
|
||||
$this->SetAngle(90);
|
||||
$this->img->SetMargin($lm-$adj, $rm-$adj, $tm+$adj, $bm+$adj);
|
||||
$this->img->SetCenter(floor($this->img->width/2), floor($this->img->height/2));
|
||||
$lm2 = -$adj + ($lm-$rm+$tm+$bm)/2;
|
||||
$rm2 = -$adj + (-$lm+$rm+$tm+$bm)/2;
|
||||
$tm2 = $adj + ($tm-$bm+$lm+$rm)/2;
|
||||
$bm2 = $adj + (-$tm+$bm+$lm+$rm)/2;
|
||||
$this->SetMargin($lm2, $rm2, $tm2, $bm2);
|
||||
$this->axis->SetLabelAlign('right', 'center');
|
||||
//JpGraphError::Raise('Set90AndMargin() is not supported for polar graphs.');
|
||||
}
|
||||
|
||||
public function SetScale($aScale, $rmax=0, $dummy1=1, $dummy2=1, $dummy3=1)
|
||||
{
|
||||
if ($aScale == 'lin') {
|
||||
$this->scale = new PolarScale($rmax, $this);
|
||||
$this->scale = new PolarScale($rmax, $this, $this->iClockwise);
|
||||
} elseif ($aScale == 'log') {
|
||||
$this->scale = new PolarLogScale($rmax, $this);
|
||||
$this->scale = new PolarLogScale($rmax, $this, $this->iClockwise);
|
||||
} else {
|
||||
JpGraphError::RaiseL(17004);//('Unknown scale type for polar graph. Must be "lin" or "log"');
|
||||
}
|
||||
|
|
@ -772,9 +813,9 @@ class PolarGraph extends Graph
|
|||
public function Stroke($aStrokeFileName="")
|
||||
{
|
||||
|
||||
// Start by adjusting the margin so that potential titles will fit.
|
||||
// Start by adjusting the margin so that potential titles will fit.
|
||||
$this->AdjustMarginsForTitles();
|
||||
|
||||
|
||||
// If the filename is the predefined value = '_csim_special_'
|
||||
// we assume that the call to stroke only needs to do enough
|
||||
// to correctly generate the CSIM maps.
|
||||
|
|
@ -833,7 +874,6 @@ class PolarGraph extends Graph
|
|||
$pos = $this->img->plotheight/2 + $this->img->top_margin;
|
||||
}
|
||||
|
||||
|
||||
if (!$_csim) {
|
||||
$this->StrokePlotArea();
|
||||
}
|
||||
|
|
@ -868,16 +908,21 @@ class PolarGraph extends Graph
|
|||
$this->img->plotheight+1
|
||||
);
|
||||
} elseif ($this->img->a == 90) {
|
||||
$adj = round(($this->img->height - $this->img->width)/2);
|
||||
$adj1 = round(($this->img->height - $this->img->width)/2);
|
||||
$adj2 = round(($this->img->width - $this->img->height)/2);
|
||||
$lm = $this->img->left_margin;
|
||||
$rm = $this->img->right_margin;
|
||||
$tm = $this->img->top_margin;
|
||||
$bm = $this->img->bottom_margin;
|
||||
$this->img->CopyCanvasH(
|
||||
$oldimage,
|
||||
$this->img->img,
|
||||
$this->img->bottom_margin-$adj,
|
||||
$this->img->left_margin+$adj,
|
||||
$this->img->bottom_margin-$adj,
|
||||
$this->img->left_margin+$adj,
|
||||
$this->img->plotheight,
|
||||
$this->img->plotwidth
|
||||
$adj2 + round(($lm-$rm+$tm+$bm)/2),
|
||||
$adj1 + round(($tm-$bm+$lm+$rm)/2),
|
||||
$adj2 + round(($lm-$rm+$tm+$bm)/2),
|
||||
$adj1 + round(($tm-$bm+$lm+$rm)/2),
|
||||
$this->img->plotheight+1,
|
||||
$this->img->plotwidth+1
|
||||
);
|
||||
}
|
||||
$this->img->Destroy();
|
||||
|
|
@ -908,12 +953,12 @@ class PolarGraph extends Graph
|
|||
if (!$_csim) {
|
||||
$this->StrokeTexts();
|
||||
$this->img->SetAngle($aa);
|
||||
|
||||
|
||||
// Draw an outline around the image map
|
||||
if (_JPG_DEBUG) {
|
||||
$this->DisplayClientSideaImageMapAreas();
|
||||
}
|
||||
|
||||
|
||||
// If the filename is given as the special "__handle"
|
||||
// then the image handler is returned and the image is NOT
|
||||
// streamed back
|
||||
|
|
@ -921,12 +966,7 @@ class PolarGraph extends Graph
|
|||
return $this->img->img;
|
||||
} else {
|
||||
// Finally stream the generated picture
|
||||
$this->cache->PutAndStream(
|
||||
$this->img,
|
||||
$this->cache_name,
|
||||
$this->inline,
|
||||
$aStrokeFileName
|
||||
);
|
||||
$this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue