/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk

« back to all changes in this revision

Viewing changes to classes/axes.php

  • Committer: Suren A. Chilingaryan
  • Date: 2009-02-07 08:54:17 UTC
  • Revision ID: csa@dside.dyndns.org-20090207085417-b088uxuvcz49ezqy
Massive rewrite of DRAW (unfinished): multiple groups and axis

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
 
3
 
class GRAPHAxes {
 
3
class GRAPHAxes implements Iterator {
4
4
 var $req;
5
5
 
6
 
 var $axes;     // Already created axes
 
6
 var $default_axis;     // Default axis
 
7
 var $axes;             // Already created axes
 
8
 var $aids;             // Sequence of axis ids
 
9
 var $cur;              // Iterator
7
10
 
8
11
 function __construct(REQUEST $props = NULL) {
9
12
    if ($props) $this->req = $props;
10
13
    else $this->req = new REQUEST();
11
14
 
 
15
    $this->default_axis = false;
12
16
    $this->axes = array();
13
 
 }
14
 
 
15
 
 function GetAxis($aid) {
16
 
    if (isset($this->axes[$aid])) {
17
 
        return $this->axes[$aid];
18
 
    } else {
19
 
        $axis = new GRAPHAxis($this->req->props, $aid);
20
 
/*      
21
 
        get information from req
22
 
*/
 
17
    $this->aids = array();
 
18
 }
 
19
 
 
20
 function GetAxis($aid = false) {
 
21
    if ((!$aid)&&($aid !== 0)) {
 
22
        if (!$this->default_axis) {
 
23
            $this->default_axis = new GRAPHAxis($this->req->props);
 
24
        }
 
25
        return $this->default_axis;
 
26
    } else {
 
27
        if (isset($this->axes[$aid])) {
 
28
            return $this->axes[$aid];
 
29
        } else {
 
30
            $axis = new GRAPHAxis($this->req->props, $aid);
 
31
            $this->aids[] = $aid;
 
32
            $this->axes[$aid] = $axis;
 
33
        }
 
34
    }
 
35
 
 
36
 }
 
37
 
 
38
 function ListAxes() {
 
39
    if ($this->default_axis) return array_merge($this->aids, false);
 
40
    return $this->aids;
 
41
 }
 
42
 
 
43
 function ListCustomAxes() {
 
44
    return $this->aids;
 
45
 }
 
46
 
 
47
 function GetAxesNumber() {
 
48
    if ($this->default_axis) return sizeof($this->aids) + 1;
 
49
    return sizeof($this->aids);
 
50
 }
 
51
 
 
52
 function rewind() {
 
53
    if ($this->default_axis) $this->cur = 0;
 
54
    else $this->cur = 1;
 
55
 }
 
56
 
 
57
 function valid() {
 
58
    return ((!$this->cur)||(isset($this->aids[$this->cur-1])));
 
59
 }
 
60
 
 
61
 function current() {
 
62
    if ($this->cur > 0) {
 
63
        return $this->axes[$this->aids[$this->cur - 1]];
 
64
    } else {
 
65
        return $this->default_axis;
 
66
    }
 
67
 }
 
68
 
 
69
 function key() {
 
70
    if ($this->default_axis) return $this->cur;
 
71
    else return $this->cur - 1;
 
72
 }
 
73
 
 
74
 function next() {
 
75
    ++$this->cur;
 
76
 }
 
77
 
 
78
 
 
79
 function Enumerate() {
 
80
    if ($this->default_axis) {
 
81
        $num = sizeof($this->aids) + 1;
 
82
    } else {
 
83
        $num = sizeof($this->aids);
 
84
    }
 
85
    
 
86
    $i = 0;
 
87
    foreach ($this as $axis) {
 
88
        $axis->SetPosition($i++, $num);
 
89
    }
 
90
 }
 
91
 
 
92
 function Normalize() {
 
93
    /* DS: We could like to split default axis in order to prevent overfill
 
94
    of the screen */
 
95
    
 
96
    foreach ($this as $axis) {
 
97
        $axis->Normalize();
23
98
    }
24
99
 }
25
100
}