Skip to content

Commit ce27a3a

Browse files
100pahYi Shen
authored and
Yi Shen
committed
rename "interpret" => "calculate"
1 parent 9e38bc7 commit ce27a3a

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

src/contain/text.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ export function adjustTextY(y, height, textVerticalAlign) {
142142
}
143143

144144
/**
145-
* Follow same interface to `Displayable.prototype.interpretTextPosition`.
145+
* Follow same interface to `Displayable.prototype.calculateTextPosition`.
146146
* @public
147147
* @param {Obejct} [out] Prepared out object. If not input, auto created in the method.
148148
* @param {module:zrender/graphic/Style} style where `textPosition` and `textDistance` are visited.
149149
* @param {Object} rect {x, y, width, height} Rect of the host elment, according to which the text positioned.
150150
* @return {Object} The input `out`. Set: {x, y, textAlign, textVerticalAlign}
151151
*/
152-
export function interpretTextPosition(out, style, rect) {
152+
export function calculateTextPosition(out, style, rect) {
153153
var textPosition = style.textPosition;
154154
var distance = style.textDistance;
155155

@@ -256,7 +256,7 @@ export function interpretTextPosition(out, style, rect) {
256256
*/
257257
export function adjustTextPositionOnRect(textPosition, rect, distance) {
258258
var dummyStyle = {textPosition: textPosition, textDistance: distance};
259-
return interpretTextPosition({}, dummyStyle, rect);
259+
return calculateTextPosition({}, dummyStyle, rect);
260260
}
261261

262262
/**

src/graphic/Displayable.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ Displayable.prototype = {
268268
},
269269

270270
/**
271-
* The string value of `textPosition` needs to be interpreted to a real postion.
272-
* For example, `'inside'` is interpreted to `[rect.width/2, rect.height/2]`
273-
* by default. See `contain/text.js#interpretTextPosition` for more details.
271+
* The string value of `textPosition` needs to be calculated to a real postion.
272+
* For example, `'inside'` is calculated to `[rect.width/2, rect.height/2]`
273+
* by default. See `contain/text.js#calculateTextPosition` for more details.
274274
* But some coutom shapes like "pin", "flag" have center that is not exactly
275-
* `[width/2, height/2]`. So we provide this hook to customize the interpretation
275+
* `[width/2, height/2]`. So we provide this hook to customize the calculation
276276
* for those shapes. It will be called if the `style.textPosition` is a string.
277277
* @param {Obejct} [out] Prepared out object. If not provided, this method should
278278
* be responsible for creating one.
@@ -286,7 +286,7 @@ Displayable.prototype = {
286286
* textVerticalAlign: string. optional. use style.textVerticalAlign by default.
287287
* }
288288
*/
289-
interpretTextPosition: null
289+
calculateTextPosition: null
290290
};
291291

292292
zrUtil.inherits(Displayable, Element);

src/graphic/helper/text.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,9 @@ function getBoxPosition(out, hostEl, style, rect) {
505505
baseY = rect.y + parsePercent(textPosition[1], rect.height);
506506
}
507507
else {
508-
var res = (hostEl && hostEl.interpretTextPosition)
509-
? hostEl.interpretTextPosition(_tmpTextPositionResult, style, rect)
510-
: textContain.interpretTextPosition(_tmpTextPositionResult, style, rect);
508+
var res = (hostEl && hostEl.calculateTextPosition)
509+
? hostEl.calculateTextPosition(_tmpTextPositionResult, style, rect)
510+
: textContain.calculateTextPosition(_tmpTextPositionResult, style, rect);
511511
baseX = res.x;
512512
baseY = res.y;
513513
// Default align and baseline when has textPosition

src/svg/graphic.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ var svgTextDrawRectText = function (el, rect, textRect) {
363363
y = rect.y + textPosition[1];
364364
}
365365
else {
366-
var newPos = el.interpretTextPosition
367-
? el.interpretTextPosition(tmpTextPositionResult, style, rect)
368-
: textContain.interpretTextPosition(tmpTextPositionResult, style, rect);
366+
var newPos = el.calculateTextPosition
367+
? el.calculateTextPosition(tmpTextPositionResult, style, rect)
368+
: textContain.calculateTextPosition(tmpTextPositionResult, style, rect);
369369
x = newPos.x;
370370
y = newPos.y;
371371
verticalAlign = newPos.textVerticalAlign;

src/vml/graphic.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,9 @@ if (!env.canvasSupported) {
883883
align = align || 'left';
884884
}
885885
else {
886-
var res = this.interpretTextPosition
887-
? this.interpretTextPosition({}, style, rect)
888-
: textContain.interpretTextPosition({}, style, rect);
886+
var res = this.calculateTextPosition
887+
? this.calculateTextPosition({}, style, rect)
888+
: textContain.calculateTextPosition({}, style, rect);
889889
x = res.x;
890890
y = res.y;
891891

0 commit comments

Comments
 (0)