Allow both horizontal and vertical depiction.
Cat's Eye Technologies
11 years ago
157 | 157 | var w = 0; |
158 | 158 | var h = 0; |
159 | 159 | |
160 | origSexp.horizontal = false; | |
160 | 161 | for (var i = 0; i < len; i++) { |
161 | if (children[i] === null) { | |
162 | continue; | |
163 | } | |
164 | w += children[i].width; | |
165 | if (children[i].height + margin * 2 > h) { | |
166 | h = children[i].height + margin * 2; | |
167 | } | |
168 | } | |
169 | ||
170 | origSexp.width = w + margin * (len + 1); | |
162 | // alert(i + '...' + w); | |
163 | if (origSexp.horizontal) { | |
164 | w += children[i].width || 0; | |
165 | if (children[i].height + margin * 2 > h) { | |
166 | h = children[i].height + margin * 2; | |
167 | } | |
168 | } else { | |
169 | h += children[i].height || 0; | |
170 | if (children[i].width + margin * 2 > w) { | |
171 | w = children[i].width + margin * 2; | |
172 | } | |
173 | } | |
174 | } | |
175 | ||
176 | if (origSexp.horizontal) { | |
177 | w = w + margin * (len + 1); | |
178 | } else { | |
179 | h = h + margin * (len + 1); | |
180 | } | |
181 | origSexp.width = w; | |
171 | 182 | origSexp.height = h; |
172 | 183 | } else { |
173 | 184 | /* |
219 | 230 | ctx.strokeStyle = "black"; |
220 | 231 | ctx.lineWidth = 1; |
221 | 232 | ctx.strokeRect(x - 0.5, y - 0.5, origSexp.width, origSexp.height); |
222 | ||
233 | ||
223 | 234 | var innerX = x + margin; |
235 | var innerY = y + margin; | |
224 | 236 | for (var i = 0; i < len; i++) { |
225 | 237 | if (children[i] === null) { |
226 | 238 | continue; |
227 | 239 | } |
228 | this.depictSexp(innerX, y + margin, children[i], colour); | |
229 | innerX += children[i].width + margin; | |
240 | this.depictSexp(innerX, innerY, children[i], colour); | |
241 | if (origSexp.horizontal) { | |
242 | innerX += children[i].width + margin; | |
243 | } else { | |
244 | innerY += children[i].height + margin; | |
245 | } | |
230 | 246 | } |
231 | 247 | } else { |
232 | 248 | /* |