blob: 87f8efa97f3a77c8f40c56779d238a097f52eebc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<?php
/**
* File containing the ezcGraphBoundings class
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Graph
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @access private
*/
/**
* Provides a class representing boundings in a cartesian coordinate system.
*
* Currently only works with plane rectangular boundings, should be enhanced by
* rotated rectangular boundings.
*
* This class is only used internally to represent space which is used by
* certain obejcts on the drawing plane, or which free space is still
* available.
*
* @version //autogentag//
* @package Graph
* @access private
*/
class ezcGraphBoundings
{
/**
* Top left x coordinate
*
* @var float
*/
public $x0 = 0;
/**
* Top left y coordinate
*
* @var float
*/
public $y0 = 0;
/**
* Bottom right x coordinate
*
* @var float
*/
public $x1 = false;
/**
* Bottom right y coordinate
*
* @var float
*/
public $y1 = false;
/**
* Constructor
*
* @param float $x0 Top left x coordinate
* @param float $y0 Top left y coordinate
* @param float $x1 Bottom right x coordinate
* @param float $y1 Bottom right y coordinate
* @return ezcGraphBoundings
*/
public function __construct( $x0 = 0., $y0 = 0., $x1 = null, $y1 = null )
{
$this->x0 = $x0;
$this->y0 = $y0;
$this->x1 = $x1;
$this->y1 = $y1;
// Switch values to ensure correct order
if ( $this->x0 > $this->x1 )
{
$tmp = $this->x0;
$this->x0 = $this->x1;
$this->x1 = $tmp;
}
if ( $this->y0 > $this->y1 )
{
$tmp = $this->y0;
$this->y0 = $this->y1;
$this->y1 = $tmp;
}
}
/**
* Getter for calculated values depending on the boundings.
* - 'width': Width of bounding recangle
* - 'height': Height of bounding recangle
*
* @param string $name Name of property to get
* @return mixed Calculated value
*/
public function __get( $name )
{
switch ( $name )
{
case 'width':
return $this->x1 - $this->x0;
case 'height':
return $this->y1 - $this->y0;
default:
throw new ezcBasePropertyNotFoundException( $name );
}
}
}
?>
|