|
@ -584,7 +584,6 @@ Node.prototype._drawImageAtPosition = function (ctx) { |
|
|
Node.prototype._drawImageLabel = function (ctx) { |
|
|
Node.prototype._drawImageLabel = function (ctx) { |
|
|
var yLabel; |
|
|
var yLabel; |
|
|
if (this.imageObj.width != 0 ) { |
|
|
if (this.imageObj.width != 0 ) { |
|
|
|
|
|
|
|
|
yLabel = this.y + this.height / 2; |
|
|
yLabel = this.y + this.height / 2; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -592,7 +591,7 @@ Node.prototype._drawImageLabel = function (ctx) { |
|
|
yLabel = this.y; |
|
|
yLabel = this.y; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this._label(ctx, this.label, this.x, yLabel, undefined, "top"); |
|
|
|
|
|
|
|
|
this._label(ctx, this.label, this.x, yLabel, undefined, 'hanging'); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Node.prototype._drawImage = function (ctx) { |
|
|
Node.prototype._drawImage = function (ctx) { |
|
@ -955,7 +954,7 @@ Node.prototype._drawShape = function (ctx, shape) { |
|
|
this.boundingBox.bottom = this.y + this.options.radius; |
|
|
this.boundingBox.bottom = this.y + this.options.radius; |
|
|
|
|
|
|
|
|
if (this.label) { |
|
|
if (this.label) { |
|
|
this._label(ctx, this.label, this.x, this.y + this.height / 2, undefined, 'top',true); |
|
|
|
|
|
|
|
|
this._label(ctx, this.label, this.x, this.y + this.height / 2, undefined, 'hanging',true); |
|
|
this.boundingBox.left = Math.min(this.boundingBox.left, this.labelDimensions.left); |
|
|
this.boundingBox.left = Math.min(this.boundingBox.left, this.labelDimensions.left); |
|
|
this.boundingBox.right = Math.max(this.boundingBox.right, this.labelDimensions.left + this.labelDimensions.width); |
|
|
this.boundingBox.right = Math.max(this.boundingBox.right, this.labelDimensions.left + this.labelDimensions.width); |
|
|
this.boundingBox.bottom = Math.max(this.boundingBox.bottom, this.boundingBox.bottom + this.labelDimensions.height); |
|
|
this.boundingBox.bottom = Math.max(this.boundingBox.bottom, this.boundingBox.bottom + this.labelDimensions.height); |
|
@ -997,7 +996,7 @@ Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNo |
|
|
|
|
|
|
|
|
var lines = text.split('\n'); |
|
|
var lines = text.split('\n'); |
|
|
var lineCount = lines.length; |
|
|
var lineCount = lines.length; |
|
|
var fontSize = (Number(this.options.fontSize) + 4); // TODO: why is this +4 ?
|
|
|
|
|
|
|
|
|
var fontSize = Number(this.options.fontSize); |
|
|
var yLine = y + (1 - lineCount) / 2 * fontSize; |
|
|
var yLine = y + (1 - lineCount) / 2 * fontSize; |
|
|
if (labelUnderNode == true) { |
|
|
if (labelUnderNode == true) { |
|
|
yLine = y + (1 - lineCount) / (2 * fontSize); |
|
|
yLine = y + (1 - lineCount) / (2 * fontSize); |
|
@ -1012,8 +1011,10 @@ Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNo |
|
|
var height = this.options.fontSize * lineCount; |
|
|
var height = this.options.fontSize * lineCount; |
|
|
var left = x - width / 2; |
|
|
var left = x - width / 2; |
|
|
var top = y - height / 2; |
|
|
var top = y - height / 2; |
|
|
if (baseline == "top") { |
|
|
|
|
|
|
|
|
if (baseline == "hanging") { |
|
|
top += 0.5 * fontSize; |
|
|
top += 0.5 * fontSize; |
|
|
|
|
|
top += 3; // distance from node, required because we use hanging. Hanging has less difference between browsers
|
|
|
|
|
|
yLine += 3; // distance from node
|
|
|
} |
|
|
} |
|
|
this.labelDimensions = {top:top,left:left,width:width,height:height,yLine:yLine}; |
|
|
this.labelDimensions = {top:top,left:left,width:width,height:height,yLine:yLine}; |
|
|
|
|
|
|
|
|