protected function ParsePosition($pos, $w = 0, $h = 0, $pad = 0)
{
$inner = true;
$parts = preg_split('/\\s+/', $pos);
if (count($parts)) {
// if 'outer' is found after 'inner', it takes precedence
$parts = array_reverse($parts);
$inner_at = array_search('inner', $parts);
$outer_at = array_search('outer', $parts);
if ($outer_at !== false && ($inner_at === false || $inner_at < $outer_at)) {
$inner = false;
}
}
if ($inner) {
$t = $this->pad_top;
$l = $this->pad_left;
$b = $this->height - $this->pad_bottom;
$r = $this->width - $this->pad_right;
// make sure it fits to keep RelativePosition happy
if ($w > $r - $l) {
$w = $r - $l;
}
if ($h > $b - $t) {
$h = $b - $t;
}
} else {
$t = $l = 0;
$b = $this->height;
$r = $this->width;
}
// ParsePosition is always inside canvas or graph
$pos .= ' inside';
return Graph::RelativePosition($pos, $t, $l, $b, $r, $w, $h, $pad);
}