ultimix
graph_map.php
Go to the documentation of this file.
1 <?php
2 
3  /*
4  * This source code is a part of the Ultimix Project.
5  * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6  * it's own license wich could be found from the corresponding files or sources.
7  * This source code is provided "as is" without any warranties or garanties.
8  *
9  * Have a nice day!
10  *
11  * @url http://ultimix.sorceforge.net
12  *
13  * @author Alexey "gdever" Dodonov
14  */
15 
27 
54  private function compile_area( $Data , $Coords )
55  {
56  try
57  {
58  $this->Output .= $this->CachedMultyFS->get_template( __FILE__ , 'area.tpl' );
59  $this->Output = str_replace(
60  array( '{title}' , '{coords}' ) , array( $Data , $Coords ) , $this->Output
61  );
62  }
63  catch( Exception $e )
64  {
65  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
66  }
67  }
68 
95  function compile_map_items( $DataY , $DataX )
96  {
97  try
98  {
99  $GlobalCenterX = $this->ClientX + $this->CoordX;
100  $GlobalCenterY = $this->Height - $this->ClientY - $this->CoordY;
101 
102  list( $dX , $dY ) = $this->get_scales( $DataX , $DataY );
103 
104  $c = count( $DataX );
105 
106  $this->Output = '';
107 
108  for( $i = 0 ; $i < $c ; $i++ )
109  {
110  $x = intval( $GlobalCenterX + ( $DataX[ $i ] - min( $DataX ) ) * $dX + $this->MarginLeft );
111  $y = intval( $GlobalCenterY - ( $DataY[ $i + 0 ] - min( $DataY ) ) * $dY - $this->MarginBottom );
112 
113  $this->compile_area( $DataY[ $i ] , "$x,$y" );
114  }
115  }
116  catch( Exception $e )
117  {
118  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
119  }
120  }
121 
140  private function prepare_map_generation( &$Options )
141  {
142  try
143  {
144  $Width = $Options->get_setting( 'width' , 640 );
145  $Height = $Options->get_setting( 'height' , 480 );
146 
147  $this->set( 'Width' , $Width );
148  $this->set( 'Height' , $Height );
149 
150  $ClientX = $Options->get_setting( 'client_x' , 50 );
151  $ClientY = $Options->get_setting( 'client_y' , 20 );
152  $ClientWidth = $Options->get_setting( 'client_width' , $Width - 70 );
153  $ClientHeight = $Options->get_setting( 'client_height' , $Height - 40 );
154  $this->compile_client_width_height( $ClientX , $ClientY , $ClientWidth , $ClientHeight );
155  }
156  catch( Exception $e )
157  {
158  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
159  }
160  }
161 
180  function view_map( &$Options )
181  {
182  try
183  {
184  $this->prepare_map_generation( $Options );
185 
186  $DataY = explode( ',' , $Options->get_setting( 'data_y' ) );
187  $DataX = explode( ',' , $Options->get_setting( 'data_x' ) );
188  $this->compile_map_items( $DataY , $DataX );
189 
190  $MapName = $Options->get_setting( 'map_name' , 'graph_map' );
191  $this->Output = $this->CachedMultyFS->get_template( __FILE__ , 'map.tpl' );
192  $this->Output = str_replace(
193  array( '{map_name}' , '{output}' ) , array( $MapName , $this->Output ) , $this->Output
194  );
195  }
196  catch( Exception $e )
197  {
198  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
199  }
200  }
201  }
202 
203 ?>