@visactor/vrender-components 0.21.0-alpha.1 → 0.21.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/axis/circle.js +3 -3
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/overlap/auto-hide.js +2 -2
- package/cjs/axis/overlap/auto-hide.js.map +1 -1
- package/cjs/axis/overlap/auto-limit.js +7 -9
- package/cjs/axis/overlap/auto-limit.js.map +1 -1
- package/cjs/axis/overlap/auto-wrap.js +21 -8
- package/cjs/axis/overlap/auto-wrap.js.map +1 -1
- package/cjs/axis/tick-data/continuous.js +3 -3
- package/cjs/axis/tick-data/continuous.js.map +1 -1
- package/cjs/axis/type.d.ts +6 -2
- package/cjs/axis/type.js.map +1 -1
- package/cjs/data-zoom/type.d.ts +1 -1
- package/cjs/data-zoom/type.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interface.js.map +1 -1
- package/cjs/label/arc.js +1 -1
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +4 -2
- package/cjs/label/base.js +48 -11
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +6 -1
- package/cjs/label/overlap/place.js +7 -5
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/overlap/scaler.d.ts +6 -0
- package/cjs/label/overlap/scaler.js +16 -14
- package/cjs/label/overlap/scaler.js.map +1 -1
- package/cjs/label/overlap/shiftY.d.ts +9 -0
- package/cjs/label/overlap/shiftY.js +101 -0
- package/cjs/label/overlap/shiftY.js.map +1 -0
- package/cjs/label/type.d.ts +8 -1
- package/cjs/label/type.js.map +1 -1
- package/cjs/legend/base.d.ts +1 -0
- package/cjs/legend/base.js +7 -6
- package/cjs/legend/base.js.map +1 -1
- package/cjs/legend/color/type.d.ts +2 -2
- package/cjs/legend/color/type.js.map +1 -1
- package/cjs/legend/discrete/discrete.d.ts +8 -0
- package/cjs/legend/discrete/discrete.js +122 -32
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/legend/discrete/type.d.ts +16 -4
- package/cjs/legend/discrete/type.js.map +1 -1
- package/cjs/marker/type.d.ts +2 -2
- package/cjs/marker/type.js.map +1 -1
- package/cjs/player/type/discrete-player.d.ts +3 -3
- package/cjs/player/type/discrete-player.js.map +1 -1
- package/cjs/player/type/index.d.ts +2 -2
- package/cjs/player/type/index.js.map +1 -1
- package/cjs/scrollbar/index.d.ts +1 -0
- package/cjs/scrollbar/index.js +2 -1
- package/cjs/scrollbar/index.js.map +1 -1
- package/cjs/scrollbar/scrollbar-plugin.d.ts +18 -15
- package/cjs/scrollbar/scrollbar-plugin.js +109 -97
- package/cjs/scrollbar/scrollbar-plugin.js.map +1 -1
- package/cjs/timeline/type.js.map +1 -1
- package/dist/index.es.js +1444 -665
- package/es/axis/circle.js +3 -3
- package/es/axis/circle.js.map +1 -1
- package/es/axis/overlap/auto-hide.js +2 -2
- package/es/axis/overlap/auto-hide.js.map +1 -1
- package/es/axis/overlap/auto-limit.js +5 -8
- package/es/axis/overlap/auto-limit.js.map +1 -1
- package/es/axis/overlap/auto-wrap.js +20 -8
- package/es/axis/overlap/auto-wrap.js.map +1 -1
- package/es/axis/tick-data/continuous.js +3 -3
- package/es/axis/tick-data/continuous.js.map +1 -1
- package/es/axis/type.d.ts +6 -2
- package/es/axis/type.js.map +1 -1
- package/es/data-zoom/type.d.ts +1 -1
- package/es/data-zoom/type.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interface.js.map +1 -1
- package/es/label/arc.js +1 -1
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +4 -2
- package/es/label/base.js +48 -8
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/place.d.ts +6 -1
- package/es/label/overlap/place.js +8 -6
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/overlap/scaler.d.ts +6 -0
- package/es/label/overlap/scaler.js +11 -10
- package/es/label/overlap/scaler.js.map +1 -1
- package/es/label/overlap/shiftY.d.ts +9 -0
- package/es/label/overlap/shiftY.js +94 -0
- package/es/label/overlap/shiftY.js.map +1 -0
- package/es/label/type.d.ts +8 -1
- package/es/label/type.js.map +1 -1
- package/es/legend/base.d.ts +1 -0
- package/es/legend/base.js +7 -5
- package/es/legend/base.js.map +1 -1
- package/es/legend/color/type.d.ts +2 -2
- package/es/legend/color/type.js.map +1 -1
- package/es/legend/discrete/discrete.d.ts +8 -0
- package/es/legend/discrete/discrete.js +122 -33
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/legend/discrete/type.d.ts +16 -4
- package/es/legend/discrete/type.js.map +1 -1
- package/es/marker/type.d.ts +2 -2
- package/es/marker/type.js.map +1 -1
- package/es/player/type/discrete-player.d.ts +3 -3
- package/es/player/type/discrete-player.js.map +1 -1
- package/es/player/type/index.d.ts +2 -2
- package/es/player/type/index.js.map +1 -1
- package/es/scrollbar/index.d.ts +1 -0
- package/es/scrollbar/index.js +2 -0
- package/es/scrollbar/index.js.map +1 -1
- package/es/scrollbar/scrollbar-plugin.d.ts +18 -15
- package/es/scrollbar/scrollbar-plugin.js +111 -94
- package/es/scrollbar/scrollbar-plugin.js.map +1 -1
- package/es/timeline/type.js.map +1 -1
- package/package.json +10 -9
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, cos, sin, pi, isArray, pointAt, isNumber, getDecimalPlaces, isNil, Color, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, sqrt, transformBoundsWithMatrix, arrayEqual, getContextFont, rotatePoint, clampAngleByRadian, asin, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, array, isValidNumber, calculateAnchorOfBounds, computeQuadrant, isGreater, isLess,
|
|
1
|
+
import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, cos, sin, pi, isArray, pointAt, isNumber, getDecimalPlaces, isNil, Color, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, sqrt, transformBoundsWithMatrix, arrayEqual, getContextFont, rotatePoint, clampAngleByRadian, asin, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, array, isValidNumber, calculateAnchorOfBounds, computeQuadrant, isGreater, isLess, normalizeAngle, flattenArray, cloneDeep, get, last, isRotateAABBIntersect, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, polygonContainPoint } from '@visactor/vutils';
|
|
2
2
|
import { isContinuous, isDiscrete, LinearScale } from '@visactor/vscale';
|
|
3
3
|
|
|
4
4
|
class Generator {
|
|
@@ -745,6 +745,11 @@ let DefaultGlobal = class {
|
|
|
745
745
|
};
|
|
746
746
|
DefaultGlobal = __decorate$P([injectable(), __param$z(0, inject(ContributionProvider)), __param$z(0, named(EnvContribution)), __metadata$E("design:paramtypes", [Object])], DefaultGlobal);
|
|
747
747
|
|
|
748
|
+
var MeasureModeEnum;
|
|
749
|
+
!function (MeasureModeEnum) {
|
|
750
|
+
MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding", MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
|
|
751
|
+
}(MeasureModeEnum || (MeasureModeEnum = {}));
|
|
752
|
+
|
|
748
753
|
const circleThreshold = tau - 1e-8;
|
|
749
754
|
class BoundsContext {
|
|
750
755
|
constructor(bounds) {
|
|
@@ -860,11 +865,12 @@ function parseSvgPath(str) {
|
|
|
860
865
|
for (let i = 0, len = paths.length; i < len; i++) if (currPath = paths[i], coordsStr = currPath.slice(1), commandChar = currPath[0], currCommandData = [commandChar], coordsStrArr = coordsStr.match(rePathCommand), null !== coordsStrArr) {
|
|
861
866
|
for (let i = 0, len = coordsStrArr.length; i < len; i++) coordStr = coordsStrArr[i], coordNumber = parseFloat(coordStr), Number.isNaN(coordNumber) || currCommandData.push(coordNumber);
|
|
862
867
|
if (standardCommandLen = commandLengths[commandChar], currCommandData.length - 1 > standardCommandLen) {
|
|
863
|
-
let subCommand
|
|
868
|
+
let subCommand,
|
|
869
|
+
bestCommandChar = commandChar;
|
|
864
870
|
for (let i = 1, len = currCommandData.length; i < len; i += standardCommandLen) {
|
|
865
|
-
subCommand = [
|
|
871
|
+
subCommand = [bestCommandChar];
|
|
866
872
|
for (let j = i, subLen = i + standardCommandLen; j < subLen; j++) subCommand.push(currCommandData[j]);
|
|
867
|
-
result.push(subCommand);
|
|
873
|
+
result.push(subCommand), "m" === bestCommandChar ? bestCommandChar = "l" : "M" === bestCommandChar && (bestCommandChar = "L");
|
|
868
874
|
}
|
|
869
875
|
} else result.push(currCommandData);
|
|
870
876
|
} else result.push(currCommandData);
|
|
@@ -2008,6 +2014,7 @@ const DefaultStrokeStyle = Object.assign({
|
|
|
2008
2014
|
const DefaultTextStyle = {
|
|
2009
2015
|
text: "",
|
|
2010
2016
|
maxLineWidth: 1 / 0,
|
|
2017
|
+
maxWidth: 1 / 0,
|
|
2011
2018
|
textAlign: "left",
|
|
2012
2019
|
textBaseline: "alphabetic",
|
|
2013
2020
|
fontSize: 16,
|
|
@@ -2031,7 +2038,9 @@ const DefaultTextStyle = {
|
|
|
2031
2038
|
suffixPosition: "end",
|
|
2032
2039
|
underlineDash: [],
|
|
2033
2040
|
underlineOffset: 0,
|
|
2034
|
-
disableAutoClipedPoptip: void 0
|
|
2041
|
+
disableAutoClipedPoptip: void 0,
|
|
2042
|
+
measureMode: MeasureModeEnum.fontBounding,
|
|
2043
|
+
keepCenterInLine: !1
|
|
2035
2044
|
};
|
|
2036
2045
|
const DefaultPickStyle = {
|
|
2037
2046
|
pickStrokeBuffer: 0
|
|
@@ -2075,6 +2084,7 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
|
|
|
2075
2084
|
zIndex: 0,
|
|
2076
2085
|
layout: null,
|
|
2077
2086
|
boundsPadding: 0,
|
|
2087
|
+
fillStrokeOrder: 0,
|
|
2078
2088
|
renderStyle: "default",
|
|
2079
2089
|
pickMode: "accurate",
|
|
2080
2090
|
customPickShape: null,
|
|
@@ -2084,7 +2094,8 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
|
|
|
2084
2094
|
globalZIndex: 1,
|
|
2085
2095
|
globalCompositeOperation: "",
|
|
2086
2096
|
overflow: "hidden",
|
|
2087
|
-
shadowPickMode: "graphic"
|
|
2097
|
+
shadowPickMode: "graphic",
|
|
2098
|
+
keepStrokeScale: !1
|
|
2088
2099
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
2089
2100
|
const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2090
2101
|
startAngle: 0,
|
|
@@ -2145,6 +2156,7 @@ const DefaultLineAttribute = Object.assign(Object.assign(Object.assign({}, Defau
|
|
|
2145
2156
|
});
|
|
2146
2157
|
const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2147
2158
|
path: new CustomPath2D(),
|
|
2159
|
+
fillStrokeOrder: 1,
|
|
2148
2160
|
customPath: () => {
|
|
2149
2161
|
Logger.getInstance().warn("空函数");
|
|
2150
2162
|
}
|
|
@@ -2350,10 +2362,32 @@ let ATextMeasure = class {
|
|
|
2350
2362
|
configure(service, env) {
|
|
2351
2363
|
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
2352
2364
|
}
|
|
2353
|
-
|
|
2354
|
-
if (!this.context) return this.estimate(text, options).width;
|
|
2365
|
+
_measureTextWithoutAlignBaseline(text, options, compatible) {
|
|
2355
2366
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2356
|
-
|
|
2367
|
+
const metrics = this.context.measureText(text);
|
|
2368
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2369
|
+
}
|
|
2370
|
+
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
2371
|
+
this.context.setTextStyle(options);
|
|
2372
|
+
const metrics = this.context.measureText(text);
|
|
2373
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2374
|
+
}
|
|
2375
|
+
compatibleMetrics(metrics, options) {
|
|
2376
|
+
if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
|
|
2377
|
+
const {
|
|
2378
|
+
ascent: ascent,
|
|
2379
|
+
descent: descent
|
|
2380
|
+
} = this.measureTextBoundADscentEstimate(options);
|
|
2381
|
+
metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
|
|
2382
|
+
}
|
|
2383
|
+
if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
|
|
2384
|
+
const {
|
|
2385
|
+
left: left,
|
|
2386
|
+
right: right
|
|
2387
|
+
} = this.measureTextBoundLeftRightEstimate(options);
|
|
2388
|
+
metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
|
|
2389
|
+
}
|
|
2390
|
+
return metrics;
|
|
2357
2391
|
}
|
|
2358
2392
|
estimate(text, _ref) {
|
|
2359
2393
|
let {
|
|
@@ -2367,19 +2401,97 @@ let ATextMeasure = class {
|
|
|
2367
2401
|
height: fontSize
|
|
2368
2402
|
};
|
|
2369
2403
|
}
|
|
2370
|
-
|
|
2404
|
+
measureTextWidth(text, options, textMeasure) {
|
|
2405
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2406
|
+
}
|
|
2407
|
+
measureTextBoundsWidth(text, options, textMeasure) {
|
|
2408
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2409
|
+
}
|
|
2410
|
+
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
2411
|
+
return this.context ? {
|
|
2412
|
+
left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
|
|
2413
|
+
right: textMeasure.actualBoundingBoxRight
|
|
2414
|
+
} : this.measureTextBoundLeftRightEstimate(options);
|
|
2415
|
+
}
|
|
2416
|
+
measureTextPixelHeight(text, options, textMeasure) {
|
|
2371
2417
|
var _a;
|
|
2372
|
-
|
|
2373
|
-
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2374
|
-
const textMeasure = this.context.measureText(text);
|
|
2375
|
-
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
2418
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2376
2419
|
}
|
|
2377
|
-
|
|
2420
|
+
measureTextPixelADscent(text, options, textMeasure) {
|
|
2421
|
+
return this.context ? {
|
|
2422
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
2423
|
+
descent: textMeasure.actualBoundingBoxDescent
|
|
2424
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
2425
|
+
}
|
|
2426
|
+
measureTextBoundHieght(text, options, textMeasure) {
|
|
2378
2427
|
var _a;
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
return
|
|
2428
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2429
|
+
}
|
|
2430
|
+
measureTextBoundADscent(text, options, textMeasure) {
|
|
2431
|
+
return this.context ? {
|
|
2432
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
|
|
2433
|
+
descent: textMeasure.fontBoundingBoxDescent
|
|
2434
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
2435
|
+
}
|
|
2436
|
+
measureTextBoundADscentEstimate(options) {
|
|
2437
|
+
var _a;
|
|
2438
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2439
|
+
return {
|
|
2440
|
+
ascent: .79 * fontSize,
|
|
2441
|
+
descent: .21 * fontSize
|
|
2442
|
+
};
|
|
2443
|
+
}
|
|
2444
|
+
measureTextBoundLeftRightEstimate(options) {
|
|
2445
|
+
var _a;
|
|
2446
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
|
|
2447
|
+
{
|
|
2448
|
+
textAlign: textAlign
|
|
2449
|
+
} = options;
|
|
2450
|
+
return "center" === textAlign ? {
|
|
2451
|
+
left: fontSize / 2,
|
|
2452
|
+
right: fontSize / 2
|
|
2453
|
+
} : "right" === textAlign || "end" === textAlign ? {
|
|
2454
|
+
left: fontSize,
|
|
2455
|
+
right: 0
|
|
2456
|
+
} : {
|
|
2457
|
+
left: 0,
|
|
2458
|
+
right: fontSize
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
measureTextPixelADscentAndWidth(text, options, mode) {
|
|
2462
|
+
if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
2463
|
+
width: this.estimate(text, options).width
|
|
2464
|
+
});
|
|
2465
|
+
const out = this._measureTextWithoutAlignBaseline(text, options, !0);
|
|
2466
|
+
if (mode === MeasureModeEnum.actualBounding) return {
|
|
2467
|
+
ascent: out.actualBoundingBoxAscent,
|
|
2468
|
+
descent: out.actualBoundingBoxDescent,
|
|
2469
|
+
width: out.width
|
|
2470
|
+
};
|
|
2471
|
+
if (mode === MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
2472
|
+
width: out.width
|
|
2473
|
+
});
|
|
2474
|
+
if (mode === MeasureModeEnum.fontBounding) {
|
|
2475
|
+
let ascent = out.fontBoundingBoxAscent,
|
|
2476
|
+
descent = out.fontBoundingBoxDescent;
|
|
2477
|
+
if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
|
|
2478
|
+
const delta = out.actualBoundingBoxDescent - descent;
|
|
2479
|
+
descent += delta, ascent -= delta;
|
|
2480
|
+
} else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
|
|
2481
|
+
const delta = out.actualBoundingBoxAscent - ascent;
|
|
2482
|
+
ascent += delta, descent -= delta;
|
|
2483
|
+
}
|
|
2484
|
+
return {
|
|
2485
|
+
ascent: ascent,
|
|
2486
|
+
descent: descent,
|
|
2487
|
+
width: out.width
|
|
2488
|
+
};
|
|
2489
|
+
}
|
|
2490
|
+
return {
|
|
2491
|
+
ascent: out.actualBoundingBoxAscent,
|
|
2492
|
+
descent: out.actualBoundingBoxDescent,
|
|
2493
|
+
width: out.width
|
|
2494
|
+
};
|
|
2383
2495
|
}
|
|
2384
2496
|
measureText(text, options) {
|
|
2385
2497
|
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
@@ -2457,6 +2569,14 @@ let ATextMeasure = class {
|
|
|
2457
2569
|
return data;
|
|
2458
2570
|
}
|
|
2459
2571
|
_clipTextEnd(text, options, width, leftIdx, rightIdx) {
|
|
2572
|
+
if (leftIdx === rightIdx) {
|
|
2573
|
+
Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
|
|
2574
|
+
const subText = text.substring(0, rightIdx + 1);
|
|
2575
|
+
return {
|
|
2576
|
+
str: subText,
|
|
2577
|
+
width: this.measureTextWidth(subText, options)
|
|
2578
|
+
};
|
|
2579
|
+
}
|
|
2460
2580
|
const middleIdx = Math.floor((leftIdx + rightIdx) / 2),
|
|
2461
2581
|
subText = text.substring(0, middleIdx + 1),
|
|
2462
2582
|
strWidth = this.measureTextWidth(subText, options);
|
|
@@ -2490,7 +2610,7 @@ let ATextMeasure = class {
|
|
|
2490
2610
|
}
|
|
2491
2611
|
_clipTextStart(text, options, width, leftIdx, rightIdx) {
|
|
2492
2612
|
const middleIdx = Math.ceil((leftIdx + rightIdx) / 2),
|
|
2493
|
-
subText = text.substring(middleIdx - 1, text.length
|
|
2613
|
+
subText = text.substring(middleIdx - 1, text.length),
|
|
2494
2614
|
strWidth = this.measureTextWidth(subText, options);
|
|
2495
2615
|
let length;
|
|
2496
2616
|
if (strWidth > width) {
|
|
@@ -2498,18 +2618,18 @@ let ATextMeasure = class {
|
|
|
2498
2618
|
str: "",
|
|
2499
2619
|
width: 0
|
|
2500
2620
|
};
|
|
2501
|
-
const str = text.substring(middleIdx, text.length
|
|
2621
|
+
const str = text.substring(middleIdx, text.length);
|
|
2502
2622
|
return length = this.measureTextWidth(str, options), length <= width ? {
|
|
2503
2623
|
str: str,
|
|
2504
2624
|
width: length
|
|
2505
|
-
} : this._clipTextStart(text, options, width, middleIdx, text.length
|
|
2625
|
+
} : this._clipTextStart(text, options, width, middleIdx, text.length);
|
|
2506
2626
|
}
|
|
2507
2627
|
if (strWidth < width) {
|
|
2508
2628
|
if (middleIdx <= 0) return {
|
|
2509
2629
|
str: text,
|
|
2510
2630
|
width: this.measureTextWidth(text, options)
|
|
2511
2631
|
};
|
|
2512
|
-
const str = text.substring(middleIdx - 2, text.length
|
|
2632
|
+
const str = text.substring(middleIdx - 2, text.length);
|
|
2513
2633
|
return length = this.measureTextWidth(str, options), length >= width ? {
|
|
2514
2634
|
str: subText,
|
|
2515
2635
|
width: strWidth
|
|
@@ -2817,7 +2937,7 @@ let DefaultWindow = class {
|
|
|
2817
2937
|
}
|
|
2818
2938
|
hasSubView() {
|
|
2819
2939
|
const viewBox = this._handler.getViewBox();
|
|
2820
|
-
return !(0 === viewBox.x1 && 0 === viewBox.y1 && this.width
|
|
2940
|
+
return !(0 === viewBox.x1 && 0 === viewBox.y1 && isNumberClose(this.width, viewBox.width()) && isNumberClose(this.height, viewBox.height()));
|
|
2821
2941
|
}
|
|
2822
2942
|
isVisible(bbox) {
|
|
2823
2943
|
return this._handler.isVisible(bbox);
|
|
@@ -6025,9 +6145,6 @@ const SymbolRenderContribution = Symbol.for("SymbolRenderContribution");
|
|
|
6025
6145
|
const TextRenderContribution = Symbol.for("TextRenderContribution");
|
|
6026
6146
|
const InteractiveSubRenderContribution = Symbol.for("InteractiveSubRenderContribution");
|
|
6027
6147
|
|
|
6028
|
-
function textDrawOffsetY(baseline, h) {
|
|
6029
|
-
return "top" === baseline ? Math.ceil(.79 * h) : "middle" === baseline ? Math.round(.3 * h) : "bottom" === baseline ? Math.round(-.21 * h) : 0;
|
|
6030
|
-
}
|
|
6031
6148
|
function textDrawOffsetX(textAlign, width) {
|
|
6032
6149
|
return "end" === textAlign || "right" === textAlign ? -width : "center" === textAlign ? -width / 2 : 0;
|
|
6033
6150
|
}
|
|
@@ -7016,7 +7133,8 @@ class DefaultArcRenderContribution {
|
|
|
7016
7133
|
x: originX = arcAttribute.x,
|
|
7017
7134
|
y: originY = arcAttribute.y,
|
|
7018
7135
|
scaleX = arcAttribute.scaleX,
|
|
7019
|
-
scaleY = arcAttribute.scaleY
|
|
7136
|
+
scaleY = arcAttribute.scaleY,
|
|
7137
|
+
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
7020
7138
|
} = arc.attribute;
|
|
7021
7139
|
let {
|
|
7022
7140
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -7028,7 +7146,7 @@ class DefaultArcRenderContribution {
|
|
|
7028
7146
|
{
|
|
7029
7147
|
distance = arcAttribute[key].distance
|
|
7030
7148
|
} = borderStyle,
|
|
7031
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7149
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7032
7150
|
deltaAngle = distance / outerRadius,
|
|
7033
7151
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7034
7152
|
if (arc.setAttributes({
|
|
@@ -7073,14 +7191,15 @@ class DefaultCircleRenderContribution {
|
|
|
7073
7191
|
x: originX = circleAttribute.x,
|
|
7074
7192
|
y: originY = circleAttribute.y,
|
|
7075
7193
|
scaleX = circleAttribute.scaleX,
|
|
7076
|
-
scaleY = circleAttribute.scaleY
|
|
7194
|
+
scaleY = circleAttribute.scaleY,
|
|
7195
|
+
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
7077
7196
|
} = circle.attribute,
|
|
7078
7197
|
renderBorder = (borderStyle, key) => {
|
|
7079
7198
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7080
7199
|
{
|
|
7081
7200
|
distance = circleAttribute[key].distance
|
|
7082
7201
|
} = borderStyle,
|
|
7083
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7202
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7084
7203
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7085
7204
|
if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), strokeCb) strokeCb(context, borderStyle, circleAttribute[key]);else if (doStroke) {
|
|
7086
7205
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -7199,7 +7318,8 @@ class DefaultRectRenderContribution {
|
|
|
7199
7318
|
scaleX = rectAttribute.scaleX,
|
|
7200
7319
|
scaleY = rectAttribute.scaleY,
|
|
7201
7320
|
x1: x1,
|
|
7202
|
-
y1: y1
|
|
7321
|
+
y1: y1,
|
|
7322
|
+
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
7203
7323
|
} = rect.attribute;
|
|
7204
7324
|
let {
|
|
7205
7325
|
width: width,
|
|
@@ -7212,7 +7332,7 @@ class DefaultRectRenderContribution {
|
|
|
7212
7332
|
{
|
|
7213
7333
|
distance = rectAttribute[key].distance
|
|
7214
7334
|
} = borderStyle,
|
|
7215
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7335
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7216
7336
|
nextX = x + sign * d,
|
|
7217
7337
|
nextY = y + sign * d,
|
|
7218
7338
|
dw = 2 * d;
|
|
@@ -7369,14 +7489,15 @@ class DefaultSymbolRenderContribution {
|
|
|
7369
7489
|
x: originX = symbolAttribute.x,
|
|
7370
7490
|
y: originY = symbolAttribute.y,
|
|
7371
7491
|
scaleX = symbolAttribute.scaleX,
|
|
7372
|
-
scaleY = symbolAttribute.scaleY
|
|
7492
|
+
scaleY = symbolAttribute.scaleY,
|
|
7493
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
7373
7494
|
} = symbol.attribute,
|
|
7374
7495
|
renderBorder = (borderStyle, key) => {
|
|
7375
7496
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7376
7497
|
{
|
|
7377
7498
|
distance = symbolAttribute[key].distance
|
|
7378
7499
|
} = borderStyle,
|
|
7379
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7500
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7380
7501
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7381
7502
|
if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]);else if (doStroke) {
|
|
7382
7503
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -7497,7 +7618,8 @@ let DefaultCanvasArcRender = class extends BaseRender {
|
|
|
7497
7618
|
fill = arcAttribute.fill,
|
|
7498
7619
|
stroke = arcAttribute.stroke,
|
|
7499
7620
|
x: originX = arcAttribute.x,
|
|
7500
|
-
y: originY = arcAttribute.y
|
|
7621
|
+
y: originY = arcAttribute.y,
|
|
7622
|
+
fillStrokeOrder = arcAttribute.fillStrokeOrder
|
|
7501
7623
|
} = arc.attribute,
|
|
7502
7624
|
data = this.valid(arc, arcAttribute, fillCb, strokeCb);
|
|
7503
7625
|
if (!data) return;
|
|
@@ -7533,7 +7655,17 @@ let DefaultCanvasArcRender = class extends BaseRender {
|
|
|
7533
7655
|
isFullStroke: isFullStroke,
|
|
7534
7656
|
stroke: arrayStroke
|
|
7535
7657
|
} = parseStroke(stroke);
|
|
7536
|
-
if (
|
|
7658
|
+
if (doFill || isFullStroke) {
|
|
7659
|
+
context.beginPath(), drawArcPath(arc, context, x, y, outerRadius, innerRadius), beforeRenderContribitionsRuned = !0, context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute), this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
|
|
7660
|
+
const _runFill = () => {
|
|
7661
|
+
doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill()));
|
|
7662
|
+
},
|
|
7663
|
+
_runStroke = () => {
|
|
7664
|
+
doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.stroke()));
|
|
7665
|
+
};
|
|
7666
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
|
|
7667
|
+
}
|
|
7668
|
+
if (!isFullStroke && doStroke) {
|
|
7537
7669
|
context.beginPath();
|
|
7538
7670
|
drawArcPath(arc, context, x, y, outerRadius, innerRadius, arrayStroke);
|
|
7539
7671
|
beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke());
|
|
@@ -7551,14 +7683,20 @@ let DefaultCanvasArcRender = class extends BaseRender {
|
|
|
7551
7683
|
fill = arcAttribute.fill
|
|
7552
7684
|
} = arc.attribute,
|
|
7553
7685
|
startAngle = endAngle;
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7686
|
+
this.drawArcTailCapPath(arc, context, x, y, outerRadius, innerRadius, startAngle, startAngle + capAngle), beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
|
|
7687
|
+
const _runFill = () => {
|
|
7688
|
+
if (doFill) {
|
|
7689
|
+
const color = fill;
|
|
7690
|
+
if ("conical" === color.gradient) {
|
|
7691
|
+
const lastColor = getConicGradientAt(0, 0, endAngle, color);
|
|
7692
|
+
fillCb || fillVisible && (context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute), context.fillStyle = lastColor, context.fill());
|
|
7693
|
+
}
|
|
7694
|
+
}
|
|
7695
|
+
},
|
|
7696
|
+
_runStroke = () => {
|
|
7697
|
+
doStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
|
|
7698
|
+
};
|
|
7699
|
+
_runFill(), _runStroke();
|
|
7562
7700
|
}
|
|
7563
7701
|
}
|
|
7564
7702
|
this.afterRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), tempChangeConicalColor && (fill.startAngle += conicalOffset, fill.endAngle += conicalOffset);
|
|
@@ -7596,7 +7734,8 @@ let DefaultCanvasCircleRender = class extends BaseRender {
|
|
|
7596
7734
|
startAngle = circleAttribute.startAngle,
|
|
7597
7735
|
endAngle = circleAttribute.endAngle,
|
|
7598
7736
|
x: originX = circleAttribute.x,
|
|
7599
|
-
y: originY = circleAttribute.y
|
|
7737
|
+
y: originY = circleAttribute.y,
|
|
7738
|
+
fillStrokeOrder = circleAttribute.fillStrokeOrder
|
|
7600
7739
|
} = circle.attribute,
|
|
7601
7740
|
data = this.valid(circle, circleAttribute, fillCb, strokeCb);
|
|
7602
7741
|
if (!data) return;
|
|
@@ -7606,7 +7745,14 @@ let DefaultCanvasCircleRender = class extends BaseRender {
|
|
|
7606
7745
|
doFill: doFill,
|
|
7607
7746
|
doStroke: doStroke
|
|
7608
7747
|
} = data;
|
|
7609
|
-
context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb)
|
|
7748
|
+
context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
|
|
7749
|
+
const _runFill = () => {
|
|
7750
|
+
doFill && (fillCb ? fillCb(context, circle.attribute, circleAttribute) : fVisible && (context.setCommonStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.fill()));
|
|
7751
|
+
},
|
|
7752
|
+
_runStroke = () => {
|
|
7753
|
+
doStroke && (strokeCb ? strokeCb(context, circle.attribute, circleAttribute) : sVisible && (context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.stroke()));
|
|
7754
|
+
};
|
|
7755
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
|
|
7610
7756
|
}
|
|
7611
7757
|
draw(circle, renderService, drawContext, params) {
|
|
7612
7758
|
const circleAttribute = getTheme(circle, null == params ? void 0 : params.theme).circle;
|
|
@@ -8047,7 +8193,7 @@ let DefaultCanvasAreaRender = class extends BaseRender {
|
|
|
8047
8193
|
super(), this.areaRenderContribitions = areaRenderContribitions, this.numberType = AREA_NUMBER_TYPE, this.builtinContributions = [defaultAreaTextureRenderContribution, defaultAreaBackgroundRenderContribution], this.init(areaRenderContribitions);
|
|
8048
8194
|
}
|
|
8049
8195
|
drawLinearAreaHighPerformance(area, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, areaAttribute, drawContext, params, fillCb, strokeCb) {
|
|
8050
|
-
var _a, _b, _c
|
|
8196
|
+
var _a, _b, _c;
|
|
8051
8197
|
const {
|
|
8052
8198
|
points: points
|
|
8053
8199
|
} = area.attribute;
|
|
@@ -8071,28 +8217,31 @@ let DefaultCanvasAreaRender = class extends BaseRender {
|
|
|
8071
8217
|
x: originX = 0,
|
|
8072
8218
|
x: originY = 0
|
|
8073
8219
|
} = area.attribute;
|
|
8074
|
-
|
|
8220
|
+
!1 !== fill && (fillCb ? fillCb(context, area.attribute, areaAttribute) : fillOpacity && (context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, areaAttribute, drawContext, fillCb, null, {
|
|
8075
8221
|
attribute: area.attribute
|
|
8076
|
-
}),
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8222
|
+
}), (() => {
|
|
8223
|
+
var _a, _b;
|
|
8224
|
+
if (stroke) {
|
|
8225
|
+
const {
|
|
8226
|
+
stroke = areaAttribute && areaAttribute.stroke
|
|
8227
|
+
} = area.attribute;
|
|
8228
|
+
if (isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1]) if (context.beginPath(), stroke[0]) {
|
|
8229
|
+
context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
|
|
8230
|
+
for (let i = 1; i < points.length; i++) {
|
|
8231
|
+
const p = points[i];
|
|
8232
|
+
context.lineTo(p.x + offsetX, p.y + offsetY, z);
|
|
8233
|
+
}
|
|
8234
|
+
} else if (stroke[2]) {
|
|
8235
|
+
const endP = points[points.length - 1];
|
|
8236
|
+
context.moveTo(endP.x + offsetX, endP.y + offsetY, z);
|
|
8237
|
+
for (let i = points.length - 2; i >= 0; i--) {
|
|
8238
|
+
const p = points[i];
|
|
8239
|
+
context.lineTo((null !== (_a = p.x1) && void 0 !== _a ? _a : p.x) + offsetX, (null !== (_b = p.y1) && void 0 !== _b ? _b : p.y) + offsetY, z);
|
|
8240
|
+
}
|
|
8092
8241
|
}
|
|
8242
|
+
strokeCb ? strokeCb(context, area.attribute, areaAttribute) : (context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.stroke());
|
|
8093
8243
|
}
|
|
8094
|
-
|
|
8095
|
-
}
|
|
8244
|
+
})();
|
|
8096
8245
|
}
|
|
8097
8246
|
drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
8098
8247
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -8257,23 +8406,24 @@ let DefaultCanvasAreaRender = class extends BaseRender {
|
|
|
8257
8406
|
x: originX = 0,
|
|
8258
8407
|
x: originY = 0
|
|
8259
8408
|
} = attribute;
|
|
8260
|
-
|
|
8409
|
+
return !1 !== fill && (fillCb ? fillCb(context, attribute, defaultAttribute) : fillOpacity && (context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, defaultAttribute, drawContext, fillCb, null, {
|
|
8261
8410
|
attribute: attribute
|
|
8262
|
-
}),
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8411
|
+
}), (() => {
|
|
8412
|
+
if (!1 !== stroke) if (strokeCb) strokeCb(context, attribute, defaultAttribute);else {
|
|
8413
|
+
const {
|
|
8414
|
+
stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
|
|
8415
|
+
} = attribute;
|
|
8416
|
+
isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? "x" : "y", {
|
|
8417
|
+
offsetX: offsetX,
|
|
8418
|
+
offsetY: offsetY,
|
|
8419
|
+
offsetZ: offsetZ,
|
|
8420
|
+
drawConnect: connect,
|
|
8421
|
+
mode: connectedType,
|
|
8422
|
+
zeroX: connectedX,
|
|
8423
|
+
zeroY: connectedY
|
|
8424
|
+
})), context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.stroke();
|
|
8425
|
+
}
|
|
8426
|
+
})(), !1;
|
|
8277
8427
|
}
|
|
8278
8428
|
};
|
|
8279
8429
|
DefaultCanvasAreaRender = __decorate$D([injectable(), __param$t(0, inject(ContributionProvider)), __param$t(0, named(AreaRenderContribution)), __metadata$w("design:paramtypes", [Object])], DefaultCanvasAreaRender);
|
|
@@ -8305,7 +8455,8 @@ let DefaultCanvasPathRender = class extends BaseRender {
|
|
|
8305
8455
|
const pathAttribute = null !== (_a = this.tempTheme) && void 0 !== _a ? _a : getTheme(path, null == params ? void 0 : params.theme).path,
|
|
8306
8456
|
{
|
|
8307
8457
|
x: originX = pathAttribute.x,
|
|
8308
|
-
y: originY = pathAttribute.y
|
|
8458
|
+
y: originY = pathAttribute.y,
|
|
8459
|
+
fillStrokeOrder = pathAttribute.fillStrokeOrder
|
|
8309
8460
|
} = path.attribute,
|
|
8310
8461
|
z = null !== (_b = this.z) && void 0 !== _b ? _b : 0,
|
|
8311
8462
|
data = this.valid(path, pathAttribute, fillCb, strokeCb);
|
|
@@ -8320,7 +8471,14 @@ let DefaultCanvasPathRender = class extends BaseRender {
|
|
|
8320
8471
|
const path2D = null !== (_c = path.attribute.path) && void 0 !== _c ? _c : pathAttribute.path;
|
|
8321
8472
|
renderCommandList(path2D.commandList, context, x, y, 1, 1, z);
|
|
8322
8473
|
}
|
|
8323
|
-
context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb)
|
|
8474
|
+
context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
|
|
8475
|
+
const _runStroke = () => {
|
|
8476
|
+
doStroke && (strokeCb ? strokeCb(context, path.attribute, pathAttribute) : sVisible && (context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.stroke()));
|
|
8477
|
+
},
|
|
8478
|
+
_runFill = () => {
|
|
8479
|
+
doFill && (fillCb ? fillCb(context, path.attribute, pathAttribute) : fVisible && (context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.fill()));
|
|
8480
|
+
};
|
|
8481
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
|
|
8324
8482
|
}
|
|
8325
8483
|
draw(path, renderService, drawContext, params) {
|
|
8326
8484
|
const pathAttribute = getTheme(path, null == params ? void 0 : params.theme).path;
|
|
@@ -8364,7 +8522,8 @@ let DefaultCanvasRectRender = class extends BaseRender {
|
|
|
8364
8522
|
x1: x1,
|
|
8365
8523
|
y1: y1,
|
|
8366
8524
|
x: originX = rectAttribute.x,
|
|
8367
|
-
y: originY = rectAttribute.y
|
|
8525
|
+
y: originY = rectAttribute.y,
|
|
8526
|
+
fillStrokeOrder = rectAttribute.fillStrokeOrder
|
|
8368
8527
|
} = rect.attribute;
|
|
8369
8528
|
let {
|
|
8370
8529
|
width: width,
|
|
@@ -8383,7 +8542,14 @@ let DefaultCanvasRectRender = class extends BaseRender {
|
|
|
8383
8542
|
doFill: doFill,
|
|
8384
8543
|
doStroke: doStroke
|
|
8385
8544
|
};
|
|
8386
|
-
context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke)
|
|
8545
|
+
context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
|
|
8546
|
+
const _runFill = () => {
|
|
8547
|
+
doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.fill()));
|
|
8548
|
+
},
|
|
8549
|
+
_runStroke = () => {
|
|
8550
|
+
doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.stroke()));
|
|
8551
|
+
};
|
|
8552
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
8387
8553
|
}
|
|
8388
8554
|
draw(rect, renderService, drawContext, params) {
|
|
8389
8555
|
const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect;
|
|
@@ -8419,7 +8585,8 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
|
|
|
8419
8585
|
x: originX = symbolAttribute.x,
|
|
8420
8586
|
y: originY = symbolAttribute.y,
|
|
8421
8587
|
scaleX = symbolAttribute.scaleX,
|
|
8422
|
-
scaleY = symbolAttribute.scaleY
|
|
8588
|
+
scaleY = symbolAttribute.scaleY,
|
|
8589
|
+
fillStrokeOrder = symbolAttribute.fillStrokeOrder
|
|
8423
8590
|
} = symbol.attribute,
|
|
8424
8591
|
data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);
|
|
8425
8592
|
if (!data) return;
|
|
@@ -8442,14 +8609,27 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
|
|
|
8442
8609
|
const obj = Object.assign({}, a);
|
|
8443
8610
|
obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill, obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : symbol.attribute.opacity, obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke, a = obj;
|
|
8444
8611
|
}
|
|
8445
|
-
|
|
8612
|
+
const _runFill = () => {
|
|
8613
|
+
a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute), context.fill()));
|
|
8614
|
+
},
|
|
8615
|
+
_runStroke = () => {
|
|
8616
|
+
a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
|
|
8617
|
+
};
|
|
8618
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
|
|
8446
8619
|
};
|
|
8447
8620
|
if (keepDirIn3d && context.camera && context.project) {
|
|
8448
8621
|
const p = context.project(x, y, z),
|
|
8449
8622
|
camera = context.camera;
|
|
8450
8623
|
context.camera = null, !1 === parsedPath.draw(context, isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX, p.x, p.y, void 0, callback) && context.closePath(), context.camera = camera;
|
|
8451
8624
|
} else !1 === parsedPath.draw(context, size, x, y, z, callback) && context.closePath();
|
|
8452
|
-
context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb)
|
|
8625
|
+
context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
|
|
8626
|
+
const _runFill = () => {
|
|
8627
|
+
doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute), context.fill()));
|
|
8628
|
+
},
|
|
8629
|
+
_runStroke = () => {
|
|
8630
|
+
doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
|
|
8631
|
+
};
|
|
8632
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
|
|
8453
8633
|
}
|
|
8454
8634
|
draw(symbol, renderService, drawContext, params) {
|
|
8455
8635
|
const symbolAttribute = getTheme(symbol, null == params ? void 0 : params.theme).symbol;
|
|
@@ -8593,16 +8773,8 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8593
8773
|
verticalMode = textAttribute.verticalMode,
|
|
8594
8774
|
x: originX = textAttribute.x,
|
|
8595
8775
|
y: originY = textAttribute.y
|
|
8596
|
-
} = text.attribute
|
|
8597
|
-
|
|
8598
|
-
textAlign = textAttribute.textAlign,
|
|
8599
|
-
textBaseline = textAttribute.textBaseline
|
|
8600
|
-
} = text.attribute;
|
|
8601
|
-
if (!verticalMode && "vertical" === direction) {
|
|
8602
|
-
const t = textAlign;
|
|
8603
|
-
textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
|
|
8604
|
-
}
|
|
8605
|
-
const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
|
|
8776
|
+
} = text.attribute,
|
|
8777
|
+
lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
|
|
8606
8778
|
data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
8607
8779
|
if (!data) return;
|
|
8608
8780
|
const {
|
|
@@ -8622,79 +8794,60 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8622
8794
|
const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
|
|
8623
8795
|
matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
|
|
8624
8796
|
}
|
|
8625
|
-
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z)
|
|
8797
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
|
|
8626
8798
|
};
|
|
8627
|
-
if (text.
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
width: line.width
|
|
8642
|
-
});
|
|
8643
|
-
})));
|
|
8644
|
-
} else {
|
|
8645
|
-
text.tryUpdateAABBBounds();
|
|
8646
|
-
const cache = text.cache,
|
|
8647
|
-
{
|
|
8648
|
-
verticalList: verticalList
|
|
8649
|
-
} = cache;
|
|
8650
|
-
context.textAlign = "left", context.textBaseline = "top";
|
|
8651
|
-
const totalHeight = lineHeight * verticalList.length;
|
|
8652
|
-
let totalW = 0;
|
|
8653
|
-
verticalList.forEach(verticalData => {
|
|
8654
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
8655
|
-
totalW = max(_w, totalW);
|
|
8656
|
-
});
|
|
8657
|
-
let offsetY = 0,
|
|
8658
|
-
offsetX = 0;
|
|
8659
|
-
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
8660
|
-
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
8661
|
-
dw = totalW - currentW;
|
|
8662
|
-
let currentOffsetY = offsetY;
|
|
8663
|
-
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
8664
|
-
const {
|
|
8665
|
-
text: text,
|
|
8666
|
-
width: width,
|
|
8667
|
-
direction: direction
|
|
8668
|
-
} = item;
|
|
8669
|
-
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
8670
|
-
});
|
|
8799
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
8800
|
+
const {
|
|
8801
|
+
multilineLayout: multilineLayout
|
|
8802
|
+
} = text;
|
|
8803
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
8804
|
+
const {
|
|
8805
|
+
xOffset: xOffset,
|
|
8806
|
+
yOffset: yOffset
|
|
8807
|
+
} = multilineLayout.bbox;
|
|
8808
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
8809
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
8810
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
8811
|
+
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
|
|
8812
|
+
width: line.width
|
|
8671
8813
|
});
|
|
8672
|
-
}
|
|
8673
|
-
} else if ("horizontal" === direction) {
|
|
8674
|
-
context.setTextStyle(text.attribute, textAttribute, z);
|
|
8675
|
-
const t = text.clipedText;
|
|
8676
|
-
let dy = 0;
|
|
8677
|
-
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
|
|
8814
|
+
})));
|
|
8678
8815
|
} else {
|
|
8816
|
+
let {
|
|
8817
|
+
textAlign = textAttribute.textAlign,
|
|
8818
|
+
textBaseline = textAttribute.textBaseline
|
|
8819
|
+
} = text.attribute;
|
|
8820
|
+
if (!verticalMode) {
|
|
8821
|
+
const t = textAlign;
|
|
8822
|
+
textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
|
|
8823
|
+
}
|
|
8679
8824
|
text.tryUpdateAABBBounds();
|
|
8680
|
-
const cache = text.cache
|
|
8681
|
-
|
|
8682
|
-
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
8683
|
-
const {
|
|
8825
|
+
const cache = text.cache,
|
|
8826
|
+
{
|
|
8684
8827
|
verticalList: verticalList
|
|
8685
8828
|
} = cache;
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8829
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
8830
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
8831
|
+
let totalW = 0;
|
|
8832
|
+
verticalList.forEach(verticalData => {
|
|
8833
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
8834
|
+
totalW = max(_w, totalW);
|
|
8835
|
+
});
|
|
8836
|
+
let offsetY = 0,
|
|
8837
|
+
offsetX = 0;
|
|
8838
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
8839
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
8840
|
+
dw = totalW - currentW;
|
|
8841
|
+
let currentOffsetY = offsetY;
|
|
8842
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
8690
8843
|
const {
|
|
8691
8844
|
text: text,
|
|
8692
8845
|
width: width,
|
|
8693
8846
|
direction: direction
|
|
8694
8847
|
} = item;
|
|
8695
|
-
drawText(text, offsetX,
|
|
8848
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
8696
8849
|
});
|
|
8697
|
-
}
|
|
8850
|
+
});
|
|
8698
8851
|
}
|
|
8699
8852
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
8700
8853
|
}
|
|
@@ -8706,12 +8859,10 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8706
8859
|
computed3dMatrix = !keepDirIn3d;
|
|
8707
8860
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
8708
8861
|
}
|
|
8709
|
-
drawUnderLine(underline, lineThrough, text,
|
|
8862
|
+
drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
|
|
8710
8863
|
if (lineThrough + underline <= 0) return;
|
|
8711
8864
|
const {
|
|
8712
8865
|
textAlign = textAttribute.textAlign,
|
|
8713
|
-
textBaseline = textAttribute.textBaseline,
|
|
8714
|
-
fontSize = textAttribute.fontSize,
|
|
8715
8866
|
fill = textAttribute.fill,
|
|
8716
8867
|
opacity = textAttribute.opacity,
|
|
8717
8868
|
underlineOffset = textAttribute.underlineOffset,
|
|
@@ -8721,23 +8872,21 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8721
8872
|
isMulti = !isNil(multiOption),
|
|
8722
8873
|
w = isMulti ? multiOption.width : text.clipedWidth,
|
|
8723
8874
|
offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
|
|
8724
|
-
offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
|
|
8725
8875
|
attribute = {
|
|
8726
8876
|
lineWidth: 0,
|
|
8727
8877
|
stroke: fill,
|
|
8728
8878
|
opacity: opacity,
|
|
8729
8879
|
strokeOpacity: fillOpacity
|
|
8730
8880
|
};
|
|
8731
|
-
let deltaY = isMulti ? -3 : 0;
|
|
8732
8881
|
if (underline) {
|
|
8733
|
-
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute,
|
|
8734
|
-
const dy =
|
|
8735
|
-
context.moveTo(
|
|
8882
|
+
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
|
|
8883
|
+
const dy = anchorY + offsetUnderLineY + underlineOffset;
|
|
8884
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
8736
8885
|
}
|
|
8737
|
-
if (
|
|
8738
|
-
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute,
|
|
8739
|
-
const dy =
|
|
8740
|
-
context.moveTo(
|
|
8886
|
+
if (lineThrough) {
|
|
8887
|
+
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
|
|
8888
|
+
const dy = anchorY + offsetThroughLineY;
|
|
8889
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
8741
8890
|
}
|
|
8742
8891
|
}
|
|
8743
8892
|
};
|
|
@@ -8823,7 +8972,8 @@ let DefaultCanvasPolygonRender = class extends BaseRender {
|
|
|
8823
8972
|
cornerRadius = polygonAttribute.cornerRadius,
|
|
8824
8973
|
x: originX = polygonAttribute.x,
|
|
8825
8974
|
y: originY = polygonAttribute.y,
|
|
8826
|
-
closePath = polygonAttribute.closePath
|
|
8975
|
+
closePath = polygonAttribute.closePath,
|
|
8976
|
+
fillStrokeOrder = polygonAttribute.fillStrokeOrder
|
|
8827
8977
|
} = polygon.attribute,
|
|
8828
8978
|
data = this.valid(polygon, polygonAttribute, fillCb, strokeCb);
|
|
8829
8979
|
if (!data) return;
|
|
@@ -8833,7 +8983,14 @@ let DefaultCanvasPolygonRender = class extends BaseRender {
|
|
|
8833
8983
|
doFill: doFill,
|
|
8834
8984
|
doStroke: doStroke
|
|
8835
8985
|
} = data;
|
|
8836
|
-
context.beginPath(), cornerRadius <= 0 || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb)
|
|
8986
|
+
context.beginPath(), cornerRadius <= 0 || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
|
|
8987
|
+
const _runFill = () => {
|
|
8988
|
+
doFill && (fillCb ? fillCb(context, polygon.attribute, polygonAttribute) : fVisible && (context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.fill()));
|
|
8989
|
+
},
|
|
8990
|
+
_runStroke = () => {
|
|
8991
|
+
doStroke && (strokeCb ? strokeCb(context, polygon.attribute, polygonAttribute) : sVisible && (context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.stroke()));
|
|
8992
|
+
};
|
|
8993
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
|
|
8837
8994
|
}
|
|
8838
8995
|
draw(polygon, renderService, drawContext, params) {
|
|
8839
8996
|
const polygonAttribute = getTheme(polygon, null == params ? void 0 : params.theme).polygon;
|
|
@@ -8876,7 +9033,10 @@ let DefaultCanvasGroupRender = class {
|
|
|
8876
9033
|
cornerRadius = groupAttribute.cornerRadius,
|
|
8877
9034
|
path = groupAttribute.path,
|
|
8878
9035
|
lineWidth = groupAttribute.lineWidth,
|
|
8879
|
-
visible = groupAttribute.visible
|
|
9036
|
+
visible = groupAttribute.visible,
|
|
9037
|
+
fillStrokeOrder = groupAttribute.fillStrokeOrder,
|
|
9038
|
+
x: originX = groupAttribute.x,
|
|
9039
|
+
y: originY = groupAttribute.y
|
|
8880
9040
|
} = group.attribute,
|
|
8881
9041
|
fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
|
|
8882
9042
|
sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
|
|
@@ -8902,7 +9062,14 @@ let DefaultCanvasGroupRender = class {
|
|
|
8902
9062
|
};
|
|
8903
9063
|
this._groupRenderContribitions.forEach(c => {
|
|
8904
9064
|
c.time === BaseRenderContributionTime.beforeFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
|
|
8905
|
-
}), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute)
|
|
9065
|
+
}), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);
|
|
9066
|
+
const _runFill = () => {
|
|
9067
|
+
doFillOrStroke.doFill && (fillCb ? fillCb(context, group.attribute, groupAttribute) : fVisible && (context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.fill()));
|
|
9068
|
+
},
|
|
9069
|
+
_runStroke = () => {
|
|
9070
|
+
doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, group.attribute, groupAttribute) : sVisible && (context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.stroke()));
|
|
9071
|
+
};
|
|
9072
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this._groupRenderContribitions.forEach(c => {
|
|
8906
9073
|
c.time === BaseRenderContributionTime.afterFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb);
|
|
8907
9074
|
});
|
|
8908
9075
|
}
|
|
@@ -8968,6 +9135,7 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
8968
9135
|
x: originX = imageAttribute.x,
|
|
8969
9136
|
y: originY = imageAttribute.y,
|
|
8970
9137
|
cornerRadius = imageAttribute.cornerRadius,
|
|
9138
|
+
fillStrokeOrder = imageAttribute.fillStrokeOrder,
|
|
8971
9139
|
image: url
|
|
8972
9140
|
} = image.attribute,
|
|
8973
9141
|
data = this.valid(image, imageAttribute, fillCb);
|
|
@@ -8978,20 +9146,26 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
8978
9146
|
doFill: doFill,
|
|
8979
9147
|
doStroke: doStroke
|
|
8980
9148
|
} = data;
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
9149
|
+
context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
|
|
9150
|
+
const _runFill = () => {
|
|
9151
|
+
if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
|
|
9152
|
+
if (!url || !image.resources) return;
|
|
9153
|
+
const res = image.resources.get(url);
|
|
9154
|
+
if ("success" !== res.state) return;
|
|
9155
|
+
let needRestore = !1;
|
|
9156
|
+
0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) || (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(), needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
|
|
9157
|
+
let repeat = 0;
|
|
9158
|
+
if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
|
|
9159
|
+
const pattern = context.createPattern(res.data, repeatStr[repeat]);
|
|
9160
|
+
context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
|
|
9161
|
+
} else context.drawImage(res.data, x, y, width, height);
|
|
9162
|
+
needRestore && context.restore();
|
|
9163
|
+
}
|
|
9164
|
+
},
|
|
9165
|
+
_runStroke = () => {
|
|
9166
|
+
doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
|
|
9167
|
+
};
|
|
9168
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
|
|
8995
9169
|
}
|
|
8996
9170
|
draw(image, renderService, drawContext) {
|
|
8997
9171
|
const {
|
|
@@ -9377,58 +9551,63 @@ class CanvasTextLayout {
|
|
|
9377
9551
|
constructor(fontFamily, options, textMeasure) {
|
|
9378
9552
|
this.fontFamily = fontFamily, this.textOptions = options, this.textMeasure = textMeasure;
|
|
9379
9553
|
}
|
|
9380
|
-
LayoutBBox(bbox, textAlign, textBaseline) {
|
|
9554
|
+
LayoutBBox(bbox, textAlign, textBaseline, linesLayout) {
|
|
9381
9555
|
if ("left" === textAlign || "start" === textAlign) bbox.xOffset = 0;else if ("center" === textAlign) bbox.xOffset = bbox.width / -2;else {
|
|
9382
9556
|
if ("right" !== textAlign && "end" !== textAlign) throw new Error("非法的textAlign");
|
|
9383
9557
|
bbox.xOffset = -bbox.width;
|
|
9384
9558
|
}
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
} = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
9395
|
-
linesLayout.push({
|
|
9396
|
-
str: clipText,
|
|
9397
|
-
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
9398
|
-
}), str = str.substring(clipText.length);
|
|
9399
|
-
}
|
|
9400
|
-
"left" === textAlign || "start" === textAlign || ("center" === textAlign ? bboxOffset[0] = bboxWH[0] / -2 : "right" !== textAlign && "end" !== textAlign || (bboxOffset[0] = -bboxWH[0])), "top" === textBaseline || ("middle" === textBaseline ? bboxOffset[1] = bboxWH[1] / -2 : "bottom" === textBaseline && (bboxOffset[1] = -bboxWH[1]));
|
|
9401
|
-
const bbox = {
|
|
9402
|
-
xOffset: bboxOffset[0],
|
|
9403
|
-
yOffset: bboxOffset[1],
|
|
9404
|
-
width: bboxWH[0],
|
|
9405
|
-
height: bboxWH[1]
|
|
9406
|
-
};
|
|
9407
|
-
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9559
|
+
if ("top" === textBaseline) bbox.yOffset = 0;else if ("middle" === textBaseline) bbox.yOffset = bbox.height / -2;else if ("alphabetic" === textBaseline) {
|
|
9560
|
+
let percent = .79;
|
|
9561
|
+
if (1 === linesLayout.length) {
|
|
9562
|
+
const lineInfo = linesLayout[0];
|
|
9563
|
+
percent = lineInfo.ascent / (lineInfo.ascent + lineInfo.descent);
|
|
9564
|
+
}
|
|
9565
|
+
bbox.yOffset = bbox.height * -percent;
|
|
9566
|
+
} else bbox.yOffset = -bbox.height;
|
|
9567
|
+
return bbox;
|
|
9408
9568
|
}
|
|
9409
9569
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
9410
9570
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
9411
9571
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
9412
|
-
let
|
|
9413
|
-
|
|
9572
|
+
let params = arguments.length > 6 ? arguments[6] : undefined;
|
|
9573
|
+
const {
|
|
9574
|
+
lineWidth: lineWidth,
|
|
9575
|
+
suffixPosition = "end",
|
|
9576
|
+
measureMode = MeasureModeEnum.actualBounding,
|
|
9577
|
+
keepCenterInLine = !1
|
|
9578
|
+
} = null != params ? params : {};
|
|
9414
9579
|
lines = lines.map(l => l.toString());
|
|
9415
9580
|
const linesLayout = [],
|
|
9416
9581
|
bboxWH = [0, 0];
|
|
9417
9582
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
9418
9583
|
let width;
|
|
9419
|
-
for (let i = 0, len = lines.length; i < len; i++)
|
|
9420
|
-
|
|
9421
|
-
width
|
|
9422
|
-
|
|
9584
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9585
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
9586
|
+
width = Math.min(metrics.width, lineWidth), linesLayout.push({
|
|
9587
|
+
str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
9588
|
+
width: width,
|
|
9589
|
+
ascent: metrics.ascent,
|
|
9590
|
+
descent: metrics.descent,
|
|
9591
|
+
keepCenterInLine: keepCenterInLine
|
|
9592
|
+
});
|
|
9593
|
+
}
|
|
9423
9594
|
bboxWH[0] = lineWidth;
|
|
9424
9595
|
} else {
|
|
9425
|
-
let width,
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
|
|
9596
|
+
let width,
|
|
9597
|
+
text,
|
|
9598
|
+
_lineWidth = 0;
|
|
9599
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9600
|
+
text = lines[i];
|
|
9601
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
9602
|
+
width = metrics.width, _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
|
|
9603
|
+
str: text,
|
|
9604
|
+
width: width,
|
|
9605
|
+
ascent: metrics.ascent,
|
|
9606
|
+
descent: metrics.descent,
|
|
9607
|
+
keepCenterInLine: keepCenterInLine
|
|
9608
|
+
});
|
|
9609
|
+
}
|
|
9610
|
+
bboxWH[0] = _lineWidth;
|
|
9432
9611
|
}
|
|
9433
9612
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
9434
9613
|
const bbox = {
|
|
@@ -9437,7 +9616,7 @@ class CanvasTextLayout {
|
|
|
9437
9616
|
width: bboxWH[0],
|
|
9438
9617
|
height: bboxWH[1]
|
|
9439
9618
|
};
|
|
9440
|
-
return this.LayoutBBox(bbox, textAlign, textBaseline), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9619
|
+
return this.LayoutBBox(bbox, textAlign, textBaseline, linesLayout), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9441
9620
|
}
|
|
9442
9621
|
layoutWithBBox(bbox, lines, textAlign, textBaseline, lineHeight) {
|
|
9443
9622
|
const origin = [0, 0],
|
|
@@ -9456,11 +9635,16 @@ class CanvasTextLayout {
|
|
|
9456
9635
|
};
|
|
9457
9636
|
}
|
|
9458
9637
|
lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
|
|
9459
|
-
|
|
9638
|
+
if ("left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width), line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1], !line.keepCenterInLine) {
|
|
9639
|
+
const buf = 0,
|
|
9640
|
+
actualHeightWithBuf = line.ascent + line.descent + buf;
|
|
9641
|
+
actualHeightWithBuf < lineHeight - buf && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2));
|
|
9642
|
+
}
|
|
9643
|
+
return origin[1] += lineHeight, line;
|
|
9460
9644
|
}
|
|
9461
9645
|
}
|
|
9462
9646
|
|
|
9463
|
-
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
9647
|
+
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "maxWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
9464
9648
|
class Text extends Graphic {
|
|
9465
9649
|
get font() {
|
|
9466
9650
|
const textTheme = this.getGraphicTheme();
|
|
@@ -9469,26 +9653,22 @@ class Text extends Graphic {
|
|
|
9469
9653
|
get clipedText() {
|
|
9470
9654
|
var _a;
|
|
9471
9655
|
const attribute = this.attribute,
|
|
9472
|
-
textTheme = this.getGraphicTheme()
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
maxLineWidth = textTheme.maxLineWidth
|
|
9476
|
-
} = attribute;
|
|
9477
|
-
return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
9656
|
+
textTheme = this.getGraphicTheme(),
|
|
9657
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
9658
|
+
return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
9478
9659
|
}
|
|
9479
9660
|
get clipedWidth() {
|
|
9480
|
-
|
|
9661
|
+
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
9481
9662
|
}
|
|
9482
9663
|
get cliped() {
|
|
9483
9664
|
var _a, _b;
|
|
9484
9665
|
const textTheme = this.getGraphicTheme(),
|
|
9485
9666
|
attribute = this.attribute,
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
9667
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
9668
|
+
if (!Number.isFinite(maxWidth)) return !1;
|
|
9669
|
+
const {
|
|
9670
|
+
text: text
|
|
9671
|
+
} = this.attribute;
|
|
9492
9672
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
9493
9673
|
let mergedText = "";
|
|
9494
9674
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -9499,10 +9679,7 @@ class Text extends Graphic {
|
|
|
9499
9679
|
return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
|
|
9500
9680
|
}
|
|
9501
9681
|
get multilineLayout() {
|
|
9502
|
-
|
|
9503
|
-
}
|
|
9504
|
-
isSimplify() {
|
|
9505
|
-
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
9682
|
+
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
9506
9683
|
}
|
|
9507
9684
|
get isMultiLine() {
|
|
9508
9685
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -9575,8 +9752,74 @@ class Text extends Graphic {
|
|
|
9575
9752
|
}
|
|
9576
9753
|
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
9577
9754
|
}
|
|
9755
|
+
updateSingallineAABBBounds(text) {
|
|
9756
|
+
this.updateMultilineAABBBounds([text]);
|
|
9757
|
+
const layoutData = this.cache.layoutData;
|
|
9758
|
+
if (layoutData) {
|
|
9759
|
+
const line = layoutData.lines[0];
|
|
9760
|
+
this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
|
|
9761
|
+
}
|
|
9762
|
+
return this._AABBBounds;
|
|
9763
|
+
}
|
|
9764
|
+
updateMultilineAABBBounds(text) {
|
|
9765
|
+
const textTheme = this.getGraphicTheme(),
|
|
9766
|
+
{
|
|
9767
|
+
direction = textTheme.direction,
|
|
9768
|
+
underlineOffset = textTheme.underlineOffset
|
|
9769
|
+
} = this.attribute,
|
|
9770
|
+
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
9771
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9772
|
+
}
|
|
9773
|
+
guessLineHeightBuf(fontSize) {
|
|
9774
|
+
return fontSize ? .1 * fontSize : 0;
|
|
9775
|
+
}
|
|
9776
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
9777
|
+
var _a;
|
|
9778
|
+
const textTheme = this.getGraphicTheme(),
|
|
9779
|
+
attribute = this.attribute,
|
|
9780
|
+
{
|
|
9781
|
+
fontFamily = textTheme.fontFamily,
|
|
9782
|
+
textAlign = textTheme.textAlign,
|
|
9783
|
+
textBaseline = textTheme.textBaseline,
|
|
9784
|
+
fontSize = textTheme.fontSize,
|
|
9785
|
+
fontWeight = textTheme.fontWeight,
|
|
9786
|
+
ellipsis = textTheme.ellipsis,
|
|
9787
|
+
maxLineWidth: maxLineWidth,
|
|
9788
|
+
stroke = textTheme.stroke,
|
|
9789
|
+
wrap = textTheme.wrap,
|
|
9790
|
+
measureMode = textTheme.measureMode,
|
|
9791
|
+
lineWidth = textTheme.lineWidth,
|
|
9792
|
+
whiteSpace = textTheme.whiteSpace,
|
|
9793
|
+
suffixPosition = textTheme.suffixPosition,
|
|
9794
|
+
ignoreBuf = textTheme.ignoreBuf,
|
|
9795
|
+
keepCenterInLine = textTheme.keepCenterInLine
|
|
9796
|
+
} = attribute,
|
|
9797
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
9798
|
+
lineHeight = this.getLineHeight(attribute, textTheme) + buf;
|
|
9799
|
+
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
9800
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
9801
|
+
const bbox = this.cache.layoutData.bbox;
|
|
9802
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9803
|
+
}
|
|
9804
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
9805
|
+
layoutData = new CanvasTextLayout(fontFamily, {
|
|
9806
|
+
fontSize: fontSize,
|
|
9807
|
+
fontWeight: fontWeight,
|
|
9808
|
+
fontFamily: fontFamily,
|
|
9809
|
+
lineHeight: lineHeight
|
|
9810
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
|
|
9811
|
+
lineWidth: maxLineWidth,
|
|
9812
|
+
suffixPosition: suffixPosition,
|
|
9813
|
+
measureMode: measureMode,
|
|
9814
|
+
keepCenterInLine: keepCenterInLine
|
|
9815
|
+
}),
|
|
9816
|
+
{
|
|
9817
|
+
bbox: bbox
|
|
9818
|
+
} = layoutData;
|
|
9819
|
+
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9820
|
+
}
|
|
9578
9821
|
updateWrapAABBBounds(text) {
|
|
9579
|
-
var _a, _b, _c
|
|
9822
|
+
var _a, _b, _c;
|
|
9580
9823
|
const textTheme = this.getGraphicTheme(),
|
|
9581
9824
|
{
|
|
9582
9825
|
fontFamily = textTheme.fontFamily,
|
|
@@ -9590,22 +9833,26 @@ class Text extends Graphic {
|
|
|
9590
9833
|
wordBreak = textTheme.wordBreak,
|
|
9591
9834
|
fontWeight = textTheme.fontWeight,
|
|
9592
9835
|
ignoreBuf = textTheme.ignoreBuf,
|
|
9836
|
+
measureMode = textTheme.measureMode,
|
|
9593
9837
|
suffixPosition = textTheme.suffixPosition,
|
|
9594
9838
|
heightLimit = 0,
|
|
9595
|
-
lineClamp: lineClamp
|
|
9839
|
+
lineClamp: lineClamp,
|
|
9840
|
+
keepCenterInLine = textTheme.keepCenterInLine
|
|
9596
9841
|
} = this.attribute,
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
if (!this.shouldUpdateShape() && (null === (
|
|
9842
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
9843
|
+
lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
|
|
9844
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
9600
9845
|
const bbox = this.cache.layoutData.bbox;
|
|
9601
9846
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9602
9847
|
}
|
|
9603
9848
|
const textMeasure = application.graphicUtil.textMeasure,
|
|
9604
|
-
|
|
9849
|
+
textOptions = {
|
|
9605
9850
|
fontSize: fontSize,
|
|
9606
9851
|
fontWeight: fontWeight,
|
|
9607
|
-
fontFamily: fontFamily
|
|
9608
|
-
|
|
9852
|
+
fontFamily: fontFamily,
|
|
9853
|
+
lineHeight: lineHeight
|
|
9854
|
+
},
|
|
9855
|
+
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
9609
9856
|
lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
9610
9857
|
linesLayout = [],
|
|
9611
9858
|
bboxWH = [0, 0];
|
|
@@ -9615,29 +9862,37 @@ class Text extends Graphic {
|
|
|
9615
9862
|
const str = lines[i];
|
|
9616
9863
|
let needCut = !0;
|
|
9617
9864
|
if (i === lineCountLimit - 1) {
|
|
9618
|
-
const clip =
|
|
9865
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
|
|
9866
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
9619
9867
|
linesLayout.push({
|
|
9620
9868
|
str: clip.str,
|
|
9621
|
-
width: clip.width
|
|
9869
|
+
width: clip.width,
|
|
9870
|
+
ascent: matrics.ascent,
|
|
9871
|
+
descent: matrics.descent,
|
|
9872
|
+
keepCenterInLine: keepCenterInLine
|
|
9622
9873
|
});
|
|
9623
9874
|
break;
|
|
9624
9875
|
}
|
|
9625
|
-
const clip =
|
|
9876
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
9626
9877
|
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
9627
9878
|
if (ellipsis) {
|
|
9628
|
-
const clipEllipsis =
|
|
9629
|
-
clip.str = null !== (
|
|
9879
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
9880
|
+
clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
|
|
9630
9881
|
} else clip.str = "", clip.width = 0;
|
|
9631
9882
|
needCut = !1;
|
|
9632
9883
|
}
|
|
9884
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
9633
9885
|
linesLayout.push({
|
|
9634
9886
|
str: clip.str,
|
|
9635
|
-
width: clip.width
|
|
9887
|
+
width: clip.width,
|
|
9888
|
+
ascent: matrics.ascent,
|
|
9889
|
+
descent: matrics.descent,
|
|
9890
|
+
keepCenterInLine: keepCenterInLine
|
|
9636
9891
|
});
|
|
9637
9892
|
let cutLength = clip.str.length;
|
|
9638
9893
|
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
9639
|
-
|
|
9640
|
-
|
|
9894
|
+
const newStr = str.substring(cutLength);
|
|
9895
|
+
lines.splice(i + 1, 0, newStr);
|
|
9641
9896
|
}
|
|
9642
9897
|
}
|
|
9643
9898
|
let maxWidth = 0;
|
|
@@ -9650,235 +9905,46 @@ class Text extends Graphic {
|
|
|
9650
9905
|
lineWidth = 0;
|
|
9651
9906
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9652
9907
|
if (i === lineCountLimit - 1) {
|
|
9653
|
-
const clip =
|
|
9908
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
|
|
9909
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
9654
9910
|
linesLayout.push({
|
|
9655
9911
|
str: clip.str,
|
|
9656
|
-
width: clip.width
|
|
9912
|
+
width: clip.width,
|
|
9913
|
+
ascent: matrics.ascent,
|
|
9914
|
+
descent: matrics.descent,
|
|
9915
|
+
keepCenterInLine: keepCenterInLine
|
|
9657
9916
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
9658
9917
|
break;
|
|
9659
9918
|
}
|
|
9660
|
-
text = lines[i], width =
|
|
9919
|
+
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
|
|
9920
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
|
|
9921
|
+
linesLayout.push({
|
|
9661
9922
|
str: text,
|
|
9662
|
-
width: width
|
|
9923
|
+
width: width,
|
|
9924
|
+
ascent: matrics.ascent,
|
|
9925
|
+
descent: matrics.descent,
|
|
9926
|
+
keepCenterInLine: keepCenterInLine
|
|
9663
9927
|
});
|
|
9664
9928
|
}
|
|
9665
9929
|
bboxWH[0] = lineWidth;
|
|
9666
9930
|
}
|
|
9667
|
-
bboxWH[1] = linesLayout.length *
|
|
9931
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
9668
9932
|
const bbox = {
|
|
9669
9933
|
xOffset: 0,
|
|
9670
9934
|
yOffset: 0,
|
|
9671
9935
|
width: bboxWH[0],
|
|
9672
9936
|
height: bboxWH[1]
|
|
9673
9937
|
};
|
|
9674
|
-
layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
|
|
9938
|
+
layoutObj.LayoutBBox(bbox, textAlign, textBaseline, linesLayout);
|
|
9675
9939
|
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9676
9940
|
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9677
9941
|
}
|
|
9678
|
-
updateSingallineAABBBounds(text) {
|
|
9679
|
-
const textTheme = this.getGraphicTheme(),
|
|
9680
|
-
{
|
|
9681
|
-
direction = textTheme.direction,
|
|
9682
|
-
underlineOffset = textTheme.underlineOffset
|
|
9683
|
-
} = this.attribute,
|
|
9684
|
-
b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
|
|
9685
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9686
|
-
}
|
|
9687
|
-
updateMultilineAABBBounds(text) {
|
|
9688
|
-
const textTheme = this.getGraphicTheme(),
|
|
9689
|
-
{
|
|
9690
|
-
direction = textTheme.direction,
|
|
9691
|
-
underlineOffset = textTheme.underlineOffset
|
|
9692
|
-
} = this.attribute,
|
|
9693
|
-
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
9694
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9695
|
-
}
|
|
9696
|
-
updateHorizontalSinglelineAABBBounds(text) {
|
|
9697
|
-
var _a, _b;
|
|
9698
|
-
const textTheme = this.getGraphicTheme(),
|
|
9699
|
-
{
|
|
9700
|
-
wrap = textTheme.wrap
|
|
9701
|
-
} = this.attribute;
|
|
9702
|
-
if (wrap) return this.updateWrapAABBBounds([text]);
|
|
9703
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
9704
|
-
let width, str;
|
|
9705
|
-
const attribute = this.attribute,
|
|
9706
|
-
{
|
|
9707
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
9708
|
-
ellipsis = textTheme.ellipsis,
|
|
9709
|
-
textAlign = textTheme.textAlign,
|
|
9710
|
-
textBaseline = textTheme.textBaseline,
|
|
9711
|
-
fontFamily = textTheme.fontFamily,
|
|
9712
|
-
fontSize = textTheme.fontSize,
|
|
9713
|
-
fontWeight = textTheme.fontWeight,
|
|
9714
|
-
stroke = textTheme.stroke,
|
|
9715
|
-
lineWidth = textTheme.lineWidth,
|
|
9716
|
-
ignoreBuf = textTheme.ignoreBuf,
|
|
9717
|
-
whiteSpace = textTheme.whiteSpace,
|
|
9718
|
-
suffixPosition = textTheme.suffixPosition
|
|
9719
|
-
} = attribute;
|
|
9720
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
9721
|
-
const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
|
|
9722
|
-
textFontSize = attribute.fontSize || textTheme.fontSize,
|
|
9723
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
|
|
9724
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
9725
|
-
width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
|
|
9726
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
9727
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
9728
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9729
|
-
}
|
|
9730
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
9731
|
-
if (ellipsis) {
|
|
9732
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
9733
|
-
data = textMeasure.clipTextWithSuffix(text.toString(), {
|
|
9734
|
-
fontSize: fontSize,
|
|
9735
|
-
fontWeight: fontWeight,
|
|
9736
|
-
fontFamily: fontFamily
|
|
9737
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
9738
|
-
str = data.str, width = data.width;
|
|
9739
|
-
} else {
|
|
9740
|
-
const data = textMeasure.clipText(text.toString(), {
|
|
9741
|
-
fontSize: fontSize,
|
|
9742
|
-
fontWeight: fontWeight,
|
|
9743
|
-
fontFamily: fontFamily
|
|
9744
|
-
}, maxLineWidth, !1);
|
|
9745
|
-
str = data.str, width = data.width;
|
|
9746
|
-
}
|
|
9747
|
-
this.cache.clipedText = str, this.cache.clipedWidth = width;
|
|
9748
|
-
} else width = textMeasure.measureTextWidth(text.toString(), {
|
|
9749
|
-
fontSize: fontSize,
|
|
9750
|
-
fontWeight: fontWeight,
|
|
9751
|
-
fontFamily: fontFamily
|
|
9752
|
-
}), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
|
|
9753
|
-
this.clearUpdateShapeTag();
|
|
9754
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
9755
|
-
let lh = lineHeight;
|
|
9756
|
-
application.global && application.global.isSafari() && (lh += .2 * fontSize);
|
|
9757
|
-
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
9758
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9759
|
-
}
|
|
9760
|
-
getBaselineMapAlign() {
|
|
9761
|
-
return Text.baselineMapAlign;
|
|
9762
|
-
}
|
|
9763
|
-
getAlignMapBaseline() {
|
|
9764
|
-
return Text.alignMapBaseline;
|
|
9765
|
-
}
|
|
9766
|
-
updateVerticalSinglelineAABBBounds(text) {
|
|
9767
|
-
var _a, _b, _c;
|
|
9768
|
-
const textTheme = this.getGraphicTheme(),
|
|
9769
|
-
textMeasure = application.graphicUtil.textMeasure;
|
|
9770
|
-
let width;
|
|
9771
|
-
const attribute = this.attribute,
|
|
9772
|
-
{
|
|
9773
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
9774
|
-
} = attribute,
|
|
9775
|
-
buf = ignoreBuf ? 0 : 2,
|
|
9776
|
-
{
|
|
9777
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
9778
|
-
ellipsis = textTheme.ellipsis,
|
|
9779
|
-
fontSize = textTheme.fontSize,
|
|
9780
|
-
fontWeight = textTheme.fontWeight,
|
|
9781
|
-
fontFamily = textTheme.fontFamily,
|
|
9782
|
-
stroke = textTheme.stroke,
|
|
9783
|
-
lineWidth = textTheme.lineWidth,
|
|
9784
|
-
verticalMode = textTheme.verticalMode,
|
|
9785
|
-
suffixPosition = textTheme.suffixPosition
|
|
9786
|
-
} = attribute,
|
|
9787
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
9788
|
-
let {
|
|
9789
|
-
textAlign = textTheme.textAlign,
|
|
9790
|
-
textBaseline = textTheme.textBaseline
|
|
9791
|
-
} = attribute;
|
|
9792
|
-
if (!verticalMode) {
|
|
9793
|
-
const t = textAlign;
|
|
9794
|
-
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
9795
|
-
}
|
|
9796
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
9797
|
-
width = this.cache.clipedWidth;
|
|
9798
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
9799
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
9800
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9801
|
-
}
|
|
9802
|
-
let verticalList = [verticalLayout(text.toString())];
|
|
9803
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
9804
|
-
if (ellipsis) {
|
|
9805
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
9806
|
-
data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
|
|
9807
|
-
fontSize: fontSize,
|
|
9808
|
-
fontWeight: fontWeight,
|
|
9809
|
-
fontFamily: fontFamily
|
|
9810
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
9811
|
-
verticalList = [data.verticalList], width = data.width;
|
|
9812
|
-
} else {
|
|
9813
|
-
const data = textMeasure.clipTextVertical(verticalList[0], {
|
|
9814
|
-
fontSize: fontSize,
|
|
9815
|
-
fontWeight: fontWeight,
|
|
9816
|
-
fontFamily: fontFamily
|
|
9817
|
-
}, maxLineWidth, !1);
|
|
9818
|
-
verticalList = [data.verticalList], width = data.width;
|
|
9819
|
-
}
|
|
9820
|
-
this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
9821
|
-
} else width = 0, verticalList[0].forEach(t => {
|
|
9822
|
-
const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
9823
|
-
fontSize: fontSize,
|
|
9824
|
-
fontWeight: fontWeight,
|
|
9825
|
-
fontFamily: fontFamily
|
|
9826
|
-
});
|
|
9827
|
-
width += w, t.width = w;
|
|
9828
|
-
}), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
9829
|
-
this.clearUpdateShapeTag();
|
|
9830
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
9831
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
9832
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9833
|
-
}
|
|
9834
|
-
updateHorizontalMultilineAABBBounds(text) {
|
|
9835
|
-
var _a, _b;
|
|
9836
|
-
const textTheme = this.getGraphicTheme(),
|
|
9837
|
-
{
|
|
9838
|
-
wrap = textTheme.wrap
|
|
9839
|
-
} = this.attribute;
|
|
9840
|
-
if (wrap) return this.updateWrapAABBBounds(text);
|
|
9841
|
-
const attribute = this.attribute,
|
|
9842
|
-
{
|
|
9843
|
-
fontFamily = textTheme.fontFamily,
|
|
9844
|
-
textAlign = textTheme.textAlign,
|
|
9845
|
-
textBaseline = textTheme.textBaseline,
|
|
9846
|
-
fontSize = textTheme.fontSize,
|
|
9847
|
-
fontWeight = textTheme.fontWeight,
|
|
9848
|
-
ellipsis = textTheme.ellipsis,
|
|
9849
|
-
maxLineWidth: maxLineWidth,
|
|
9850
|
-
stroke = textTheme.stroke,
|
|
9851
|
-
lineWidth = textTheme.lineWidth,
|
|
9852
|
-
whiteSpace = textTheme.whiteSpace,
|
|
9853
|
-
suffixPosition = textTheme.suffixPosition
|
|
9854
|
-
} = attribute,
|
|
9855
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
9856
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
9857
|
-
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
9858
|
-
const bbox = this.cache.layoutData.bbox;
|
|
9859
|
-
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9860
|
-
}
|
|
9861
|
-
const textMeasure = application.graphicUtil.textMeasure,
|
|
9862
|
-
layoutData = new CanvasTextLayout(fontFamily, {
|
|
9863
|
-
fontSize: fontSize,
|
|
9864
|
-
fontWeight: fontWeight,
|
|
9865
|
-
fontFamily: fontFamily
|
|
9866
|
-
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
|
|
9867
|
-
{
|
|
9868
|
-
bbox: bbox
|
|
9869
|
-
} = layoutData;
|
|
9870
|
-
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9871
|
-
}
|
|
9872
9942
|
updateVerticalMultilineAABBBounds(text) {
|
|
9873
|
-
var _a, _b
|
|
9943
|
+
var _a, _b;
|
|
9874
9944
|
const textTheme = this.getGraphicTheme(),
|
|
9875
9945
|
textMeasure = application.graphicUtil.textMeasure;
|
|
9876
9946
|
let width;
|
|
9877
9947
|
const attribute = this.attribute,
|
|
9878
|
-
{
|
|
9879
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
9880
|
-
} = attribute,
|
|
9881
|
-
buf = ignoreBuf ? 0 : 2,
|
|
9882
9948
|
{
|
|
9883
9949
|
maxLineWidth = textTheme.maxLineWidth,
|
|
9884
9950
|
ellipsis = textTheme.ellipsis,
|
|
@@ -9890,14 +9956,14 @@ class Text extends Graphic {
|
|
|
9890
9956
|
verticalMode = textTheme.verticalMode,
|
|
9891
9957
|
suffixPosition = textTheme.suffixPosition
|
|
9892
9958
|
} = attribute,
|
|
9893
|
-
lineHeight =
|
|
9959
|
+
lineHeight = this.getLineHeight(attribute, textTheme);
|
|
9894
9960
|
let {
|
|
9895
9961
|
textAlign = textTheme.textAlign,
|
|
9896
9962
|
textBaseline = textTheme.textBaseline
|
|
9897
9963
|
} = attribute;
|
|
9898
9964
|
if (!verticalMode) {
|
|
9899
9965
|
const t = textAlign;
|
|
9900
|
-
textAlign = null !== (
|
|
9966
|
+
textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
|
|
9901
9967
|
}
|
|
9902
9968
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
9903
9969
|
this.cache.verticalList.forEach(item => {
|
|
@@ -9945,6 +10011,15 @@ class Text extends Graphic {
|
|
|
9945
10011
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
9946
10012
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9947
10013
|
}
|
|
10014
|
+
getMaxWidth(theme) {
|
|
10015
|
+
var _a, _b;
|
|
10016
|
+
const attribute = this.attribute;
|
|
10017
|
+
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
10018
|
+
}
|
|
10019
|
+
getLineHeight(attribute, textTheme) {
|
|
10020
|
+
var _a;
|
|
10021
|
+
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
10022
|
+
}
|
|
9948
10023
|
needUpdateTags(keys) {
|
|
9949
10024
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
9950
10025
|
return super.needUpdateTags(keys, k);
|
|
@@ -9959,6 +10034,12 @@ class Text extends Graphic {
|
|
|
9959
10034
|
getNoWorkAnimateAttr() {
|
|
9960
10035
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
9961
10036
|
}
|
|
10037
|
+
getBaselineMapAlign() {
|
|
10038
|
+
return Text.baselineMapAlign;
|
|
10039
|
+
}
|
|
10040
|
+
getAlignMapBaseline() {
|
|
10041
|
+
return Text.alignMapBaseline;
|
|
10042
|
+
}
|
|
9962
10043
|
}
|
|
9963
10044
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
9964
10045
|
ellipsis: 1,
|
|
@@ -10037,7 +10118,10 @@ class WrapText extends Text {
|
|
|
10037
10118
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
10038
10119
|
linesLayout.push({
|
|
10039
10120
|
str: clip.str,
|
|
10040
|
-
width: clip.width
|
|
10121
|
+
width: clip.width,
|
|
10122
|
+
ascent: 0,
|
|
10123
|
+
descent: 0,
|
|
10124
|
+
keepCenterInLine: !1
|
|
10041
10125
|
});
|
|
10042
10126
|
break;
|
|
10043
10127
|
}
|
|
@@ -10051,7 +10135,10 @@ class WrapText extends Text {
|
|
|
10051
10135
|
}
|
|
10052
10136
|
if (linesLayout.push({
|
|
10053
10137
|
str: clip.str,
|
|
10054
|
-
width: clip.width
|
|
10138
|
+
width: clip.width,
|
|
10139
|
+
ascent: 0,
|
|
10140
|
+
descent: 0,
|
|
10141
|
+
keepCenterInLine: !1
|
|
10055
10142
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
10056
10143
|
const newStr = str.substring(clip.str.length);
|
|
10057
10144
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -10070,13 +10157,19 @@ class WrapText extends Text {
|
|
|
10070
10157
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
10071
10158
|
linesLayout.push({
|
|
10072
10159
|
str: clip.str,
|
|
10073
|
-
width: clip.width
|
|
10160
|
+
width: clip.width,
|
|
10161
|
+
ascent: 0,
|
|
10162
|
+
descent: 0,
|
|
10163
|
+
keepCenterInLine: !1
|
|
10074
10164
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
10075
10165
|
break;
|
|
10076
10166
|
}
|
|
10077
10167
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
10078
10168
|
str: text,
|
|
10079
|
-
width: width
|
|
10169
|
+
width: width,
|
|
10170
|
+
ascent: 0,
|
|
10171
|
+
descent: 0,
|
|
10172
|
+
keepCenterInLine: !1
|
|
10080
10173
|
});
|
|
10081
10174
|
}
|
|
10082
10175
|
bboxWH[0] = lineWidth;
|
|
@@ -10120,6 +10213,9 @@ class BaseSymbol {
|
|
|
10120
10213
|
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
10121
10214
|
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
10122
10215
|
}
|
|
10216
|
+
parseSize(size) {
|
|
10217
|
+
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
10218
|
+
}
|
|
10123
10219
|
}
|
|
10124
10220
|
|
|
10125
10221
|
function circle(ctx, r, x, y, z) {
|
|
@@ -10130,13 +10226,13 @@ class CircleSymbol extends BaseSymbol {
|
|
|
10130
10226
|
super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
|
|
10131
10227
|
}
|
|
10132
10228
|
draw(ctx, size, x, y, z) {
|
|
10133
|
-
return circle(ctx, size / 2, x, y, z);
|
|
10229
|
+
return circle(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10134
10230
|
}
|
|
10135
10231
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10136
|
-
return circle(ctx, size / 2 + offset, x, y, z);
|
|
10232
|
+
return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
10137
10233
|
}
|
|
10138
10234
|
drawToSvgPath(size, x, y, z) {
|
|
10139
|
-
const r = size / 2;
|
|
10235
|
+
const r = this.parseSize(size) / 2;
|
|
10140
10236
|
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
|
|
10141
10237
|
}
|
|
10142
10238
|
}
|
|
@@ -10153,10 +10249,10 @@ class CrossSymbol extends BaseSymbol {
|
|
|
10153
10249
|
super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
|
|
10154
10250
|
}
|
|
10155
10251
|
draw(ctx, size, x, y, z) {
|
|
10156
|
-
return cross(ctx, size / 6, x, y, z);
|
|
10252
|
+
return cross(ctx, this.parseSize(size) / 6, x, y, z);
|
|
10157
10253
|
}
|
|
10158
10254
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10159
|
-
return crossOffset(ctx, size / 6, x, y, offset, z);
|
|
10255
|
+
return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
|
|
10160
10256
|
}
|
|
10161
10257
|
}
|
|
10162
10258
|
var cross$1 = new CrossSymbol();
|
|
@@ -10169,13 +10265,13 @@ class DiamondSymbol extends BaseSymbol {
|
|
|
10169
10265
|
super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
|
|
10170
10266
|
}
|
|
10171
10267
|
draw(ctx, size, x, y, z) {
|
|
10172
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
10268
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10173
10269
|
}
|
|
10174
10270
|
drawFitDir(ctx, size, x, y, z) {
|
|
10175
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
10271
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10176
10272
|
}
|
|
10177
10273
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10178
|
-
return diamond(ctx, size / 2 + offset, x, y, z);
|
|
10274
|
+
return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
10179
10275
|
}
|
|
10180
10276
|
}
|
|
10181
10277
|
var diamond$1 = new DiamondSymbol();
|
|
@@ -10189,10 +10285,10 @@ class SquareSymbol extends BaseSymbol {
|
|
|
10189
10285
|
super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
|
|
10190
10286
|
}
|
|
10191
10287
|
draw(ctx, size, x, y) {
|
|
10192
|
-
return square(ctx, size / 2, x, y);
|
|
10288
|
+
return square(ctx, this.parseSize(size) / 2, x, y);
|
|
10193
10289
|
}
|
|
10194
10290
|
drawOffset(ctx, size, x, y, offset) {
|
|
10195
|
-
return square(ctx, size / 2 + offset, x, y);
|
|
10291
|
+
return square(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10196
10292
|
}
|
|
10197
10293
|
}
|
|
10198
10294
|
var square$1 = new SquareSymbol();
|
|
@@ -10206,10 +10302,10 @@ class TriangleUpSymbol extends BaseSymbol {
|
|
|
10206
10302
|
super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
|
|
10207
10303
|
}
|
|
10208
10304
|
draw(ctx, size, x, y) {
|
|
10209
|
-
return trianglUpOffset(ctx, size / 2, x, y);
|
|
10305
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10210
10306
|
}
|
|
10211
10307
|
drawOffset(ctx, size, x, y, offset) {
|
|
10212
|
-
return trianglUpOffset(ctx, size / 2, x, y, offset);
|
|
10308
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10213
10309
|
}
|
|
10214
10310
|
}
|
|
10215
10311
|
var triangleUp = new TriangleUpSymbol();
|
|
@@ -10241,10 +10337,10 @@ class StarSymbol extends BaseSymbol {
|
|
|
10241
10337
|
super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
|
|
10242
10338
|
}
|
|
10243
10339
|
draw(ctx, size, transX, transY) {
|
|
10244
|
-
return star(ctx, size / 2, transX, transY);
|
|
10340
|
+
return star(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10245
10341
|
}
|
|
10246
10342
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10247
|
-
return star(ctx, size / 2 + offset, transX, transY);
|
|
10343
|
+
return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10248
10344
|
}
|
|
10249
10345
|
}
|
|
10250
10346
|
var star$1 = new StarSymbol();
|
|
@@ -10262,10 +10358,10 @@ class ArrowSymbol extends BaseSymbol {
|
|
|
10262
10358
|
super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
|
|
10263
10359
|
}
|
|
10264
10360
|
draw(ctx, size, transX, transY) {
|
|
10265
|
-
return arrow(ctx, size / 2, transX, transY);
|
|
10361
|
+
return arrow(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10266
10362
|
}
|
|
10267
10363
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10268
|
-
return arrow(ctx, size / 2 + offset, transX, transY);
|
|
10364
|
+
return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10269
10365
|
}
|
|
10270
10366
|
}
|
|
10271
10367
|
var arrow$1 = new ArrowSymbol();
|
|
@@ -10279,10 +10375,10 @@ class WedgeSymbol extends BaseSymbol {
|
|
|
10279
10375
|
super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
|
|
10280
10376
|
}
|
|
10281
10377
|
draw(ctx, size, transX, transY) {
|
|
10282
|
-
return wedge(ctx, size / 2, transX, transY);
|
|
10378
|
+
return wedge(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10283
10379
|
}
|
|
10284
10380
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10285
|
-
return wedge(ctx, size / 2 + offset, transX, transY);
|
|
10381
|
+
return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10286
10382
|
}
|
|
10287
10383
|
}
|
|
10288
10384
|
var wedge$1 = new WedgeSymbol();
|
|
@@ -10295,10 +10391,10 @@ class StrokeSymbol extends BaseSymbol {
|
|
|
10295
10391
|
super(...arguments), this.type = "stroke", this.pathStr = "";
|
|
10296
10392
|
}
|
|
10297
10393
|
draw(ctx, size, transX, transY) {
|
|
10298
|
-
return stroke(ctx, size / 2, transX, transY);
|
|
10394
|
+
return stroke(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10299
10395
|
}
|
|
10300
10396
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10301
|
-
return stroke(ctx, size / 2 + offset, transX, transY);
|
|
10397
|
+
return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10302
10398
|
}
|
|
10303
10399
|
}
|
|
10304
10400
|
var stroke$1 = new StrokeSymbol();
|
|
@@ -10320,10 +10416,10 @@ class WyeSymbol extends BaseSymbol {
|
|
|
10320
10416
|
super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
|
|
10321
10417
|
}
|
|
10322
10418
|
draw(ctx, size, transX, transY) {
|
|
10323
|
-
return wye(ctx, size / 2, transX, transY);
|
|
10419
|
+
return wye(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10324
10420
|
}
|
|
10325
10421
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10326
|
-
return wye(ctx, size / 2 + offset, transX, transY);
|
|
10422
|
+
return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10327
10423
|
}
|
|
10328
10424
|
}
|
|
10329
10425
|
var wye$1 = new WyeSymbol();
|
|
@@ -10336,10 +10432,10 @@ class TriangleLeftSymbol extends BaseSymbol {
|
|
|
10336
10432
|
super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
|
|
10337
10433
|
}
|
|
10338
10434
|
draw(ctx, size, x, y) {
|
|
10339
|
-
return trianglLeftOffset(ctx, size / 2, x, y, 0);
|
|
10435
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
|
|
10340
10436
|
}
|
|
10341
10437
|
drawOffset(ctx, size, x, y, offset) {
|
|
10342
|
-
return trianglLeftOffset(ctx, size / 2, x, y, offset);
|
|
10438
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10343
10439
|
}
|
|
10344
10440
|
}
|
|
10345
10441
|
var triangleLeft = new TriangleLeftSymbol();
|
|
@@ -10353,10 +10449,10 @@ class TriangleRightSymbol extends BaseSymbol {
|
|
|
10353
10449
|
super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
|
|
10354
10450
|
}
|
|
10355
10451
|
draw(ctx, size, x, y) {
|
|
10356
|
-
return trianglRightOffset(ctx, size / 2, x, y);
|
|
10452
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10357
10453
|
}
|
|
10358
10454
|
drawOffset(ctx, size, x, y, offset) {
|
|
10359
|
-
return trianglRightOffset(ctx, size / 2, x, y, offset);
|
|
10455
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10360
10456
|
}
|
|
10361
10457
|
}
|
|
10362
10458
|
var triangleRight = new TriangleRightSymbol();
|
|
@@ -10370,10 +10466,10 @@ class TriangleDownSymbol extends BaseSymbol {
|
|
|
10370
10466
|
super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
|
|
10371
10467
|
}
|
|
10372
10468
|
draw(ctx, size, x, y) {
|
|
10373
|
-
return trianglDownOffset(ctx, size / 2, x, y);
|
|
10469
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10374
10470
|
}
|
|
10375
10471
|
drawOffset(ctx, size, x, y, offset) {
|
|
10376
|
-
return trianglDownOffset(ctx, size / 2, x, y, offset);
|
|
10472
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10377
10473
|
}
|
|
10378
10474
|
}
|
|
10379
10475
|
var triangleDown = new TriangleDownSymbol();
|
|
@@ -10388,10 +10484,10 @@ class ThinTriangleSymbol extends BaseSymbol {
|
|
|
10388
10484
|
super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
|
|
10389
10485
|
}
|
|
10390
10486
|
draw(ctx, size, x, y) {
|
|
10391
|
-
return thinTriangle(ctx, size / 2 / sqrt3, x, y);
|
|
10487
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
|
|
10392
10488
|
}
|
|
10393
10489
|
drawOffset(ctx, size, x, y, offset) {
|
|
10394
|
-
return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
|
|
10490
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
|
|
10395
10491
|
}
|
|
10396
10492
|
}
|
|
10397
10493
|
var thinTriangle$1 = new ThinTriangleSymbol();
|
|
@@ -10405,10 +10501,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
|
|
|
10405
10501
|
super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
|
|
10406
10502
|
}
|
|
10407
10503
|
draw(ctx, size, transX, transY) {
|
|
10408
|
-
return arrow2Left(ctx, size / 4, transX, transY);
|
|
10504
|
+
return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10409
10505
|
}
|
|
10410
10506
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10411
|
-
return arrow2Left(ctx, size / 4 + offset, transX, transY);
|
|
10507
|
+
return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10412
10508
|
}
|
|
10413
10509
|
}
|
|
10414
10510
|
var arrow2Left$1 = new Arrow2LeftSymbol();
|
|
@@ -10422,10 +10518,10 @@ class Arrow2RightSymbol extends BaseSymbol {
|
|
|
10422
10518
|
super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
|
|
10423
10519
|
}
|
|
10424
10520
|
draw(ctx, size, transX, transY) {
|
|
10425
|
-
return arrow2Right(ctx, size / 4, transX, transY);
|
|
10521
|
+
return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10426
10522
|
}
|
|
10427
10523
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10428
|
-
return arrow2Right(ctx, size / 4 + offset, transX, transY);
|
|
10524
|
+
return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10429
10525
|
}
|
|
10430
10526
|
}
|
|
10431
10527
|
var arrow2Right$1 = new Arrow2RightSymbol();
|
|
@@ -10439,10 +10535,10 @@ class Arrow2UpSymbol extends BaseSymbol {
|
|
|
10439
10535
|
super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
|
|
10440
10536
|
}
|
|
10441
10537
|
draw(ctx, size, transX, transY) {
|
|
10442
|
-
return arrow2Up(ctx, size / 4, transX, transY);
|
|
10538
|
+
return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10443
10539
|
}
|
|
10444
10540
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10445
|
-
return arrow2Up(ctx, size / 4 + offset, transX, transY);
|
|
10541
|
+
return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10446
10542
|
}
|
|
10447
10543
|
}
|
|
10448
10544
|
var arrow2Up$1 = new Arrow2UpSymbol();
|
|
@@ -10456,10 +10552,10 @@ class Arrow2DownSymbol extends BaseSymbol {
|
|
|
10456
10552
|
super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
|
|
10457
10553
|
}
|
|
10458
10554
|
draw(ctx, size, transX, transY) {
|
|
10459
|
-
return arrow2Down(ctx, size / 4, transX, transY);
|
|
10555
|
+
return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10460
10556
|
}
|
|
10461
10557
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10462
|
-
return arrow2Down(ctx, size / 4 + offset, transX, transY);
|
|
10558
|
+
return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10463
10559
|
}
|
|
10464
10560
|
}
|
|
10465
10561
|
var arrow2Down$1 = new Arrow2DownSymbol();
|
|
@@ -10472,13 +10568,13 @@ class LineVSymbol extends BaseSymbol {
|
|
|
10472
10568
|
super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
|
|
10473
10569
|
}
|
|
10474
10570
|
draw(ctx, size, x, y, z) {
|
|
10475
|
-
return lineV(ctx, size / 2, x, y);
|
|
10571
|
+
return lineV(ctx, this.parseSize(size) / 2, x, y);
|
|
10476
10572
|
}
|
|
10477
10573
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10478
|
-
return lineV(ctx, size / 2 + offset, x, y);
|
|
10574
|
+
return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10479
10575
|
}
|
|
10480
10576
|
drawToSvgPath(size, x, y, z) {
|
|
10481
|
-
const r = size / 2;
|
|
10577
|
+
const r = this.parseSize(size) / 2;
|
|
10482
10578
|
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
10483
10579
|
}
|
|
10484
10580
|
}
|
|
@@ -10492,13 +10588,13 @@ class LineHSymbol extends BaseSymbol {
|
|
|
10492
10588
|
super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
|
|
10493
10589
|
}
|
|
10494
10590
|
draw(ctx, size, x, y, z) {
|
|
10495
|
-
return lineH(ctx, size / 2, x, y);
|
|
10591
|
+
return lineH(ctx, this.parseSize(size) / 2, x, y);
|
|
10496
10592
|
}
|
|
10497
10593
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10498
|
-
return lineH(ctx, size / 2 + offset, x, y);
|
|
10594
|
+
return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10499
10595
|
}
|
|
10500
10596
|
drawToSvgPath(size, x, y, z) {
|
|
10501
|
-
const r = size / 2;
|
|
10597
|
+
const r = this.parseSize(size) / 2;
|
|
10502
10598
|
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
10503
10599
|
}
|
|
10504
10600
|
}
|
|
@@ -10512,13 +10608,13 @@ class CloseSymbol extends BaseSymbol {
|
|
|
10512
10608
|
super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
|
|
10513
10609
|
}
|
|
10514
10610
|
draw(ctx, size, x, y, z) {
|
|
10515
|
-
return close(ctx, size / 2, x, y);
|
|
10611
|
+
return close(ctx, this.parseSize(size) / 2, x, y);
|
|
10516
10612
|
}
|
|
10517
10613
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10518
|
-
return close(ctx, size / 2 + offset, x, y);
|
|
10614
|
+
return close(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10519
10615
|
}
|
|
10520
10616
|
drawToSvgPath(size, x, y, z) {
|
|
10521
|
-
const r = size / 2;
|
|
10617
|
+
const r = this.parseSize(size) / 2;
|
|
10522
10618
|
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
10523
10619
|
}
|
|
10524
10620
|
}
|
|
@@ -10552,15 +10648,18 @@ class CustomSymbolClass {
|
|
|
10552
10648
|
this.pathStr = "", this.type = type, isArray(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
10553
10649
|
}
|
|
10554
10650
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
10555
|
-
return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
10651
|
+
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
10556
10652
|
ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
|
|
10557
10653
|
}), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
|
|
10558
10654
|
}
|
|
10559
10655
|
draw(ctx, size, x, y, z, cb) {
|
|
10560
|
-
return this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
10656
|
+
return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
10657
|
+
}
|
|
10658
|
+
parseSize(size) {
|
|
10659
|
+
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
10561
10660
|
}
|
|
10562
10661
|
bounds(size, bounds) {
|
|
10563
|
-
if (this.isSvg) {
|
|
10662
|
+
if (size = this.parseSize(size), this.isSvg) {
|
|
10564
10663
|
if (!this.svgCache) return;
|
|
10565
10664
|
return bounds.clear(), void this.svgCache.forEach(_ref => {
|
|
10566
10665
|
let {
|
|
@@ -11064,7 +11163,11 @@ class Paragraph {
|
|
|
11064
11163
|
case "sub":
|
|
11065
11164
|
baseline += this.descent / 2;
|
|
11066
11165
|
}
|
|
11067
|
-
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0)
|
|
11166
|
+
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
|
|
11167
|
+
const {
|
|
11168
|
+
lineWidth = 1
|
|
11169
|
+
} = this.character;
|
|
11170
|
+
this.character.stroke && lineWidth && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
|
|
11068
11171
|
}
|
|
11069
11172
|
getWidthWithEllips(direction) {
|
|
11070
11173
|
let text = this.text;
|
|
@@ -12925,27 +13028,9 @@ function simplifyRadialDist(points, sqTolerance) {
|
|
|
12925
13028
|
for (let i = 1, len = points.length; i < len; i++) deltaX = points[i].x - lastX, deltaY = points[i].y - lastY, deltaX * deltaX + deltaY * deltaY > sqTolerance && (lastX = points[i].x, lastY = points[i].y, newPoints.push(points[i]));
|
|
12926
13029
|
return points[points.length - 1].x === lastX && points[points.length - 1].y === lastY || newPoints.push(points[points.length - 1]), newPoints;
|
|
12927
13030
|
}
|
|
12928
|
-
function simplifyDPStep(points, startIdx, endIdx, sqTolerance, simplified) {
|
|
12929
|
-
let maxSqDist = sqTolerance,
|
|
12930
|
-
nextIdx = startIdx;
|
|
12931
|
-
const startX = points[startIdx].x,
|
|
12932
|
-
startY = points[startIdx].y,
|
|
12933
|
-
vecX2 = points[endIdx].x - startX,
|
|
12934
|
-
vecY2 = points[endIdx].y - startY,
|
|
12935
|
-
sqLength = vecX2 * vecX2 + vecY2 * vecY2;
|
|
12936
|
-
let area, sqArea, sqDistance, vecX1, vecY1;
|
|
12937
|
-
for (let i = startIdx + 1, len = endIdx - 1; i < len; i++) vecX1 = points[i].x - startX, vecY1 = points[i].y - startY, area = vecX1 * vecY2 - vecX2 * vecY1, sqArea = area * area, sqDistance = sqArea / sqLength, sqDistance > maxSqDist && (maxSqDist = sqDistance, nextIdx = i);
|
|
12938
|
-
maxSqDist > sqTolerance && (nextIdx - startIdx > 2 && simplifyDPStep(points, startIdx, nextIdx, sqTolerance, simplified), simplified.push(points[nextIdx], points[nextIdx + 1]), endIdx - nextIdx > 2 && simplifyDPStep(points, nextIdx, endIdx, sqTolerance, simplified));
|
|
12939
|
-
}
|
|
12940
|
-
function simplifyDouglasPeucker(points, sqTolerance) {
|
|
12941
|
-
const lastIdx = points.length - 1,
|
|
12942
|
-
simplified = [points[0]];
|
|
12943
|
-
return simplifyDPStep(points, 0, lastIdx, sqTolerance, simplified), simplified.push(points[lastIdx]), simplified;
|
|
12944
|
-
}
|
|
12945
13031
|
function flatten_simplify(points, tolerance, highestQuality) {
|
|
12946
13032
|
if (points.length <= 10) return points;
|
|
12947
|
-
|
|
12948
|
-
return points = simplifyDouglasPeucker(points = highestQuality ? points : simplifyRadialDist(points, sqTolerance), sqTolerance);
|
|
13033
|
+
return points = highestQuality ? points : simplifyRadialDist(points, void 0 !== tolerance ? tolerance * tolerance : 1);
|
|
12949
13034
|
}
|
|
12950
13035
|
|
|
12951
13036
|
let loadArcModule = !1;
|
|
@@ -13269,8 +13354,9 @@ class PickerBase {
|
|
|
13269
13354
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
|
|
13270
13355
|
if (picked) return !0;
|
|
13271
13356
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13272
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13273
|
-
|
|
13357
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13358
|
+
keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13359
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13274
13360
|
}), pickContext.highPerformanceRestore(), picked;
|
|
13275
13361
|
}
|
|
13276
13362
|
}
|
|
@@ -13492,8 +13578,9 @@ class RectPickerBase {
|
|
|
13492
13578
|
if (!onlyTranslate || rect.shadowRoot || isNumber(cornerRadius, !0) && 0 !== cornerRadius || isArray(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
|
|
13493
13579
|
if (picked) return !0;
|
|
13494
13580
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13495
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13496
|
-
|
|
13581
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13582
|
+
keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13583
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13497
13584
|
});else {
|
|
13498
13585
|
const {
|
|
13499
13586
|
fill = rectAttribute.fill,
|
|
@@ -13672,8 +13759,9 @@ class BaseLinePicker extends BaseRender {
|
|
|
13672
13759
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
13673
13760
|
if (picked) return !0;
|
|
13674
13761
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13675
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13676
|
-
|
|
13762
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13763
|
+
keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13764
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13677
13765
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13678
13766
|
}
|
|
13679
13767
|
}
|
|
@@ -13808,8 +13896,9 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
|
|
|
13808
13896
|
return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
|
|
13809
13897
|
if (picked) return !0;
|
|
13810
13898
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13811
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13812
|
-
|
|
13899
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13900
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13901
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13813
13902
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13814
13903
|
}
|
|
13815
13904
|
};
|
|
@@ -14456,6 +14545,288 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
14456
14545
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
14457
14546
|
};
|
|
14458
14547
|
|
|
14548
|
+
var ScrollBarPlugin_1;
|
|
14549
|
+
let ScrollBarPlugin = ScrollBarPlugin_1 = class ScrollBarPlugin {
|
|
14550
|
+
constructor() {
|
|
14551
|
+
this.name = 'scrollbar';
|
|
14552
|
+
this.activeEvent = 'onRegister';
|
|
14553
|
+
this._uid = Generator.GenAutoIncrementId();
|
|
14554
|
+
this.key = this.name + this._uid;
|
|
14555
|
+
this.scroll = (e) => {
|
|
14556
|
+
var _a, _b;
|
|
14557
|
+
const graphic = e.target;
|
|
14558
|
+
const data = this.getScrollContainer(graphic);
|
|
14559
|
+
if (!data && !this.scrollContainer) {
|
|
14560
|
+
return;
|
|
14561
|
+
}
|
|
14562
|
+
if (!data && this.scrollContainer) {
|
|
14563
|
+
if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {
|
|
14564
|
+
return;
|
|
14565
|
+
}
|
|
14566
|
+
const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);
|
|
14567
|
+
if (!newScrollContainer) {
|
|
14568
|
+
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14569
|
+
return;
|
|
14570
|
+
}
|
|
14571
|
+
if (this.scrollContainer.showH && !newScrollContainer.showH) {
|
|
14572
|
+
this.clearScrollbar(this.scrollContainer.g, 'horizontal');
|
|
14573
|
+
}
|
|
14574
|
+
if (this.scrollContainer.showV && !newScrollContainer.showV) {
|
|
14575
|
+
this.clearScrollbar(this.scrollContainer.g, 'vertical');
|
|
14576
|
+
}
|
|
14577
|
+
this.scrollContainer = newScrollContainer;
|
|
14578
|
+
}
|
|
14579
|
+
else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {
|
|
14580
|
+
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14581
|
+
}
|
|
14582
|
+
this.scrollContainer = data !== null && data !== void 0 ? data : this.scrollContainer;
|
|
14583
|
+
const scrollContainer = data.g;
|
|
14584
|
+
const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;
|
|
14585
|
+
let newScrollX = scrollX;
|
|
14586
|
+
let newScrollY = scrollY;
|
|
14587
|
+
let { showH, showV } = data;
|
|
14588
|
+
this.scrollContainerBounds = new Bounds().set(0, 0, scrollContainer.attribute.width, scrollContainer.attribute.height);
|
|
14589
|
+
if (showH && showH) {
|
|
14590
|
+
if (abs(e.deltaX) > abs(e.deltaY)) {
|
|
14591
|
+
showH = showH && true;
|
|
14592
|
+
showV = showV && false;
|
|
14593
|
+
}
|
|
14594
|
+
else {
|
|
14595
|
+
showH = showH && false;
|
|
14596
|
+
showV = showV && true;
|
|
14597
|
+
}
|
|
14598
|
+
}
|
|
14599
|
+
const childrenBounds = this.childrenBounds;
|
|
14600
|
+
childrenBounds.clear();
|
|
14601
|
+
childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());
|
|
14602
|
+
const scrollWidth = childrenBounds.width();
|
|
14603
|
+
const scrollHeight = childrenBounds.height();
|
|
14604
|
+
if (showH) {
|
|
14605
|
+
newScrollX = Math.max(Math.min(((_a = e.deltaX) !== null && _a !== void 0 ? _a : 0) - scrollX, scrollWidth - width), 0);
|
|
14606
|
+
}
|
|
14607
|
+
else {
|
|
14608
|
+
newScrollX = -scrollX;
|
|
14609
|
+
}
|
|
14610
|
+
if (showV) {
|
|
14611
|
+
newScrollY = Math.max(Math.min(((_b = e.deltaY) !== null && _b !== void 0 ? _b : 0) - scrollY, scrollHeight - height), 0);
|
|
14612
|
+
}
|
|
14613
|
+
else {
|
|
14614
|
+
newScrollY = -scrollY;
|
|
14615
|
+
}
|
|
14616
|
+
childrenBounds.translate(-newScrollX, -newScrollY);
|
|
14617
|
+
this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);
|
|
14618
|
+
scrollContainer.setAttributes({
|
|
14619
|
+
scrollX: -newScrollX,
|
|
14620
|
+
scrollY: -newScrollY
|
|
14621
|
+
});
|
|
14622
|
+
};
|
|
14623
|
+
this.handleScrollBarChange = (params) => {
|
|
14624
|
+
if (!this.scrollContainer ||
|
|
14625
|
+
!this.scrollContainerBounds ||
|
|
14626
|
+
!this.childrenBounds ||
|
|
14627
|
+
!params ||
|
|
14628
|
+
!params.target ||
|
|
14629
|
+
!params.detail ||
|
|
14630
|
+
!params.detail.value) {
|
|
14631
|
+
return;
|
|
14632
|
+
}
|
|
14633
|
+
const scrollbar = params.target;
|
|
14634
|
+
const newRange = params.detail.value;
|
|
14635
|
+
if (scrollbar.attribute.direction === 'horizontal') {
|
|
14636
|
+
const scrollWidth = this.childrenBounds.width();
|
|
14637
|
+
this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });
|
|
14638
|
+
}
|
|
14639
|
+
else {
|
|
14640
|
+
const scrollHeight = this.childrenBounds.height();
|
|
14641
|
+
this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });
|
|
14642
|
+
}
|
|
14643
|
+
};
|
|
14644
|
+
}
|
|
14645
|
+
activate(context) {
|
|
14646
|
+
this.pluginService = context;
|
|
14647
|
+
const { stage } = this.pluginService;
|
|
14648
|
+
this.childrenBounds = new AABBBounds();
|
|
14649
|
+
stage.addEventListener('wheel', this.scroll);
|
|
14650
|
+
this.params = ScrollBarPlugin_1.defaultParams;
|
|
14651
|
+
}
|
|
14652
|
+
initEventOfScrollbar(scrollContainer, scrollbar, isHorozntal) {
|
|
14653
|
+
scrollContainer.addEventListener('pointerover', () => {
|
|
14654
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14655
|
+
});
|
|
14656
|
+
scrollContainer.addEventListener('pointermove', () => {
|
|
14657
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14658
|
+
});
|
|
14659
|
+
scrollContainer.addEventListener('pointerout', () => {
|
|
14660
|
+
scrollbar.setAttribute('visibleAll', false);
|
|
14661
|
+
});
|
|
14662
|
+
scrollbar.addEventListener('pointerover', () => {
|
|
14663
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14664
|
+
});
|
|
14665
|
+
scrollbar.addEventListener('pointerout', () => {
|
|
14666
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14667
|
+
});
|
|
14668
|
+
scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);
|
|
14669
|
+
scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);
|
|
14670
|
+
}
|
|
14671
|
+
addOrUpdateScroll(showH, showV, container, scrollContainer) {
|
|
14672
|
+
if (showH) {
|
|
14673
|
+
const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);
|
|
14674
|
+
if (!isUpdate) {
|
|
14675
|
+
this.initEventOfScrollbar(scrollContainer, hScrollbar, true);
|
|
14676
|
+
}
|
|
14677
|
+
}
|
|
14678
|
+
else {
|
|
14679
|
+
this.clearScrollbar(scrollContainer, 'horizontal');
|
|
14680
|
+
}
|
|
14681
|
+
if (showV) {
|
|
14682
|
+
const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);
|
|
14683
|
+
if (!isUpdate) {
|
|
14684
|
+
this.initEventOfScrollbar(scrollContainer, vScrollbar, false);
|
|
14685
|
+
}
|
|
14686
|
+
}
|
|
14687
|
+
else {
|
|
14688
|
+
this.clearScrollbar(scrollContainer, 'vertical');
|
|
14689
|
+
}
|
|
14690
|
+
}
|
|
14691
|
+
getDirection(isHorozntal) {
|
|
14692
|
+
return isHorozntal ? 'horizontal' : 'vertical';
|
|
14693
|
+
}
|
|
14694
|
+
addOrUpdateHScroll(scrollContainer, container, isHorozntal) {
|
|
14695
|
+
var _a;
|
|
14696
|
+
const direction = this.getDirection(isHorozntal);
|
|
14697
|
+
const name = `${(_a = scrollContainer.name) !== null && _a !== void 0 ? _a : scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;
|
|
14698
|
+
const scrollbars = container.children.filter((g) => g.name === name);
|
|
14699
|
+
let isUpdate = true;
|
|
14700
|
+
let scrollBar = scrollbars[0];
|
|
14701
|
+
const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;
|
|
14702
|
+
const attrs = {
|
|
14703
|
+
x: 0,
|
|
14704
|
+
y: 0,
|
|
14705
|
+
direction,
|
|
14706
|
+
zIndex: zIndex + 1,
|
|
14707
|
+
visibleAll: true,
|
|
14708
|
+
padding: [2, 0],
|
|
14709
|
+
railStyle: {
|
|
14710
|
+
fill: 'rgba(0, 0, 0, .1)'
|
|
14711
|
+
},
|
|
14712
|
+
range: [0, 0.05]
|
|
14713
|
+
};
|
|
14714
|
+
if (isHorozntal) {
|
|
14715
|
+
attrs.width = this.scrollContainerBounds.width();
|
|
14716
|
+
attrs.height = 12;
|
|
14717
|
+
}
|
|
14718
|
+
else {
|
|
14719
|
+
attrs.height = this.scrollContainerBounds.height();
|
|
14720
|
+
attrs.width = 12;
|
|
14721
|
+
}
|
|
14722
|
+
if (!scrollBar) {
|
|
14723
|
+
isUpdate = false;
|
|
14724
|
+
scrollBar = new ScrollBar(attrs);
|
|
14725
|
+
scrollBar.name = name;
|
|
14726
|
+
container.add(scrollBar);
|
|
14727
|
+
scrollBar.isScrollBar = true;
|
|
14728
|
+
}
|
|
14729
|
+
else if (scrollbars.length > 1) {
|
|
14730
|
+
scrollbars.forEach((child, index) => {
|
|
14731
|
+
var _a;
|
|
14732
|
+
if (index) {
|
|
14733
|
+
(_a = child.parent) === null || _a === void 0 ? void 0 : _a.removeChild(child);
|
|
14734
|
+
}
|
|
14735
|
+
});
|
|
14736
|
+
}
|
|
14737
|
+
const childrenBounds = this.childrenBounds;
|
|
14738
|
+
if (isHorozntal) {
|
|
14739
|
+
const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);
|
|
14740
|
+
const start = Math.max(Math.min(this.childrenBounds.x1 / this.childrenBounds.width(), 0), ratio - 1);
|
|
14741
|
+
attrs.x = x + dx;
|
|
14742
|
+
attrs.y = y + dy + height - this.scrollContainerBounds.height();
|
|
14743
|
+
attrs.range = [-start, -start + ratio];
|
|
14744
|
+
}
|
|
14745
|
+
else {
|
|
14746
|
+
const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);
|
|
14747
|
+
const start = Math.max(Math.min(this.childrenBounds.y1 / this.childrenBounds.height(), 0), ratio - 1);
|
|
14748
|
+
attrs.x = x + dx + width - this.scrollContainerBounds.width();
|
|
14749
|
+
attrs.y = y + dy;
|
|
14750
|
+
attrs.range = [-start, -start + ratio];
|
|
14751
|
+
}
|
|
14752
|
+
scrollBar.setAttributes(attrs);
|
|
14753
|
+
return {
|
|
14754
|
+
scrollBar,
|
|
14755
|
+
isUpdate
|
|
14756
|
+
};
|
|
14757
|
+
}
|
|
14758
|
+
clearScrollbar(scrollContainer, type) {
|
|
14759
|
+
if (!scrollContainer.parent) {
|
|
14760
|
+
return;
|
|
14761
|
+
}
|
|
14762
|
+
const scrollbarBars = scrollContainer.parent.children.filter((child) => {
|
|
14763
|
+
return child.isScrollBar && (type === 'all' || child.attribute.direction === type);
|
|
14764
|
+
});
|
|
14765
|
+
scrollbarBars.forEach((child) => {
|
|
14766
|
+
child.parent.removeChild(child);
|
|
14767
|
+
});
|
|
14768
|
+
}
|
|
14769
|
+
formatScrollContainer(g) {
|
|
14770
|
+
if (!g || g.type !== 'group' || !g.attribute) {
|
|
14771
|
+
return null;
|
|
14772
|
+
}
|
|
14773
|
+
const { overflow, width, height } = g.attribute;
|
|
14774
|
+
if (!overflow || overflow === 'hidden') {
|
|
14775
|
+
return null;
|
|
14776
|
+
}
|
|
14777
|
+
let showH = false;
|
|
14778
|
+
let showV = false;
|
|
14779
|
+
if (overflow === 'scroll') {
|
|
14780
|
+
showH = true;
|
|
14781
|
+
showV = true;
|
|
14782
|
+
}
|
|
14783
|
+
else {
|
|
14784
|
+
showH = overflow === 'scroll-x';
|
|
14785
|
+
showV = !showH;
|
|
14786
|
+
}
|
|
14787
|
+
if (!g.AABBBounds.empty()) {
|
|
14788
|
+
if (showH) {
|
|
14789
|
+
showH = width < g.AABBBounds.width();
|
|
14790
|
+
}
|
|
14791
|
+
if (showV) {
|
|
14792
|
+
showV = height < g.AABBBounds.height();
|
|
14793
|
+
}
|
|
14794
|
+
}
|
|
14795
|
+
return showH || showV ? { g: g, showH, showV } : null;
|
|
14796
|
+
}
|
|
14797
|
+
getScrollContainer(graphic) {
|
|
14798
|
+
let g = graphic;
|
|
14799
|
+
while (g) {
|
|
14800
|
+
const res = this.formatScrollContainer(g);
|
|
14801
|
+
if (res) {
|
|
14802
|
+
return res;
|
|
14803
|
+
}
|
|
14804
|
+
g = g.parent;
|
|
14805
|
+
}
|
|
14806
|
+
return null;
|
|
14807
|
+
}
|
|
14808
|
+
deactivate(context) {
|
|
14809
|
+
const { stage } = this.pluginService;
|
|
14810
|
+
stage.removeEventListener('wheel', this.scroll);
|
|
14811
|
+
}
|
|
14812
|
+
};
|
|
14813
|
+
ScrollBarPlugin.defaultParams = {
|
|
14814
|
+
timeout: 500
|
|
14815
|
+
};
|
|
14816
|
+
ScrollBarPlugin = ScrollBarPlugin_1 = __decorate([
|
|
14817
|
+
injectable()
|
|
14818
|
+
], ScrollBarPlugin);
|
|
14819
|
+
|
|
14820
|
+
const scrollbarModule = new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
14821
|
+
if (!isBound(ScrollBarPlugin)) {
|
|
14822
|
+
bind(ScrollBarPlugin).toSelf();
|
|
14823
|
+
bind(AutoEnablePlugins).toService(ScrollBarPlugin);
|
|
14824
|
+
}
|
|
14825
|
+
});
|
|
14826
|
+
function loadScrollbar() {
|
|
14827
|
+
container.load(scrollbarModule);
|
|
14828
|
+
}
|
|
14829
|
+
|
|
14459
14830
|
function traverseGroup(group, cb) {
|
|
14460
14831
|
group.forEachChildren(node => {
|
|
14461
14832
|
const stopped = cb(node);
|
|
@@ -15807,19 +16178,22 @@ function bitmapTool(width, height, padding = { top: 0, left: 0, right: 0, bottom
|
|
|
15807
16178
|
scale.height = height;
|
|
15808
16179
|
return scale;
|
|
15809
16180
|
}
|
|
15810
|
-
function
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
|
|
15816
|
-
|
|
15817
|
-
|
|
15818
|
-
|
|
15819
|
-
|
|
15820
|
-
|
|
15821
|
-
|
|
15822
|
-
|
|
16181
|
+
function clampRangeByBitmap($, range) {
|
|
16182
|
+
const { x1, x2, y1, y2 } = range;
|
|
16183
|
+
const _x1 = clamp(x1, 0, $.width);
|
|
16184
|
+
const _x2 = clamp(x2, 0, $.width);
|
|
16185
|
+
const _y1 = clamp(y1, 0, $.height);
|
|
16186
|
+
const _y2 = clamp(y2, 0, $.height);
|
|
16187
|
+
return {
|
|
16188
|
+
x1: $.x(_x1),
|
|
16189
|
+
x2: $.x(_x2),
|
|
16190
|
+
y1: $.y(_y1),
|
|
16191
|
+
y2: $.y(_y2)
|
|
16192
|
+
};
|
|
16193
|
+
}
|
|
16194
|
+
function boundToRange($, bound, clamp = false) {
|
|
16195
|
+
if (clamp) {
|
|
16196
|
+
return clampRangeByBitmap($, bound);
|
|
15823
16197
|
}
|
|
15824
16198
|
return {
|
|
15825
16199
|
x1: $.x(bound.x1),
|
|
@@ -15840,10 +16214,13 @@ function canPlace($, bitmap, bound, checkBound = true, pad = 0) {
|
|
|
15840
16214
|
};
|
|
15841
16215
|
}
|
|
15842
16216
|
range = boundToRange($, range);
|
|
15843
|
-
const outOfBounds =
|
|
15844
|
-
if (outOfBounds) {
|
|
16217
|
+
const outOfBounds = bitmap.outOfBounds(range);
|
|
16218
|
+
if (checkBound && outOfBounds) {
|
|
15845
16219
|
return false;
|
|
15846
16220
|
}
|
|
16221
|
+
if (outOfBounds) {
|
|
16222
|
+
range = clampRangeByBitmap($, range);
|
|
16223
|
+
}
|
|
15847
16224
|
return !bitmap.getRange(range);
|
|
15848
16225
|
}
|
|
15849
16226
|
function placeToCandidates($, bitmap, text, candidates = [], clampForce = true, pad = 0) {
|
|
@@ -15907,24 +16284,29 @@ function defaultLabelPosition(type) {
|
|
|
15907
16284
|
return DefaultPositions;
|
|
15908
16285
|
}
|
|
15909
16286
|
}
|
|
15910
|
-
function clampText(text, width, height) {
|
|
16287
|
+
function clampText(text, width, height, padding = {}) {
|
|
15911
16288
|
const { x1, x2, y1, y2 } = text.AABBBounds;
|
|
16289
|
+
const { top = 0, left = 0, right = 0, bottom = 0 } = padding;
|
|
15912
16290
|
const minX = Math.min(x1, x2);
|
|
15913
16291
|
const maxX = Math.max(x1, x2);
|
|
15914
16292
|
const minY = Math.min(y1, y2);
|
|
15915
16293
|
const maxY = Math.max(y1, y2);
|
|
16294
|
+
const minXWithPadding = 0 - left;
|
|
16295
|
+
const maxXWithPadding = width + right;
|
|
16296
|
+
const minYWithPadding = 0 - top;
|
|
16297
|
+
const maxYWithPadding = height + bottom;
|
|
15916
16298
|
let dx = 0;
|
|
15917
16299
|
let dy = 0;
|
|
15918
|
-
if (minX <
|
|
16300
|
+
if (minX < minXWithPadding && maxX - minX <= width) {
|
|
15919
16301
|
dx = -minX;
|
|
15920
16302
|
}
|
|
15921
|
-
else if (maxX >
|
|
16303
|
+
else if (maxX > maxXWithPadding && minX - (maxX - width) >= minXWithPadding) {
|
|
15922
16304
|
dx = width - maxX;
|
|
15923
16305
|
}
|
|
15924
|
-
if (minY <
|
|
16306
|
+
if (minY < minYWithPadding && maxY - minY <= height) {
|
|
15925
16307
|
dy = -minY;
|
|
15926
16308
|
}
|
|
15927
|
-
else if (maxY >
|
|
16309
|
+
else if (maxY > maxYWithPadding && minY - (maxY - height) >= minYWithPadding) {
|
|
15928
16310
|
dy = height - maxY;
|
|
15929
16311
|
}
|
|
15930
16312
|
return { dx, dy };
|
|
@@ -16224,6 +16606,151 @@ function loadLabelComponent() {
|
|
|
16224
16606
|
registerLine();
|
|
16225
16607
|
}
|
|
16226
16608
|
|
|
16609
|
+
const isIntersect = (top, bottom) => {
|
|
16610
|
+
return Math.ceil(top) > Math.floor(bottom);
|
|
16611
|
+
};
|
|
16612
|
+
const isXIntersect = ([a, b], [c, d]) => {
|
|
16613
|
+
return d > a && b > c;
|
|
16614
|
+
};
|
|
16615
|
+
function getIntersectionLength(range1, range2) {
|
|
16616
|
+
const [start1, end1] = range1;
|
|
16617
|
+
const [start2, end2] = range2;
|
|
16618
|
+
const start = Math.max(start1, start2);
|
|
16619
|
+
const end = Math.min(end1, end2);
|
|
16620
|
+
return Math.max(0, end - start);
|
|
16621
|
+
}
|
|
16622
|
+
function shiftY(texts, option) {
|
|
16623
|
+
const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE, labelling } = option;
|
|
16624
|
+
const n = texts.length;
|
|
16625
|
+
if (n <= 1) {
|
|
16626
|
+
return texts;
|
|
16627
|
+
}
|
|
16628
|
+
const xMap = new Map();
|
|
16629
|
+
const textInformation = new Map();
|
|
16630
|
+
const getY1Initial = (text) => textInformation.get(text).y1Initial;
|
|
16631
|
+
const getHeight = (text) => textInformation.get(text).height;
|
|
16632
|
+
const getY1 = (text) => textInformation.get(text).y1;
|
|
16633
|
+
const getY = (text) => textInformation.get(text).y;
|
|
16634
|
+
const getX = (text) => textInformation.get(text).x;
|
|
16635
|
+
const getX1 = (text) => textInformation.get(text).x1;
|
|
16636
|
+
const getX2 = (text) => textInformation.get(text).x2;
|
|
16637
|
+
const setY1 = (text, y) => {
|
|
16638
|
+
textInformation.get(text).y1 = y;
|
|
16639
|
+
};
|
|
16640
|
+
function adjustPositionInOneGroup(texts) {
|
|
16641
|
+
if (texts.length === 1) {
|
|
16642
|
+
return;
|
|
16643
|
+
}
|
|
16644
|
+
for (let i = texts.length - 1; i > 0; i--) {
|
|
16645
|
+
const curText = texts[i];
|
|
16646
|
+
const upperText = texts[i - 1];
|
|
16647
|
+
const lowerText = texts[i + 1];
|
|
16648
|
+
if (isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText))) {
|
|
16649
|
+
const { y } = labelling(curText);
|
|
16650
|
+
if (!lowerText || !isIntersect(y + getHeight(curText) / 2, getY1(lowerText))) {
|
|
16651
|
+
if (y + getHeight(curText) / 2 <= maxY) {
|
|
16652
|
+
setY1(curText, getY1(curText) + y - getY(curText));
|
|
16653
|
+
}
|
|
16654
|
+
}
|
|
16655
|
+
}
|
|
16656
|
+
}
|
|
16657
|
+
}
|
|
16658
|
+
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
16659
|
+
for (const text of texts) {
|
|
16660
|
+
const { y1, y2, x1, x2 } = text.AABBBounds;
|
|
16661
|
+
const { x, y } = text.attribute;
|
|
16662
|
+
textInformation.set(text, { y1Initial: y1, y1, y2, y, height: y2 - y1, x1, x2, x });
|
|
16663
|
+
let hasRange = false;
|
|
16664
|
+
for (const [range, xGroupTexts] of xMap) {
|
|
16665
|
+
const { start, end } = range;
|
|
16666
|
+
if (x1 >= start && x2 <= end) {
|
|
16667
|
+
xGroupTexts.push(text);
|
|
16668
|
+
hasRange = true;
|
|
16669
|
+
}
|
|
16670
|
+
else if (isNumberClose(x, getX(xGroupTexts[0]), undefined, 5)) {
|
|
16671
|
+
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
16672
|
+
xGroupTexts.push(text);
|
|
16673
|
+
xMap.set(newRange, xGroupTexts);
|
|
16674
|
+
xMap.delete(range);
|
|
16675
|
+
hasRange = true;
|
|
16676
|
+
}
|
|
16677
|
+
else if (getIntersectionLength([start, end], [x1, x2]) / (end - start) > 0.5) {
|
|
16678
|
+
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
16679
|
+
xGroupTexts.push(text);
|
|
16680
|
+
xMap.set(newRange, xGroupTexts);
|
|
16681
|
+
xMap.delete(range);
|
|
16682
|
+
hasRange = true;
|
|
16683
|
+
}
|
|
16684
|
+
if (hasRange) {
|
|
16685
|
+
break;
|
|
16686
|
+
}
|
|
16687
|
+
}
|
|
16688
|
+
if (!hasRange) {
|
|
16689
|
+
xMap.set({ start: x1, end: x2 }, [text]);
|
|
16690
|
+
}
|
|
16691
|
+
}
|
|
16692
|
+
for (const xTexts of xMap.values()) {
|
|
16693
|
+
xTexts.sort((a, b) => getY1Initial(a) - getY1Initial(b));
|
|
16694
|
+
adjustPositionInOneGroup(xTexts);
|
|
16695
|
+
}
|
|
16696
|
+
for (let iter = 0; iter < maxIterations; iter++) {
|
|
16697
|
+
texts.sort((a, b) => getY1(a) - getY1(b));
|
|
16698
|
+
let error = 0;
|
|
16699
|
+
for (let i = 0; i < n - 1; i++) {
|
|
16700
|
+
const curText = texts[i];
|
|
16701
|
+
let j = i + 1;
|
|
16702
|
+
let nextText;
|
|
16703
|
+
while ((nextText = texts[j]) &&
|
|
16704
|
+
!isXIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
|
|
16705
|
+
j += 1;
|
|
16706
|
+
}
|
|
16707
|
+
if (nextText) {
|
|
16708
|
+
const y1 = getY1(curText);
|
|
16709
|
+
const h0 = getHeight(curText);
|
|
16710
|
+
const nextY1 = getY1(nextText);
|
|
16711
|
+
const delta = nextY1 - (y1 + h0);
|
|
16712
|
+
if (delta < padding) {
|
|
16713
|
+
const newDelta = (padding - delta) / 2;
|
|
16714
|
+
error = Math.max(error, newDelta);
|
|
16715
|
+
if (y1 + newDelta + getHeight(nextText) > maxY) {
|
|
16716
|
+
setY1(curText, y1 - (padding - delta));
|
|
16717
|
+
}
|
|
16718
|
+
else if (y1 - newDelta < 0) {
|
|
16719
|
+
setY1(nextText, nextY1 + (padding - delta));
|
|
16720
|
+
}
|
|
16721
|
+
else {
|
|
16722
|
+
setY1(curText, y1 - newDelta);
|
|
16723
|
+
setY1(nextText, nextY1 + newDelta);
|
|
16724
|
+
}
|
|
16725
|
+
}
|
|
16726
|
+
}
|
|
16727
|
+
}
|
|
16728
|
+
if (error < maxError) {
|
|
16729
|
+
break;
|
|
16730
|
+
}
|
|
16731
|
+
}
|
|
16732
|
+
for (const text of texts) {
|
|
16733
|
+
const finalY = text.attribute.y + getY1(text) - getY1Initial(text);
|
|
16734
|
+
text.setAttribute('y', finalY);
|
|
16735
|
+
}
|
|
16736
|
+
const result = [];
|
|
16737
|
+
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
16738
|
+
let start = 0;
|
|
16739
|
+
let end = texts.length - 1;
|
|
16740
|
+
while (start <= end) {
|
|
16741
|
+
if (start === end) {
|
|
16742
|
+
result.push(texts[start]);
|
|
16743
|
+
}
|
|
16744
|
+
else {
|
|
16745
|
+
result.push(texts[start]);
|
|
16746
|
+
result.push(texts[end]);
|
|
16747
|
+
}
|
|
16748
|
+
start++;
|
|
16749
|
+
end--;
|
|
16750
|
+
}
|
|
16751
|
+
return result;
|
|
16752
|
+
}
|
|
16753
|
+
|
|
16227
16754
|
loadLabelComponent();
|
|
16228
16755
|
class LabelBase extends AbstractComponent {
|
|
16229
16756
|
setBitmap(bitmap) {
|
|
@@ -16537,12 +17064,11 @@ class LabelBase extends AbstractComponent {
|
|
|
16537
17064
|
return texts;
|
|
16538
17065
|
}
|
|
16539
17066
|
_overlapping(labels) {
|
|
16540
|
-
var _a, _b, _c
|
|
17067
|
+
var _a, _b, _c;
|
|
16541
17068
|
if (labels.length === 0) {
|
|
16542
17069
|
return [];
|
|
16543
17070
|
}
|
|
16544
17071
|
const option = (isObject(this.attribute.overlap) ? this.attribute.overlap : {});
|
|
16545
|
-
const result = [];
|
|
16546
17072
|
const baseMarkGroup = this.getBaseMarkGroup();
|
|
16547
17073
|
const size = (_a = option.size) !== null && _a !== void 0 ? _a : {
|
|
16548
17074
|
width: (_b = baseMarkGroup === null || baseMarkGroup === void 0 ? void 0 : baseMarkGroup.AABBBounds.width()) !== null && _b !== void 0 ? _b : 0,
|
|
@@ -16551,12 +17077,62 @@ class LabelBase extends AbstractComponent {
|
|
|
16551
17077
|
if (size.width === 0 || size.height === 0) {
|
|
16552
17078
|
return labels;
|
|
16553
17079
|
}
|
|
16554
|
-
const {
|
|
17080
|
+
const { strategy, priority } = option;
|
|
16555
17081
|
const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);
|
|
16556
17082
|
const bitmap = this._bitmap || bmpTool.bitmap();
|
|
17083
|
+
if (priority) {
|
|
17084
|
+
labels = labels.sort((a, b) => priority(b.attribute.data) - priority(a.attribute.data));
|
|
17085
|
+
}
|
|
17086
|
+
if ((strategy === null || strategy === void 0 ? void 0 : strategy.type) === 'shiftY') {
|
|
17087
|
+
return this._overlapGlobal(labels, option, bmpTool, bitmap);
|
|
17088
|
+
}
|
|
17089
|
+
return this._overlapByStrategy(labels, option, bmpTool, bitmap);
|
|
17090
|
+
}
|
|
17091
|
+
_overlapGlobal(labels, option, bmpTool, bitmap) {
|
|
17092
|
+
let result = labels.filter(label => label.attribute.visible && label.attribute.opacity !== 0);
|
|
17093
|
+
const { clampForce = true, hideOnHit = true, overlapPadding, strategy } = option;
|
|
17094
|
+
if (clampForce) {
|
|
17095
|
+
for (let i = 0; i < result.length; i++) {
|
|
17096
|
+
const text = labels[i];
|
|
17097
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
17098
|
+
if (dx !== 0 || dy !== 0) {
|
|
17099
|
+
text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
|
|
17100
|
+
text._isClamped = true;
|
|
17101
|
+
}
|
|
17102
|
+
}
|
|
17103
|
+
}
|
|
17104
|
+
result = shiftY(result, Object.assign(Object.assign({ maxY: bmpTool.height }, strategy), { labelling: (text) => {
|
|
17105
|
+
const baseMark = this.getRelatedGraphic(text.attribute);
|
|
17106
|
+
const graphicBound = this._isCollectionBase
|
|
17107
|
+
? this.getGraphicBounds(null, this._idToPoint.get(text.attribute.id))
|
|
17108
|
+
: this.getGraphicBounds(baseMark, text);
|
|
17109
|
+
return this.labeling(text.AABBBounds, graphicBound, 'bottom', this.attribute.offset);
|
|
17110
|
+
} }));
|
|
17111
|
+
for (let i = 0; i < result.length; i++) {
|
|
17112
|
+
const text = result[i];
|
|
17113
|
+
const bounds = text.AABBBounds;
|
|
17114
|
+
const range = boundToRange(bmpTool, bounds, true);
|
|
17115
|
+
if (canPlace(bmpTool, bitmap, bounds, clampForce, text._isClamped ? 0 : overlapPadding)) {
|
|
17116
|
+
bitmap.setRange(range);
|
|
17117
|
+
}
|
|
17118
|
+
else {
|
|
17119
|
+
if (hideOnHit) {
|
|
17120
|
+
text.setAttributes({ visible: false });
|
|
17121
|
+
}
|
|
17122
|
+
else {
|
|
17123
|
+
bitmap.setRange(range);
|
|
17124
|
+
}
|
|
17125
|
+
}
|
|
17126
|
+
}
|
|
17127
|
+
return result;
|
|
17128
|
+
}
|
|
17129
|
+
_overlapByStrategy(labels, option, bmpTool, bitmap) {
|
|
17130
|
+
var _a;
|
|
17131
|
+
const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [], overlapPadding } = option;
|
|
17132
|
+
const result = [];
|
|
16557
17133
|
const checkBounds = strategy.some(s => s.type === 'bound');
|
|
16558
17134
|
if (avoidBaseMark) {
|
|
16559
|
-
(
|
|
17135
|
+
(_a = this._baseMarks) === null || _a === void 0 ? void 0 : _a.forEach(mark => {
|
|
16560
17136
|
mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, true));
|
|
16561
17137
|
});
|
|
16562
17138
|
}
|
|
@@ -16573,7 +17149,7 @@ class LabelBase extends AbstractComponent {
|
|
|
16573
17149
|
});
|
|
16574
17150
|
}
|
|
16575
17151
|
for (let i = 0; i < labels.length; i++) {
|
|
16576
|
-
if (labels[i].visible === false) {
|
|
17152
|
+
if (labels[i].attribute.visible === false) {
|
|
16577
17153
|
continue;
|
|
16578
17154
|
}
|
|
16579
17155
|
const text = labels[i];
|
|
@@ -16609,7 +17185,7 @@ class LabelBase extends AbstractComponent {
|
|
|
16609
17185
|
}
|
|
16610
17186
|
}
|
|
16611
17187
|
if (!hasPlace && clampForce) {
|
|
16612
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
17188
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
16613
17189
|
if (dx === 0 && dy === 0) {
|
|
16614
17190
|
if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
|
|
16615
17191
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
|
|
@@ -16840,7 +17416,7 @@ class LabelBase extends AbstractComponent {
|
|
|
16840
17416
|
return listener;
|
|
16841
17417
|
}
|
|
16842
17418
|
_smartInvert(labels) {
|
|
16843
|
-
var _a, _b, _c, _d, _e;
|
|
17419
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
16844
17420
|
const option = (isObject(this.attribute.smartInvert) ? this.attribute.smartInvert : {});
|
|
16845
17421
|
const { textType, contrastRatiosThreshold, alternativeColors, mode, interactInvertType } = option;
|
|
16846
17422
|
const fillStrategy = (_a = option.fillStrategy) !== null && _a !== void 0 ? _a : 'invertBase';
|
|
@@ -16857,8 +17433,15 @@ class LabelBase extends AbstractComponent {
|
|
|
16857
17433
|
continue;
|
|
16858
17434
|
}
|
|
16859
17435
|
const baseMark = this.getRelatedGraphic(label.attribute);
|
|
16860
|
-
|
|
16861
|
-
|
|
17436
|
+
let backgroundColor = baseMark.attribute.fill;
|
|
17437
|
+
let foregroundColor = label.attribute.fill;
|
|
17438
|
+
if (isObject(backgroundColor) && backgroundColor.gradient) {
|
|
17439
|
+
const firstStopColor = (_g = (_f = backgroundColor.stops) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.color;
|
|
17440
|
+
if (firstStopColor) {
|
|
17441
|
+
backgroundColor = firstStopColor;
|
|
17442
|
+
foregroundColor = firstStopColor;
|
|
17443
|
+
}
|
|
17444
|
+
}
|
|
16862
17445
|
const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode);
|
|
16863
17446
|
const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
|
|
16864
17447
|
const isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds);
|
|
@@ -17086,6 +17669,9 @@ class ArcLabel extends LabelBase {
|
|
|
17086
17669
|
this._alignOffset = 0;
|
|
17087
17670
|
}
|
|
17088
17671
|
_overlapping(labels) {
|
|
17672
|
+
if (['inside', 'inside-center'].includes(this.attribute.position)) {
|
|
17673
|
+
return super._overlapping(labels);
|
|
17674
|
+
}
|
|
17089
17675
|
return labels;
|
|
17090
17676
|
}
|
|
17091
17677
|
labeling(textBounds, graphicBounds, position = 'outside', offset = 0) {
|
|
@@ -18902,12 +19488,14 @@ function autoHide(labels, config) {
|
|
|
18902
19488
|
do {
|
|
18903
19489
|
items = reduce(items, sep);
|
|
18904
19490
|
} while (items.length >= 3 && hasOverlap(items, sep));
|
|
18905
|
-
const shouldCheck = (length, visibility
|
|
18906
|
-
|
|
19491
|
+
const shouldCheck = (length, visibility, checkLength = true) => {
|
|
19492
|
+
return checkLength ? length < 3 || visibility : visibility;
|
|
19493
|
+
};
|
|
19494
|
+
const checkFirst = shouldCheck(items.length, config.firstVisible, false);
|
|
18907
19495
|
let checkLast = shouldCheck(items.length, config.lastVisible);
|
|
18908
19496
|
const firstSourceItem = source[0];
|
|
18909
19497
|
const lastSourceItem = last(source);
|
|
18910
|
-
if (textIntersect(firstSourceItem, lastSourceItem, sep)) {
|
|
19498
|
+
if (textIntersect(firstSourceItem, lastSourceItem, sep) && checkFirst && checkLast) {
|
|
18911
19499
|
lastSourceItem.setAttribute('opacity', 0);
|
|
18912
19500
|
checkLast = false;
|
|
18913
19501
|
}
|
|
@@ -19105,15 +19693,24 @@ function autoLimit(labels, config) {
|
|
|
19105
19693
|
return;
|
|
19106
19694
|
}
|
|
19107
19695
|
const overflowLimitLength = normalizeOverflowLimitLength(config.overflowLimitLength);
|
|
19696
|
+
const firstLabel = labels[0];
|
|
19697
|
+
const angle = firstLabel.attribute.angle;
|
|
19698
|
+
const hasAngle = !isNil(angle);
|
|
19699
|
+
const cos = hasAngle ? Math.cos(angle) : 1;
|
|
19700
|
+
const sin = hasAngle ? Math.sin(angle) : 0;
|
|
19701
|
+
const isHorizontal = isAngleHorizontal(angle);
|
|
19702
|
+
const isVertical = isAngleVertical(angle);
|
|
19703
|
+
const isX = orient === 'top' || orient === 'bottom';
|
|
19704
|
+
const direction = firstLabel.attribute.direction;
|
|
19705
|
+
const THRESHOLD = 2;
|
|
19706
|
+
const checkBox = !isHorizontal &&
|
|
19707
|
+
!isVertical &&
|
|
19708
|
+
isX &&
|
|
19709
|
+
(labels.length < 2 ||
|
|
19710
|
+
labels.some(label => Math.abs(label.AABBBounds.width() - firstLabel.AABBBounds.width()) >= THRESHOLD)) &&
|
|
19711
|
+
firstLabel.AABBBounds.width() > Math.abs(limitLength / sin);
|
|
19108
19712
|
labels.forEach(label => {
|
|
19109
19713
|
var _a;
|
|
19110
|
-
const angle = label.attribute.angle;
|
|
19111
|
-
const hasAngle = !isNil(angle);
|
|
19112
|
-
const cos = hasAngle ? Math.cos(angle) : 1;
|
|
19113
|
-
const sin = hasAngle ? Math.sin(angle) : 0;
|
|
19114
|
-
const isHorizontal = isAngleHorizontal(angle);
|
|
19115
|
-
const isVertical = isAngleVertical(angle);
|
|
19116
|
-
const isX = orient === 'top' || orient === 'bottom';
|
|
19117
19714
|
if (isX) {
|
|
19118
19715
|
if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {
|
|
19119
19716
|
return;
|
|
@@ -19122,7 +19719,6 @@ function autoLimit(labels, config) {
|
|
|
19122
19719
|
return;
|
|
19123
19720
|
}
|
|
19124
19721
|
}
|
|
19125
|
-
const direction = label.attribute.direction;
|
|
19126
19722
|
if (!isX) {
|
|
19127
19723
|
if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {
|
|
19128
19724
|
return;
|
|
@@ -19142,12 +19738,18 @@ function autoLimit(labels, config) {
|
|
|
19142
19738
|
const { x1, x2 } = label.AABBBounds;
|
|
19143
19739
|
const tan = sin / cos;
|
|
19144
19740
|
const verticalSizeLimit = Math.abs(limitLength / sin);
|
|
19145
|
-
if (
|
|
19146
|
-
|
|
19741
|
+
if (checkBox &&
|
|
19742
|
+
tan > 0 &&
|
|
19743
|
+
x1 <= axisLength + overflowLimitLength.right &&
|
|
19744
|
+
limitLength / tan + x1 > axisLength + overflowLimitLength.right) {
|
|
19745
|
+
const lengthLimit = (axisLength - x1 + overflowLimitLength.right) / Math.abs(cos);
|
|
19147
19746
|
limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
|
|
19148
19747
|
}
|
|
19149
|
-
else if (
|
|
19150
|
-
|
|
19748
|
+
else if (checkBox &&
|
|
19749
|
+
tan < 0 &&
|
|
19750
|
+
x2 >= -overflowLimitLength.left &&
|
|
19751
|
+
limitLength / tan + x2 < -overflowLimitLength.left) {
|
|
19752
|
+
const lengthLimit = (x2 + overflowLimitLength.left) / Math.abs(cos);
|
|
19151
19753
|
limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
|
|
19152
19754
|
}
|
|
19153
19755
|
else {
|
|
@@ -19181,24 +19783,37 @@ function autoWrap(labels, config) {
|
|
|
19181
19783
|
if (isEmpty(labels) || !isValidNumber(limitLength)) {
|
|
19182
19784
|
return;
|
|
19183
19785
|
}
|
|
19184
|
-
const
|
|
19185
|
-
|
|
19186
|
-
|
|
19187
|
-
|
|
19188
|
-
|
|
19189
|
-
|
|
19190
|
-
|
|
19786
|
+
const firstLabel = labels[0];
|
|
19787
|
+
const angle = firstLabel.attribute.angle;
|
|
19788
|
+
const isHorizontal = isAngleHorizontal(angle);
|
|
19789
|
+
const isVertical = isAngleVertical(angle);
|
|
19790
|
+
const isX = orient === 'top' || orient === 'bottom';
|
|
19791
|
+
let verticalLimitLength = axisLength / labels.length;
|
|
19792
|
+
labels.forEach((label, index) => {
|
|
19793
|
+
var _a, _b, _c, _d, _e;
|
|
19191
19794
|
if (isX) {
|
|
19192
19795
|
if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {
|
|
19193
19796
|
return;
|
|
19194
19797
|
}
|
|
19195
|
-
if (isHorizontal
|
|
19196
|
-
|
|
19798
|
+
if (isHorizontal) {
|
|
19799
|
+
const curLabelX = label.attribute.x;
|
|
19800
|
+
const nextLabelX = (_a = labels[index + 1]) === null || _a === void 0 ? void 0 : _a.attribute.x;
|
|
19801
|
+
const lastLabelX = (_b = labels[index - 1]) === null || _b === void 0 ? void 0 : _b.attribute.x;
|
|
19802
|
+
const minGap = getLabelMinGap(curLabelX, nextLabelX, lastLabelX);
|
|
19803
|
+
if (isValidNumber(minGap)) {
|
|
19804
|
+
verticalLimitLength = min(verticalLimitLength, minGap);
|
|
19805
|
+
}
|
|
19197
19806
|
}
|
|
19198
19807
|
}
|
|
19199
19808
|
else {
|
|
19200
|
-
if (isVertical
|
|
19201
|
-
|
|
19809
|
+
if (isVertical) {
|
|
19810
|
+
const curLabelY = label.attribute.y;
|
|
19811
|
+
const nextLabelY = (_c = labels[index + 1]) === null || _c === void 0 ? void 0 : _c.attribute.y;
|
|
19812
|
+
const lastLabelY = (_d = labels[index - 1]) === null || _d === void 0 ? void 0 : _d.attribute.y;
|
|
19813
|
+
const minGap = getLabelMinGap(curLabelY, nextLabelY, lastLabelY);
|
|
19814
|
+
if (isValidNumber(minGap)) {
|
|
19815
|
+
verticalLimitLength = min(verticalLimitLength, minGap);
|
|
19816
|
+
}
|
|
19202
19817
|
}
|
|
19203
19818
|
if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {
|
|
19204
19819
|
return;
|
|
@@ -19228,12 +19843,27 @@ function autoWrap(labels, config) {
|
|
|
19228
19843
|
}
|
|
19229
19844
|
label.setAttributes({
|
|
19230
19845
|
maxLineWidth: limitLabelLength,
|
|
19231
|
-
ellipsis: (
|
|
19846
|
+
ellipsis: (_e = label.attribute.ellipsis) !== null && _e !== void 0 ? _e : ellipsis,
|
|
19232
19847
|
whiteSpace: 'normal',
|
|
19233
19848
|
heightLimit
|
|
19234
19849
|
});
|
|
19235
19850
|
});
|
|
19236
19851
|
}
|
|
19852
|
+
function getLabelMinGap(current, next, prev) {
|
|
19853
|
+
let minGap;
|
|
19854
|
+
if (isValidNumber(next)) {
|
|
19855
|
+
minGap = Math.abs(next - current);
|
|
19856
|
+
}
|
|
19857
|
+
if (isValidNumber(prev)) {
|
|
19858
|
+
if (isValidNumber(minGap)) {
|
|
19859
|
+
minGap = Math.min(Math.abs(current - prev), minGap);
|
|
19860
|
+
}
|
|
19861
|
+
else {
|
|
19862
|
+
minGap = Math.abs(current - prev);
|
|
19863
|
+
}
|
|
19864
|
+
}
|
|
19865
|
+
return minGap;
|
|
19866
|
+
}
|
|
19237
19867
|
|
|
19238
19868
|
function alignAxisLabels(labels, start, containerSize, orient, align) {
|
|
19239
19869
|
if (orient === 'left' || orient === 'right') {
|
|
@@ -20056,13 +20686,13 @@ class CircleAxis extends AxisBase {
|
|
|
20056
20686
|
if (isEmpty(labelShapes)) {
|
|
20057
20687
|
return;
|
|
20058
20688
|
}
|
|
20059
|
-
const { inside, radius, center,
|
|
20060
|
-
const bounds =
|
|
20689
|
+
const { inside, radius, center, size, label, orient } = this.attribute;
|
|
20690
|
+
const bounds = size
|
|
20061
20691
|
? {
|
|
20062
20692
|
x1: 0,
|
|
20063
20693
|
y1: 0,
|
|
20064
|
-
x2: width,
|
|
20065
|
-
y2: height
|
|
20694
|
+
x2: size.width,
|
|
20695
|
+
y2: size.height
|
|
20066
20696
|
}
|
|
20067
20697
|
: {
|
|
20068
20698
|
x1: center.x - radius,
|
|
@@ -20430,11 +21060,10 @@ const continuousTicks = (scale, op) => {
|
|
|
20430
21060
|
while (items.length >= 3 && hasOverlap(items, labelGap)) {
|
|
20431
21061
|
items = samplingMethod(items, labelGap);
|
|
20432
21062
|
}
|
|
20433
|
-
const
|
|
20434
|
-
|
|
20435
|
-
let checkLast = shouldCheck(items.length, op.labelLastVisible);
|
|
21063
|
+
const checkFirst = op.labelFirstVisible;
|
|
21064
|
+
let checkLast = op.labelLastVisible;
|
|
20436
21065
|
if (textIntersect(firstSourceItem, lastSourceItem, labelGap)) {
|
|
20437
|
-
if (items.includes(lastSourceItem) && items.length > 1) {
|
|
21066
|
+
if (items.includes(lastSourceItem) && items.length > 1 && checkFirst && checkLast) {
|
|
20438
21067
|
items.splice(items.indexOf(lastSourceItem), 1);
|
|
20439
21068
|
checkLast = false;
|
|
20440
21069
|
}
|
|
@@ -24171,10 +24800,10 @@ class LegendBase extends AbstractComponent {
|
|
|
24171
24800
|
render() {
|
|
24172
24801
|
this.removeAllChild(true);
|
|
24173
24802
|
const { interactive = true, title, padding = 0 } = this.attribute;
|
|
24174
|
-
|
|
24803
|
+
this._parsedPadding = normalizePadding(padding);
|
|
24175
24804
|
const innerView = graphicCreator.group({
|
|
24176
|
-
x:
|
|
24177
|
-
y:
|
|
24805
|
+
x: this._parsedPadding[3],
|
|
24806
|
+
y: this._parsedPadding[0],
|
|
24178
24807
|
pickable: interactive,
|
|
24179
24808
|
childrenPickable: interactive
|
|
24180
24809
|
});
|
|
@@ -24190,8 +24819,8 @@ class LegendBase extends AbstractComponent {
|
|
|
24190
24819
|
this._bindEvents();
|
|
24191
24820
|
}
|
|
24192
24821
|
const viewBounds = this._innerView.AABBBounds;
|
|
24193
|
-
this.attribute.width = viewBounds.width() +
|
|
24194
|
-
this.attribute.height = viewBounds.height() +
|
|
24822
|
+
this.attribute.width = viewBounds.width() + this._parsedPadding[1] + this._parsedPadding[3];
|
|
24823
|
+
this.attribute.height = viewBounds.height() + this._parsedPadding[0] + this._parsedPadding[2];
|
|
24195
24824
|
}
|
|
24196
24825
|
_renderTitle(title) {
|
|
24197
24826
|
const { text = '', textStyle, padding = 0, background, minWidth, maxWidth, shape } = title;
|
|
@@ -24276,6 +24905,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
24276
24905
|
this._itemHeightByUser = undefined;
|
|
24277
24906
|
this._itemHeight = 0;
|
|
24278
24907
|
this._itemMaxWidth = 0;
|
|
24908
|
+
this._contentMaxHeight = 0;
|
|
24279
24909
|
this._onHover = (e) => {
|
|
24280
24910
|
const target = e.target;
|
|
24281
24911
|
if (target && target.name && target.name.startsWith(LEGEND_ELEMENT_NAME.item)) {
|
|
@@ -24380,11 +25010,12 @@ class DiscreteLegend extends LegendBase {
|
|
|
24380
25010
|
});
|
|
24381
25011
|
}
|
|
24382
25012
|
_renderItems() {
|
|
24383
|
-
const { item: itemAttrs = {}, maxCol = 1, maxRow = 2, maxWidth,
|
|
25013
|
+
const { item: itemAttrs = {}, maxCol = 1, maxRow = 2, maxWidth, defaultSelected, lazyload, autoPage } = this.attribute;
|
|
24384
25014
|
const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = itemAttrs;
|
|
24385
25015
|
const itemsContainer = this._itemsContainer;
|
|
24386
25016
|
const { items: legendItems, isHorizontal, startIndex, isScrollbar } = this._itemContext;
|
|
24387
25017
|
const maxPages = isScrollbar ? 1 : isHorizontal ? maxRow : maxCol;
|
|
25018
|
+
const maxHeight = this._contentMaxHeight;
|
|
24388
25019
|
let { doWrap, maxWidthInCol, startX, startY, pages } = this._itemContext;
|
|
24389
25020
|
let item;
|
|
24390
25021
|
let lastItemWidth = 0;
|
|
@@ -24481,7 +25112,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
24481
25112
|
return this._itemContext;
|
|
24482
25113
|
}
|
|
24483
25114
|
_renderContent() {
|
|
24484
|
-
const { item = {}, items, reversed, maxWidth } = this.attribute;
|
|
25115
|
+
const { item = {}, items, reversed, maxWidth, maxHeight } = this.attribute;
|
|
24485
25116
|
if (item.visible === false || isEmpty(items)) {
|
|
24486
25117
|
return;
|
|
24487
25118
|
}
|
|
@@ -24489,6 +25120,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
24489
25120
|
if (reversed) {
|
|
24490
25121
|
legendItems = items === null || items === void 0 ? void 0 : items.reverse();
|
|
24491
25122
|
}
|
|
25123
|
+
this._contentMaxHeight = Math.max(0, maxHeight - this._parsedPadding[0] - this._parsedPadding[2]);
|
|
24492
25124
|
const itemsContainer = graphicCreator.group({
|
|
24493
25125
|
x: 0,
|
|
24494
25126
|
y: 0
|
|
@@ -24526,7 +25158,8 @@ class DiscreteLegend extends LegendBase {
|
|
|
24526
25158
|
items: legendItems,
|
|
24527
25159
|
isHorizontal,
|
|
24528
25160
|
totalPage: Infinity,
|
|
24529
|
-
isScrollbar: pager && pager.type === 'scrollbar'
|
|
25161
|
+
isScrollbar: pager && pager.type === 'scrollbar',
|
|
25162
|
+
clipContainer: undefined
|
|
24530
25163
|
};
|
|
24531
25164
|
this._itemContext = this._renderItems();
|
|
24532
25165
|
let pagerRendered = false;
|
|
@@ -24547,11 +25180,21 @@ class DiscreteLegend extends LegendBase {
|
|
|
24547
25180
|
}
|
|
24548
25181
|
const { hover = true, select = true } = this.attribute;
|
|
24549
25182
|
if (hover) {
|
|
24550
|
-
|
|
24551
|
-
|
|
25183
|
+
let trigger = 'pointermove';
|
|
25184
|
+
let triggerOff = 'pointerleave';
|
|
25185
|
+
if (isObject(hover)) {
|
|
25186
|
+
hover.trigger && (trigger = hover.trigger);
|
|
25187
|
+
hover.triggerOff && (triggerOff = hover.triggerOff);
|
|
25188
|
+
}
|
|
25189
|
+
this._itemsContainer.addEventListener(trigger, this._onHover);
|
|
25190
|
+
this._itemsContainer.addEventListener(triggerOff, this._onUnHover);
|
|
24552
25191
|
}
|
|
24553
25192
|
if (select) {
|
|
24554
|
-
|
|
25193
|
+
let trigger = 'pointerdown';
|
|
25194
|
+
if (isObject(select) && select.trigger) {
|
|
25195
|
+
trigger = select.trigger;
|
|
25196
|
+
}
|
|
25197
|
+
this._itemsContainer.addEventListener(trigger, this._onClick);
|
|
24555
25198
|
}
|
|
24556
25199
|
}
|
|
24557
25200
|
_autoEllipsis(autoEllipsisStrategy, layoutWidth, labelShape, valueShape) {
|
|
@@ -24756,8 +25399,8 @@ class DiscreteLegend extends LegendBase {
|
|
|
24756
25399
|
_createScrollbar(compStyle, compSize) {
|
|
24757
25400
|
const { disableTriggerEvent } = this.attribute;
|
|
24758
25401
|
return this._itemContext.isHorizontal
|
|
24759
|
-
? new ScrollBar(Object.assign(Object.assign({ direction: 'horizontal', disableTriggerEvent, range: [0, 0.5], height: 12 }, compStyle), { width: compSize }))
|
|
24760
|
-
: new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
|
|
25402
|
+
? new ScrollBar(Object.assign(Object.assign({ direction: 'horizontal', disableTriggerEvent, range: [0, 0.5], height: compStyle.visible === false ? 0 : 12 }, compStyle), { width: compSize }))
|
|
25403
|
+
: new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: compStyle.visible === false ? 0 : 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
|
|
24761
25404
|
}
|
|
24762
25405
|
_updatePositionOfPager(renderStartY, compWidth, compHeight) {
|
|
24763
25406
|
const { pager } = this.attribute;
|
|
@@ -24797,9 +25440,26 @@ class DiscreteLegend extends LegendBase {
|
|
|
24797
25440
|
});
|
|
24798
25441
|
}
|
|
24799
25442
|
}
|
|
25443
|
+
_computeScrollbarDelta() {
|
|
25444
|
+
const { isHorizontal, clipContainer } = this._itemContext;
|
|
25445
|
+
const itemContainerBounds = this._itemsContainer.AABBBounds;
|
|
25446
|
+
const clipContainerBounds = clipContainer.AABBBounds;
|
|
25447
|
+
let delta;
|
|
25448
|
+
let innerViewSize;
|
|
25449
|
+
if (isHorizontal) {
|
|
25450
|
+
innerViewSize = clipContainerBounds.width();
|
|
25451
|
+
delta = innerViewSize / itemContainerBounds.width();
|
|
25452
|
+
}
|
|
25453
|
+
else {
|
|
25454
|
+
innerViewSize = clipContainerBounds.height();
|
|
25455
|
+
delta = innerViewSize / itemContainerBounds.height();
|
|
25456
|
+
}
|
|
25457
|
+
return delta;
|
|
25458
|
+
}
|
|
24800
25459
|
_updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY) {
|
|
24801
|
-
const { currentPage, totalPage
|
|
24802
|
-
|
|
25460
|
+
const { isHorizontal, currentPage, totalPage } = this._itemContext;
|
|
25461
|
+
const start = (currentPage - 1) / totalPage;
|
|
25462
|
+
this._pagerComponent.setScrollRange([start, start + this._computeScrollbarDelta()]);
|
|
24803
25463
|
if (isHorizontal) {
|
|
24804
25464
|
this._pagerComponent.setAttributes({
|
|
24805
25465
|
x: 0,
|
|
@@ -24827,13 +25487,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
24827
25487
|
newPage = this._itemContext.totalPage;
|
|
24828
25488
|
}
|
|
24829
25489
|
else {
|
|
24830
|
-
newPage = value[0] * this._itemContext.totalPage;
|
|
24831
|
-
if (pager.scrollByPosition) {
|
|
24832
|
-
newPage = newPage + 1;
|
|
24833
|
-
}
|
|
24834
|
-
else {
|
|
24835
|
-
newPage = Math.floor(newPage) + 1;
|
|
24836
|
-
}
|
|
25490
|
+
newPage = value[0] * this._itemContext.totalPage + 1;
|
|
24837
25491
|
}
|
|
24838
25492
|
return newPage;
|
|
24839
25493
|
}
|
|
@@ -24847,6 +25501,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
24847
25501
|
const { width, height } = scrollComponent.getSliderRenderBounds();
|
|
24848
25502
|
const currentScrollValue = direction === 'vertical' ? e.deltaY / height : e.deltaX / width;
|
|
24849
25503
|
scrollComponent.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);
|
|
25504
|
+
this.updateScrollMask();
|
|
24850
25505
|
};
|
|
24851
25506
|
const onPaging = (e) => {
|
|
24852
25507
|
const newPage = pageParser(e);
|
|
@@ -24858,15 +25513,39 @@ class DiscreteLegend extends LegendBase {
|
|
|
24858
25513
|
this._renderItems();
|
|
24859
25514
|
const newTotalPage = Math.ceil(this._itemContext.pages / this._itemContext.maxPages);
|
|
24860
25515
|
this._itemContext.totalPage = newTotalPage;
|
|
24861
|
-
this.
|
|
25516
|
+
if (this._itemContext.isScrollbar && this._pagerComponent) {
|
|
25517
|
+
const newDelta = this._computeScrollbarDelta();
|
|
25518
|
+
const [start] = this._pagerComponent.getScrollRange();
|
|
25519
|
+
this._pagerComponent.setScrollRange([start, start + newDelta]);
|
|
25520
|
+
}
|
|
24862
25521
|
}
|
|
24863
|
-
if (
|
|
24864
|
-
|
|
24865
|
-
.
|
|
24866
|
-
|
|
25522
|
+
if (!this._itemContext.isScrollbar) {
|
|
25523
|
+
if (animation) {
|
|
25524
|
+
this._itemsContainer
|
|
25525
|
+
.animate()
|
|
25526
|
+
.to({ [channel]: -(newPage - 1) * pageSize }, animationDuration, animationEasing);
|
|
25527
|
+
}
|
|
25528
|
+
else {
|
|
25529
|
+
this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
|
|
25530
|
+
}
|
|
24867
25531
|
}
|
|
24868
25532
|
else {
|
|
24869
|
-
this.
|
|
25533
|
+
const [start] = this._pagerComponent.getScrollRange();
|
|
25534
|
+
let containerSize;
|
|
25535
|
+
if (this._itemContext.isHorizontal) {
|
|
25536
|
+
containerSize = this._itemsContainer.AABBBounds.width();
|
|
25537
|
+
}
|
|
25538
|
+
else {
|
|
25539
|
+
containerSize = this._itemsContainer.AABBBounds.height();
|
|
25540
|
+
}
|
|
25541
|
+
const startOffset = containerSize * start;
|
|
25542
|
+
this.updateScrollMask();
|
|
25543
|
+
if (animation) {
|
|
25544
|
+
this._itemsContainer.animate().to({ [channel]: -startOffset }, animationDuration, animationEasing);
|
|
25545
|
+
}
|
|
25546
|
+
else {
|
|
25547
|
+
this._itemsContainer.setAttribute(channel, -startOffset);
|
|
25548
|
+
}
|
|
24870
25549
|
}
|
|
24871
25550
|
};
|
|
24872
25551
|
if (this._itemContext.isScrollbar) {
|
|
@@ -24885,11 +25564,12 @@ class DiscreteLegend extends LegendBase {
|
|
|
24885
25564
|
}
|
|
24886
25565
|
_renderPager() {
|
|
24887
25566
|
const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, 'title.space', 8) : 0;
|
|
24888
|
-
const { maxWidth,
|
|
25567
|
+
const { maxWidth, maxCol = 1, maxRow = 2, item = {}, pager = {} } = this.attribute;
|
|
24889
25568
|
const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = item;
|
|
24890
25569
|
const itemsContainer = this._itemsContainer;
|
|
24891
25570
|
const { space: pagerSpace = DEFAULT_PAGER_SPACE, defaultCurrent = 1 } = pager, compStyle = __rest(pager, ["space", "defaultCurrent"]);
|
|
24892
25571
|
const { isHorizontal } = this._itemContext;
|
|
25572
|
+
const maxHeight = this._contentMaxHeight;
|
|
24893
25573
|
let comp;
|
|
24894
25574
|
let compWidth = 0;
|
|
24895
25575
|
let compHeight = 0;
|
|
@@ -24980,57 +25660,76 @@ class DiscreteLegend extends LegendBase {
|
|
|
24980
25660
|
});
|
|
24981
25661
|
clipGroup.add(itemsContainer);
|
|
24982
25662
|
this._innerView.add(clipGroup);
|
|
25663
|
+
this._itemContext.clipContainer = clipGroup;
|
|
24983
25664
|
this._bindEventsOfPager(isHorizontal ? compHeight + spaceRow : compWidth + spaceCol, isHorizontal ? 'y' : 'x');
|
|
24984
25665
|
return true;
|
|
24985
25666
|
}
|
|
24986
25667
|
_renderScrollbar() {
|
|
25668
|
+
var _a;
|
|
24987
25669
|
const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, 'title.space', 8) : 0;
|
|
24988
|
-
const { maxWidth,
|
|
25670
|
+
const { maxWidth, item = {}, pager = {} } = this.attribute;
|
|
24989
25671
|
const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = item;
|
|
24990
25672
|
const itemsContainer = this._itemsContainer;
|
|
24991
25673
|
const { space: pagerSpace = DEFAULT_PAGER_SPACE, defaultCurrent = 1 } = pager, compStyle = __rest(pager, ["space", "defaultCurrent"]);
|
|
24992
25674
|
const { isHorizontal } = this._itemContext;
|
|
25675
|
+
const maxHeight = this._contentMaxHeight;
|
|
24993
25676
|
let comp;
|
|
24994
|
-
let compSize = 0;
|
|
24995
25677
|
let contentWidth = 0;
|
|
24996
25678
|
let contentHeight = 0;
|
|
24997
25679
|
let startY = 0;
|
|
24998
25680
|
let pages = 1;
|
|
24999
25681
|
if (isHorizontal) {
|
|
25000
|
-
compSize = maxWidth;
|
|
25001
25682
|
contentWidth = maxWidth;
|
|
25002
25683
|
contentHeight = this._itemHeight;
|
|
25003
|
-
comp = this._createScrollbar(compStyle,
|
|
25684
|
+
comp = this._createScrollbar(compStyle, contentWidth);
|
|
25004
25685
|
this._pagerComponent = comp;
|
|
25005
25686
|
this._innerView.add(comp);
|
|
25006
|
-
this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
|
|
25007
25687
|
}
|
|
25008
25688
|
else {
|
|
25009
|
-
compSize = maxHeight;
|
|
25010
|
-
comp = this._createScrollbar(compStyle, compSize);
|
|
25011
|
-
this._pagerComponent = comp;
|
|
25012
|
-
this._innerView.add(comp);
|
|
25013
25689
|
contentHeight = maxHeight - renderStartY;
|
|
25014
25690
|
contentWidth = this._itemMaxWidth;
|
|
25691
|
+
comp = this._createScrollbar(compStyle, contentHeight);
|
|
25692
|
+
this._pagerComponent = comp;
|
|
25693
|
+
this._innerView.add(comp);
|
|
25015
25694
|
if (contentHeight <= 0) {
|
|
25016
25695
|
this._innerView.removeChild(comp);
|
|
25017
25696
|
return false;
|
|
25018
25697
|
}
|
|
25019
|
-
itemsContainer.getChildren()
|
|
25020
|
-
|
|
25021
|
-
|
|
25022
|
-
|
|
25023
|
-
|
|
25698
|
+
const items = itemsContainer.getChildren();
|
|
25699
|
+
const itemsHeightArr = items.map((item) => item.attribute.height);
|
|
25700
|
+
if (itemsHeightArr.length === 1 || itemsHeightArr.every(entry => entry === itemsHeightArr[0])) {
|
|
25701
|
+
const itemHeight = itemsHeightArr[0];
|
|
25702
|
+
const maxContentHeight = contentHeight;
|
|
25703
|
+
const pageItemsCount = Math.floor(maxContentHeight / (spaceRow + itemHeight));
|
|
25704
|
+
contentHeight = pageItemsCount * (spaceRow + itemHeight);
|
|
25705
|
+
pages = Math.ceil(items.length / pageItemsCount);
|
|
25706
|
+
}
|
|
25707
|
+
else {
|
|
25708
|
+
items.forEach((item, index) => {
|
|
25709
|
+
const { height } = item.attribute;
|
|
25710
|
+
const prePages = pages;
|
|
25711
|
+
const preStartY = startY;
|
|
25712
|
+
pages = Math.floor((startY + height) / contentHeight) + 1;
|
|
25713
|
+
startY += spaceRow + height;
|
|
25714
|
+
if (prePages !== pages &&
|
|
25715
|
+
index === itemsContainer.getChildren().length - 1 &&
|
|
25716
|
+
startY - contentHeight >= (1 / 3) * height) {
|
|
25717
|
+
contentHeight = preStartY + height;
|
|
25718
|
+
pages -= 1;
|
|
25719
|
+
}
|
|
25720
|
+
});
|
|
25721
|
+
}
|
|
25024
25722
|
this._itemContext.totalPage = pages;
|
|
25025
25723
|
this._itemContext.pages = pages;
|
|
25026
|
-
this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
|
|
25027
25724
|
}
|
|
25028
25725
|
if (defaultCurrent > 1) {
|
|
25029
25726
|
if (isHorizontal) {
|
|
25030
|
-
|
|
25727
|
+
const maxOffset = this._itemsContainer.AABBBounds.width() - contentWidth;
|
|
25728
|
+
itemsContainer.setAttribute('x', -Math.min((defaultCurrent - 1) * (contentWidth + spaceCol), maxOffset));
|
|
25031
25729
|
}
|
|
25032
25730
|
else {
|
|
25033
|
-
|
|
25731
|
+
const maxOffset = this._itemsContainer.AABBBounds.height() - contentHeight;
|
|
25732
|
+
itemsContainer.setAttribute('y', -Math.min((defaultCurrent - 1) * (contentHeight + spaceRow), maxOffset));
|
|
25034
25733
|
}
|
|
25035
25734
|
}
|
|
25036
25735
|
const clipGroup = graphicCreator.group({
|
|
@@ -25043,9 +25742,89 @@ class DiscreteLegend extends LegendBase {
|
|
|
25043
25742
|
});
|
|
25044
25743
|
clipGroup.add(itemsContainer);
|
|
25045
25744
|
this._innerView.add(clipGroup);
|
|
25745
|
+
this._itemContext.clipContainer = clipGroup;
|
|
25746
|
+
this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
|
|
25747
|
+
if ((_a = pager.scrollMask) === null || _a === void 0 ? void 0 : _a.visible) {
|
|
25748
|
+
this.renderScrollMask(clipGroup);
|
|
25749
|
+
}
|
|
25046
25750
|
this._bindEventsOfPager(isHorizontal ? contentWidth : contentHeight, isHorizontal ? 'x' : 'y');
|
|
25047
25751
|
return true;
|
|
25048
25752
|
}
|
|
25753
|
+
renderScrollMask(clipGroup) {
|
|
25754
|
+
const { scrollMask = {} } = this.attribute
|
|
25755
|
+
.pager;
|
|
25756
|
+
const { visible = true, gradientLength = 16, gradientStops } = scrollMask;
|
|
25757
|
+
if (!visible || !gradientStops) {
|
|
25758
|
+
return;
|
|
25759
|
+
}
|
|
25760
|
+
const width = clipGroup.AABBBounds.width();
|
|
25761
|
+
const height = clipGroup.AABBBounds.height();
|
|
25762
|
+
const totalLength = this._itemContext.isHorizontal ? width : height;
|
|
25763
|
+
const startStops = gradientStops.map(stop => {
|
|
25764
|
+
return {
|
|
25765
|
+
offset: (gradientLength * stop.offset) / totalLength,
|
|
25766
|
+
color: stop.color
|
|
25767
|
+
};
|
|
25768
|
+
});
|
|
25769
|
+
const endStops = gradientStops.map(stop => {
|
|
25770
|
+
return {
|
|
25771
|
+
offset: (totalLength - gradientLength * stop.offset) / totalLength,
|
|
25772
|
+
color: stop.color
|
|
25773
|
+
};
|
|
25774
|
+
});
|
|
25775
|
+
const mask = graphicCreator.rect({
|
|
25776
|
+
x: 0,
|
|
25777
|
+
y: 0,
|
|
25778
|
+
width,
|
|
25779
|
+
height
|
|
25780
|
+
});
|
|
25781
|
+
this._scrollMask = mask;
|
|
25782
|
+
this._scrollMaskContext = { startStops, endStops };
|
|
25783
|
+
this.updateScrollMask();
|
|
25784
|
+
clipGroup.add(mask);
|
|
25785
|
+
}
|
|
25786
|
+
updateScrollMask() {
|
|
25787
|
+
if (!this._scrollMask || !this._pagerComponent) {
|
|
25788
|
+
return;
|
|
25789
|
+
}
|
|
25790
|
+
if (!this._itemContext.isScrollbar) {
|
|
25791
|
+
return;
|
|
25792
|
+
}
|
|
25793
|
+
const [start, end] = this._pagerComponent.getScrollRange();
|
|
25794
|
+
const stops = [];
|
|
25795
|
+
if (!isNumberClose(clamp(end, 0, 1), 1)) {
|
|
25796
|
+
stops.push(...this._scrollMaskContext.endStops);
|
|
25797
|
+
}
|
|
25798
|
+
if (!isNumberClose(clamp(start, 0, 1), 0)) {
|
|
25799
|
+
stops.push(...this._scrollMaskContext.startStops);
|
|
25800
|
+
}
|
|
25801
|
+
if (stops.length) {
|
|
25802
|
+
if (this._itemContext.isHorizontal) {
|
|
25803
|
+
this._scrollMask.setAttributes({
|
|
25804
|
+
fill: {
|
|
25805
|
+
gradient: 'linear',
|
|
25806
|
+
x0: 0,
|
|
25807
|
+
y0: 0,
|
|
25808
|
+
x1: 1,
|
|
25809
|
+
y1: 0,
|
|
25810
|
+
stops
|
|
25811
|
+
}
|
|
25812
|
+
});
|
|
25813
|
+
}
|
|
25814
|
+
else {
|
|
25815
|
+
this._scrollMask.setAttributes({
|
|
25816
|
+
fill: {
|
|
25817
|
+
gradient: 'linear',
|
|
25818
|
+
x0: 0,
|
|
25819
|
+
y0: 0,
|
|
25820
|
+
x1: 0,
|
|
25821
|
+
y1: 1,
|
|
25822
|
+
stops
|
|
25823
|
+
}
|
|
25824
|
+
});
|
|
25825
|
+
}
|
|
25826
|
+
}
|
|
25827
|
+
}
|
|
25049
25828
|
_renderPagerComponent() {
|
|
25050
25829
|
if (this._itemContext.isScrollbar) {
|
|
25051
25830
|
this._renderScrollbar();
|
|
@@ -29159,6 +29938,6 @@ EmptyTip.defaultAttributes = {
|
|
|
29159
29938
|
}
|
|
29160
29939
|
};
|
|
29161
29940
|
|
|
29162
|
-
const version = "0.21.0-alpha.
|
|
29941
|
+
const version = "0.21.0-alpha.11";
|
|
29163
29942
|
|
|
29164
|
-
export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
|
|
29943
|
+
export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, scrollbarModule, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
|