in airavata-kubernetes/workflow-composer/src/js/util/mxVmlCanvas2D.js [663:979]
mxVmlCanvas2D.prototype.text = function(x, y, w, h, str, align, valign, wrap, format, overflow, clip, rotation, dir)
{
if (this.textEnabled && str != null)
{
var s = this.state;
if (format == 'html')
{
if (s.rotation != null)
{
var pt = this.rotatePoint(x, y, s.rotation, s.rotationCx, s.rotationCy);
x = pt.x;
y = pt.y;
}
if (document.documentMode == 8 && !mxClient.IS_EM)
{
x += s.dx;
y += s.dy;
// Workaround for rendering offsets
if (overflow != 'fill' && valign == mxConstants.ALIGN_TOP)
{
y -= 1;
}
}
else
{
x *= s.scale;
y *= s.scale;
}
// Adds event transparency in IE8 standards without the transparent background
// filter which cannot be used due to bugs in the zoomed bounding box (too slow)
// FIXME: No event transparency if inside v:rect (ie part of shape)
// KNOWN: Offset wrong for rotated text with word that are longer than the wrapping
// width in IE8 because real width of text cannot be determined here.
// This should be fixed in mxText.updateBoundingBox by calling before this and
// passing the real width to this method if not clipped and wrapped.
var abs = (document.documentMode == 8 && !mxClient.IS_EM) ? this.createVmlElement('group') : this.createElement('div');
abs.style.position = 'absolute';
abs.style.display = 'inline';
abs.style.left = this.format(x) + 'px';
abs.style.top = this.format(y) + 'px';
abs.style.zoom = s.scale;
var box = this.createElement('div');
box.style.position = 'relative';
box.style.display = 'inline';
var margin = mxUtils.getAlignmentAsPoint(align, valign);
var dx = margin.x;
var dy = margin.y;
var div = this.createDiv(str, align, valign, overflow);
var inner = this.createElement('div');
if (dir != null)
{
div.setAttribute('dir', dir);
}
if (wrap && w > 0)
{
if (!clip)
{
div.style.width = Math.round(w) + 'px';
}
div.style.wordWrap = mxConstants.WORD_WRAP;
div.style.whiteSpace = 'normal';
// LATER: Check if other cases need to be handled
if (div.style.wordWrap == 'break-word')
{
var tmp = div;
if (tmp.firstChild != null && tmp.firstChild.nodeName == 'DIV')
{
tmp.firstChild.style.width = '100%';
}
}
}
else
{
div.style.whiteSpace = 'nowrap';
}
var rot = s.rotation + (rotation || 0);
if (this.rotateHtml && rot != 0)
{
inner.style.display = 'inline';
inner.style.zoom = '1';
inner.appendChild(div);
// Box not needed for rendering in IE8 standards
if (document.documentMode == 8 && !mxClient.IS_EM && this.root.nodeName != 'DIV')
{
box.appendChild(inner);
abs.appendChild(box);
}
else
{
abs.appendChild(inner);
}
}
else if (document.documentMode == 8 && !mxClient.IS_EM)
{
box.appendChild(div);
abs.appendChild(box);
}
else
{
div.style.display = 'inline';
abs.appendChild(div);
}
// Inserts the node into the DOM
if (this.root.nodeName != 'DIV')
{
// Rectangle to fix position in group
var rect = this.createVmlElement('rect');
rect.stroked = 'false';
rect.filled = 'false';
rect.appendChild(abs);
this.root.appendChild(rect);
}
else
{
this.root.appendChild(abs);
}
if (clip)
{
div.style.overflow = 'hidden';
div.style.width = Math.round(w) + 'px';
if (!mxClient.IS_QUIRKS)
{
div.style.maxHeight = Math.round(h) + 'px';
}
}
else if (overflow == 'fill')
{
// KNOWN: Affects horizontal alignment in quirks
// but fill should only be used with align=left
div.style.overflow = 'hidden';
div.style.width = (Math.max(0, w) + 1) + 'px';
div.style.height = (Math.max(0, h) + 1) + 'px';
}
else if (overflow == 'width')
{
// KNOWN: Affects horizontal alignment in quirks
// but fill should only be used with align=left
div.style.overflow = 'hidden';
div.style.width = (Math.max(0, w) + 1) + 'px';
div.style.maxHeight = (Math.max(0, h) + 1) + 'px';
}
if (this.rotateHtml && rot != 0)
{
var rad = rot * (Math.PI / 180);
// Precalculate cos and sin for the rotation
var real_cos = parseFloat(parseFloat(Math.cos(rad)).toFixed(8));
var real_sin = parseFloat(parseFloat(Math.sin(-rad)).toFixed(8));
rad %= 2 * Math.PI;
if (rad < 0) rad += 2 * Math.PI;
rad %= Math.PI;
if (rad > Math.PI / 2) rad = Math.PI - rad;
var cos = Math.cos(rad);
var sin = Math.sin(rad);
// Adds div to document to measure size
if (document.documentMode == 8 && !mxClient.IS_EM)
{
div.style.display = 'inline-block';
inner.style.display = 'inline-block';
box.style.display = 'inline-block';
}
div.style.visibility = 'hidden';
div.style.position = 'absolute';
document.body.appendChild(div);
var sizeDiv = div;
if (sizeDiv.firstChild != null && sizeDiv.firstChild.nodeName == 'DIV')
{
sizeDiv = sizeDiv.firstChild;
}
var tmp = sizeDiv.offsetWidth + 3;
var oh = sizeDiv.offsetHeight;
if (clip)
{
w = Math.min(w, tmp);
oh = Math.min(oh, h);
}
else
{
w = tmp;
}
// Handles words that are longer than the given wrapping width
if (wrap)
{
div.style.width = w + 'px';
}
// Simulates max-height in quirks
if (mxClient.IS_QUIRKS && (clip || overflow == 'width') && oh > h)
{
oh = h;
// Quirks does not support maxHeight
div.style.height = oh + 'px';
}
h = oh;
var top_fix = (h - h * cos + w * -sin) / 2 - real_sin * w * (dx + 0.5) + real_cos * h * (dy + 0.5);
var left_fix = (w - w * cos + h * -sin) / 2 + real_cos * w * (dx + 0.5) + real_sin * h * (dy + 0.5);
if (abs.nodeName == 'group' && this.root.nodeName == 'DIV')
{
// Workaround for bug where group gets moved away if left and top are non-zero in IE8 standards
var pos = this.createElement('div');
pos.style.display = 'inline-block';
pos.style.position = 'absolute';
pos.style.left = this.format(x + (left_fix - w / 2) * s.scale) + 'px';
pos.style.top = this.format(y + (top_fix - h / 2) * s.scale) + 'px';
abs.parentNode.appendChild(pos);
pos.appendChild(abs);
}
else
{
var sc = (document.documentMode == 8 && !mxClient.IS_EM) ? 1 : s.scale;
abs.style.left = this.format(x + (left_fix - w / 2) * sc) + 'px';
abs.style.top = this.format(y + (top_fix - h / 2) * sc) + 'px';
}
// KNOWN: Rotated text rendering quality is bad for IE9 quirks
inner.style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11="+real_cos+", M12="+
real_sin+", M21="+(-real_sin)+", M22="+real_cos+", sizingMethod='auto expand')";
inner.style.backgroundColor = this.rotatedHtmlBackground;
if (this.state.alpha < 1)
{
inner.style.filter += 'alpha(opacity=' + (this.state.alpha * 100) + ')';
}
// Restore parent node for DIV
inner.appendChild(div);
div.style.position = '';
div.style.visibility = '';
}
else if (document.documentMode != 8 || mxClient.IS_EM)
{
div.style.verticalAlign = 'top';
if (this.state.alpha < 1)
{
abs.style.filter = 'alpha(opacity=' + (this.state.alpha * 100) + ')';
}
// Adds div to document to measure size
var divParent = div.parentNode;
div.style.visibility = 'hidden';
document.body.appendChild(div);
w = div.offsetWidth;
var oh = div.offsetHeight;
// Simulates max-height in quirks
if (mxClient.IS_QUIRKS && clip && oh > h)
{
oh = h;
// Quirks does not support maxHeight
div.style.height = oh + 'px';
}
h = oh;
div.style.visibility = '';
divParent.appendChild(div);
abs.style.left = this.format(x + w * dx * this.state.scale) + 'px';
abs.style.top = this.format(y + h * dy * this.state.scale) + 'px';
}
else
{
if (this.state.alpha < 1)
{
div.style.filter = 'alpha(opacity=' + (this.state.alpha * 100) + ')';
}
// Faster rendering in IE8 without offsetWidth/Height
box.style.left = (dx * 100) + '%';
box.style.top = (dy * 100) + '%';
}
}
else
{
this.plainText(x, y, w, h, mxUtils.htmlEntities(str, false), align, valign, wrap, format, overflow, clip, rotation, dir);
}
}
};