TeeChartPHP
[ class tree: TeeChartPHP ] [ index: TeeChartPHP ] [ all elements ]

Source for file MarksTip.php

Documentation is available at MarksTip.php

  1. <?php
  2.  
  3. /**
  4.   *
  5.   * <p>Title: MarksTip class</p>
  6.   *
  7.   * <p>Description: Marks Tip.<br>
  8.   * Marks tip tool, use it to display "tips" or "hints" when the end-user moves
  9.   * or clicks the mouse over a series point.</p>
  10.   *
  11.   * <p>Copyright (c) 2005-2007 by Steema Software SL. All Rights Reserved.</p>
  12.   *
  13.   * <p>Company: Steema Software SL</p>
  14.   *
  15.   */
  16.   
  17.  class MarksTip extends ToolSeries {
  18.  
  19.     //private $mouseAction = $MarksTipMouseAction.MOVE;
  20.     
  21.     private $style 2// MarksStyle::$LABEL;
  22.     protected $customToolTip;    
  23.  
  24.     public function MarksTip($c=null{
  25.         parent::ToolSeries($c);
  26.         
  27.         $this->readResolve();
  28.     }
  29.  
  30.     protected function readResolve({
  31.         //$tmpDefaultResolvers = new DefaultResolvers();
  32.         //$this->customToolTip = $tmpDefaultResolvers->TEXT_RESOLVER;
  33.         return parent::readResolve();
  34.     }
  35.  
  36.     public function setToolTipResolver($resolver{
  37.         if ($resolver != null{
  38.             $this->customToolTip = $resolver;
  39.         else {
  40.             $this->removeToolTipResolver();
  41.         }
  42.     }
  43.  
  44.     public function removeToolTipResolver({
  45.     //    $tmpDefaultResolvers = new DefaultResolvers();
  46.     //    $this->customToolTip = $tmpDefaultResolvers->TEXT_RESOLVER;
  47.     }
  48.  
  49.     /**
  50.     * Defines the text format of the Mark ToolTip.<br>
  51.     * Default value: MarksStyle.Label
  52.     *
  53.     *
  54.     * @return MarksStyle 
  55.     */
  56.     public function getStyle({
  57.         return $this->style;
  58.     }
  59.  
  60.     /**
  61.     * Defines the text format of the Mark ToolTip.<br>
  62.     * Default value: MarksStyle.Label
  63.     *
  64.     *
  65.     * @param value MarksStyle
  66.     */
  67.     public function setStyle($value{
  68.         if ($this->style != $value{
  69.             $this->style $value;
  70.             $this->invalidate();
  71.         }
  72.     }
  73.  
  74.     /**
  75.     * Activates Mark Tip on mouse move or click.<br>
  76.     * Default value: MarksTipMouseAction.Move
  77.     *
  78.     * @return MarksTipMouseAction 
  79.     */
  80.     public function getMouseAction({
  81.         return $this->mouseAction;
  82.     }
  83.  
  84.     /**
  85.     * Activates Mark Tip on mouse move or click.<br>
  86.     * Default value: MarksTipMouseAction.Move
  87.     *
  88.     * @param value MarksTipMouseAction
  89.     */
  90.     public function setMouseAction($value{
  91.         $this->mouseAction $value;
  92.         $this->chart->getToolTip()->setText(null);
  93.     }
  94.  
  95.     /**
  96.     * The time lag before the Tool Tip appears.<br>
  97.     * Default value: 500
  98.     *
  99.     * @return int 
  100.     */
  101.     public function getMouseDelay({
  102.         if ($this->chart==null{
  103.             return 0;
  104.         else {
  105.              $tmp $this->chart->getToolTip();
  106.             return ($tmp==null$tmp->getInitialDelay();
  107.         }
  108.     }
  109.  
  110.     /**
  111.     * Sets the time lag before the Tool Tip appears.<br>
  112.     * Default value: 500
  113.     *
  114.     * @param value int
  115.     */
  116.     public function setMouseDelay($value{
  117.         if ($this->chart!=null{
  118.             if ($this->chart->getToolTip()!=null{
  119.                 $this->chart->getToolTip()->setInitialDelay($value);
  120.             }
  121.         }
  122.     }
  123.         
  124.     /**
  125.     * The time period during which the Tool Tip appears.<br>
  126.     * Default value: 4000 (ms)
  127.     *
  128.     * @return int 
  129.     */
  130.     public function getHideDelay({
  131.         if ($this->chart==null{
  132.             return 0;
  133.         else {
  134.              $tmp $this->chart->getToolTip();
  135.             return ($tmp==null$tmp->getDismissDelay();
  136.         }
  137.     }
  138.  
  139.     /**
  140.     * Sets the time period during which the Tool Tip appears.<br>
  141.     * Default value: 4000 (ms)
  142.     *
  143.     * @param value int
  144.     */
  145.     public function setHideDelay($value{
  146.         if ($this->chart!=null{
  147.             if ($this->chart->getToolTip()!=null{
  148.                 $this->chart->getToolTip()->setDismissDelay($value);
  149.             }
  150.         }
  151.     }
  152.  
  153.     /**
  154.     * Gets descriptive text.
  155.     *
  156.     * @return String 
  157.     */
  158.     public function getDescription({
  159.         return Language::getString("MarksTipTool");
  160.     }
  161.  
  162.     /**
  163.     * Gets detailed descriptive text.
  164.     *
  165.     * @return String 
  166.     */
  167.     public function getSummary({
  168.         return Language::getString("MarksTipSummary");
  169.     }
  170.  
  171.     private function findClickedSeries($p{
  172.         $tmp=new FindClicked();
  173.  
  174.         for $t 0$t $this->chart->getSeriesCount()$t++{
  175.             $tmp->series $this->chart->getSeries($t);
  176.             $tmp->index $tmp->series->clicked($p);
  177.             if ($tmp->index != -1{
  178.                 return $tmp;
  179.             }
  180.         }
  181.  
  182.         // no series
  183.         $tmp->series null;
  184.         $tmp->index = -1;
  185.         return $tmp;
  186.     }
  187.    
  188.     public function mouseEvent($e$c{
  189.  
  190.         $c parent::mouseEvent($e$c);
  191.  
  192.         if ((($this->getMouseAction(== MarksTipMouseAction::$MOVE&&
  193.              ($e->getID(== MouseEvent::$MOUSE_MOVED)) ||
  194.             (($this->getMouseAction(== MarksTipMouseAction::$CLICK&&
  195.              ($e->getID(== MouseEvent::$MOUSE_PRESSED))) {
  196.              $tmpSeries null;
  197.              $tmp = -1;
  198.  
  199.             // find which series is under XY
  200.             if ($this->iSeries != null{
  201.                 $tmpSeries $this->iSeries;
  202.                 $tmp $tmpSeries->clicked($e->getPoint());
  203.             else {
  204.                  $tmp2 $this->findClickedSeries($e->getPoint())/* 5.02 */
  205.                 $tmpSeries $tmp2->series;
  206.                 $tmp $tmp2->index;
  207.             }
  208.  
  209.             // if not ok, cancel hint...
  210.             if ($tmp == -1{
  211.  
  212.                  $tmpCancel true;
  213.  
  214.                 //* do not cancel if other MarkTipTools exist...
  215.                  for ($tt 0$tt sizeof($this->chart->getTools())$tt++{
  216.                      $t $this->chart->getTools()->getTool($tt);
  217.                      if (($t != $this&& ($t instanceof MarksTip)) {
  218.                          /* 5.01 */
  219.                          $tmpCancel false;
  220.                          break;
  221.                      }
  222.                  }
  223.  
  224.                 if ($tmpCancel{
  225.                     $this->chart->getToolTip()->setText(null);
  226.                 }
  227.             else {
  228.                 // show hint !
  229.                 $tmpStyle $tmpSeries->getMarks()->getStyle();
  230.                 $tmpOld $this->chart->getAutoRepaint();
  231.                 $this->chart->setAutoRepaint(false);
  232.                 $tmpSeries->getMarks()->etStyle($style);
  233.  
  234.                 $tmpText $tmpSeries->getValueMarkText($tmp);
  235.  
  236.                 $tmpText $this->customToolTip->getText($this,$tmpText);
  237.  
  238.                 if ($this->chart->getToolTip()->getText()->equals($tmpText)) {
  239.                     // chart.ShowHint=True; /* 5.02 */
  240.                     $this->chart->getToolTip()->setText($tmpText);
  241.                 }
  242.                 $tmpSeries->getMarks()->setStyle($tmpStyle);
  243.                 $this->chart->setAutoRepaint($tmpOld);
  244.             }
  245.         }
  246.  
  247.         return $c;
  248.     }
  249.  
  250.     public function setActive($value{
  251.         parent::setActive($value);
  252.         //super.setActive(value);
  253.         if (!$this->getActive()) {
  254.             $this->chart->getToolTip()->setText(null);
  255.         }
  256.     }
  257. }
  258.  
  259. class FindClicked {
  260.     private $series;
  261.     private $index;
  262. }
  263. ?>

Documentation generated on Wed, 16 Jun 2010 12:07:01 +0200 by phpDocumentor 1.4.1