19 require_once(BASE.
"wcmf/lib/output/class.OutputStrategy.php");
23 define(
"LINETYPE_DIRECT", 0);
24 define(
"LINETYPE_ROUTED", 1);
63 if (!(ImageTypes() & $format))
67 $this->_format = $format;
70 $this->_lineType = $lineType;
71 $this->_xscale = $scale;
72 $this->_yscale = $scale/$aspect;
73 $this->_border = $border;
74 $this->_usemap = $usemap;
76 $this->_labelDim[
'left'] = -10;
77 $this->_labelDim[
'top'] = -10;
78 $this->_labelDim[
'right'] = 80;
79 $this->_labelDim[
'bottom'] = 20;
81 $this->_textPos[
'left'] = -5;
82 $this->_textPos[
'top'] = -8;
90 while (list ($key, $val) = each ($this->_map)) {
91 if($val->x >= $this->_width)
92 $this->_width = $val->x;
93 if($val->y >= $this->_height)
94 $this->_height = $val->y;
96 $this->_width = $this->_width * $this->_xscale + $this->_labelDim[
'right'] - $this->_labelDim[
'left'] + 2*
$this->_border;
97 $this->_height = $this->_height * $this->_yscale + $this->_labelDim[
'bottom'] - $this->_labelDim[
'top'] + 2*
$this->_border;
98 $this->_img = ImageCreate($this->_width,$this->_height);
99 $this->_bgColor = ImageColorAllocate($this->_img,255,255,255);
100 $this->_txtColor = ImageColorAllocate($this->_img,0,128,192);
102 ImageFilledRectangle($this->_img,0,0,$this->_width,$this->_height,$this->_bgColor);
104 if ($this->_usemap !=
'')
105 echo
"\n".
'<map name="'.$this->_usemap.
'">'.
"\n";
112 ImageString($this->_img,1,$this->_width-350,$this->_height-10,
'wemove digital solutions. '.date (
"l dS of F Y h:i:s A"),$this->_txtColor);
113 if ($this->_format & IMG_GIF)
114 ImageGIF($this->_img, $this->_file);
115 if ($this->_format & IMG_PNG)
116 ImagePNG($this->_img, $this->_file);
117 if ($this->_format & IMG_JPEG)
118 ImageJPEG($this->_img, $this->_file);
119 if ($this->_format & IMG_WBMP)
120 ImageWBMP($this->_img, $this->_file);
122 if ($this->_usemap !=
'')
123 echo
"\n".
'</map>'.
"\n";
131 $oid = $obj->getOID();
132 $x = $this->_map[$oid]->x * $this->_xscale - $this->_labelDim[
'left'] +
$this->_border;
133 $y = $this->_map[$oid]->y * $this->_yscale - $this->_labelDim[
'top'] +
$this->_border;
144 ImageRectangle($this->_img,
145 $x + $this->_labelDim[
'left'],
146 $y + $this->_labelDim[
'top'],
147 $x + $this->_labelDim[
'right'],
148 $y + $this->_labelDim[
'bottom'],
151 ImageString($this->_img,1,
152 $x + $this->_textPos[
'left'],
153 $y + $this->_textPos[
'top'],
156 if (strlen($oid) > 7)
157 $idStr =
"...".subStr($oid, strlen($oid)-4, 4);
160 ImageString($this->_img,5,
161 $x + $this->_textPos[
'left'],
162 $y + $this->_textPos[
'top']+14,
163 $idStr.
' '.$statusStr,
167 $parent = & $obj->getParent();
172 if ($this->_usemap !=
'')
174 echo
'<area shape="rect" coords="'.
175 ($x + $this->_labelDim[
'left']).
','.
176 ($y + $this->_labelDim[
'top']).
','.
177 ($x + $this->_labelDim[
'right']).
','.
178 ($y + $this->_labelDim[
'bottom'] + 8*$this->_map[$oid]->z).
179 '" onclick="javascript:if (nodeClicked) nodeClicked(\''.$obj->getOID().
'\')
" alt="'.$obj->getOID().'">'."\n
";
188 function drawConnectionLine($poid, $oid)
190 list($start, $end) = $this->calculateEndPoints($poid, $oid);
191 if($this->_lineType == LINETYPE_DIRECT)
192 $this->drawDirectLine($start, $end);
193 else if($this->_lineType == LINETYPE_ROUTED)
194 $this->drawRoutedLine($start, $end);
202 function drawDirectLine($start, $end)
204 ImageLine($this->_img,
217 function drawRoutedLine($start, $end)
219 if ($this->_map["type
"] == MAPTYPE_HORIZONTAL)
221 ImageLine($this->_img,
225 $start->y-($start->y-$end->y)/2,
227 ImageLine($this->_img,
229 $start->y-($start->y-$end->y)/2,
231 $start->y-($start->y-$end->y)/2,
233 ImageLine($this->_img,
235 $start->y-($start->y-$end->y)/2,
242 ImageLine($this->_img,
245 $start->x+($end->x-$start->x)/2,
248 ImageLine($this->_img,
249 $start->x+($end->x-$start->x)/2,
251 $start->x+($end->x-$start->x)/2,
254 ImageLine($this->_img,
255 $start->x+($end->x-$start->x)/2,
269 function calculateEndPoints($poid, $oid)
272 if ($this->_map["type
"] == MAPTYPE_HORIZONTAL)
274 // connect from mid top...
275 $x1 = $this->_map[$oid]->x * $this->_xscale + ($this->_labelDim['right'] - $this->_labelDim['left'])/2 + $this->_border;
276 $y1 = $this->_map[$oid]->y * $this->_yscale + $this->_border - 1;
280 // connect from mid left...
281 $x1 = $this->_map[$oid]->x * $this->_xscale + $this->_border - 1;
282 $y1 = $this->_map[$oid]->y * $this->_yscale + ($this->_labelDim['bottom'] - $this->_labelDim['top'])/2 + $this->_border;
285 if ($this->_map["type
"] == MAPTYPE_HORIZONTAL)
288 $x2 = $this->_map[$poid]->x * $this->_xscale + ($this->_labelDim['right'] - $this->_labelDim['left'])/2 + $this->_border;
289 $y2 = $this->_map[$poid]->y * $this->_yscale + ($this->_labelDim['bottom'] - $this->_labelDim['top']) + $this->_border + 1;
294 $x2 = $this->_map[$poid]->x * $this->_xscale + $this->_labelDim['right'] - $this->_labelDim['left'] + $this->_border + 1;
295 $y2 = $this->_map[$poid]->y * $this->_yscale + ($this->_labelDim['bottom'] - $this->_labelDim['top'])/2 + $this->_border;
297 return array(new Position($x1,$y1,0), new Position($x2,$y2,0));
OutputStrategy is used to write an object's content to a destination (called 'document') using a spec...
This OutputStrategy outputs a tree of objects into an image file. It must be configured with a map th...
ImageOutputStrategy($format, $file, $map, $lineType=LINETYPE_DIRECT, $scale=100, $aspect=0.5, $border=50, $usemap='')
throwEx($message, $file='', $line='')
drawConnectionLine($poid, $oid)