@visactor/vrender-components 0.21.0-vstory.1 → 0.21.0-vstory.3
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/type.d.ts +2 -2
- package/cjs/axis/type.js.map +1 -1
- package/cjs/brush/brush.js +1 -2
- package/cjs/brush/type.js +2 -1
- package/cjs/core/base.d.ts +1 -0
- package/cjs/core/base.js +3 -3
- package/cjs/core/base.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.js +20 -10
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +6 -1
- package/cjs/label/overlap/place.js +4 -4
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/overlap/shiftY.d.ts +10 -4
- package/cjs/label/overlap/shiftY.js +103 -27
- package/cjs/label/overlap/shiftY.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 +7 -0
- package/cjs/legend/discrete/discrete.js +106 -23
- 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/radio/radio.d.ts +2 -2
- package/cjs/radio/radio.js +1 -1
- package/cjs/radio/radio.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 +2326 -1751
- package/es/axis/type.d.ts +2 -2
- package/es/axis/type.js.map +1 -1
- package/es/brush/brush.js +1 -2
- package/es/brush/type.js +2 -1
- package/es/core/base.d.ts +1 -0
- package/es/core/base.js +4 -3
- package/es/core/base.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.js +20 -9
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/place.d.ts +6 -1
- package/es/label/overlap/place.js +4 -4
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/overlap/shiftY.d.ts +10 -4
- package/es/label/overlap/shiftY.js +99 -24
- package/es/label/overlap/shiftY.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 +7 -0
- package/es/legend/discrete/discrete.js +106 -24
- 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/radio/radio.d.ts +2 -2
- package/es/radio/radio.js +2 -2
- package/es/radio/radio.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 +8 -7
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, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction,
|
|
1
|
+
import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, cos, sin, isString, pointAt, isNumber, getDecimalPlaces, isNil, Color, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, sqrt, transformBoundsWithMatrix, getContextFont, rotatePoint, clampAngleByRadian, asin, arrayEqual, 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) {
|
|
@@ -2180,6 +2185,7 @@ const DefaultStrokeStyle = Object.assign({
|
|
|
2180
2185
|
const DefaultTextStyle = {
|
|
2181
2186
|
text: "",
|
|
2182
2187
|
maxLineWidth: 1 / 0,
|
|
2188
|
+
maxWidth: 1 / 0,
|
|
2183
2189
|
textAlign: "left",
|
|
2184
2190
|
textBaseline: "alphabetic",
|
|
2185
2191
|
fontSize: 16,
|
|
@@ -2203,7 +2209,9 @@ const DefaultTextStyle = {
|
|
|
2203
2209
|
suffixPosition: "end",
|
|
2204
2210
|
underlineDash: [],
|
|
2205
2211
|
underlineOffset: 0,
|
|
2206
|
-
disableAutoClipedPoptip: void 0
|
|
2212
|
+
disableAutoClipedPoptip: void 0,
|
|
2213
|
+
measureMode: MeasureModeEnum.fontBounding,
|
|
2214
|
+
keepCenterInLine: !1
|
|
2207
2215
|
};
|
|
2208
2216
|
const DefaultPickStyle = {
|
|
2209
2217
|
pickStrokeBuffer: 0
|
|
@@ -2260,7 +2268,8 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
|
|
|
2260
2268
|
globalZIndex: 1,
|
|
2261
2269
|
globalCompositeOperation: "",
|
|
2262
2270
|
overflow: "hidden",
|
|
2263
|
-
shadowPickMode: "graphic"
|
|
2271
|
+
shadowPickMode: "graphic",
|
|
2272
|
+
keepStrokeScale: !1
|
|
2264
2273
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
2265
2274
|
const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2266
2275
|
startAngle: 0,
|
|
@@ -2406,671 +2415,1067 @@ const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImag
|
|
|
2406
2415
|
class Application {}
|
|
2407
2416
|
const application = new Application();
|
|
2408
2417
|
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
fontSize: 16,
|
|
2431
|
-
fontFamily: "sans-serif",
|
|
2432
|
-
fill: !0,
|
|
2433
|
-
stroke: !1,
|
|
2434
|
-
fontWeight: "normal",
|
|
2435
|
-
lineHeight: "normal",
|
|
2436
|
-
fontStyle: "normal",
|
|
2437
|
-
textDecoration: "none",
|
|
2438
|
-
textAlign: "left",
|
|
2439
|
-
script: "normal"
|
|
2418
|
+
const parse = function () {
|
|
2419
|
+
const tokens = {
|
|
2420
|
+
linearGradient: /^(linear\-gradient)/i,
|
|
2421
|
+
radialGradient: /^(radial\-gradient)/i,
|
|
2422
|
+
conicGradient: /^(conic\-gradient)/i,
|
|
2423
|
+
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
|
2424
|
+
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
|
2425
|
+
positionKeywords: /^(left|center|right|top|bottom)/i,
|
|
2426
|
+
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
|
2427
|
+
percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
|
|
2428
|
+
emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
|
|
2429
|
+
angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
2430
|
+
fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
2431
|
+
startCall: /^\(/,
|
|
2432
|
+
endCall: /^\)/,
|
|
2433
|
+
comma: /^,/,
|
|
2434
|
+
hexColor: /(^\#[0-9a-fA-F]+)/,
|
|
2435
|
+
literalColor: /^([a-zA-Z]+)/,
|
|
2436
|
+
rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
|
|
2437
|
+
rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
|
|
2438
|
+
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
2440
2439
|
};
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
const
|
|
2444
|
-
|
|
2445
|
-
let fontSize = character.fontSize || 16;
|
|
2446
|
-
switch (character.script) {
|
|
2447
|
-
case "super":
|
|
2448
|
-
case "sub":
|
|
2449
|
-
fontSize *= .8;
|
|
2440
|
+
let input = "";
|
|
2441
|
+
function error(msg) {
|
|
2442
|
+
const err = new Error(input + ": " + msg);
|
|
2443
|
+
throw err.source = input, err;
|
|
2450
2444
|
}
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
}
|
|
2478
|
-
function
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2445
|
+
function getAST() {
|
|
2446
|
+
const ast = matchListing(matchDefinition);
|
|
2447
|
+
return input.length > 0 && error("Invalid input not EOF"), ast;
|
|
2448
|
+
}
|
|
2449
|
+
function matchDefinition() {
|
|
2450
|
+
return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
|
|
2451
|
+
}
|
|
2452
|
+
function matchGradient(gradientType, pattern, orientationMatcher) {
|
|
2453
|
+
return function (pattern, callback) {
|
|
2454
|
+
const captures = scan(pattern);
|
|
2455
|
+
if (captures) {
|
|
2456
|
+
scan(tokens.startCall) || error("Missing (");
|
|
2457
|
+
const result = callback(captures);
|
|
2458
|
+
return scan(tokens.endCall) || error("Missing )"), result;
|
|
2459
|
+
}
|
|
2460
|
+
}(pattern, function (captures) {
|
|
2461
|
+
const orientation = orientationMatcher();
|
|
2462
|
+
return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
|
|
2463
|
+
type: gradientType,
|
|
2464
|
+
orientation: orientation,
|
|
2465
|
+
colorStops: matchListing(matchColorStop)
|
|
2466
|
+
};
|
|
2467
|
+
});
|
|
2468
|
+
}
|
|
2469
|
+
function matchLinearOrientation() {
|
|
2470
|
+
return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
|
|
2471
|
+
}
|
|
2472
|
+
function matchConicalOrientation() {
|
|
2473
|
+
return match("angular", tokens.fromAngleValue, 1);
|
|
2474
|
+
}
|
|
2475
|
+
function matchListRadialOrientations() {
|
|
2476
|
+
let radialOrientations,
|
|
2477
|
+
lookaheadCache,
|
|
2478
|
+
radialOrientation = matchRadialOrientation();
|
|
2479
|
+
return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
|
|
2480
|
+
}
|
|
2481
|
+
function matchRadialOrientation() {
|
|
2482
|
+
let radialType = function () {
|
|
2483
|
+
const circle = match("shape", /^(circle)/i, 0);
|
|
2484
|
+
circle && (circle.style = matchLength() || matchExtentKeyword());
|
|
2485
|
+
return circle;
|
|
2486
|
+
}() || function () {
|
|
2487
|
+
const ellipse = match("shape", /^(ellipse)/i, 0);
|
|
2488
|
+
ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
|
|
2489
|
+
return ellipse;
|
|
2490
|
+
}();
|
|
2491
|
+
if (radialType) radialType.at = matchAtPosition();else {
|
|
2492
|
+
const extent = matchExtentKeyword();
|
|
2493
|
+
if (extent) {
|
|
2494
|
+
radialType = extent;
|
|
2495
|
+
const positionAt = matchAtPosition();
|
|
2496
|
+
positionAt && (radialType.at = positionAt);
|
|
2497
|
+
} else {
|
|
2498
|
+
const defaultPosition = matchPositioning();
|
|
2499
|
+
defaultPosition && (radialType = {
|
|
2500
|
+
type: "default-radial",
|
|
2501
|
+
at: defaultPosition
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2494
2504
|
}
|
|
2495
|
-
|
|
2505
|
+
return radialType;
|
|
2496
2506
|
}
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
function testLetter(string, index) {
|
|
2500
|
-
let negativeWrongMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
|
|
2501
|
-
let i = index;
|
|
2502
|
-
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i--, i <= 0) return negativeWrongMatch ? testLetter2(string, index) : index;
|
|
2503
|
-
return i;
|
|
2504
|
-
}
|
|
2505
|
-
function testLetter2(string, index) {
|
|
2506
|
-
let i = index;
|
|
2507
|
-
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i++, i >= string.length) return i;
|
|
2508
|
-
return i;
|
|
2509
|
-
}
|
|
2510
|
-
function measureTextCanvas(text, character) {
|
|
2511
|
-
const measurement = application.graphicUtil.textMeasure.measureText(text, character),
|
|
2512
|
-
result = {
|
|
2513
|
-
ascent: 0,
|
|
2514
|
-
height: 0,
|
|
2515
|
-
descent: 0,
|
|
2516
|
-
width: 0
|
|
2517
|
-
};
|
|
2518
|
-
return "number" != typeof measurement.actualBoundingBoxAscent || "number" != typeof measurement.actualBoundingBoxDescent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(measurement.actualBoundingBoxAscent + measurement.actualBoundingBoxDescent), result.ascent = Math.floor(measurement.actualBoundingBoxAscent), result.descent = result.height - result.ascent), result;
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
-
var __decorate$O = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
2522
|
-
var d,
|
|
2523
|
-
c = arguments.length,
|
|
2524
|
-
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
2525
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
2526
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2527
|
-
};
|
|
2528
|
-
let ATextMeasure = class {
|
|
2529
|
-
configure(service, env) {
|
|
2530
|
-
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
2507
|
+
function matchExtentKeyword() {
|
|
2508
|
+
return match("extent-keyword", tokens.extentKeywords, 1);
|
|
2531
2509
|
}
|
|
2532
|
-
|
|
2533
|
-
if (
|
|
2534
|
-
|
|
2535
|
-
|
|
2510
|
+
function matchAtPosition() {
|
|
2511
|
+
if (match("position", /^at/, 0)) {
|
|
2512
|
+
const positioning = matchPositioning();
|
|
2513
|
+
return positioning || error("Missing positioning value"), positioning;
|
|
2514
|
+
}
|
|
2536
2515
|
}
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
width: ~~(.8 * eCharLen * fontSize + cCharLen * fontSize),
|
|
2546
|
-
height: fontSize
|
|
2516
|
+
function matchPositioning() {
|
|
2517
|
+
const location = {
|
|
2518
|
+
x: matchDistance(),
|
|
2519
|
+
y: matchDistance()
|
|
2520
|
+
};
|
|
2521
|
+
if (location.x || location.y) return {
|
|
2522
|
+
type: "position",
|
|
2523
|
+
value: location
|
|
2547
2524
|
};
|
|
2548
2525
|
}
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
2526
|
+
function matchListing(matcher) {
|
|
2527
|
+
let captures = matcher();
|
|
2528
|
+
const result = [];
|
|
2529
|
+
if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
|
|
2530
|
+
return result;
|
|
2555
2531
|
}
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2560
|
-
const textMeasure = this.context.measureText(text);
|
|
2561
|
-
return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
|
|
2532
|
+
function matchColorStop() {
|
|
2533
|
+
const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
|
|
2534
|
+
return color || error("Expected color definition"), color.length = matchDistance(), color;
|
|
2562
2535
|
}
|
|
2563
|
-
|
|
2564
|
-
return
|
|
2536
|
+
function matchDistance() {
|
|
2537
|
+
return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
|
|
2565
2538
|
}
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
verticalList.forEach(item => {
|
|
2575
|
-
item.width = 0 === item.direction ? fontSize : this.measureTextWidth(item.text, options);
|
|
2576
|
-
});
|
|
2577
|
-
const out = [];
|
|
2578
|
-
let length = 0,
|
|
2579
|
-
i = 0;
|
|
2580
|
-
for (; i < verticalList.length && length + verticalList[i].width < width; i++) length += verticalList[i].width, out.push(verticalList[i]);
|
|
2581
|
-
if (verticalList[i] && verticalList[i].text.length > 1) {
|
|
2582
|
-
const clipedData = this._clipText(verticalList[i].text, options, width - length, 0, verticalList[i].text.length - 1, "end", !1);
|
|
2583
|
-
if (wordBreak && clipedData.str !== verticalList[i].text) {
|
|
2584
|
-
let text = "",
|
|
2585
|
-
length = 0;
|
|
2586
|
-
for (let j = 0; j < i; j++) {
|
|
2587
|
-
const item = verticalList[j];
|
|
2588
|
-
text += item.text, length += item.text.length;
|
|
2589
|
-
}
|
|
2590
|
-
text += verticalList[i].text;
|
|
2591
|
-
const totalLength = length + clipedData.str.length;
|
|
2592
|
-
let index = testLetter(text, totalLength);
|
|
2593
|
-
index -= length, index !== clipedData.str.length - 1 && (clipedData.str = clipedData.str.substring(0, index), clipedData.width = this.measureTextWidth(clipedData.str, options));
|
|
2594
|
-
}
|
|
2595
|
-
out.push(Object.assign(Object.assign({}, verticalList[i]), {
|
|
2596
|
-
text: clipedData.str,
|
|
2597
|
-
width: clipedData.width
|
|
2598
|
-
})), length += clipedData.width;
|
|
2599
|
-
}
|
|
2600
|
-
return {
|
|
2601
|
-
verticalList: out,
|
|
2602
|
-
width: length
|
|
2539
|
+
function matchLength() {
|
|
2540
|
+
return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
|
|
2541
|
+
}
|
|
2542
|
+
function match(type, pattern, captureIndex) {
|
|
2543
|
+
const captures = scan(pattern);
|
|
2544
|
+
if (captures) return {
|
|
2545
|
+
type: type,
|
|
2546
|
+
value: captures[captureIndex]
|
|
2603
2547
|
};
|
|
2604
2548
|
}
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
let length = this.measureTextWidth(text, options);
|
|
2611
|
-
if (length <= width) return {
|
|
2612
|
-
str: text,
|
|
2613
|
-
width: length
|
|
2614
|
-
};
|
|
2615
|
-
if (length = this.measureTextWidth(text[0], options), length > width) return {
|
|
2616
|
-
str: "",
|
|
2617
|
-
width: 0
|
|
2618
|
-
};
|
|
2619
|
-
const data = this._clipText(text, options, width, 0, text.length - 1, "end", !1);
|
|
2620
|
-
if (wordBreak && data.str !== text) {
|
|
2621
|
-
let index = testLetter(text, data.str.length, keepAllBreak);
|
|
2622
|
-
index !== data.str.length && (index > data.str.length && (data.wordBreaked = index, index = data.str.length), data.str = text.substring(0, index), data.width = this.measureTextWidth(data.str, options));
|
|
2623
|
-
}
|
|
2624
|
-
return data;
|
|
2549
|
+
function scan(regexp) {
|
|
2550
|
+
const blankCaptures = /^[\n\r\t\s]+/.exec(input);
|
|
2551
|
+
blankCaptures && consume(blankCaptures[0].length);
|
|
2552
|
+
const captures = regexp.exec(input);
|
|
2553
|
+
return captures && consume(captures[0].length), captures;
|
|
2625
2554
|
}
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
if ("start" === position) data = this._clipTextStart(text, options, width, leftIdx, rightIdx), suffix && (data.result = suffix + data.str);else if ("middle" === position) {
|
|
2629
|
-
const d = this._clipTextMiddle(text, options, width, "", "", 0, 0, 1);
|
|
2630
|
-
data = {
|
|
2631
|
-
str: "none",
|
|
2632
|
-
width: d.width,
|
|
2633
|
-
result: d.left + suffix + d.right
|
|
2634
|
-
};
|
|
2635
|
-
} else data = this._clipTextEnd(text, options, width, leftIdx, rightIdx), suffix && (data.result = data.str + suffix);
|
|
2636
|
-
return data;
|
|
2555
|
+
function consume(size) {
|
|
2556
|
+
input = input.substr(size);
|
|
2637
2557
|
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
str: "",
|
|
2646
|
-
width: 0
|
|
2647
|
-
};
|
|
2648
|
-
const str = text.substring(0, middleIdx);
|
|
2649
|
-
return length = this.measureTextWidth(str, options), length <= width ? {
|
|
2650
|
-
str: str,
|
|
2651
|
-
width: length
|
|
2652
|
-
} : this._clipTextEnd(text, options, width, leftIdx, middleIdx);
|
|
2653
|
-
}
|
|
2654
|
-
if (strWidth < width) {
|
|
2655
|
-
if (middleIdx >= text.length - 1) return {
|
|
2656
|
-
str: text,
|
|
2657
|
-
width: this.measureTextWidth(text, options)
|
|
2658
|
-
};
|
|
2659
|
-
const str = text.substring(0, middleIdx + 2);
|
|
2660
|
-
return length = this.measureTextWidth(str, options), length >= width ? {
|
|
2661
|
-
str: subText,
|
|
2662
|
-
width: strWidth
|
|
2663
|
-
} : this._clipTextEnd(text, options, width, middleIdx, rightIdx);
|
|
2664
|
-
}
|
|
2665
|
-
return {
|
|
2666
|
-
str: subText,
|
|
2667
|
-
width: strWidth
|
|
2668
|
-
};
|
|
2558
|
+
return function (code) {
|
|
2559
|
+
return input = code.toString(), getAST();
|
|
2560
|
+
};
|
|
2561
|
+
}();
|
|
2562
|
+
class GradientParser {
|
|
2563
|
+
static IsGradient(c) {
|
|
2564
|
+
return !("string" == typeof c && !c.includes("gradient"));
|
|
2669
2565
|
}
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
if (
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
width: length
|
|
2684
|
-
} : this._clipTextStart(text, options, width, middleIdx, text.length - 1);
|
|
2685
|
-
}
|
|
2686
|
-
if (strWidth < width) {
|
|
2687
|
-
if (middleIdx <= 0) return {
|
|
2688
|
-
str: text,
|
|
2689
|
-
width: this.measureTextWidth(text, options)
|
|
2690
|
-
};
|
|
2691
|
-
const str = text.substring(middleIdx - 2, text.length - 1);
|
|
2692
|
-
return length = this.measureTextWidth(str, options), length >= width ? {
|
|
2693
|
-
str: subText,
|
|
2694
|
-
width: strWidth
|
|
2695
|
-
} : this._clipTextStart(text, options, width, leftIdx, middleIdx);
|
|
2566
|
+
static IsGradientStr(c) {
|
|
2567
|
+
return "string" == typeof c && c.includes("gradient");
|
|
2568
|
+
}
|
|
2569
|
+
static Parse(c) {
|
|
2570
|
+
if (GradientParser.IsGradientStr(c)) try {
|
|
2571
|
+
const datum = parse(c)[0];
|
|
2572
|
+
if (datum) {
|
|
2573
|
+
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
2574
|
+
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
2575
|
+
if ("conic" === datum.type) return GradientParser.ParseConic(datum);
|
|
2576
|
+
}
|
|
2577
|
+
} catch (err) {
|
|
2578
|
+
return c;
|
|
2696
2579
|
}
|
|
2580
|
+
return c;
|
|
2581
|
+
}
|
|
2582
|
+
static ParseConic(datum) {
|
|
2583
|
+
const {
|
|
2584
|
+
orientation: orientation,
|
|
2585
|
+
colorStops = []
|
|
2586
|
+
} = datum,
|
|
2587
|
+
halfPi = pi / 2,
|
|
2588
|
+
sa = parseFloat(orientation.value) / 180 * pi - halfPi;
|
|
2697
2589
|
return {
|
|
2698
|
-
|
|
2699
|
-
|
|
2590
|
+
gradient: "conical",
|
|
2591
|
+
x: .5,
|
|
2592
|
+
y: .5,
|
|
2593
|
+
startAngle: sa,
|
|
2594
|
+
endAngle: sa + pi2,
|
|
2595
|
+
stops: colorStops.map(item => ({
|
|
2596
|
+
color: item.value,
|
|
2597
|
+
offset: parseFloat(item.length.value) / 100
|
|
2598
|
+
}))
|
|
2700
2599
|
};
|
|
2701
2600
|
}
|
|
2702
|
-
|
|
2703
|
-
const
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2601
|
+
static ParseRadial(datum) {
|
|
2602
|
+
const {
|
|
2603
|
+
colorStops = []
|
|
2604
|
+
} = datum;
|
|
2605
|
+
return {
|
|
2606
|
+
gradient: "radial",
|
|
2607
|
+
x0: .5,
|
|
2608
|
+
y0: .5,
|
|
2609
|
+
x1: .5,
|
|
2610
|
+
y1: .5,
|
|
2611
|
+
r0: 0,
|
|
2612
|
+
r1: 1,
|
|
2613
|
+
stops: colorStops.map(item => ({
|
|
2614
|
+
color: item.value,
|
|
2615
|
+
offset: parseFloat(item.length.value) / 100
|
|
2616
|
+
}))
|
|
2709
2617
|
};
|
|
2710
|
-
const subRightText = text.substring(text.length - buffer, text.length),
|
|
2711
|
-
strRightWidth = this.measureTextWidth(subRightText, options);
|
|
2712
|
-
return strLeftWidth + strRightWidth > width ? {
|
|
2713
|
-
left: subLeftText,
|
|
2714
|
-
right: right,
|
|
2715
|
-
width: strLeftWidth + rightW
|
|
2716
|
-
} : this._clipTextMiddle(text, options, width, subLeftText, subRightText, strLeftWidth, strRightWidth, buffer + 1);
|
|
2717
2618
|
}
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2619
|
+
static ParseLinear(datum) {
|
|
2620
|
+
const {
|
|
2621
|
+
orientation: orientation,
|
|
2622
|
+
colorStops = []
|
|
2623
|
+
} = datum,
|
|
2624
|
+
halfPi = pi / 2;
|
|
2625
|
+
let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
|
|
2626
|
+
for (; angle < 0;) angle += pi2;
|
|
2627
|
+
for (; angle >= pi2;) angle -= pi2;
|
|
2628
|
+
let x0 = 0,
|
|
2629
|
+
y0 = 0,
|
|
2630
|
+
x1 = 0,
|
|
2631
|
+
y1 = 0;
|
|
2632
|
+
return angle < halfPi ? (x0 = 0, y0 = 1, x1 = Math.sin(angle), y1 = y0 - Math.cos(angle)) : angle < pi ? (x0 = 0, y0 = 0, x1 = Math.cos(angle - halfPi), y1 = Math.sin(angle - halfPi)) : angle < pi + halfPi ? (x0 = 1, y0 = 0, x1 = x0 - Math.sin(angle - pi), y1 = Math.cos(angle - pi)) : (x0 = 1, x1 = x0 - Math.cos(angle - halfPi - pi), y1 -= Math.sin(angle - halfPi - pi)), {
|
|
2633
|
+
gradient: "linear",
|
|
2634
|
+
x0: x0,
|
|
2635
|
+
y0: y0,
|
|
2636
|
+
x1: x1,
|
|
2637
|
+
y1: y1,
|
|
2638
|
+
stops: colorStops.map(item => ({
|
|
2639
|
+
color: item.value,
|
|
2640
|
+
offset: parseFloat(item.length.value) / 100
|
|
2641
|
+
}))
|
|
2723
2642
|
};
|
|
2724
|
-
const output = this.clipTextVertical(verticalList, options, width, wordBreak);
|
|
2725
|
-
if (output.verticalList.length === verticalList.length && output.verticalList[output.verticalList.length - 1].width === verticalList[verticalList.length - 1].width) return output;
|
|
2726
|
-
const suffixWidth = this.measureTextWidth(suffix, options);
|
|
2727
|
-
if (suffixWidth > width) return output;
|
|
2728
|
-
let out;
|
|
2729
|
-
if (width -= suffixWidth, "start" === suffixPosition) {
|
|
2730
|
-
const nextVerticalList = this.revertVerticalList(verticalList);
|
|
2731
|
-
out = this.clipTextVertical(nextVerticalList, options, width, wordBreak);
|
|
2732
|
-
const v = this.revertVerticalList(out.verticalList);
|
|
2733
|
-
v.unshift({
|
|
2734
|
-
text: suffix,
|
|
2735
|
-
direction: 1,
|
|
2736
|
-
width: suffixWidth
|
|
2737
|
-
}), out.verticalList = v;
|
|
2738
|
-
} else if ("middle" === suffixPosition) {
|
|
2739
|
-
const leftOut = this.clipTextVertical(verticalList, options, width / 2, wordBreak),
|
|
2740
|
-
nextVerticalList = this.revertVerticalList(verticalList),
|
|
2741
|
-
rightOut = this.clipTextVertical(nextVerticalList, options, width / 2, wordBreak);
|
|
2742
|
-
leftOut.verticalList.push({
|
|
2743
|
-
text: suffix,
|
|
2744
|
-
direction: 1,
|
|
2745
|
-
width: suffixWidth
|
|
2746
|
-
}), this.revertVerticalList(rightOut.verticalList).forEach(v => leftOut.verticalList.push(v)), out = {
|
|
2747
|
-
verticalList: leftOut.verticalList,
|
|
2748
|
-
width: leftOut.width + rightOut.width
|
|
2749
|
-
};
|
|
2750
|
-
} else out = this.clipTextVertical(verticalList, options, width, wordBreak), out.verticalList.push({
|
|
2751
|
-
text: suffix,
|
|
2752
|
-
direction: 1,
|
|
2753
|
-
width: suffixWidth
|
|
2754
|
-
});
|
|
2755
|
-
return out.width += suffixWidth, out;
|
|
2756
2643
|
}
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
function getScaledStroke(context, width, dpr) {
|
|
2647
|
+
let strokeWidth = width;
|
|
2648
|
+
const {
|
|
2649
|
+
a: a,
|
|
2650
|
+
b: b,
|
|
2651
|
+
c: c,
|
|
2652
|
+
d: d
|
|
2653
|
+
} = context.currentMatrix,
|
|
2654
|
+
scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
|
|
2655
|
+
scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
|
|
2656
|
+
return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
|
|
2657
|
+
}
|
|
2658
|
+
function createColor(context, c, params) {
|
|
2659
|
+
let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
2660
|
+
let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
2661
|
+
if (!c || !0 === c) return "black";
|
|
2662
|
+
let result, color;
|
|
2663
|
+
if (isArray(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
|
|
2664
|
+
if (color = GradientParser.Parse(color), "string" == typeof color) return color;
|
|
2665
|
+
if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
|
|
2666
|
+
const bounds = params.AABBBounds;
|
|
2667
|
+
let w = bounds.x2 - bounds.x1,
|
|
2668
|
+
h = bounds.y2 - bounds.y1,
|
|
2669
|
+
x = bounds.x1 - offsetX,
|
|
2670
|
+
y = bounds.y1 - offsetY;
|
|
2671
|
+
if (params.attribute) {
|
|
2672
|
+
const {
|
|
2673
|
+
scaleX = 1,
|
|
2674
|
+
scaleY = 1
|
|
2675
|
+
} = params.attribute;
|
|
2676
|
+
w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
|
|
2677
|
+
}
|
|
2678
|
+
"linear" === color.gradient ? result = createLinearGradient(context, color, x, y, w, h) : "conical" === color.gradient ? result = createConicGradient(context, color, x, y, w, h) : "radial" === color.gradient && (result = createRadialGradient(context, color, x, y, w, h));
|
|
2764
2679
|
}
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2680
|
+
return result || "orange";
|
|
2681
|
+
}
|
|
2682
|
+
function createLinearGradient(context, color, x, y, w, h) {
|
|
2683
|
+
var _a, _b, _c, _d;
|
|
2684
|
+
const canvasGradient = context.createLinearGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : 0) * h, x + (null !== (_c = color.x1) && void 0 !== _c ? _c : 1) * w, y + (null !== (_d = color.y1) && void 0 !== _d ? _d : 0) * h);
|
|
2685
|
+
return color.stops.forEach(stop => {
|
|
2686
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
2687
|
+
}), canvasGradient;
|
|
2688
|
+
}
|
|
2689
|
+
function createRadialGradient(context, color, x, y, w, h) {
|
|
2690
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2691
|
+
const canvasGradient = context.createRadialGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : .5) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : .5) * h, Math.max(w, h) * (null !== (_c = color.r0) && void 0 !== _c ? _c : 0), x + (null !== (_d = color.x1) && void 0 !== _d ? _d : .5) * w, y + (null !== (_e = color.y1) && void 0 !== _e ? _e : .5) * h, Math.max(w, h) * (null !== (_f = color.r1) && void 0 !== _f ? _f : .5));
|
|
2692
|
+
return color.stops.forEach(stop => {
|
|
2693
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
2694
|
+
}), canvasGradient;
|
|
2695
|
+
}
|
|
2696
|
+
function createConicGradient(context, color, x, y, w, h) {
|
|
2697
|
+
var _a, _b;
|
|
2698
|
+
const canvasGradient = context.createConicGradient(x + (null !== (_a = color.x) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y) && void 0 !== _b ? _b : 0) * h, color.startAngle, color.endAngle);
|
|
2699
|
+
return color.stops.forEach(stop => {
|
|
2700
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
2701
|
+
}), canvasGradient.GetPattern(w + x, h + y, undefined);
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
const DIRECTION_KEY = {
|
|
2705
|
+
horizontal: {
|
|
2706
|
+
width: "width",
|
|
2707
|
+
height: "height",
|
|
2708
|
+
left: "left",
|
|
2709
|
+
top: "top",
|
|
2710
|
+
x: "x",
|
|
2711
|
+
y: "y",
|
|
2712
|
+
bottom: "bottom"
|
|
2713
|
+
},
|
|
2714
|
+
vertical: {
|
|
2715
|
+
width: "height",
|
|
2716
|
+
height: "width",
|
|
2717
|
+
left: "top",
|
|
2718
|
+
top: "left",
|
|
2719
|
+
x: "y",
|
|
2720
|
+
y: "x",
|
|
2721
|
+
bottom: "right"
|
|
2793
2722
|
}
|
|
2794
2723
|
};
|
|
2795
|
-
|
|
2724
|
+
const defaultFormatting = {
|
|
2725
|
+
fontSize: 16,
|
|
2726
|
+
fontFamily: "sans-serif",
|
|
2727
|
+
fill: !0,
|
|
2728
|
+
stroke: !1,
|
|
2729
|
+
fontWeight: "normal",
|
|
2730
|
+
lineHeight: "normal",
|
|
2731
|
+
fontStyle: "normal",
|
|
2732
|
+
textDecoration: "none",
|
|
2733
|
+
textAlign: "left",
|
|
2734
|
+
script: "normal"
|
|
2735
|
+
};
|
|
2736
|
+
const regLetter = /\w|\(|\)|-/;
|
|
2737
|
+
const regPunctuation = /[.?!,;:/,。?!、;:]/;
|
|
2738
|
+
const regFirstSpace = /\S/;
|
|
2739
|
+
const setTextStyle = (ctx, character) => {
|
|
2740
|
+
let fontSize = character.fontSize || 16;
|
|
2741
|
+
switch (character.script) {
|
|
2742
|
+
case "super":
|
|
2743
|
+
case "sub":
|
|
2744
|
+
fontSize *= .8;
|
|
2745
|
+
}
|
|
2746
|
+
ctx.setTextStyle({
|
|
2747
|
+
textAlign: "left",
|
|
2748
|
+
textBaseline: character.textBaseline || "alphabetic",
|
|
2749
|
+
fontStyle: character.fontStyle || "",
|
|
2750
|
+
fontWeight: character.fontWeight || "",
|
|
2751
|
+
fontSize: fontSize,
|
|
2752
|
+
fontFamily: character.fontFamily || "sans-serif"
|
|
2753
|
+
});
|
|
2754
|
+
};
|
|
2755
|
+
function applyFillStyle(ctx, character, b) {
|
|
2756
|
+
const fillStyle = character && character.fill || defaultFormatting.fill;
|
|
2757
|
+
if (!fillStyle) return void (ctx.globalAlpha = 0);
|
|
2758
|
+
const {
|
|
2759
|
+
fillOpacity = 1,
|
|
2760
|
+
opacity = 1
|
|
2761
|
+
} = character;
|
|
2762
|
+
ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
|
|
2763
|
+
AABBBounds: b
|
|
2764
|
+
}) : fillStyle, setTextStyle(ctx, character);
|
|
2765
|
+
}
|
|
2766
|
+
function applyStrokeStyle(ctx, character) {
|
|
2767
|
+
const strokeStyle = character && character.stroke || defaultFormatting.stroke;
|
|
2768
|
+
if (!strokeStyle) return void (ctx.globalAlpha = 0);
|
|
2769
|
+
const {
|
|
2770
|
+
strokeOpacity = 1,
|
|
2771
|
+
opacity = 1
|
|
2772
|
+
} = character;
|
|
2773
|
+
ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
|
|
2774
|
+
}
|
|
2775
|
+
function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
|
|
2776
|
+
if (!width || width <= 0) return 0;
|
|
2777
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
2778
|
+
let index = guessIndex,
|
|
2779
|
+
temp = desc.slice(0, index),
|
|
2780
|
+
tempWidth = Math.floor(textMeasure.measureText(temp, character).width),
|
|
2781
|
+
tempNext = desc.slice(0, index + 1),
|
|
2782
|
+
tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
|
|
2783
|
+
for (; tempWidth > width || tempWidthNext <= width;) {
|
|
2784
|
+
if (tempWidth > width ? index-- : index++, index > desc.length) {
|
|
2785
|
+
index = desc.length;
|
|
2786
|
+
break;
|
|
2787
|
+
}
|
|
2788
|
+
if (index < 0) {
|
|
2789
|
+
index = 0;
|
|
2790
|
+
break;
|
|
2791
|
+
}
|
|
2792
|
+
temp = desc.slice(0, index), tempWidth = Math.floor(textMeasure.measureText(temp, character).width), tempNext = desc.slice(0, index + 1), tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
|
|
2793
|
+
}
|
|
2794
|
+
return needTestLetter && (index = testLetter(desc, index)), index;
|
|
2795
|
+
}
|
|
2796
|
+
function testLetter(string, index) {
|
|
2797
|
+
let negativeWrongMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
|
|
2798
|
+
let i = index;
|
|
2799
|
+
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i--, i <= 0) return negativeWrongMatch ? testLetter2(string, index) : index;
|
|
2800
|
+
return i;
|
|
2801
|
+
}
|
|
2802
|
+
function testLetter2(string, index) {
|
|
2803
|
+
let i = index;
|
|
2804
|
+
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i++, i >= string.length) return i;
|
|
2805
|
+
return i;
|
|
2806
|
+
}
|
|
2807
|
+
function measureTextCanvas(text, character) {
|
|
2808
|
+
const measurement = application.graphicUtil.textMeasure.measureText(text, character),
|
|
2809
|
+
result = {
|
|
2810
|
+
ascent: 0,
|
|
2811
|
+
height: 0,
|
|
2812
|
+
descent: 0,
|
|
2813
|
+
width: 0
|
|
2814
|
+
};
|
|
2815
|
+
return "number" != typeof measurement.actualBoundingBoxAscent || "number" != typeof measurement.actualBoundingBoxDescent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(measurement.actualBoundingBoxAscent + measurement.actualBoundingBoxDescent), result.ascent = Math.floor(measurement.actualBoundingBoxAscent), result.descent = result.height - result.ascent), result;
|
|
2816
|
+
}
|
|
2796
2817
|
|
|
2797
|
-
var __decorate$
|
|
2818
|
+
var __decorate$O = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
2798
2819
|
var d,
|
|
2799
2820
|
c = arguments.length,
|
|
2800
2821
|
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
2801
2822
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
2802
2823
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2803
2824
|
};
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
const container = new Container();
|
|
2809
|
-
|
|
2810
|
-
const CanvasFactory = Symbol.for("CanvasFactory");
|
|
2811
|
-
|
|
2812
|
-
function wrapCanvas(params) {
|
|
2813
|
-
return container.getNamed(CanvasFactory, application.global.env)(params);
|
|
2814
|
-
}
|
|
2815
|
-
|
|
2816
|
-
class DefaultCanvasAllocate {
|
|
2817
|
-
constructor() {
|
|
2818
|
-
this.pools = [], this.allocatedCanvas = [];
|
|
2825
|
+
let ATextMeasure = class {
|
|
2826
|
+
configure(service, env) {
|
|
2827
|
+
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
2819
2828
|
}
|
|
2820
|
-
|
|
2821
|
-
|
|
2829
|
+
_measureTextWithoutAlignBaseline(text, options, compatible) {
|
|
2830
|
+
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2831
|
+
const metrics = this.context.measureText(text);
|
|
2832
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2822
2833
|
}
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
dpr: 2
|
|
2828
|
-
})), this._commonCanvas;
|
|
2834
|
+
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
2835
|
+
this.context.setTextStyle(options);
|
|
2836
|
+
const metrics = this.context.measureText(text);
|
|
2837
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2829
2838
|
}
|
|
2830
|
-
|
|
2831
|
-
if (
|
|
2832
|
-
const
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2839
|
+
compatibleMetrics(metrics, options) {
|
|
2840
|
+
if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
|
|
2841
|
+
const {
|
|
2842
|
+
ascent: ascent,
|
|
2843
|
+
descent: descent
|
|
2844
|
+
} = this.measureTextBoundADscentEstimate(options);
|
|
2845
|
+
metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
|
|
2836
2846
|
}
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
width: canvas.width / canvas.dpr,
|
|
2844
|
-
height: canvas.height / canvas.dpr,
|
|
2845
|
-
dpr: canvas.dpr
|
|
2846
|
-
},
|
|
2847
|
-
c = wrapCanvas(Object.assign({
|
|
2848
|
-
nativeCanvas: application.global.createCanvas(data)
|
|
2849
|
-
}, data));
|
|
2850
|
-
return this.allocatedCanvas.push(c), c;
|
|
2847
|
+
if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
|
|
2848
|
+
const {
|
|
2849
|
+
left: left,
|
|
2850
|
+
right: right
|
|
2851
|
+
} = this.measureTextBoundLeftRightEstimate(options);
|
|
2852
|
+
metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
|
|
2851
2853
|
}
|
|
2852
|
-
|
|
2853
|
-
return m.width = canvas.width, m.height = canvas.height, m;
|
|
2854
|
-
}
|
|
2855
|
-
free(d) {
|
|
2856
|
-
this.pools.push(d);
|
|
2854
|
+
return metrics;
|
|
2857
2855
|
}
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
c = arguments.length,
|
|
2870
|
-
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
2871
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
2872
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2873
|
-
},
|
|
2874
|
-
__metadata$D = undefined && undefined.__metadata || function (k, v) {
|
|
2875
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
2876
|
-
};
|
|
2877
|
-
const VWindow = Symbol.for("VWindow");
|
|
2878
|
-
const WindowHandlerContribution = Symbol.for("WindowHandlerContribution");
|
|
2879
|
-
let DefaultWindow = class {
|
|
2880
|
-
get width() {
|
|
2881
|
-
if (this._handler) {
|
|
2882
|
-
const wh = this._handler.getWH();
|
|
2883
|
-
return this._width = wh.width;
|
|
2884
|
-
}
|
|
2885
|
-
return this._width;
|
|
2886
|
-
}
|
|
2887
|
-
get height() {
|
|
2888
|
-
if (this._handler) {
|
|
2889
|
-
const wh = this._handler.getWH();
|
|
2890
|
-
return this._height = wh.height;
|
|
2891
|
-
}
|
|
2892
|
-
return this._height;
|
|
2856
|
+
estimate(text, _ref) {
|
|
2857
|
+
let {
|
|
2858
|
+
fontSize = DefaultTextAttribute.fontSize
|
|
2859
|
+
} = _ref;
|
|
2860
|
+
let eCharLen = 0,
|
|
2861
|
+
cCharLen = 0;
|
|
2862
|
+
for (let i = 0; i < text.length; i++) text.charCodeAt(i) < 128 ? eCharLen++ : cCharLen++;
|
|
2863
|
+
return {
|
|
2864
|
+
width: ~~(.8 * eCharLen * fontSize + cCharLen * fontSize),
|
|
2865
|
+
height: fontSize
|
|
2866
|
+
};
|
|
2893
2867
|
}
|
|
2894
|
-
|
|
2895
|
-
return this.
|
|
2868
|
+
measureTextWidth(text, options, textMeasure) {
|
|
2869
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2896
2870
|
}
|
|
2897
|
-
|
|
2898
|
-
this.
|
|
2899
|
-
onChange: new SyncHook(["x", "y", "width", "height"])
|
|
2900
|
-
}, this.active = () => {
|
|
2901
|
-
const global = this.global;
|
|
2902
|
-
if (!global.env || this.actived) return;
|
|
2903
|
-
container.getNamed(WindowHandlerContribution, global.env).configure(this, global), this.actived = !0;
|
|
2904
|
-
}, this._uid = Generator.GenAutoIncrementId(), this.global = application.global, this.postInit();
|
|
2871
|
+
measureTextBoundsWidth(text, options, textMeasure) {
|
|
2872
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2905
2873
|
}
|
|
2906
|
-
|
|
2907
|
-
|
|
2874
|
+
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
2875
|
+
return this.context ? {
|
|
2876
|
+
left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
|
|
2877
|
+
right: textMeasure.actualBoundingBoxRight
|
|
2878
|
+
} : this.measureTextBoundLeftRightEstimate(options);
|
|
2908
2879
|
}
|
|
2909
|
-
|
|
2880
|
+
measureTextPixelHeight(text, options, textMeasure) {
|
|
2910
2881
|
var _a;
|
|
2911
|
-
return
|
|
2912
|
-
}
|
|
2913
|
-
set style(style) {
|
|
2914
|
-
this._handler.setStyle(style);
|
|
2915
|
-
}
|
|
2916
|
-
create(params) {
|
|
2917
|
-
var _a, _b;
|
|
2918
|
-
this._handler.createWindow(params);
|
|
2919
|
-
const windowWH = this._handler.getWH();
|
|
2920
|
-
this._width = windowWH.width, this._height = windowWH.height, params.viewBox ? this.setViewBox(params.viewBox) : !1 !== params.canvasControled ? this.setViewBox({
|
|
2921
|
-
x1: 0,
|
|
2922
|
-
y1: 0,
|
|
2923
|
-
x2: this._width,
|
|
2924
|
-
y2: this._height
|
|
2925
|
-
}) : this.setViewBox({
|
|
2926
|
-
x1: 0,
|
|
2927
|
-
y1: 0,
|
|
2928
|
-
x2: null !== (_a = params.width) && void 0 !== _a ? _a : this._width,
|
|
2929
|
-
y2: null !== (_b = params.height) && void 0 !== _b ? _b : this._height
|
|
2930
|
-
}), this.title = this._handler.getTitle(), this.resizable = !0;
|
|
2931
|
-
}
|
|
2932
|
-
setWindowHandler(handler) {
|
|
2933
|
-
this._handler = handler;
|
|
2934
|
-
}
|
|
2935
|
-
setDpr(dpr) {
|
|
2936
|
-
return this._handler.setDpr(dpr);
|
|
2937
|
-
}
|
|
2938
|
-
resize(w, h) {
|
|
2939
|
-
return this._handler.resizeWindow(w, h);
|
|
2940
|
-
}
|
|
2941
|
-
configure() {
|
|
2942
|
-
throw new Error("暂不支持");
|
|
2943
|
-
}
|
|
2944
|
-
release() {
|
|
2945
|
-
return this.global.hooks.onSetEnv.unTap("window", this.active), this._handler.releaseWindow();
|
|
2946
|
-
}
|
|
2947
|
-
getContext() {
|
|
2948
|
-
return this._handler.getContext();
|
|
2949
|
-
}
|
|
2950
|
-
getNativeHandler() {
|
|
2951
|
-
return this._handler.getNativeHandler();
|
|
2952
|
-
}
|
|
2953
|
-
getImageBuffer(type) {
|
|
2954
|
-
return this._handler.getImageBuffer ? this._handler.getImageBuffer(type) : null;
|
|
2955
|
-
}
|
|
2956
|
-
addEventListener(type, listener, options) {
|
|
2957
|
-
return this._handler.addEventListener(type, listener, options);
|
|
2958
|
-
}
|
|
2959
|
-
removeEventListener(type, listener, options) {
|
|
2960
|
-
return this._handler.removeEventListener(type, listener, options);
|
|
2961
|
-
}
|
|
2962
|
-
dispatchEvent(event) {
|
|
2963
|
-
return this._handler.dispatchEvent(event);
|
|
2964
|
-
}
|
|
2965
|
-
getBoundingClientRect() {
|
|
2966
|
-
return this._handler.getBoundingClientRect();
|
|
2967
|
-
}
|
|
2968
|
-
getContainer() {
|
|
2969
|
-
return this._handler.container;
|
|
2882
|
+
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;
|
|
2970
2883
|
}
|
|
2971
|
-
|
|
2972
|
-
this.
|
|
2884
|
+
measureTextPixelADscent(text, options, textMeasure) {
|
|
2885
|
+
return this.context ? {
|
|
2886
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
2887
|
+
descent: textMeasure.actualBoundingBoxDescent
|
|
2888
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
2973
2889
|
}
|
|
2974
|
-
|
|
2975
|
-
|
|
2890
|
+
measureTextBoundHieght(text, options, textMeasure) {
|
|
2891
|
+
var _a;
|
|
2892
|
+
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;
|
|
2976
2893
|
}
|
|
2977
|
-
|
|
2978
|
-
this.
|
|
2894
|
+
measureTextBoundADscent(text, options, textMeasure) {
|
|
2895
|
+
return this.context ? {
|
|
2896
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
|
|
2897
|
+
descent: textMeasure.fontBoundingBoxDescent
|
|
2898
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
2979
2899
|
}
|
|
2980
|
-
|
|
2981
|
-
|
|
2900
|
+
measureTextBoundADscentEstimate(options) {
|
|
2901
|
+
var _a;
|
|
2902
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2903
|
+
return {
|
|
2904
|
+
ascent: .79 * fontSize,
|
|
2905
|
+
descent: .21 * fontSize
|
|
2906
|
+
};
|
|
2982
2907
|
}
|
|
2983
|
-
|
|
2984
|
-
|
|
2908
|
+
measureTextBoundLeftRightEstimate(options) {
|
|
2909
|
+
var _a;
|
|
2910
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
|
|
2911
|
+
{
|
|
2912
|
+
textAlign: textAlign
|
|
2913
|
+
} = options;
|
|
2914
|
+
return "center" === textAlign ? {
|
|
2915
|
+
left: fontSize / 2,
|
|
2916
|
+
right: fontSize / 2
|
|
2917
|
+
} : "right" === textAlign || "end" === textAlign ? {
|
|
2918
|
+
left: fontSize,
|
|
2919
|
+
right: 0
|
|
2920
|
+
} : {
|
|
2921
|
+
left: 0,
|
|
2922
|
+
right: fontSize
|
|
2923
|
+
};
|
|
2985
2924
|
}
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2925
|
+
measureTextPixelADscentAndWidth(text, options, mode) {
|
|
2926
|
+
if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
2927
|
+
width: this.estimate(text, options).width
|
|
2928
|
+
});
|
|
2929
|
+
const out = this._measureTextWithoutAlignBaseline(text, options, !0);
|
|
2930
|
+
if (mode === MeasureModeEnum.actualBounding) return {
|
|
2931
|
+
ascent: out.actualBoundingBoxAscent,
|
|
2932
|
+
descent: out.actualBoundingBoxDescent,
|
|
2933
|
+
width: out.width
|
|
2934
|
+
};
|
|
2935
|
+
if (mode === MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
2936
|
+
width: out.width
|
|
2937
|
+
});
|
|
2938
|
+
if (mode === MeasureModeEnum.fontBounding) {
|
|
2939
|
+
let ascent = out.fontBoundingBoxAscent,
|
|
2940
|
+
descent = out.fontBoundingBoxDescent;
|
|
2941
|
+
if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
|
|
2942
|
+
const delta = out.actualBoundingBoxDescent - descent;
|
|
2943
|
+
descent += delta, ascent -= delta;
|
|
2944
|
+
} else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
|
|
2945
|
+
const delta = out.actualBoundingBoxAscent - ascent;
|
|
2946
|
+
ascent += delta, descent -= delta;
|
|
2947
|
+
}
|
|
2948
|
+
return {
|
|
2949
|
+
ascent: ascent,
|
|
2950
|
+
descent: descent,
|
|
2951
|
+
width: out.width
|
|
2991
2952
|
};
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
hasSubView() {
|
|
2998
|
-
const viewBox = this._handler.getViewBox();
|
|
2999
|
-
return !(0 === viewBox.x1 && 0 === viewBox.y1 && isNumberClose(this.width, viewBox.width()) && isNumberClose(this.height, viewBox.height()));
|
|
3000
|
-
}
|
|
3001
|
-
isVisible(bbox) {
|
|
3002
|
-
return this._handler.isVisible(bbox);
|
|
3003
|
-
}
|
|
3004
|
-
onVisibleChange(cb) {
|
|
3005
|
-
return this._handler.onVisibleChange(cb);
|
|
3006
|
-
}
|
|
3007
|
-
getTopLeft(baseWindow) {
|
|
3008
|
-
return this._handler.getTopLeft(baseWindow);
|
|
3009
|
-
}
|
|
3010
|
-
};
|
|
3011
|
-
DefaultWindow = __decorate$M([injectable(), __metadata$D("design:paramtypes", [])], DefaultWindow);
|
|
3012
|
-
|
|
3013
|
-
var __decorate$L = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
3014
|
-
var d,
|
|
3015
|
-
c = arguments.length,
|
|
3016
|
-
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
3017
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
3018
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3019
|
-
},
|
|
3020
|
-
__metadata$C = undefined && undefined.__metadata || function (k, v) {
|
|
3021
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
3022
|
-
},
|
|
3023
|
-
__param$y = undefined && undefined.__param || function (paramIndex, decorator) {
|
|
3024
|
-
return function (target, key) {
|
|
3025
|
-
decorator(target, key, paramIndex);
|
|
2953
|
+
}
|
|
2954
|
+
return {
|
|
2955
|
+
ascent: out.actualBoundingBoxAscent,
|
|
2956
|
+
descent: out.actualBoundingBoxDescent,
|
|
2957
|
+
width: out.width
|
|
3026
2958
|
};
|
|
3027
|
-
};
|
|
3028
|
-
let DefaultGraphicUtil = class {
|
|
3029
|
-
get canvas() {
|
|
3030
|
-
return this.tryInitCanvas(), this._canvas;
|
|
3031
2959
|
}
|
|
3032
|
-
|
|
3033
|
-
return this.
|
|
2960
|
+
measureText(text, options) {
|
|
2961
|
+
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
3034
2962
|
}
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
2963
|
+
clipTextVertical(verticalList, options, width, wordBreak) {
|
|
2964
|
+
if (0 === verticalList.length) return {
|
|
2965
|
+
verticalList: verticalList,
|
|
2966
|
+
width: 0
|
|
2967
|
+
};
|
|
2968
|
+
const {
|
|
2969
|
+
fontSize = 12
|
|
2970
|
+
} = options;
|
|
2971
|
+
verticalList.forEach(item => {
|
|
2972
|
+
item.width = 0 === item.direction ? fontSize : this.measureTextWidth(item.text, options);
|
|
3038
2973
|
});
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
2974
|
+
const out = [];
|
|
2975
|
+
let length = 0,
|
|
2976
|
+
i = 0;
|
|
2977
|
+
for (; i < verticalList.length && length + verticalList[i].width < width; i++) length += verticalList[i].width, out.push(verticalList[i]);
|
|
2978
|
+
if (verticalList[i] && verticalList[i].text.length > 1) {
|
|
2979
|
+
const clipedData = this._clipText(verticalList[i].text, options, width - length, 0, verticalList[i].text.length - 1, "end", !1);
|
|
2980
|
+
if (wordBreak && clipedData.str !== verticalList[i].text) {
|
|
2981
|
+
let text = "",
|
|
2982
|
+
length = 0;
|
|
2983
|
+
for (let j = 0; j < i; j++) {
|
|
2984
|
+
const item = verticalList[j];
|
|
2985
|
+
text += item.text, length += item.text.length;
|
|
2986
|
+
}
|
|
2987
|
+
text += verticalList[i].text;
|
|
2988
|
+
const totalLength = length + clipedData.str.length;
|
|
2989
|
+
let index = testLetter(text, totalLength);
|
|
2990
|
+
index -= length, index !== clipedData.str.length - 1 && (clipedData.str = clipedData.str.substring(0, index), clipedData.width = this.measureTextWidth(clipedData.str, options));
|
|
2991
|
+
}
|
|
2992
|
+
out.push(Object.assign(Object.assign({}, verticalList[i]), {
|
|
2993
|
+
text: clipedData.str,
|
|
2994
|
+
width: clipedData.width
|
|
2995
|
+
})), length += clipedData.width;
|
|
3052
2996
|
}
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
}
|
|
3057
|
-
measureText(text, tc) {
|
|
3058
|
-
let method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "native";
|
|
3059
|
-
var _a;
|
|
3060
|
-
this.configure(this.global, this.global.env);
|
|
3061
|
-
const m = this.global.measureTextMethod;
|
|
3062
|
-
this.global.measureTextMethod = method;
|
|
3063
|
-
const data = {
|
|
3064
|
-
width: this._textMeasure.measureTextWidth(text, tc),
|
|
3065
|
-
height: null !== (_a = tc.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize
|
|
2997
|
+
return {
|
|
2998
|
+
verticalList: out,
|
|
2999
|
+
width: length
|
|
3066
3000
|
};
|
|
3067
|
-
return this.global.measureTextMethod = m, data;
|
|
3068
3001
|
}
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3002
|
+
clipText(text, options, width, wordBreak, keepAllBreak) {
|
|
3003
|
+
if (0 === text.length) return {
|
|
3004
|
+
str: "",
|
|
3005
|
+
width: 0
|
|
3006
|
+
};
|
|
3007
|
+
let length = this.measureTextWidth(text, options);
|
|
3008
|
+
if (length <= width) return {
|
|
3009
|
+
str: text,
|
|
3010
|
+
width: length
|
|
3011
|
+
};
|
|
3012
|
+
if (length = this.measureTextWidth(text[0], options), length > width) return {
|
|
3013
|
+
str: "",
|
|
3014
|
+
width: 0
|
|
3015
|
+
};
|
|
3016
|
+
const data = this._clipText(text, options, width, 0, text.length - 1, "end", !1);
|
|
3017
|
+
if (wordBreak && data.str !== text) {
|
|
3018
|
+
let index = testLetter(text, data.str.length, keepAllBreak);
|
|
3019
|
+
index !== data.str.length && (index > data.str.length && (data.wordBreaked = index, index = data.str.length), data.str = text.substring(0, index), data.width = this.measureTextWidth(data.str, options));
|
|
3020
|
+
}
|
|
3021
|
+
return data;
|
|
3022
|
+
}
|
|
3023
|
+
_clipText(text, options, width, leftIdx, rightIdx, position, suffix) {
|
|
3024
|
+
let data;
|
|
3025
|
+
if ("start" === position) data = this._clipTextStart(text, options, width, leftIdx, rightIdx), suffix && (data.result = suffix + data.str);else if ("middle" === position) {
|
|
3026
|
+
const d = this._clipTextMiddle(text, options, width, "", "", 0, 0, 1);
|
|
3027
|
+
data = {
|
|
3028
|
+
str: "none",
|
|
3029
|
+
width: d.width,
|
|
3030
|
+
result: d.left + suffix + d.right
|
|
3031
|
+
};
|
|
3032
|
+
} else data = this._clipTextEnd(text, options, width, leftIdx, rightIdx), suffix && (data.result = data.str + suffix);
|
|
3033
|
+
return data;
|
|
3034
|
+
}
|
|
3035
|
+
_clipTextEnd(text, options, width, leftIdx, rightIdx) {
|
|
3036
|
+
if (leftIdx === rightIdx) {
|
|
3037
|
+
Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
|
|
3038
|
+
const subText = text.substring(0, rightIdx + 1);
|
|
3039
|
+
return {
|
|
3040
|
+
str: subText,
|
|
3041
|
+
width: this.measureTextWidth(subText, options)
|
|
3042
|
+
};
|
|
3043
|
+
}
|
|
3044
|
+
const middleIdx = Math.floor((leftIdx + rightIdx) / 2),
|
|
3045
|
+
subText = text.substring(0, middleIdx + 1),
|
|
3046
|
+
strWidth = this.measureTextWidth(subText, options);
|
|
3047
|
+
let length;
|
|
3048
|
+
if (strWidth > width) {
|
|
3049
|
+
if (subText.length <= 1) return {
|
|
3050
|
+
str: "",
|
|
3051
|
+
width: 0
|
|
3052
|
+
};
|
|
3053
|
+
const str = text.substring(0, middleIdx);
|
|
3054
|
+
return length = this.measureTextWidth(str, options), length <= width ? {
|
|
3055
|
+
str: str,
|
|
3056
|
+
width: length
|
|
3057
|
+
} : this._clipTextEnd(text, options, width, leftIdx, middleIdx);
|
|
3058
|
+
}
|
|
3059
|
+
if (strWidth < width) {
|
|
3060
|
+
if (middleIdx >= text.length - 1) return {
|
|
3061
|
+
str: text,
|
|
3062
|
+
width: this.measureTextWidth(text, options)
|
|
3063
|
+
};
|
|
3064
|
+
const str = text.substring(0, middleIdx + 2);
|
|
3065
|
+
return length = this.measureTextWidth(str, options), length >= width ? {
|
|
3066
|
+
str: subText,
|
|
3067
|
+
width: strWidth
|
|
3068
|
+
} : this._clipTextEnd(text, options, width, middleIdx, rightIdx);
|
|
3069
|
+
}
|
|
3070
|
+
return {
|
|
3071
|
+
str: subText,
|
|
3072
|
+
width: strWidth
|
|
3073
|
+
};
|
|
3074
|
+
}
|
|
3075
|
+
_clipTextStart(text, options, width, leftIdx, rightIdx) {
|
|
3076
|
+
const middleIdx = Math.ceil((leftIdx + rightIdx) / 2),
|
|
3077
|
+
subText = text.substring(middleIdx - 1, text.length),
|
|
3078
|
+
strWidth = this.measureTextWidth(subText, options);
|
|
3079
|
+
let length;
|
|
3080
|
+
if (strWidth > width) {
|
|
3081
|
+
if (subText.length <= 1) return {
|
|
3082
|
+
str: "",
|
|
3083
|
+
width: 0
|
|
3084
|
+
};
|
|
3085
|
+
const str = text.substring(middleIdx, text.length);
|
|
3086
|
+
return length = this.measureTextWidth(str, options), length <= width ? {
|
|
3087
|
+
str: str,
|
|
3088
|
+
width: length
|
|
3089
|
+
} : this._clipTextStart(text, options, width, middleIdx, text.length);
|
|
3090
|
+
}
|
|
3091
|
+
if (strWidth < width) {
|
|
3092
|
+
if (middleIdx <= 0) return {
|
|
3093
|
+
str: text,
|
|
3094
|
+
width: this.measureTextWidth(text, options)
|
|
3095
|
+
};
|
|
3096
|
+
const str = text.substring(middleIdx - 2, text.length);
|
|
3097
|
+
return length = this.measureTextWidth(str, options), length >= width ? {
|
|
3098
|
+
str: subText,
|
|
3099
|
+
width: strWidth
|
|
3100
|
+
} : this._clipTextStart(text, options, width, leftIdx, middleIdx);
|
|
3101
|
+
}
|
|
3102
|
+
return {
|
|
3103
|
+
str: subText,
|
|
3104
|
+
width: strWidth
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
_clipTextMiddle(text, options, width, left, right, leftW, rightW, buffer) {
|
|
3108
|
+
const subLeftText = text.substring(0, buffer),
|
|
3109
|
+
strLeftWidth = this.measureTextWidth(subLeftText, options);
|
|
3110
|
+
if (strLeftWidth + rightW > width) return {
|
|
3111
|
+
left: left,
|
|
3112
|
+
right: right,
|
|
3113
|
+
width: leftW + rightW
|
|
3114
|
+
};
|
|
3115
|
+
const subRightText = text.substring(text.length - buffer, text.length),
|
|
3116
|
+
strRightWidth = this.measureTextWidth(subRightText, options);
|
|
3117
|
+
return strLeftWidth + strRightWidth > width ? {
|
|
3118
|
+
left: subLeftText,
|
|
3119
|
+
right: right,
|
|
3120
|
+
width: strLeftWidth + rightW
|
|
3121
|
+
} : this._clipTextMiddle(text, options, width, subLeftText, subRightText, strLeftWidth, strRightWidth, buffer + 1);
|
|
3122
|
+
}
|
|
3123
|
+
clipTextWithSuffixVertical(verticalList, options, width, suffix, wordBreak, suffixPosition) {
|
|
3124
|
+
if ("" === suffix) return this.clipTextVertical(verticalList, options, width, wordBreak);
|
|
3125
|
+
if (0 === verticalList.length) return {
|
|
3126
|
+
verticalList: verticalList,
|
|
3127
|
+
width: 0
|
|
3128
|
+
};
|
|
3129
|
+
const output = this.clipTextVertical(verticalList, options, width, wordBreak);
|
|
3130
|
+
if (output.verticalList.length === verticalList.length && output.verticalList[output.verticalList.length - 1].width === verticalList[verticalList.length - 1].width) return output;
|
|
3131
|
+
const suffixWidth = this.measureTextWidth(suffix, options);
|
|
3132
|
+
if (suffixWidth > width) return output;
|
|
3133
|
+
let out;
|
|
3134
|
+
if (width -= suffixWidth, "start" === suffixPosition) {
|
|
3135
|
+
const nextVerticalList = this.revertVerticalList(verticalList);
|
|
3136
|
+
out = this.clipTextVertical(nextVerticalList, options, width, wordBreak);
|
|
3137
|
+
const v = this.revertVerticalList(out.verticalList);
|
|
3138
|
+
v.unshift({
|
|
3139
|
+
text: suffix,
|
|
3140
|
+
direction: 1,
|
|
3141
|
+
width: suffixWidth
|
|
3142
|
+
}), out.verticalList = v;
|
|
3143
|
+
} else if ("middle" === suffixPosition) {
|
|
3144
|
+
const leftOut = this.clipTextVertical(verticalList, options, width / 2, wordBreak),
|
|
3145
|
+
nextVerticalList = this.revertVerticalList(verticalList),
|
|
3146
|
+
rightOut = this.clipTextVertical(nextVerticalList, options, width / 2, wordBreak);
|
|
3147
|
+
leftOut.verticalList.push({
|
|
3148
|
+
text: suffix,
|
|
3149
|
+
direction: 1,
|
|
3150
|
+
width: suffixWidth
|
|
3151
|
+
}), this.revertVerticalList(rightOut.verticalList).forEach(v => leftOut.verticalList.push(v)), out = {
|
|
3152
|
+
verticalList: leftOut.verticalList,
|
|
3153
|
+
width: leftOut.width + rightOut.width
|
|
3154
|
+
};
|
|
3155
|
+
} else out = this.clipTextVertical(verticalList, options, width, wordBreak), out.verticalList.push({
|
|
3156
|
+
text: suffix,
|
|
3157
|
+
direction: 1,
|
|
3158
|
+
width: suffixWidth
|
|
3159
|
+
});
|
|
3160
|
+
return out.width += suffixWidth, out;
|
|
3161
|
+
}
|
|
3162
|
+
revertVerticalList(verticalList) {
|
|
3163
|
+
return verticalList.reverse().map(l => {
|
|
3164
|
+
const t = l.text.split("").reverse().join("");
|
|
3165
|
+
return Object.assign(Object.assign({}, l), {
|
|
3166
|
+
text: t
|
|
3167
|
+
});
|
|
3168
|
+
});
|
|
3169
|
+
}
|
|
3170
|
+
clipTextWithSuffix(text, options, width, suffix, wordBreak, position) {
|
|
3171
|
+
let forceSuffix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : !1;
|
|
3172
|
+
if ("" === suffix) return this.clipText(text, options, width, wordBreak);
|
|
3173
|
+
if (0 === text.length) return {
|
|
3174
|
+
str: "",
|
|
3175
|
+
width: 0
|
|
3176
|
+
};
|
|
3177
|
+
const length = this.measureTextWidth(text, options);
|
|
3178
|
+
if (!forceSuffix && length <= width) return {
|
|
3179
|
+
str: text,
|
|
3180
|
+
width: length
|
|
3181
|
+
};
|
|
3182
|
+
const suffixWidth = this.measureTextWidth(suffix, options);
|
|
3183
|
+
if (suffixWidth > width) return {
|
|
3184
|
+
str: "",
|
|
3185
|
+
width: 0
|
|
3186
|
+
};
|
|
3187
|
+
if (forceSuffix && length + suffixWidth <= width) return {
|
|
3188
|
+
str: text + suffix,
|
|
3189
|
+
width: length + suffixWidth
|
|
3190
|
+
};
|
|
3191
|
+
width -= suffixWidth;
|
|
3192
|
+
const data = this._clipText(text, options, width, 0, text.length - 1, position, suffix);
|
|
3193
|
+
if (wordBreak && data.str !== text) {
|
|
3194
|
+
const index = testLetter(text, data.str.length);
|
|
3195
|
+
index !== data.str.length && (data.result = text.substring(0, index), data.width = this.measureTextWidth(data.str, options));
|
|
3196
|
+
} else forceSuffix && data.str === text && (data.result = text + suffix);
|
|
3197
|
+
return data.str = data.result, data.width += suffixWidth, data;
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
ATextMeasure = __decorate$O([injectable()], ATextMeasure);
|
|
3201
|
+
|
|
3202
|
+
var __decorate$N = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
3203
|
+
var d,
|
|
3204
|
+
c = arguments.length,
|
|
3205
|
+
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
3206
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
3207
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3208
|
+
};
|
|
3209
|
+
const TextMeasureContribution = Symbol.for("TextMeasureContribution");
|
|
3210
|
+
let DefaultTextMeasureContribution = class extends ATextMeasure {};
|
|
3211
|
+
DefaultTextMeasureContribution = __decorate$N([injectable()], DefaultTextMeasureContribution);
|
|
3212
|
+
|
|
3213
|
+
const container = new Container();
|
|
3214
|
+
|
|
3215
|
+
const CanvasFactory = Symbol.for("CanvasFactory");
|
|
3216
|
+
|
|
3217
|
+
function wrapCanvas(params) {
|
|
3218
|
+
return container.getNamed(CanvasFactory, application.global.env)(params);
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
class DefaultCanvasAllocate {
|
|
3222
|
+
constructor() {
|
|
3223
|
+
this.pools = [], this.allocatedCanvas = [];
|
|
3224
|
+
}
|
|
3225
|
+
shareCanvas() {
|
|
3226
|
+
return this.allocatedCanvas.length ? this.allocatedCanvas[0] : this.getCommonCanvas();
|
|
3227
|
+
}
|
|
3228
|
+
getCommonCanvas() {
|
|
3229
|
+
return this._commonCanvas || (this._commonCanvas = this.allocate({
|
|
3230
|
+
width: 100,
|
|
3231
|
+
height: 100,
|
|
3232
|
+
dpr: 2
|
|
3233
|
+
})), this._commonCanvas;
|
|
3234
|
+
}
|
|
3235
|
+
allocate(data) {
|
|
3236
|
+
if (!this.pools.length) {
|
|
3237
|
+
const c = wrapCanvas(Object.assign({
|
|
3238
|
+
nativeCanvas: application.global.createCanvas(data)
|
|
3239
|
+
}, data));
|
|
3240
|
+
return this.allocatedCanvas.push(c), c;
|
|
3241
|
+
}
|
|
3242
|
+
const m = this.pools.pop();
|
|
3243
|
+
return m.resize(data.width, data.height), m.dpr = data.dpr, m;
|
|
3244
|
+
}
|
|
3245
|
+
allocateByObj(canvas) {
|
|
3246
|
+
if (!this.pools.length) {
|
|
3247
|
+
const data = {
|
|
3248
|
+
width: canvas.width / canvas.dpr,
|
|
3249
|
+
height: canvas.height / canvas.dpr,
|
|
3250
|
+
dpr: canvas.dpr
|
|
3251
|
+
},
|
|
3252
|
+
c = wrapCanvas(Object.assign({
|
|
3253
|
+
nativeCanvas: application.global.createCanvas(data)
|
|
3254
|
+
}, data));
|
|
3255
|
+
return this.allocatedCanvas.push(c), c;
|
|
3256
|
+
}
|
|
3257
|
+
const m = this.pools.pop();
|
|
3258
|
+
return m.width = canvas.width, m.height = canvas.height, m;
|
|
3259
|
+
}
|
|
3260
|
+
free(d) {
|
|
3261
|
+
this.pools.push(d);
|
|
3262
|
+
}
|
|
3263
|
+
get length() {
|
|
3264
|
+
return this.pools.length;
|
|
3265
|
+
}
|
|
3266
|
+
release() {
|
|
3267
|
+
this.pools = [];
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
const canvasAllocate = new DefaultCanvasAllocate();
|
|
3271
|
+
|
|
3272
|
+
var __decorate$M = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
3273
|
+
var d,
|
|
3274
|
+
c = arguments.length,
|
|
3275
|
+
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
3276
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
3277
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3278
|
+
},
|
|
3279
|
+
__metadata$D = undefined && undefined.__metadata || function (k, v) {
|
|
3280
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
3281
|
+
};
|
|
3282
|
+
const VWindow = Symbol.for("VWindow");
|
|
3283
|
+
const WindowHandlerContribution = Symbol.for("WindowHandlerContribution");
|
|
3284
|
+
let DefaultWindow = class {
|
|
3285
|
+
get width() {
|
|
3286
|
+
if (this._handler) {
|
|
3287
|
+
const wh = this._handler.getWH();
|
|
3288
|
+
return this._width = wh.width;
|
|
3289
|
+
}
|
|
3290
|
+
return this._width;
|
|
3291
|
+
}
|
|
3292
|
+
get height() {
|
|
3293
|
+
if (this._handler) {
|
|
3294
|
+
const wh = this._handler.getWH();
|
|
3295
|
+
return this._height = wh.height;
|
|
3296
|
+
}
|
|
3297
|
+
return this._height;
|
|
3298
|
+
}
|
|
3299
|
+
get dpr() {
|
|
3300
|
+
return this._handler.getDpr();
|
|
3301
|
+
}
|
|
3302
|
+
constructor() {
|
|
3303
|
+
this.hooks = {
|
|
3304
|
+
onChange: new SyncHook(["x", "y", "width", "height"])
|
|
3305
|
+
}, this.active = () => {
|
|
3306
|
+
const global = this.global;
|
|
3307
|
+
if (!global.env || this.actived) return;
|
|
3308
|
+
container.getNamed(WindowHandlerContribution, global.env).configure(this, global), this.actived = !0;
|
|
3309
|
+
}, this._uid = Generator.GenAutoIncrementId(), this.global = application.global, this.postInit();
|
|
3310
|
+
}
|
|
3311
|
+
postInit() {
|
|
3312
|
+
this.global.hooks.onSetEnv.tap("window", this.active), this.active();
|
|
3313
|
+
}
|
|
3314
|
+
get style() {
|
|
3315
|
+
var _a;
|
|
3316
|
+
return null !== (_a = this._handler.getStyle()) && void 0 !== _a ? _a : {};
|
|
3317
|
+
}
|
|
3318
|
+
set style(style) {
|
|
3319
|
+
this._handler.setStyle(style);
|
|
3320
|
+
}
|
|
3321
|
+
create(params) {
|
|
3322
|
+
var _a, _b;
|
|
3323
|
+
this._handler.createWindow(params);
|
|
3324
|
+
const windowWH = this._handler.getWH();
|
|
3325
|
+
this._width = windowWH.width, this._height = windowWH.height, params.viewBox ? this.setViewBox(params.viewBox) : !1 !== params.canvasControled ? this.setViewBox({
|
|
3326
|
+
x1: 0,
|
|
3327
|
+
y1: 0,
|
|
3328
|
+
x2: this._width,
|
|
3329
|
+
y2: this._height
|
|
3330
|
+
}) : this.setViewBox({
|
|
3331
|
+
x1: 0,
|
|
3332
|
+
y1: 0,
|
|
3333
|
+
x2: null !== (_a = params.width) && void 0 !== _a ? _a : this._width,
|
|
3334
|
+
y2: null !== (_b = params.height) && void 0 !== _b ? _b : this._height
|
|
3335
|
+
}), this.title = this._handler.getTitle(), this.resizable = !0;
|
|
3336
|
+
}
|
|
3337
|
+
setWindowHandler(handler) {
|
|
3338
|
+
this._handler = handler;
|
|
3339
|
+
}
|
|
3340
|
+
setDpr(dpr) {
|
|
3341
|
+
return this._handler.setDpr(dpr);
|
|
3342
|
+
}
|
|
3343
|
+
resize(w, h) {
|
|
3344
|
+
return this._handler.resizeWindow(w, h);
|
|
3345
|
+
}
|
|
3346
|
+
configure() {
|
|
3347
|
+
throw new Error("暂不支持");
|
|
3348
|
+
}
|
|
3349
|
+
release() {
|
|
3350
|
+
return this.global.hooks.onSetEnv.unTap("window", this.active), this._handler.releaseWindow();
|
|
3351
|
+
}
|
|
3352
|
+
getContext() {
|
|
3353
|
+
return this._handler.getContext();
|
|
3354
|
+
}
|
|
3355
|
+
getNativeHandler() {
|
|
3356
|
+
return this._handler.getNativeHandler();
|
|
3357
|
+
}
|
|
3358
|
+
getImageBuffer(type) {
|
|
3359
|
+
return this._handler.getImageBuffer ? this._handler.getImageBuffer(type) : null;
|
|
3360
|
+
}
|
|
3361
|
+
addEventListener(type, listener, options) {
|
|
3362
|
+
return this._handler.addEventListener(type, listener, options);
|
|
3363
|
+
}
|
|
3364
|
+
removeEventListener(type, listener, options) {
|
|
3365
|
+
return this._handler.removeEventListener(type, listener, options);
|
|
3366
|
+
}
|
|
3367
|
+
dispatchEvent(event) {
|
|
3368
|
+
return this._handler.dispatchEvent(event);
|
|
3369
|
+
}
|
|
3370
|
+
getBoundingClientRect() {
|
|
3371
|
+
return this._handler.getBoundingClientRect();
|
|
3372
|
+
}
|
|
3373
|
+
getContainer() {
|
|
3374
|
+
return this._handler.container;
|
|
3375
|
+
}
|
|
3376
|
+
clearViewBox(color) {
|
|
3377
|
+
this._handler.clearViewBox(color);
|
|
3378
|
+
}
|
|
3379
|
+
setViewBox(viewBox) {
|
|
3380
|
+
this._handler.setViewBox(viewBox);
|
|
3381
|
+
}
|
|
3382
|
+
setViewBoxTransform(a, b, c, d, e, f) {
|
|
3383
|
+
this._handler.setViewBoxTransform(a, b, c, d, e, f);
|
|
3384
|
+
}
|
|
3385
|
+
getViewBox() {
|
|
3386
|
+
return this._handler.getViewBox();
|
|
3387
|
+
}
|
|
3388
|
+
getViewBoxTransform() {
|
|
3389
|
+
return this._handler.getViewBoxTransform();
|
|
3390
|
+
}
|
|
3391
|
+
pointTransform(x, y) {
|
|
3392
|
+
const vb = this._handler.getViewBox(),
|
|
3393
|
+
nextP = {
|
|
3394
|
+
x: x,
|
|
3395
|
+
y: y
|
|
3396
|
+
};
|
|
3397
|
+
return this._handler.getViewBoxTransform().transformPoint({
|
|
3398
|
+
x: x,
|
|
3399
|
+
y: y
|
|
3400
|
+
}, nextP), nextP.x -= vb.x1, nextP.y -= vb.y1, nextP;
|
|
3401
|
+
}
|
|
3402
|
+
hasSubView() {
|
|
3403
|
+
const viewBox = this._handler.getViewBox();
|
|
3404
|
+
return !(0 === viewBox.x1 && 0 === viewBox.y1 && isNumberClose(this.width, viewBox.width()) && isNumberClose(this.height, viewBox.height()));
|
|
3405
|
+
}
|
|
3406
|
+
isVisible(bbox) {
|
|
3407
|
+
return this._handler.isVisible(bbox);
|
|
3408
|
+
}
|
|
3409
|
+
onVisibleChange(cb) {
|
|
3410
|
+
return this._handler.onVisibleChange(cb);
|
|
3411
|
+
}
|
|
3412
|
+
getTopLeft(baseWindow) {
|
|
3413
|
+
return this._handler.getTopLeft(baseWindow);
|
|
3414
|
+
}
|
|
3415
|
+
};
|
|
3416
|
+
DefaultWindow = __decorate$M([injectable(), __metadata$D("design:paramtypes", [])], DefaultWindow);
|
|
3417
|
+
|
|
3418
|
+
var __decorate$L = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
3419
|
+
var d,
|
|
3420
|
+
c = arguments.length,
|
|
3421
|
+
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
3422
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
3423
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3424
|
+
},
|
|
3425
|
+
__metadata$C = undefined && undefined.__metadata || function (k, v) {
|
|
3426
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
3427
|
+
},
|
|
3428
|
+
__param$y = undefined && undefined.__param || function (paramIndex, decorator) {
|
|
3429
|
+
return function (target, key) {
|
|
3430
|
+
decorator(target, key, paramIndex);
|
|
3431
|
+
};
|
|
3432
|
+
};
|
|
3433
|
+
let DefaultGraphicUtil = class {
|
|
3434
|
+
get canvas() {
|
|
3435
|
+
return this.tryInitCanvas(), this._canvas;
|
|
3436
|
+
}
|
|
3437
|
+
get context() {
|
|
3438
|
+
return this.tryInitCanvas(), this._context;
|
|
3439
|
+
}
|
|
3440
|
+
constructor(contributions) {
|
|
3441
|
+
this.contributions = contributions, this.configured = !1, this.global = application.global, this.global.hooks.onSetEnv.tap("graphic-util", (lastEnv, env, global) => {
|
|
3442
|
+
this.configured = !1, this.configure(global, env);
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
get textMeasure() {
|
|
3446
|
+
return this._textMeasure || this.configure(this.global, this.global.env), this._textMeasure;
|
|
3447
|
+
}
|
|
3448
|
+
configure(global, env) {
|
|
3449
|
+
this.configured || (this.contributions.getContributions().forEach(contribution => {
|
|
3450
|
+
contribution.configure(this, env);
|
|
3451
|
+
}), this.configured = !0);
|
|
3452
|
+
}
|
|
3453
|
+
tryInitCanvas() {
|
|
3454
|
+
if (!this._canvas) {
|
|
3455
|
+
const canvas = canvasAllocate.shareCanvas();
|
|
3456
|
+
this._canvas = canvas, this._context = canvas.getContext("2d");
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
bindTextMeasure(tm) {
|
|
3460
|
+
this._textMeasure = tm;
|
|
3461
|
+
}
|
|
3462
|
+
measureText(text, tc) {
|
|
3463
|
+
let method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "native";
|
|
3464
|
+
var _a;
|
|
3465
|
+
this.configure(this.global, this.global.env);
|
|
3466
|
+
const m = this.global.measureTextMethod;
|
|
3467
|
+
this.global.measureTextMethod = method;
|
|
3468
|
+
const data = {
|
|
3469
|
+
width: this._textMeasure.measureTextWidth(text, tc),
|
|
3470
|
+
height: null !== (_a = tc.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize
|
|
3471
|
+
};
|
|
3472
|
+
return this.global.measureTextMethod = m, data;
|
|
3473
|
+
}
|
|
3474
|
+
createTextMeasureInstance(textSpec, option, getCanvasForMeasure) {
|
|
3475
|
+
return this.configure(this.global, this.global.env), new TextMeasure(Object.assign({
|
|
3476
|
+
defaultFontParams: {
|
|
3477
|
+
fontFamily: DefaultTextStyle.fontFamily,
|
|
3478
|
+
fontSize: DefaultTextStyle.fontSize
|
|
3074
3479
|
},
|
|
3075
3480
|
getCanvasForMeasure: getCanvasForMeasure || (() => this.canvas),
|
|
3076
3481
|
getTextBounds: void 0,
|
|
@@ -3390,19 +3795,19 @@ class Node extends EventEmitter {
|
|
|
3390
3795
|
}
|
|
3391
3796
|
insertBefore(newNode, referenceNode) {
|
|
3392
3797
|
if (!referenceNode) return this.appendChild(newNode);
|
|
3393
|
-
if (this
|
|
3798
|
+
if (this === newNode || newNode === referenceNode) return null;
|
|
3394
3799
|
if (newNode.isAncestorsOf(this)) throw new Error("【Node::insertBefore】不能将父辈元素insert为子元素");
|
|
3395
3800
|
return referenceNode.parent !== this ? null : (newNode.parent && newNode.parent.removeChild(newNode), newNode.parent = this, newNode._prev = referenceNode._prev, referenceNode._prev ? referenceNode._prev._next = newNode : this._firstChild = newNode, referenceNode._prev = newNode, newNode._next = referenceNode, this._idMap || (this._idMap = new Map()), this._idMap.set(newNode._uid, newNode), this._structEdit = !0, this.setCount(newNode.count), newNode);
|
|
3396
3801
|
}
|
|
3397
3802
|
insertAfter(newNode, referenceNode) {
|
|
3398
3803
|
if (!referenceNode) return this.appendChild(newNode);
|
|
3399
|
-
if (this
|
|
3804
|
+
if (this === newNode || newNode === referenceNode) return null;
|
|
3400
3805
|
if (newNode.isAncestorsOf(this)) throw new Error("【Node::insertAfter】不能将父辈元素insert为子元素");
|
|
3401
3806
|
return referenceNode.parent !== this ? null : (newNode.parent && newNode.parent.removeChild(newNode), newNode.parent = this, referenceNode._next ? (referenceNode._next._prev = newNode, newNode._next = referenceNode._next) : this._lastChild = newNode, referenceNode._next = newNode, newNode._prev = referenceNode, this._idMap || (this._idMap = new Map()), this._idMap.set(newNode._uid, newNode), this._structEdit = !0, this.setCount(newNode.count), newNode);
|
|
3402
3807
|
}
|
|
3403
3808
|
insertInto(newNode, idx) {
|
|
3404
3809
|
if (!this._ignoreWarn && this._nodeList && Logger.getInstance().warn("insertIntoKeepIdx和insertInto混用可能会存在错误"), idx >= this.childrenCount) return this.appendChild(newNode);
|
|
3405
|
-
if (this
|
|
3810
|
+
if (this === newNode) return null;
|
|
3406
3811
|
if (newNode.isAncestorsOf(this)) throw new Error("【Node::insertBefore】不能将父辈元素insert为子元素");
|
|
3407
3812
|
if (newNode.parent && newNode.parent.removeChild(newNode), newNode.parent = this, 0 === idx) newNode._next = this._firstChild, this._firstChild && (this._firstChild._prev = newNode), newNode._prev = null, this._firstChild = newNode;else {
|
|
3408
3813
|
let child = this._firstChild;
|
|
@@ -3831,6 +4236,9 @@ class Easing {
|
|
|
3831
4236
|
return (t *= 2) < 1 ? amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * -.5 : amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * .5 + 1;
|
|
3832
4237
|
};
|
|
3833
4238
|
}
|
|
4239
|
+
static registerFunc(name, func) {
|
|
4240
|
+
Easing[name] = func;
|
|
4241
|
+
}
|
|
3834
4242
|
}
|
|
3835
4243
|
Easing.quadIn = Easing.getPowIn(2), Easing.quadOut = Easing.getPowOut(2), Easing.quadInOut = Easing.getPowInOut(2), Easing.cubicIn = Easing.getPowIn(3), Easing.cubicOut = Easing.getPowOut(3), Easing.cubicInOut = Easing.getPowInOut(3), Easing.quartIn = Easing.getPowIn(4), Easing.quartOut = Easing.getPowOut(4), Easing.quartInOut = Easing.getPowInOut(4), Easing.quintIn = Easing.getPowIn(5), Easing.quintOut = Easing.getPowOut(5), Easing.quintInOut = Easing.getPowInOut(5), Easing.backIn = Easing.getBackIn(1.7), Easing.backOut = Easing.getBackOut(1.7), Easing.backInOut = Easing.getBackInOut(1.7), Easing.elasticIn = Easing.getElasticIn(1, .3), Easing.elasticOut = Easing.getElasticOut(1, .3), Easing.elasticInOut = Easing.getElasticInOut(1, .3 * 1.5), Easing.easeInOutQuad = t => (t /= .5) < 1 ? .5 * Math.pow(t, 2) : -.5 * ((t -= 2) * t - 2), Easing.easeOutElastic = x => {
|
|
3836
4244
|
const c4 = 2 * Math.PI / 3;
|
|
@@ -4339,12 +4747,16 @@ function getAttributeFromDefaultAttrList(attr, key) {
|
|
|
4339
4747
|
}
|
|
4340
4748
|
return attr[key];
|
|
4341
4749
|
}
|
|
4342
|
-
const
|
|
4750
|
+
const _calculateLineHeight = (lineHeight, fontSize) => {
|
|
4343
4751
|
if (isString(lineHeight) && "%" === lineHeight[lineHeight.length - 1]) {
|
|
4344
4752
|
return fontSize * (Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100);
|
|
4345
4753
|
}
|
|
4346
4754
|
return lineHeight;
|
|
4347
4755
|
};
|
|
4756
|
+
const calculateLineHeight = (lineHeight, fontSize) => {
|
|
4757
|
+
const _lh = _calculateLineHeight(lineHeight, fontSize);
|
|
4758
|
+
return isNaN(_lh) ? _lh : Math.max(fontSize, _lh);
|
|
4759
|
+
};
|
|
4348
4760
|
|
|
4349
4761
|
class IncreaseCount extends ACustomAnimate {
|
|
4350
4762
|
constructor(from, to, duration, easing, params) {
|
|
@@ -6186,9 +6598,6 @@ const SymbolRenderContribution = Symbol.for("SymbolRenderContribution");
|
|
|
6186
6598
|
const TextRenderContribution = Symbol.for("TextRenderContribution");
|
|
6187
6599
|
const InteractiveSubRenderContribution = Symbol.for("InteractiveSubRenderContribution");
|
|
6188
6600
|
|
|
6189
|
-
function textDrawOffsetY(baseline, h) {
|
|
6190
|
-
return "top" === baseline ? Math.ceil(.79 * h) : "middle" === baseline ? Math.round(.3 * h) : "bottom" === baseline ? Math.round(-.21 * h) : 0;
|
|
6191
|
-
}
|
|
6192
6601
|
function textDrawOffsetX(textAlign, width) {
|
|
6193
6602
|
return "end" === textAlign || "right" === textAlign ? -width : "center" === textAlign ? -width / 2 : 0;
|
|
6194
6603
|
}
|
|
@@ -6620,58 +7029,64 @@ class CanvasTextLayout {
|
|
|
6620
7029
|
constructor(fontFamily, options, textMeasure) {
|
|
6621
7030
|
this.fontFamily = fontFamily, this.textOptions = options, this.textMeasure = textMeasure;
|
|
6622
7031
|
}
|
|
6623
|
-
LayoutBBox(bbox, textAlign, textBaseline) {
|
|
6624
|
-
if ("left" === textAlign || "start" === textAlign) bbox.
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
bboxOffset = [0, 0];
|
|
6634
|
-
for (; str.length > 0;) {
|
|
6635
|
-
const {
|
|
6636
|
-
str: clipText
|
|
6637
|
-
} = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
6638
|
-
linesLayout.push({
|
|
6639
|
-
str: clipText,
|
|
6640
|
-
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
6641
|
-
}), str = str.substring(clipText.length);
|
|
6642
|
-
}
|
|
6643
|
-
"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]));
|
|
6644
|
-
const bbox = {
|
|
6645
|
-
xOffset: bboxOffset[0],
|
|
6646
|
-
yOffset: bboxOffset[1],
|
|
6647
|
-
width: bboxWH[0],
|
|
6648
|
-
height: bboxWH[1]
|
|
6649
|
-
};
|
|
6650
|
-
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
7032
|
+
LayoutBBox(bbox, textAlign, textBaseline, linesLayout) {
|
|
7033
|
+
if (bbox.xOffset = "left" === textAlign || "start" === textAlign ? 0 : "center" === textAlign ? bbox.width / -2 : "right" === textAlign || "end" === textAlign ? -bbox.width : 0, "top" === textBaseline) bbox.yOffset = 0;else if ("middle" === textBaseline) bbox.yOffset = bbox.height / -2;else if ("alphabetic" === textBaseline) {
|
|
7034
|
+
let percent = .79;
|
|
7035
|
+
if (1 === linesLayout.length) {
|
|
7036
|
+
const lineInfo = linesLayout[0];
|
|
7037
|
+
percent = lineInfo.ascent / (lineInfo.ascent + lineInfo.descent);
|
|
7038
|
+
}
|
|
7039
|
+
bbox.yOffset = bbox.height * -percent;
|
|
7040
|
+
} else bbox.yOffset = -bbox.height;
|
|
7041
|
+
return bbox;
|
|
6651
7042
|
}
|
|
6652
7043
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
6653
7044
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
6654
7045
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
6655
|
-
let
|
|
6656
|
-
|
|
7046
|
+
let params = arguments.length > 6 ? arguments[6] : undefined;
|
|
7047
|
+
const {
|
|
7048
|
+
lineWidth: lineWidth,
|
|
7049
|
+
suffixPosition = "end",
|
|
7050
|
+
measureMode = MeasureModeEnum.actualBounding,
|
|
7051
|
+
keepCenterInLine = !1
|
|
7052
|
+
} = null != params ? params : {};
|
|
6657
7053
|
lines = lines.map(l => l.toString());
|
|
6658
7054
|
const linesLayout = [],
|
|
6659
7055
|
bboxWH = [0, 0];
|
|
6660
7056
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
6661
7057
|
let width;
|
|
6662
|
-
for (let i = 0, len = lines.length; i < len; i++)
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
7058
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
7059
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
7060
|
+
let str = lines[i].toString();
|
|
7061
|
+
if (metrics.width > lineWidth) {
|
|
7062
|
+
const data = this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, lineWidth, suffix, wordBreak, suffixPosition);
|
|
7063
|
+
str = data.str, width = data.width;
|
|
7064
|
+
} else width = metrics.width;
|
|
7065
|
+
linesLayout.push({
|
|
7066
|
+
str: str,
|
|
7067
|
+
width: width,
|
|
7068
|
+
ascent: metrics.ascent,
|
|
7069
|
+
descent: metrics.descent,
|
|
7070
|
+
keepCenterInLine: keepCenterInLine
|
|
7071
|
+
});
|
|
7072
|
+
}
|
|
6666
7073
|
bboxWH[0] = lineWidth;
|
|
6667
7074
|
} else {
|
|
6668
|
-
let width,
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
7075
|
+
let width,
|
|
7076
|
+
text,
|
|
7077
|
+
_lineWidth = 0;
|
|
7078
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
7079
|
+
text = lines[i];
|
|
7080
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
7081
|
+
width = metrics.width, _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
|
|
7082
|
+
str: text,
|
|
7083
|
+
width: width,
|
|
7084
|
+
ascent: metrics.ascent,
|
|
7085
|
+
descent: metrics.descent,
|
|
7086
|
+
keepCenterInLine: keepCenterInLine
|
|
7087
|
+
});
|
|
7088
|
+
}
|
|
7089
|
+
bboxWH[0] = _lineWidth;
|
|
6675
7090
|
}
|
|
6676
7091
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
6677
7092
|
const bbox = {
|
|
@@ -6680,7 +7095,7 @@ class CanvasTextLayout {
|
|
|
6680
7095
|
width: bboxWH[0],
|
|
6681
7096
|
height: bboxWH[1]
|
|
6682
7097
|
};
|
|
6683
|
-
return this.LayoutBBox(bbox, textAlign, textBaseline), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
7098
|
+
return this.LayoutBBox(bbox, textAlign, textBaseline, linesLayout), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
6684
7099
|
}
|
|
6685
7100
|
layoutWithBBox(bbox, lines, textAlign, textBaseline, lineHeight) {
|
|
6686
7101
|
const origin = [0, 0],
|
|
@@ -6699,11 +7114,19 @@ class CanvasTextLayout {
|
|
|
6699
7114
|
};
|
|
6700
7115
|
}
|
|
6701
7116
|
lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
|
|
6702
|
-
|
|
7117
|
+
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) {
|
|
7118
|
+
const buf = 0,
|
|
7119
|
+
actualHeightWithBuf = line.ascent + line.descent + buf;
|
|
7120
|
+
if (actualHeightWithBuf < lineHeight - buf && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2)), "alphabetic" === textBaseline) {
|
|
7121
|
+
const ratio = lineHeight / (line.ascent + line.descent);
|
|
7122
|
+
line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 * ratio + origin[1];
|
|
7123
|
+
}
|
|
7124
|
+
}
|
|
7125
|
+
return origin[1] += lineHeight, line;
|
|
6703
7126
|
}
|
|
6704
7127
|
}
|
|
6705
7128
|
|
|
6706
|
-
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
7129
|
+
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];
|
|
6707
7130
|
class Text extends Graphic {
|
|
6708
7131
|
get font() {
|
|
6709
7132
|
const textTheme = this.getGraphicTheme();
|
|
@@ -6712,26 +7135,22 @@ class Text extends Graphic {
|
|
|
6712
7135
|
get clipedText() {
|
|
6713
7136
|
var _a;
|
|
6714
7137
|
const attribute = this.attribute,
|
|
6715
|
-
textTheme = this.getGraphicTheme()
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
maxLineWidth = textTheme.maxLineWidth
|
|
6719
|
-
} = attribute;
|
|
6720
|
-
return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
7138
|
+
textTheme = this.getGraphicTheme(),
|
|
7139
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
7140
|
+
return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
6721
7141
|
}
|
|
6722
7142
|
get clipedWidth() {
|
|
6723
|
-
|
|
7143
|
+
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
6724
7144
|
}
|
|
6725
7145
|
get cliped() {
|
|
6726
7146
|
var _a, _b;
|
|
6727
7147
|
const textTheme = this.getGraphicTheme(),
|
|
6728
7148
|
attribute = this.attribute,
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
7149
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
7150
|
+
if (!Number.isFinite(maxWidth)) return !1;
|
|
7151
|
+
const {
|
|
7152
|
+
text: text
|
|
7153
|
+
} = this.attribute;
|
|
6735
7154
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
6736
7155
|
let mergedText = "";
|
|
6737
7156
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -6742,10 +7161,7 @@ class Text extends Graphic {
|
|
|
6742
7161
|
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();
|
|
6743
7162
|
}
|
|
6744
7163
|
get multilineLayout() {
|
|
6745
|
-
|
|
6746
|
-
}
|
|
6747
|
-
isSimplify() {
|
|
6748
|
-
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
7164
|
+
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
6749
7165
|
}
|
|
6750
7166
|
get isMultiLine() {
|
|
6751
7167
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -6818,114 +7234,14 @@ class Text extends Graphic {
|
|
|
6818
7234
|
}
|
|
6819
7235
|
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
6820
7236
|
}
|
|
6821
|
-
updateWrapAABBBounds(text) {
|
|
6822
|
-
var _a, _b, _c, _d;
|
|
6823
|
-
const textTheme = this.getGraphicTheme(),
|
|
6824
|
-
{
|
|
6825
|
-
fontFamily = textTheme.fontFamily,
|
|
6826
|
-
textAlign = textTheme.textAlign,
|
|
6827
|
-
textBaseline = textTheme.textBaseline,
|
|
6828
|
-
fontSize = textTheme.fontSize,
|
|
6829
|
-
ellipsis = textTheme.ellipsis,
|
|
6830
|
-
maxLineWidth: maxLineWidth,
|
|
6831
|
-
stroke = textTheme.stroke,
|
|
6832
|
-
lineWidth = textTheme.lineWidth,
|
|
6833
|
-
wordBreak = textTheme.wordBreak,
|
|
6834
|
-
fontWeight = textTheme.fontWeight,
|
|
6835
|
-
ignoreBuf = textTheme.ignoreBuf,
|
|
6836
|
-
suffixPosition = textTheme.suffixPosition,
|
|
6837
|
-
heightLimit = 0,
|
|
6838
|
-
lineClamp: lineClamp
|
|
6839
|
-
} = this.attribute,
|
|
6840
|
-
lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
|
|
6841
|
-
buf = ignoreBuf ? 0 : 2;
|
|
6842
|
-
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
6843
|
-
const bbox = this.cache.layoutData.bbox;
|
|
6844
|
-
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
6845
|
-
}
|
|
6846
|
-
const textMeasure = application.graphicUtil.textMeasure,
|
|
6847
|
-
layoutObj = new CanvasTextLayout(fontFamily, {
|
|
6848
|
-
fontSize: fontSize,
|
|
6849
|
-
fontWeight: fontWeight,
|
|
6850
|
-
fontFamily: fontFamily
|
|
6851
|
-
}, textMeasure),
|
|
6852
|
-
lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
6853
|
-
linesLayout = [],
|
|
6854
|
-
bboxWH = [0, 0];
|
|
6855
|
-
let lineCountLimit = 1 / 0;
|
|
6856
|
-
if (heightLimit > 0 && (lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1)), lineClamp && (lineCountLimit = Math.min(lineCountLimit, lineClamp)), "number" == typeof maxLineWidth && maxLineWidth !== 1 / 0) {
|
|
6857
|
-
if (maxLineWidth > 0) for (let i = 0; i < lines.length; i++) {
|
|
6858
|
-
const str = lines[i];
|
|
6859
|
-
let needCut = !0;
|
|
6860
|
-
if (i === lineCountLimit - 1) {
|
|
6861
|
-
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
|
|
6862
|
-
linesLayout.push({
|
|
6863
|
-
str: clip.str,
|
|
6864
|
-
width: clip.width
|
|
6865
|
-
});
|
|
6866
|
-
break;
|
|
6867
|
-
}
|
|
6868
|
-
const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
6869
|
-
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
6870
|
-
if (ellipsis) {
|
|
6871
|
-
const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
6872
|
-
clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
|
|
6873
|
-
} else clip.str = "", clip.width = 0;
|
|
6874
|
-
needCut = !1;
|
|
6875
|
-
}
|
|
6876
|
-
linesLayout.push({
|
|
6877
|
-
str: clip.str,
|
|
6878
|
-
width: clip.width
|
|
6879
|
-
});
|
|
6880
|
-
let cutLength = clip.str.length;
|
|
6881
|
-
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
6882
|
-
let newStr = str.substring(cutLength);
|
|
6883
|
-
"keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
|
|
6884
|
-
}
|
|
6885
|
-
}
|
|
6886
|
-
let maxWidth = 0;
|
|
6887
|
-
linesLayout.forEach(layout => {
|
|
6888
|
-
maxWidth = Math.max(maxWidth, layout.width);
|
|
6889
|
-
}), bboxWH[0] = maxWidth;
|
|
6890
|
-
} else {
|
|
6891
|
-
let width,
|
|
6892
|
-
text,
|
|
6893
|
-
lineWidth = 0;
|
|
6894
|
-
for (let i = 0, len = lines.length; i < len; i++) {
|
|
6895
|
-
if (i === lineCountLimit - 1) {
|
|
6896
|
-
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
6897
|
-
linesLayout.push({
|
|
6898
|
-
str: clip.str,
|
|
6899
|
-
width: clip.width
|
|
6900
|
-
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
6901
|
-
break;
|
|
6902
|
-
}
|
|
6903
|
-
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
6904
|
-
str: text,
|
|
6905
|
-
width: width
|
|
6906
|
-
});
|
|
6907
|
-
}
|
|
6908
|
-
bboxWH[0] = lineWidth;
|
|
6909
|
-
}
|
|
6910
|
-
bboxWH[1] = linesLayout.length * (lineHeight + buf);
|
|
6911
|
-
const bbox = {
|
|
6912
|
-
xOffset: 0,
|
|
6913
|
-
yOffset: 0,
|
|
6914
|
-
width: bboxWH[0],
|
|
6915
|
-
height: bboxWH[1]
|
|
6916
|
-
};
|
|
6917
|
-
layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
|
|
6918
|
-
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
6919
|
-
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;
|
|
6920
|
-
}
|
|
6921
7237
|
updateSingallineAABBBounds(text) {
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
return
|
|
7238
|
+
this.updateMultilineAABBBounds([text]);
|
|
7239
|
+
const layoutData = this.cache.layoutData;
|
|
7240
|
+
if (layoutData && layoutData.lines && layoutData.lines.length) {
|
|
7241
|
+
const line = layoutData.lines[0];
|
|
7242
|
+
this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
|
|
7243
|
+
}
|
|
7244
|
+
return this._AABBBounds;
|
|
6929
7245
|
}
|
|
6930
7246
|
updateMultilineAABBBounds(text) {
|
|
6931
7247
|
const textTheme = this.getGraphicTheme(),
|
|
@@ -6936,152 +7252,13 @@ class Text extends Graphic {
|
|
|
6936
7252
|
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
6937
7253
|
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
6938
7254
|
}
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
{
|
|
6943
|
-
wrap = textTheme.wrap
|
|
6944
|
-
} = this.attribute;
|
|
6945
|
-
if (wrap) return this.updateWrapAABBBounds([text]);
|
|
6946
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
6947
|
-
let width, str;
|
|
6948
|
-
const attribute = this.attribute,
|
|
6949
|
-
{
|
|
6950
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
6951
|
-
ellipsis = textTheme.ellipsis,
|
|
6952
|
-
textAlign = textTheme.textAlign,
|
|
6953
|
-
textBaseline = textTheme.textBaseline,
|
|
6954
|
-
fontFamily = textTheme.fontFamily,
|
|
6955
|
-
fontSize = textTheme.fontSize,
|
|
6956
|
-
fontWeight = textTheme.fontWeight,
|
|
6957
|
-
stroke = textTheme.stroke,
|
|
6958
|
-
lineWidth = textTheme.lineWidth,
|
|
6959
|
-
ignoreBuf = textTheme.ignoreBuf,
|
|
6960
|
-
whiteSpace = textTheme.whiteSpace,
|
|
6961
|
-
suffixPosition = textTheme.suffixPosition
|
|
6962
|
-
} = attribute;
|
|
6963
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
6964
|
-
const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
|
|
6965
|
-
textFontSize = attribute.fontSize || textTheme.fontSize,
|
|
6966
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
|
|
6967
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
6968
|
-
width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
|
|
6969
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
6970
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
6971
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
6972
|
-
}
|
|
6973
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
6974
|
-
if (ellipsis) {
|
|
6975
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
6976
|
-
data = textMeasure.clipTextWithSuffix(text.toString(), {
|
|
6977
|
-
fontSize: fontSize,
|
|
6978
|
-
fontWeight: fontWeight,
|
|
6979
|
-
fontFamily: fontFamily
|
|
6980
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
6981
|
-
str = data.str, width = data.width;
|
|
6982
|
-
} else {
|
|
6983
|
-
const data = textMeasure.clipText(text.toString(), {
|
|
6984
|
-
fontSize: fontSize,
|
|
6985
|
-
fontWeight: fontWeight,
|
|
6986
|
-
fontFamily: fontFamily
|
|
6987
|
-
}, maxLineWidth, !1);
|
|
6988
|
-
str = data.str, width = data.width;
|
|
6989
|
-
}
|
|
6990
|
-
this.cache.clipedText = str, this.cache.clipedWidth = width;
|
|
6991
|
-
} else width = textMeasure.measureTextWidth(text.toString(), {
|
|
6992
|
-
fontSize: fontSize,
|
|
6993
|
-
fontWeight: fontWeight,
|
|
6994
|
-
fontFamily: fontFamily
|
|
6995
|
-
}), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
|
|
6996
|
-
this.clearUpdateShapeTag();
|
|
6997
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
6998
|
-
let lh = lineHeight;
|
|
6999
|
-
application.global && application.global.isSafari() && (lh += .2 * fontSize);
|
|
7000
|
-
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
7001
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
7002
|
-
}
|
|
7003
|
-
getBaselineMapAlign() {
|
|
7004
|
-
return Text.baselineMapAlign;
|
|
7005
|
-
}
|
|
7006
|
-
getAlignMapBaseline() {
|
|
7007
|
-
return Text.alignMapBaseline;
|
|
7008
|
-
}
|
|
7009
|
-
updateVerticalSinglelineAABBBounds(text) {
|
|
7010
|
-
var _a, _b, _c;
|
|
7011
|
-
const textTheme = this.getGraphicTheme(),
|
|
7012
|
-
textMeasure = application.graphicUtil.textMeasure;
|
|
7013
|
-
let width;
|
|
7014
|
-
const attribute = this.attribute,
|
|
7015
|
-
{
|
|
7016
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
7017
|
-
} = attribute,
|
|
7018
|
-
buf = ignoreBuf ? 0 : 2,
|
|
7019
|
-
{
|
|
7020
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
7021
|
-
ellipsis = textTheme.ellipsis,
|
|
7022
|
-
fontSize = textTheme.fontSize,
|
|
7023
|
-
fontWeight = textTheme.fontWeight,
|
|
7024
|
-
fontFamily = textTheme.fontFamily,
|
|
7025
|
-
stroke = textTheme.stroke,
|
|
7026
|
-
lineWidth = textTheme.lineWidth,
|
|
7027
|
-
verticalMode = textTheme.verticalMode,
|
|
7028
|
-
suffixPosition = textTheme.suffixPosition
|
|
7029
|
-
} = attribute,
|
|
7030
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
7031
|
-
let {
|
|
7032
|
-
textAlign = textTheme.textAlign,
|
|
7033
|
-
textBaseline = textTheme.textBaseline
|
|
7034
|
-
} = attribute;
|
|
7035
|
-
if (!verticalMode) {
|
|
7036
|
-
const t = textAlign;
|
|
7037
|
-
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
7038
|
-
}
|
|
7039
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
7040
|
-
width = this.cache.clipedWidth;
|
|
7041
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
7042
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
7043
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
7044
|
-
}
|
|
7045
|
-
let verticalList = [verticalLayout(text.toString())];
|
|
7046
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
7047
|
-
if (ellipsis) {
|
|
7048
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
7049
|
-
data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
|
|
7050
|
-
fontSize: fontSize,
|
|
7051
|
-
fontWeight: fontWeight,
|
|
7052
|
-
fontFamily: fontFamily
|
|
7053
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
7054
|
-
verticalList = [data.verticalList], width = data.width;
|
|
7055
|
-
} else {
|
|
7056
|
-
const data = textMeasure.clipTextVertical(verticalList[0], {
|
|
7057
|
-
fontSize: fontSize,
|
|
7058
|
-
fontWeight: fontWeight,
|
|
7059
|
-
fontFamily: fontFamily
|
|
7060
|
-
}, maxLineWidth, !1);
|
|
7061
|
-
verticalList = [data.verticalList], width = data.width;
|
|
7062
|
-
}
|
|
7063
|
-
this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
7064
|
-
} else width = 0, verticalList[0].forEach(t => {
|
|
7065
|
-
const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
7066
|
-
fontSize: fontSize,
|
|
7067
|
-
fontWeight: fontWeight,
|
|
7068
|
-
fontFamily: fontFamily
|
|
7069
|
-
});
|
|
7070
|
-
width += w, t.width = w;
|
|
7071
|
-
}), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
7072
|
-
this.clearUpdateShapeTag();
|
|
7073
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
7074
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
7075
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
7076
|
-
}
|
|
7255
|
+
guessLineHeightBuf(fontSize) {
|
|
7256
|
+
return fontSize ? .1 * fontSize : 0;
|
|
7257
|
+
}
|
|
7077
7258
|
updateHorizontalMultilineAABBBounds(text) {
|
|
7078
|
-
var _a
|
|
7259
|
+
var _a;
|
|
7079
7260
|
const textTheme = this.getGraphicTheme(),
|
|
7080
|
-
|
|
7081
|
-
wrap = textTheme.wrap
|
|
7082
|
-
} = this.attribute;
|
|
7083
|
-
if (wrap) return this.updateWrapAABBBounds(text);
|
|
7084
|
-
const attribute = this.attribute,
|
|
7261
|
+
attribute = this.attribute,
|
|
7085
7262
|
{
|
|
7086
7263
|
fontFamily = textTheme.fontFamily,
|
|
7087
7264
|
textAlign = textTheme.textAlign,
|
|
@@ -7091,13 +7268,18 @@ class Text extends Graphic {
|
|
|
7091
7268
|
ellipsis = textTheme.ellipsis,
|
|
7092
7269
|
maxLineWidth: maxLineWidth,
|
|
7093
7270
|
stroke = textTheme.stroke,
|
|
7271
|
+
wrap = textTheme.wrap,
|
|
7272
|
+
measureMode = textTheme.measureMode,
|
|
7094
7273
|
lineWidth = textTheme.lineWidth,
|
|
7095
7274
|
whiteSpace = textTheme.whiteSpace,
|
|
7096
|
-
suffixPosition = textTheme.suffixPosition
|
|
7275
|
+
suffixPosition = textTheme.suffixPosition,
|
|
7276
|
+
ignoreBuf = textTheme.ignoreBuf,
|
|
7277
|
+
keepCenterInLine = textTheme.keepCenterInLine
|
|
7097
7278
|
} = attribute,
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
if (
|
|
7279
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
7280
|
+
lineHeight = this.getLineHeight(attribute, textTheme, buf);
|
|
7281
|
+
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
7282
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
7101
7283
|
const bbox = this.cache.layoutData.bbox;
|
|
7102
7284
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
7103
7285
|
}
|
|
@@ -7105,23 +7287,146 @@ class Text extends Graphic {
|
|
|
7105
7287
|
layoutData = new CanvasTextLayout(fontFamily, {
|
|
7106
7288
|
fontSize: fontSize,
|
|
7107
7289
|
fontWeight: fontWeight,
|
|
7108
|
-
fontFamily: fontFamily
|
|
7109
|
-
|
|
7290
|
+
fontFamily: fontFamily,
|
|
7291
|
+
lineHeight: lineHeight
|
|
7292
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
|
|
7293
|
+
lineWidth: maxLineWidth,
|
|
7294
|
+
suffixPosition: suffixPosition,
|
|
7295
|
+
measureMode: measureMode,
|
|
7296
|
+
keepCenterInLine: keepCenterInLine
|
|
7297
|
+
}),
|
|
7110
7298
|
{
|
|
7111
7299
|
bbox: bbox
|
|
7112
7300
|
} = layoutData;
|
|
7113
7301
|
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;
|
|
7114
7302
|
}
|
|
7115
|
-
|
|
7303
|
+
updateWrapAABBBounds(text) {
|
|
7116
7304
|
var _a, _b, _c;
|
|
7305
|
+
const textTheme = this.getGraphicTheme(),
|
|
7306
|
+
{
|
|
7307
|
+
fontFamily = textTheme.fontFamily,
|
|
7308
|
+
textAlign = textTheme.textAlign,
|
|
7309
|
+
textBaseline = textTheme.textBaseline,
|
|
7310
|
+
fontSize = textTheme.fontSize,
|
|
7311
|
+
ellipsis = textTheme.ellipsis,
|
|
7312
|
+
maxLineWidth: maxLineWidth,
|
|
7313
|
+
stroke = textTheme.stroke,
|
|
7314
|
+
lineWidth = textTheme.lineWidth,
|
|
7315
|
+
wordBreak = textTheme.wordBreak,
|
|
7316
|
+
fontWeight = textTheme.fontWeight,
|
|
7317
|
+
ignoreBuf = textTheme.ignoreBuf,
|
|
7318
|
+
measureMode = textTheme.measureMode,
|
|
7319
|
+
suffixPosition = textTheme.suffixPosition,
|
|
7320
|
+
heightLimit = 0,
|
|
7321
|
+
lineClamp: lineClamp,
|
|
7322
|
+
keepCenterInLine = textTheme.keepCenterInLine
|
|
7323
|
+
} = this.attribute,
|
|
7324
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
7325
|
+
lineHeight = this.getLineHeight(this.attribute, textTheme, buf);
|
|
7326
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
7327
|
+
const bbox = this.cache.layoutData.bbox;
|
|
7328
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
7329
|
+
}
|
|
7330
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
7331
|
+
textOptions = {
|
|
7332
|
+
fontSize: fontSize,
|
|
7333
|
+
fontWeight: fontWeight,
|
|
7334
|
+
fontFamily: fontFamily,
|
|
7335
|
+
lineHeight: lineHeight
|
|
7336
|
+
},
|
|
7337
|
+
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
7338
|
+
lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
7339
|
+
linesLayout = [],
|
|
7340
|
+
bboxWH = [0, 0];
|
|
7341
|
+
let lineCountLimit = 1 / 0;
|
|
7342
|
+
if (heightLimit > 0 && (lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1)), lineClamp && (lineCountLimit = Math.min(lineCountLimit, lineClamp)), "number" == typeof maxLineWidth && maxLineWidth !== 1 / 0) {
|
|
7343
|
+
if (maxLineWidth > 0) for (let i = 0; i < lines.length; i++) {
|
|
7344
|
+
const str = lines[i];
|
|
7345
|
+
let needCut = !0;
|
|
7346
|
+
if (i === lineCountLimit - 1) {
|
|
7347
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
|
|
7348
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
7349
|
+
linesLayout.push({
|
|
7350
|
+
str: clip.str,
|
|
7351
|
+
width: clip.width,
|
|
7352
|
+
ascent: matrics.ascent,
|
|
7353
|
+
descent: matrics.descent,
|
|
7354
|
+
keepCenterInLine: keepCenterInLine
|
|
7355
|
+
});
|
|
7356
|
+
break;
|
|
7357
|
+
}
|
|
7358
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
7359
|
+
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
7360
|
+
if (ellipsis) {
|
|
7361
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
7362
|
+
clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
|
|
7363
|
+
} else clip.str = "", clip.width = 0;
|
|
7364
|
+
needCut = !1;
|
|
7365
|
+
}
|
|
7366
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
7367
|
+
linesLayout.push({
|
|
7368
|
+
str: clip.str,
|
|
7369
|
+
width: clip.width,
|
|
7370
|
+
ascent: matrics.ascent,
|
|
7371
|
+
descent: matrics.descent,
|
|
7372
|
+
keepCenterInLine: keepCenterInLine
|
|
7373
|
+
});
|
|
7374
|
+
let cutLength = clip.str.length;
|
|
7375
|
+
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
7376
|
+
let newStr = str.substring(cutLength);
|
|
7377
|
+
"keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
|
|
7378
|
+
}
|
|
7379
|
+
}
|
|
7380
|
+
let maxWidth = 0;
|
|
7381
|
+
linesLayout.forEach(layout => {
|
|
7382
|
+
maxWidth = Math.max(maxWidth, layout.width);
|
|
7383
|
+
}), bboxWH[0] = maxWidth;
|
|
7384
|
+
} else {
|
|
7385
|
+
let width,
|
|
7386
|
+
text,
|
|
7387
|
+
lineWidth = 0;
|
|
7388
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
7389
|
+
if (i === lineCountLimit - 1) {
|
|
7390
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
|
|
7391
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
7392
|
+
linesLayout.push({
|
|
7393
|
+
str: clip.str,
|
|
7394
|
+
width: clip.width,
|
|
7395
|
+
ascent: matrics.ascent,
|
|
7396
|
+
descent: matrics.descent,
|
|
7397
|
+
keepCenterInLine: keepCenterInLine
|
|
7398
|
+
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
7399
|
+
break;
|
|
7400
|
+
}
|
|
7401
|
+
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
|
|
7402
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
|
|
7403
|
+
linesLayout.push({
|
|
7404
|
+
str: text,
|
|
7405
|
+
width: width,
|
|
7406
|
+
ascent: matrics.ascent,
|
|
7407
|
+
descent: matrics.descent,
|
|
7408
|
+
keepCenterInLine: keepCenterInLine
|
|
7409
|
+
});
|
|
7410
|
+
}
|
|
7411
|
+
bboxWH[0] = lineWidth;
|
|
7412
|
+
}
|
|
7413
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
7414
|
+
const bbox = {
|
|
7415
|
+
xOffset: 0,
|
|
7416
|
+
yOffset: 0,
|
|
7417
|
+
width: bboxWH[0],
|
|
7418
|
+
height: bboxWH[1]
|
|
7419
|
+
};
|
|
7420
|
+
layoutObj.LayoutBBox(bbox, textAlign, textBaseline, linesLayout);
|
|
7421
|
+
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
7422
|
+
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;
|
|
7423
|
+
}
|
|
7424
|
+
updateVerticalMultilineAABBBounds(text) {
|
|
7425
|
+
var _a, _b;
|
|
7117
7426
|
const textTheme = this.getGraphicTheme(),
|
|
7118
7427
|
textMeasure = application.graphicUtil.textMeasure;
|
|
7119
7428
|
let width;
|
|
7120
7429
|
const attribute = this.attribute,
|
|
7121
|
-
{
|
|
7122
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
7123
|
-
} = attribute,
|
|
7124
|
-
buf = ignoreBuf ? 0 : 2,
|
|
7125
7430
|
{
|
|
7126
7431
|
maxLineWidth = textTheme.maxLineWidth,
|
|
7127
7432
|
ellipsis = textTheme.ellipsis,
|
|
@@ -7133,14 +7438,14 @@ class Text extends Graphic {
|
|
|
7133
7438
|
verticalMode = textTheme.verticalMode,
|
|
7134
7439
|
suffixPosition = textTheme.suffixPosition
|
|
7135
7440
|
} = attribute,
|
|
7136
|
-
lineHeight =
|
|
7441
|
+
lineHeight = this.getLineHeight(attribute, textTheme, 0);
|
|
7137
7442
|
let {
|
|
7138
7443
|
textAlign = textTheme.textAlign,
|
|
7139
7444
|
textBaseline = textTheme.textBaseline
|
|
7140
7445
|
} = attribute;
|
|
7141
7446
|
if (!verticalMode) {
|
|
7142
7447
|
const t = textAlign;
|
|
7143
|
-
textAlign = null !== (
|
|
7448
|
+
textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
|
|
7144
7449
|
}
|
|
7145
7450
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
7146
7451
|
this.cache.verticalList.forEach(item => {
|
|
@@ -7188,6 +7493,15 @@ class Text extends Graphic {
|
|
|
7188
7493
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
7189
7494
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
7190
7495
|
}
|
|
7496
|
+
getMaxWidth(theme) {
|
|
7497
|
+
var _a, _b;
|
|
7498
|
+
const attribute = this.attribute;
|
|
7499
|
+
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
7500
|
+
}
|
|
7501
|
+
getLineHeight(attribute, textTheme, buf) {
|
|
7502
|
+
var _a;
|
|
7503
|
+
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
7504
|
+
}
|
|
7191
7505
|
needUpdateTags(keys) {
|
|
7192
7506
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
7193
7507
|
return super.needUpdateTags(keys, k);
|
|
@@ -7202,6 +7516,12 @@ class Text extends Graphic {
|
|
|
7202
7516
|
getNoWorkAnimateAttr() {
|
|
7203
7517
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
7204
7518
|
}
|
|
7519
|
+
getBaselineMapAlign() {
|
|
7520
|
+
return Text.baselineMapAlign;
|
|
7521
|
+
}
|
|
7522
|
+
getAlignMapBaseline() {
|
|
7523
|
+
return Text.alignMapBaseline;
|
|
7524
|
+
}
|
|
7205
7525
|
}
|
|
7206
7526
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
7207
7527
|
ellipsis: 1,
|
|
@@ -7280,7 +7600,10 @@ class WrapText extends Text {
|
|
|
7280
7600
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
7281
7601
|
linesLayout.push({
|
|
7282
7602
|
str: clip.str,
|
|
7283
|
-
width: clip.width
|
|
7603
|
+
width: clip.width,
|
|
7604
|
+
ascent: 0,
|
|
7605
|
+
descent: 0,
|
|
7606
|
+
keepCenterInLine: !1
|
|
7284
7607
|
});
|
|
7285
7608
|
break;
|
|
7286
7609
|
}
|
|
@@ -7294,7 +7617,10 @@ class WrapText extends Text {
|
|
|
7294
7617
|
}
|
|
7295
7618
|
if (linesLayout.push({
|
|
7296
7619
|
str: clip.str,
|
|
7297
|
-
width: clip.width
|
|
7620
|
+
width: clip.width,
|
|
7621
|
+
ascent: 0,
|
|
7622
|
+
descent: 0,
|
|
7623
|
+
keepCenterInLine: !1
|
|
7298
7624
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
7299
7625
|
const newStr = str.substring(clip.str.length);
|
|
7300
7626
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -7313,13 +7639,19 @@ class WrapText extends Text {
|
|
|
7313
7639
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
7314
7640
|
linesLayout.push({
|
|
7315
7641
|
str: clip.str,
|
|
7316
|
-
width: clip.width
|
|
7642
|
+
width: clip.width,
|
|
7643
|
+
ascent: 0,
|
|
7644
|
+
descent: 0,
|
|
7645
|
+
keepCenterInLine: !1
|
|
7317
7646
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
7318
7647
|
break;
|
|
7319
7648
|
}
|
|
7320
7649
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
7321
7650
|
str: text,
|
|
7322
|
-
width: width
|
|
7651
|
+
width: width,
|
|
7652
|
+
ascent: 0,
|
|
7653
|
+
descent: 0,
|
|
7654
|
+
keepCenterInLine: !1
|
|
7323
7655
|
});
|
|
7324
7656
|
}
|
|
7325
7657
|
bboxWH[0] = lineWidth;
|
|
@@ -8350,7 +8682,11 @@ class Paragraph {
|
|
|
8350
8682
|
case "sub":
|
|
8351
8683
|
baseline += this.descent / 2;
|
|
8352
8684
|
}
|
|
8353
|
-
"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)
|
|
8685
|
+
"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);
|
|
8686
|
+
const {
|
|
8687
|
+
lineWidth = 1
|
|
8688
|
+
} = this.character;
|
|
8689
|
+
this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline), 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();
|
|
8354
8690
|
}
|
|
8355
8691
|
getWidthWithEllips(direction) {
|
|
8356
8692
|
let text = this.text;
|
|
@@ -8573,12 +8909,18 @@ class Line {
|
|
|
8573
8909
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
8574
8910
|
}
|
|
8575
8911
|
}
|
|
8576
|
-
this.paragraphs.
|
|
8912
|
+
this.paragraphs.forEach((paragraph, index) => {
|
|
8577
8913
|
if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
|
|
8578
8914
|
x: x + paragraph._x,
|
|
8579
8915
|
y: y + paragraph._y
|
|
8580
8916
|
}), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
|
|
8581
|
-
|
|
8917
|
+
const b = {
|
|
8918
|
+
x1: this.left,
|
|
8919
|
+
y1: this.top,
|
|
8920
|
+
x2: this.left + this.actualWidth,
|
|
8921
|
+
y2: this.top + this.height
|
|
8922
|
+
};
|
|
8923
|
+
applyStrokeStyle(ctx, paragraph.character), applyFillStyle(ctx, paragraph.character, b), paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
|
|
8582
8924
|
});
|
|
8583
8925
|
}
|
|
8584
8926
|
getWidthWithEllips(ellipsis) {
|
|
@@ -8601,7 +8943,7 @@ class Line {
|
|
|
8601
8943
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
8602
8944
|
}
|
|
8603
8945
|
let width = 0;
|
|
8604
|
-
return this.paragraphs.
|
|
8946
|
+
return this.paragraphs.forEach((paragraph, index) => {
|
|
8605
8947
|
width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
|
|
8606
8948
|
}), width;
|
|
8607
8949
|
}
|
|
@@ -9182,663 +9524,377 @@ class Arc extends Graphic {
|
|
|
9182
9524
|
padAngle = arcTheme.padAngle
|
|
9183
9525
|
} = this.attribute;
|
|
9184
9526
|
let {
|
|
9185
|
-
outerRadius = arcTheme.outerRadius,
|
|
9186
|
-
innerRadius = arcTheme.innerRadius
|
|
9187
|
-
} = this.attribute;
|
|
9188
|
-
outerRadius += outerPadding, innerRadius -= innerPadding;
|
|
9189
|
-
const {
|
|
9190
|
-
padRadius = sqrt(outerRadius * outerRadius + innerRadius * innerRadius)
|
|
9191
|
-
} = this.attribute,
|
|
9192
|
-
deltaAngle = abs(endAngle - startAngle);
|
|
9193
|
-
let outerStartAngle = startAngle,
|
|
9194
|
-
outerEndAngle = endAngle,
|
|
9195
|
-
innerStartAngle = startAngle,
|
|
9196
|
-
innerEndAngle = endAngle;
|
|
9197
|
-
const halfPadAngle = padAngle / 2;
|
|
9198
|
-
let innerDeltaAngle = deltaAngle,
|
|
9199
|
-
outerDeltaAngle = deltaAngle;
|
|
9200
|
-
if (halfPadAngle > epsilon && padRadius > epsilon) {
|
|
9201
|
-
const sign = endAngle > startAngle ? 1 : -1;
|
|
9202
|
-
let p0 = asin(Number(padRadius) / innerRadius * sin(halfPadAngle)),
|
|
9203
|
-
p1 = asin(Number(padRadius) / outerRadius * sin(halfPadAngle));
|
|
9204
|
-
return (innerDeltaAngle -= 2 * p0) > epsilon ? (p0 *= sign, innerStartAngle += p0, innerEndAngle -= p0) : (innerDeltaAngle = 0, innerStartAngle = innerEndAngle = (startAngle + endAngle) / 2), (outerDeltaAngle -= 2 * p1) > epsilon ? (p1 *= sign, outerStartAngle += p1, outerEndAngle -= p1) : (outerDeltaAngle = 0, outerStartAngle = outerEndAngle = (startAngle + endAngle) / 2), {
|
|
9205
|
-
outerStartAngle: outerStartAngle,
|
|
9206
|
-
outerEndAngle: outerEndAngle,
|
|
9207
|
-
innerStartAngle: innerStartAngle,
|
|
9208
|
-
innerEndAngle: innerEndAngle,
|
|
9209
|
-
innerDeltaAngle: innerDeltaAngle,
|
|
9210
|
-
outerDeltaAngle: outerDeltaAngle
|
|
9211
|
-
};
|
|
9212
|
-
}
|
|
9213
|
-
return {
|
|
9214
|
-
outerStartAngle: outerStartAngle,
|
|
9215
|
-
outerEndAngle: outerEndAngle,
|
|
9216
|
-
innerStartAngle: innerStartAngle,
|
|
9217
|
-
innerEndAngle: innerEndAngle,
|
|
9218
|
-
innerDeltaAngle: innerDeltaAngle,
|
|
9219
|
-
outerDeltaAngle: outerDeltaAngle
|
|
9220
|
-
};
|
|
9221
|
-
}
|
|
9222
|
-
getGraphicTheme() {
|
|
9223
|
-
return getTheme(this).arc;
|
|
9224
|
-
}
|
|
9225
|
-
updateAABBBounds(attribute, arcTheme, aabbBounds, full) {
|
|
9226
|
-
this.updatePathProxyAABBBounds(aabbBounds) || (full ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) : this.updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds));
|
|
9227
|
-
const {
|
|
9228
|
-
tb1: tb1,
|
|
9229
|
-
tb2: tb2
|
|
9230
|
-
} = application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
9231
|
-
updateBoundsOfCommonOuterBorder(attribute, arcTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
9232
|
-
const {
|
|
9233
|
-
lineJoin = arcTheme.lineJoin
|
|
9234
|
-
} = attribute;
|
|
9235
|
-
return application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, "miter" === lineJoin, this), aabbBounds;
|
|
9236
|
-
}
|
|
9237
|
-
updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) {
|
|
9238
|
-
let {
|
|
9239
|
-
outerRadius = arcTheme.outerRadius,
|
|
9240
|
-
innerRadius = arcTheme.innerRadius
|
|
9241
|
-
} = attribute;
|
|
9242
|
-
const {
|
|
9243
|
-
outerPadding = arcTheme.outerPadding,
|
|
9244
|
-
innerPadding = arcTheme.innerPadding
|
|
9245
|
-
} = attribute;
|
|
9246
|
-
return outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius && (outerRadius = innerRadius), aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius), aabbBounds;
|
|
9247
|
-
}
|
|
9248
|
-
updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds) {
|
|
9249
|
-
let {
|
|
9250
|
-
outerRadius = arcTheme.outerRadius,
|
|
9251
|
-
innerRadius = arcTheme.innerRadius
|
|
9252
|
-
} = attribute;
|
|
9253
|
-
const {
|
|
9254
|
-
outerPadding = arcTheme.outerPadding,
|
|
9255
|
-
innerPadding = arcTheme.innerPadding
|
|
9256
|
-
} = attribute;
|
|
9257
|
-
if (outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius) {
|
|
9258
|
-
const temp = outerRadius;
|
|
9259
|
-
outerRadius = innerRadius, innerRadius = temp;
|
|
9260
|
-
}
|
|
9261
|
-
let {
|
|
9262
|
-
endAngle = arcTheme.endAngle,
|
|
9263
|
-
startAngle = arcTheme.startAngle
|
|
9264
|
-
} = attribute;
|
|
9265
|
-
if (startAngle > endAngle) {
|
|
9266
|
-
const temp = startAngle;
|
|
9267
|
-
startAngle = endAngle, endAngle = temp;
|
|
9268
|
-
}
|
|
9269
|
-
return outerRadius <= epsilon ? aabbBounds.set(0, 0, 0, 0) : Math.abs(endAngle - startAngle) > pi2 - epsilon ? aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius) : (circleBounds(startAngle, endAngle, outerRadius, aabbBounds), circleBounds(startAngle, endAngle, innerRadius, aabbBounds)), aabbBounds;
|
|
9270
|
-
}
|
|
9271
|
-
needUpdateTags(keys) {
|
|
9272
|
-
return super.needUpdateTags(keys, ARC_UPDATE_TAG_KEY);
|
|
9273
|
-
}
|
|
9274
|
-
needUpdateTag(key) {
|
|
9275
|
-
return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
|
|
9276
|
-
}
|
|
9277
|
-
toCustomPath() {
|
|
9278
|
-
var _a, _b, _c, _d;
|
|
9279
|
-
const attribute = this.attribute,
|
|
9280
|
-
{
|
|
9281
|
-
startAngle: startAngle,
|
|
9282
|
-
endAngle: endAngle
|
|
9283
|
-
} = this.getParsedAngle();
|
|
9284
|
-
let innerRadius = (null !== (_a = attribute.innerRadius) && void 0 !== _a ? _a : 0) - (null !== (_b = attribute.innerPadding) && void 0 !== _b ? _b : 0),
|
|
9285
|
-
outerRadius = (null !== (_c = attribute.outerRadius) && void 0 !== _c ? _c : 0) - (null !== (_d = attribute.outerPadding) && void 0 !== _d ? _d : 0);
|
|
9286
|
-
const deltaAngle = abs(endAngle - startAngle),
|
|
9287
|
-
clockwise = endAngle > startAngle;
|
|
9288
|
-
if (outerRadius < innerRadius) {
|
|
9289
|
-
const temp = outerRadius;
|
|
9290
|
-
outerRadius = innerRadius, innerRadius = temp;
|
|
9291
|
-
}
|
|
9292
|
-
const path = new CustomPath2D();
|
|
9293
|
-
if (outerRadius <= epsilon) path.moveTo(0, 0);else if (deltaAngle >= pi2 - epsilon) path.moveTo(0 + outerRadius * cos(startAngle), 0 + outerRadius * sin(startAngle)), path.arc(0, 0, outerRadius, startAngle, endAngle, !clockwise), innerRadius > epsilon && (path.moveTo(0 + innerRadius * cos(endAngle), 0 + innerRadius * sin(endAngle)), path.arc(0, 0, innerRadius, endAngle, startAngle, clockwise));else {
|
|
9294
|
-
const xors = outerRadius * cos(startAngle),
|
|
9295
|
-
yors = outerRadius * sin(startAngle),
|
|
9296
|
-
xire = innerRadius * cos(endAngle),
|
|
9297
|
-
yire = innerRadius * sin(endAngle);
|
|
9298
|
-
path.moveTo(0 + xors, 0 + yors), path.arc(0, 0, outerRadius, startAngle, endAngle, !clockwise), path.lineTo(0 + xire, 0 + yire), path.arc(0, 0, innerRadius, endAngle, startAngle, clockwise), path.closePath();
|
|
9299
|
-
}
|
|
9300
|
-
return path;
|
|
9301
|
-
}
|
|
9302
|
-
clone() {
|
|
9303
|
-
return new Arc(Object.assign({}, this.attribute));
|
|
9304
|
-
}
|
|
9305
|
-
getNoWorkAnimateAttr() {
|
|
9306
|
-
return Arc.NOWORK_ANIMATE_ATTR;
|
|
9307
|
-
}
|
|
9308
|
-
}
|
|
9309
|
-
Arc.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
9310
|
-
cap: 1
|
|
9311
|
-
}, NOWORK_ANIMATE_ATTR);
|
|
9312
|
-
function createArc(attributes) {
|
|
9313
|
-
return new Arc(attributes);
|
|
9314
|
-
}
|
|
9315
|
-
|
|
9316
|
-
const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
9317
|
-
class Polygon extends Graphic {
|
|
9318
|
-
constructor(params) {
|
|
9319
|
-
super(params), this.type = "polygon", this.numberType = POLYGON_NUMBER_TYPE;
|
|
9320
|
-
}
|
|
9321
|
-
isValid() {
|
|
9322
|
-
return super.isValid() && this._isValid();
|
|
9323
|
-
}
|
|
9324
|
-
_isValid() {
|
|
9325
|
-
const {
|
|
9326
|
-
points: points
|
|
9527
|
+
outerRadius = arcTheme.outerRadius,
|
|
9528
|
+
innerRadius = arcTheme.innerRadius
|
|
9327
9529
|
} = this.attribute;
|
|
9328
|
-
|
|
9530
|
+
outerRadius += outerPadding, innerRadius -= innerPadding;
|
|
9531
|
+
const {
|
|
9532
|
+
padRadius = sqrt(outerRadius * outerRadius + innerRadius * innerRadius)
|
|
9533
|
+
} = this.attribute,
|
|
9534
|
+
deltaAngle = abs(endAngle - startAngle);
|
|
9535
|
+
let outerStartAngle = startAngle,
|
|
9536
|
+
outerEndAngle = endAngle,
|
|
9537
|
+
innerStartAngle = startAngle,
|
|
9538
|
+
innerEndAngle = endAngle;
|
|
9539
|
+
const halfPadAngle = padAngle / 2;
|
|
9540
|
+
let innerDeltaAngle = deltaAngle,
|
|
9541
|
+
outerDeltaAngle = deltaAngle;
|
|
9542
|
+
if (halfPadAngle > epsilon && padRadius > epsilon) {
|
|
9543
|
+
const sign = endAngle > startAngle ? 1 : -1;
|
|
9544
|
+
let p0 = asin(Number(padRadius) / innerRadius * sin(halfPadAngle)),
|
|
9545
|
+
p1 = asin(Number(padRadius) / outerRadius * sin(halfPadAngle));
|
|
9546
|
+
return (innerDeltaAngle -= 2 * p0) > epsilon ? (p0 *= sign, innerStartAngle += p0, innerEndAngle -= p0) : (innerDeltaAngle = 0, innerStartAngle = innerEndAngle = (startAngle + endAngle) / 2), (outerDeltaAngle -= 2 * p1) > epsilon ? (p1 *= sign, outerStartAngle += p1, outerEndAngle -= p1) : (outerDeltaAngle = 0, outerStartAngle = outerEndAngle = (startAngle + endAngle) / 2), {
|
|
9547
|
+
outerStartAngle: outerStartAngle,
|
|
9548
|
+
outerEndAngle: outerEndAngle,
|
|
9549
|
+
innerStartAngle: innerStartAngle,
|
|
9550
|
+
innerEndAngle: innerEndAngle,
|
|
9551
|
+
innerDeltaAngle: innerDeltaAngle,
|
|
9552
|
+
outerDeltaAngle: outerDeltaAngle
|
|
9553
|
+
};
|
|
9554
|
+
}
|
|
9555
|
+
return {
|
|
9556
|
+
outerStartAngle: outerStartAngle,
|
|
9557
|
+
outerEndAngle: outerEndAngle,
|
|
9558
|
+
innerStartAngle: innerStartAngle,
|
|
9559
|
+
innerEndAngle: innerEndAngle,
|
|
9560
|
+
innerDeltaAngle: innerDeltaAngle,
|
|
9561
|
+
outerDeltaAngle: outerDeltaAngle
|
|
9562
|
+
};
|
|
9329
9563
|
}
|
|
9330
9564
|
getGraphicTheme() {
|
|
9331
|
-
return getTheme(this).
|
|
9565
|
+
return getTheme(this).arc;
|
|
9332
9566
|
}
|
|
9333
|
-
updateAABBBounds(attribute,
|
|
9334
|
-
this.updatePathProxyAABBBounds(aabbBounds) || this.
|
|
9567
|
+
updateAABBBounds(attribute, arcTheme, aabbBounds, full) {
|
|
9568
|
+
this.updatePathProxyAABBBounds(aabbBounds) || (full ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) : this.updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds));
|
|
9335
9569
|
const {
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds) {
|
|
9570
|
+
tb1: tb1,
|
|
9571
|
+
tb2: tb2
|
|
9572
|
+
} = application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
9573
|
+
updateBoundsOfCommonOuterBorder(attribute, arcTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
9341
9574
|
const {
|
|
9342
|
-
|
|
9575
|
+
lineJoin = arcTheme.lineJoin
|
|
9343
9576
|
} = attribute;
|
|
9344
|
-
return
|
|
9345
|
-
aabbBounds.add(p.x, p.y);
|
|
9346
|
-
}), aabbBounds;
|
|
9347
|
-
}
|
|
9348
|
-
_interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
|
|
9349
|
-
"points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
|
|
9350
|
-
}
|
|
9351
|
-
needUpdateTags(keys) {
|
|
9352
|
-
return super.needUpdateTags(keys, POLYGON_UPDATE_TAG_KEY);
|
|
9353
|
-
}
|
|
9354
|
-
needUpdateTag(key) {
|
|
9355
|
-
return super.needUpdateTag(key, POLYGON_UPDATE_TAG_KEY);
|
|
9356
|
-
}
|
|
9357
|
-
toCustomPath() {
|
|
9358
|
-
const points = this.attribute.points,
|
|
9359
|
-
path = new CustomPath2D();
|
|
9360
|
-
return points.forEach((point, index) => {
|
|
9361
|
-
0 === index ? path.moveTo(point.x, point.y) : path.lineTo(point.x, point.y);
|
|
9362
|
-
}), path.closePath(), path;
|
|
9363
|
-
}
|
|
9364
|
-
clone() {
|
|
9365
|
-
return new Polygon(Object.assign({}, this.attribute));
|
|
9366
|
-
}
|
|
9367
|
-
getNoWorkAnimateAttr() {
|
|
9368
|
-
return Polygon.NOWORK_ANIMATE_ATTR;
|
|
9369
|
-
}
|
|
9370
|
-
}
|
|
9371
|
-
Polygon.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
9372
|
-
function createPolygon(attributes) {
|
|
9373
|
-
return new Polygon(attributes);
|
|
9374
|
-
}
|
|
9375
|
-
|
|
9376
|
-
class GraphicCreator {
|
|
9377
|
-
constructor() {
|
|
9378
|
-
this.store = new Map();
|
|
9379
|
-
}
|
|
9380
|
-
RegisterGraphicCreator(name, cb) {
|
|
9381
|
-
this.store.set(name, cb), this[name] = cb;
|
|
9382
|
-
}
|
|
9383
|
-
CreateGraphic(name, params) {
|
|
9384
|
-
const cb = this.store.get(name);
|
|
9385
|
-
return cb ? cb(params) : null;
|
|
9386
|
-
}
|
|
9387
|
-
}
|
|
9388
|
-
const graphicCreator = new GraphicCreator();
|
|
9389
|
-
|
|
9390
|
-
let text;
|
|
9391
|
-
function getTextBounds(params) {
|
|
9392
|
-
return text || (text = graphicCreator.CreateGraphic("text", {})), text.initAttributes(params), text.AABBBounds;
|
|
9393
|
-
}
|
|
9394
|
-
|
|
9395
|
-
const result = {
|
|
9396
|
-
x: 0,
|
|
9397
|
-
y: 0,
|
|
9398
|
-
z: 0,
|
|
9399
|
-
lastModelMatrix: null
|
|
9400
|
-
};
|
|
9401
|
-
class BaseRender {
|
|
9402
|
-
init(contributions) {
|
|
9403
|
-
contributions && (this._renderContribitions = contributions.getContributions()), this._renderContribitions || (this._renderContribitions = []), this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item)), this._renderContribitions.length && (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === BaseRenderContributionTime.afterFillStroke));
|
|
9404
|
-
}
|
|
9405
|
-
beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
9406
|
-
this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
|
|
9407
|
-
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
9408
|
-
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
9409
|
-
}
|
|
9410
|
-
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
9411
|
-
});
|
|
9412
|
-
}
|
|
9413
|
-
afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
9414
|
-
this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
|
|
9415
|
-
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
9416
|
-
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
9417
|
-
}
|
|
9418
|
-
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
9419
|
-
});
|
|
9420
|
-
}
|
|
9421
|
-
drawPathProxy(graphic, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
9422
|
-
if (!graphic.pathProxy) return !1;
|
|
9423
|
-
const themeAttributes = getTheme(graphic, null == params ? void 0 : params.theme)[graphic.type.replace("3d", "")],
|
|
9424
|
-
{
|
|
9425
|
-
fill = themeAttributes.fill,
|
|
9426
|
-
stroke = themeAttributes.stroke,
|
|
9427
|
-
opacity = themeAttributes.opacity,
|
|
9428
|
-
fillOpacity = themeAttributes.fillOpacity,
|
|
9429
|
-
lineWidth = themeAttributes.lineWidth,
|
|
9430
|
-
strokeOpacity = themeAttributes.strokeOpacity,
|
|
9431
|
-
visible = themeAttributes.visible,
|
|
9432
|
-
x: originX = themeAttributes.x,
|
|
9433
|
-
y: originY = themeAttributes.y
|
|
9434
|
-
} = graphic.attribute,
|
|
9435
|
-
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
9436
|
-
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
9437
|
-
doFill = runFill(fill),
|
|
9438
|
-
doStroke = runStroke(stroke, lineWidth);
|
|
9439
|
-
if (!visible) return !0;
|
|
9440
|
-
if (!doFill && !doStroke) return !0;
|
|
9441
|
-
if (!(fVisible || sVisible || fillCb || strokeCb)) return !0;
|
|
9442
|
-
context.beginPath();
|
|
9443
|
-
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
9444
|
-
return renderCommandList(path.commandList, context, x, y), context.setShadowBlendStyle && context.setShadowBlendStyle(graphic, graphic.attribute, themeAttributes), this.beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, themeAttributes, drawContext, fillCb, strokeCb), doStroke && (strokeCb ? strokeCb(context, graphic.attribute, themeAttributes) : sVisible && (context.setStrokeStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.stroke())), doFill && (fillCb ? fillCb(context, graphic.attribute, themeAttributes) : fVisible && (context.setCommonStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.fill())), this.afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, themeAttributes, drawContext, fillCb, strokeCb), !0;
|
|
9577
|
+
return application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, "miter" === lineJoin, this), aabbBounds;
|
|
9445
9578
|
}
|
|
9446
|
-
|
|
9579
|
+
updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) {
|
|
9580
|
+
let {
|
|
9581
|
+
outerRadius = arcTheme.outerRadius,
|
|
9582
|
+
innerRadius = arcTheme.innerRadius
|
|
9583
|
+
} = attribute;
|
|
9447
9584
|
const {
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
fillOpacity = defaultAttribute.fillOpacity,
|
|
9453
|
-
lineWidth = defaultAttribute.lineWidth,
|
|
9454
|
-
strokeOpacity = defaultAttribute.strokeOpacity,
|
|
9455
|
-
visible = defaultAttribute.visible
|
|
9456
|
-
} = graphic.attribute,
|
|
9457
|
-
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
9458
|
-
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
9459
|
-
doFill = runFill(fill, background),
|
|
9460
|
-
doStroke = runStroke(stroke, lineWidth);
|
|
9461
|
-
return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
|
|
9462
|
-
fVisible: fVisible,
|
|
9463
|
-
sVisible: sVisible,
|
|
9464
|
-
doFill: doFill,
|
|
9465
|
-
doStroke: doStroke
|
|
9466
|
-
};
|
|
9585
|
+
outerPadding = arcTheme.outerPadding,
|
|
9586
|
+
innerPadding = arcTheme.innerPadding
|
|
9587
|
+
} = attribute;
|
|
9588
|
+
return outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius && (outerRadius = innerRadius), aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius), aabbBounds;
|
|
9467
9589
|
}
|
|
9468
|
-
|
|
9469
|
-
let
|
|
9590
|
+
updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds) {
|
|
9591
|
+
let {
|
|
9592
|
+
outerRadius = arcTheme.outerRadius,
|
|
9593
|
+
innerRadius = arcTheme.innerRadius
|
|
9594
|
+
} = attribute;
|
|
9470
9595
|
const {
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
postMatrix: postMatrix
|
|
9478
|
-
} = graphic.attribute,
|
|
9479
|
-
lastModelMatrix = context.modelMatrix,
|
|
9480
|
-
camera = context.camera;
|
|
9481
|
-
result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
|
|
9482
|
-
const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
|
|
9483
|
-
onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
|
|
9484
|
-
if (shouldTransform3d) {
|
|
9485
|
-
const nextModelMatrix = mat4Allocate.allocate(),
|
|
9486
|
-
modelMatrix = mat4Allocate.allocate();
|
|
9487
|
-
getModelMatrix(modelMatrix, graphic, graphicAttribute), multiplyMat4Mat4(nextModelMatrix, lastModelMatrix || nextModelMatrix, modelMatrix), result.x = 0, result.y = 0, result.z = 0, context.modelMatrix = nextModelMatrix, context.setTransform(1, 0, 0, 1, 0, 0, !0), mat4Allocate.free(modelMatrix);
|
|
9596
|
+
outerPadding = arcTheme.outerPadding,
|
|
9597
|
+
innerPadding = arcTheme.innerPadding
|
|
9598
|
+
} = attribute;
|
|
9599
|
+
if (outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius) {
|
|
9600
|
+
const temp = outerRadius;
|
|
9601
|
+
outerRadius = innerRadius, innerRadius = temp;
|
|
9488
9602
|
}
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
}
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
return result;
|
|
9497
|
-
}
|
|
9498
|
-
transformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
9499
|
-
const camera = context.camera;
|
|
9500
|
-
if (this.camera = camera, camera) {
|
|
9501
|
-
const bounds = graphic.AABBBounds,
|
|
9502
|
-
width = bounds.x2 - bounds.x1,
|
|
9503
|
-
height = bounds.y2 - bounds.y1,
|
|
9504
|
-
p1 = context.project(0, 0, z),
|
|
9505
|
-
p2 = context.project(width, 0, z),
|
|
9506
|
-
p3 = context.project(width, height, z),
|
|
9507
|
-
_p1 = {
|
|
9508
|
-
x: 0,
|
|
9509
|
-
y: 0
|
|
9510
|
-
},
|
|
9511
|
-
_p2 = {
|
|
9512
|
-
x: width,
|
|
9513
|
-
y: 0
|
|
9514
|
-
},
|
|
9515
|
-
_p3 = {
|
|
9516
|
-
x: width,
|
|
9517
|
-
y: height
|
|
9518
|
-
};
|
|
9519
|
-
context.camera = null;
|
|
9520
|
-
const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
|
|
9521
|
-
m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
|
|
9522
|
-
m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
|
|
9523
|
-
m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
|
|
9524
|
-
m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
|
|
9525
|
-
dx = (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) + _p1.y * (_p2.x * p3.x - _p3.x * p2.x) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) * denom,
|
|
9526
|
-
dy = (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) + _p1.y * (_p2.x * p3.y - _p3.x * p2.y) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) * denom;
|
|
9527
|
-
context.setTransform(m11, m12, m21, m22, dx, dy, !0);
|
|
9603
|
+
let {
|
|
9604
|
+
endAngle = arcTheme.endAngle,
|
|
9605
|
+
startAngle = arcTheme.startAngle
|
|
9606
|
+
} = attribute;
|
|
9607
|
+
if (startAngle > endAngle) {
|
|
9608
|
+
const temp = startAngle;
|
|
9609
|
+
startAngle = endAngle, endAngle = temp;
|
|
9528
9610
|
}
|
|
9611
|
+
return outerRadius <= epsilon ? aabbBounds.set(0, 0, 0, 0) : Math.abs(endAngle - startAngle) > pi2 - epsilon ? aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius) : (circleBounds(startAngle, endAngle, outerRadius, aabbBounds), circleBounds(startAngle, endAngle, innerRadius, aabbBounds)), aabbBounds;
|
|
9529
9612
|
}
|
|
9530
|
-
|
|
9531
|
-
|
|
9613
|
+
needUpdateTags(keys) {
|
|
9614
|
+
return super.needUpdateTags(keys, ARC_UPDATE_TAG_KEY);
|
|
9532
9615
|
}
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
context.translate(p.x, p.y, !1), context.scale(scaleX, scaleY, !1), context.rotate(angle, !1), context.translate(-p.x, -p.y, !1), context.setTransformForCurrent();
|
|
9616
|
+
needUpdateTag(key) {
|
|
9617
|
+
return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
|
|
9536
9618
|
}
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
} = drawContext;
|
|
9541
|
-
if (!context) return;
|
|
9542
|
-
const {
|
|
9543
|
-
renderable: renderable
|
|
9544
|
-
} = graphic.attribute;
|
|
9545
|
-
if (!1 === renderable) return;
|
|
9546
|
-
context.highPerformanceSave();
|
|
9547
|
-
const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
|
|
9619
|
+
toCustomPath() {
|
|
9620
|
+
var _a, _b, _c, _d;
|
|
9621
|
+
const attribute = this.attribute,
|
|
9548
9622
|
{
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
9570
|
-
fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
9571
|
-
startCall: /^\(/,
|
|
9572
|
-
endCall: /^\)/,
|
|
9573
|
-
comma: /^,/,
|
|
9574
|
-
hexColor: /(^\#[0-9a-fA-F]+)/,
|
|
9575
|
-
literalColor: /^([a-zA-Z]+)/,
|
|
9576
|
-
rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
|
|
9577
|
-
rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
|
|
9578
|
-
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
9579
|
-
};
|
|
9580
|
-
let input = "";
|
|
9581
|
-
function error(msg) {
|
|
9582
|
-
const err = new Error(input + ": " + msg);
|
|
9583
|
-
throw err.source = input, err;
|
|
9623
|
+
startAngle: startAngle,
|
|
9624
|
+
endAngle: endAngle
|
|
9625
|
+
} = this.getParsedAngle();
|
|
9626
|
+
let innerRadius = (null !== (_a = attribute.innerRadius) && void 0 !== _a ? _a : 0) - (null !== (_b = attribute.innerPadding) && void 0 !== _b ? _b : 0),
|
|
9627
|
+
outerRadius = (null !== (_c = attribute.outerRadius) && void 0 !== _c ? _c : 0) - (null !== (_d = attribute.outerPadding) && void 0 !== _d ? _d : 0);
|
|
9628
|
+
const deltaAngle = abs(endAngle - startAngle),
|
|
9629
|
+
clockwise = endAngle > startAngle;
|
|
9630
|
+
if (outerRadius < innerRadius) {
|
|
9631
|
+
const temp = outerRadius;
|
|
9632
|
+
outerRadius = innerRadius, innerRadius = temp;
|
|
9633
|
+
}
|
|
9634
|
+
const path = new CustomPath2D();
|
|
9635
|
+
if (outerRadius <= epsilon) path.moveTo(0, 0);else if (deltaAngle >= pi2 - epsilon) path.moveTo(0 + outerRadius * cos(startAngle), 0 + outerRadius * sin(startAngle)), path.arc(0, 0, outerRadius, startAngle, endAngle, !clockwise), innerRadius > epsilon && (path.moveTo(0 + innerRadius * cos(endAngle), 0 + innerRadius * sin(endAngle)), path.arc(0, 0, innerRadius, endAngle, startAngle, clockwise));else {
|
|
9636
|
+
const xors = outerRadius * cos(startAngle),
|
|
9637
|
+
yors = outerRadius * sin(startAngle),
|
|
9638
|
+
xire = innerRadius * cos(endAngle),
|
|
9639
|
+
yire = innerRadius * sin(endAngle);
|
|
9640
|
+
path.moveTo(0 + xors, 0 + yors), path.arc(0, 0, outerRadius, startAngle, endAngle, !clockwise), path.lineTo(0 + xire, 0 + yire), path.arc(0, 0, innerRadius, endAngle, startAngle, clockwise), path.closePath();
|
|
9641
|
+
}
|
|
9642
|
+
return path;
|
|
9584
9643
|
}
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
return input.length > 0 && error("Invalid input not EOF"), ast;
|
|
9644
|
+
clone() {
|
|
9645
|
+
return new Arc(Object.assign({}, this.attribute));
|
|
9588
9646
|
}
|
|
9589
|
-
|
|
9590
|
-
return
|
|
9647
|
+
getNoWorkAnimateAttr() {
|
|
9648
|
+
return Arc.NOWORK_ANIMATE_ATTR;
|
|
9591
9649
|
}
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
orientation: orientation,
|
|
9605
|
-
colorStops: matchListing(matchColorStop)
|
|
9606
|
-
};
|
|
9607
|
-
});
|
|
9650
|
+
}
|
|
9651
|
+
Arc.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
9652
|
+
cap: 1
|
|
9653
|
+
}, NOWORK_ANIMATE_ATTR);
|
|
9654
|
+
function createArc(attributes) {
|
|
9655
|
+
return new Arc(attributes);
|
|
9656
|
+
}
|
|
9657
|
+
|
|
9658
|
+
const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
9659
|
+
class Polygon extends Graphic {
|
|
9660
|
+
constructor(params) {
|
|
9661
|
+
super(params), this.type = "polygon", this.numberType = POLYGON_NUMBER_TYPE;
|
|
9608
9662
|
}
|
|
9609
|
-
|
|
9610
|
-
return
|
|
9663
|
+
isValid() {
|
|
9664
|
+
return super.isValid() && this._isValid();
|
|
9611
9665
|
}
|
|
9612
|
-
|
|
9613
|
-
|
|
9666
|
+
_isValid() {
|
|
9667
|
+
const {
|
|
9668
|
+
points: points
|
|
9669
|
+
} = this.attribute;
|
|
9670
|
+
return points && points.length >= 2;
|
|
9614
9671
|
}
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
lookaheadCache,
|
|
9618
|
-
radialOrientation = matchRadialOrientation();
|
|
9619
|
-
return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
|
|
9672
|
+
getGraphicTheme() {
|
|
9673
|
+
return getTheme(this).polygon;
|
|
9620
9674
|
}
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
const ellipse = match("shape", /^(ellipse)/i, 0);
|
|
9628
|
-
ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
|
|
9629
|
-
return ellipse;
|
|
9630
|
-
}();
|
|
9631
|
-
if (radialType) radialType.at = matchAtPosition();else {
|
|
9632
|
-
const extent = matchExtentKeyword();
|
|
9633
|
-
if (extent) {
|
|
9634
|
-
radialType = extent;
|
|
9635
|
-
const positionAt = matchAtPosition();
|
|
9636
|
-
positionAt && (radialType.at = positionAt);
|
|
9637
|
-
} else {
|
|
9638
|
-
const defaultPosition = matchPositioning();
|
|
9639
|
-
defaultPosition && (radialType = {
|
|
9640
|
-
type: "default-radial",
|
|
9641
|
-
at: defaultPosition
|
|
9642
|
-
});
|
|
9643
|
-
}
|
|
9644
|
-
}
|
|
9645
|
-
return radialType;
|
|
9675
|
+
updateAABBBounds(attribute, polygonTheme, aabbBounds) {
|
|
9676
|
+
this.updatePathProxyAABBBounds(aabbBounds) || this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds), application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
9677
|
+
const {
|
|
9678
|
+
lineJoin = polygonTheme.lineJoin
|
|
9679
|
+
} = attribute;
|
|
9680
|
+
return application.graphicService.transformAABBBounds(attribute, aabbBounds, polygonTheme, "miter" === lineJoin, this), aabbBounds;
|
|
9646
9681
|
}
|
|
9647
|
-
|
|
9648
|
-
|
|
9682
|
+
updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds) {
|
|
9683
|
+
const {
|
|
9684
|
+
points = polygonTheme.points
|
|
9685
|
+
} = attribute;
|
|
9686
|
+
return points.forEach(p => {
|
|
9687
|
+
aabbBounds.add(p.x, p.y);
|
|
9688
|
+
}), aabbBounds;
|
|
9649
9689
|
}
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
const positioning = matchPositioning();
|
|
9653
|
-
return positioning || error("Missing positioning value"), positioning;
|
|
9654
|
-
}
|
|
9690
|
+
_interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
|
|
9691
|
+
"points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
|
|
9655
9692
|
}
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
x: matchDistance(),
|
|
9659
|
-
y: matchDistance()
|
|
9660
|
-
};
|
|
9661
|
-
if (location.x || location.y) return {
|
|
9662
|
-
type: "position",
|
|
9663
|
-
value: location
|
|
9664
|
-
};
|
|
9693
|
+
needUpdateTags(keys) {
|
|
9694
|
+
return super.needUpdateTags(keys, POLYGON_UPDATE_TAG_KEY);
|
|
9665
9695
|
}
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
const result = [];
|
|
9669
|
-
if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
|
|
9670
|
-
return result;
|
|
9696
|
+
needUpdateTag(key) {
|
|
9697
|
+
return super.needUpdateTag(key, POLYGON_UPDATE_TAG_KEY);
|
|
9671
9698
|
}
|
|
9672
|
-
|
|
9673
|
-
const
|
|
9674
|
-
|
|
9699
|
+
toCustomPath() {
|
|
9700
|
+
const points = this.attribute.points,
|
|
9701
|
+
path = new CustomPath2D();
|
|
9702
|
+
return points.forEach((point, index) => {
|
|
9703
|
+
0 === index ? path.moveTo(point.x, point.y) : path.lineTo(point.x, point.y);
|
|
9704
|
+
}), path.closePath(), path;
|
|
9675
9705
|
}
|
|
9676
|
-
|
|
9677
|
-
return
|
|
9706
|
+
clone() {
|
|
9707
|
+
return new Polygon(Object.assign({}, this.attribute));
|
|
9678
9708
|
}
|
|
9679
|
-
|
|
9680
|
-
return
|
|
9709
|
+
getNoWorkAnimateAttr() {
|
|
9710
|
+
return Polygon.NOWORK_ANIMATE_ATTR;
|
|
9681
9711
|
}
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9712
|
+
}
|
|
9713
|
+
Polygon.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
9714
|
+
function createPolygon(attributes) {
|
|
9715
|
+
return new Polygon(attributes);
|
|
9716
|
+
}
|
|
9717
|
+
|
|
9718
|
+
class GraphicCreator {
|
|
9719
|
+
constructor() {
|
|
9720
|
+
this.store = new Map();
|
|
9688
9721
|
}
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
blankCaptures && consume(blankCaptures[0].length);
|
|
9692
|
-
const captures = regexp.exec(input);
|
|
9693
|
-
return captures && consume(captures[0].length), captures;
|
|
9722
|
+
RegisterGraphicCreator(name, cb) {
|
|
9723
|
+
this.store.set(name, cb), this[name] = cb;
|
|
9694
9724
|
}
|
|
9695
|
-
|
|
9696
|
-
|
|
9725
|
+
CreateGraphic(name, params) {
|
|
9726
|
+
const cb = this.store.get(name);
|
|
9727
|
+
return cb ? cb(params) : null;
|
|
9697
9728
|
}
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9729
|
+
}
|
|
9730
|
+
const graphicCreator = new GraphicCreator();
|
|
9731
|
+
|
|
9732
|
+
let text;
|
|
9733
|
+
function getTextBounds(params) {
|
|
9734
|
+
return text || (text = graphicCreator.CreateGraphic("text", {})), text.initAttributes(params), text.AABBBounds;
|
|
9735
|
+
}
|
|
9736
|
+
|
|
9737
|
+
const result = {
|
|
9738
|
+
x: 0,
|
|
9739
|
+
y: 0,
|
|
9740
|
+
z: 0,
|
|
9741
|
+
lastModelMatrix: null
|
|
9742
|
+
};
|
|
9743
|
+
class BaseRender {
|
|
9744
|
+
init(contributions) {
|
|
9745
|
+
contributions && (this._renderContribitions = contributions.getContributions()), this._renderContribitions || (this._renderContribitions = []), this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item)), this._renderContribitions.length && (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === BaseRenderContributionTime.afterFillStroke));
|
|
9705
9746
|
}
|
|
9706
|
-
|
|
9707
|
-
|
|
9747
|
+
beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
9748
|
+
this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
|
|
9749
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
9750
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
9751
|
+
}
|
|
9752
|
+
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
9753
|
+
});
|
|
9708
9754
|
}
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
9714
|
-
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
9715
|
-
if ("conic" === datum.type) return GradientParser.ParseConic(datum);
|
|
9755
|
+
afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
9756
|
+
this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
|
|
9757
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
9758
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
9716
9759
|
}
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
}
|
|
9720
|
-
return c;
|
|
9760
|
+
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
9761
|
+
});
|
|
9721
9762
|
}
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9763
|
+
drawPathProxy(graphic, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
9764
|
+
if (!graphic.pathProxy) return !1;
|
|
9765
|
+
const themeAttributes = getTheme(graphic, null == params ? void 0 : params.theme)[graphic.type.replace("3d", "")],
|
|
9766
|
+
{
|
|
9767
|
+
fill = themeAttributes.fill,
|
|
9768
|
+
stroke = themeAttributes.stroke,
|
|
9769
|
+
opacity = themeAttributes.opacity,
|
|
9770
|
+
fillOpacity = themeAttributes.fillOpacity,
|
|
9771
|
+
lineWidth = themeAttributes.lineWidth,
|
|
9772
|
+
strokeOpacity = themeAttributes.strokeOpacity,
|
|
9773
|
+
visible = themeAttributes.visible,
|
|
9774
|
+
x: originX = themeAttributes.x,
|
|
9775
|
+
y: originY = themeAttributes.y
|
|
9776
|
+
} = graphic.attribute,
|
|
9777
|
+
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
9778
|
+
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
9779
|
+
doFill = runFill(fill),
|
|
9780
|
+
doStroke = runStroke(stroke, lineWidth);
|
|
9781
|
+
if (!visible) return !0;
|
|
9782
|
+
if (!doFill && !doStroke) return !0;
|
|
9783
|
+
if (!(fVisible || sVisible || fillCb || strokeCb)) return !0;
|
|
9784
|
+
context.beginPath();
|
|
9785
|
+
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
9786
|
+
return renderCommandList(path.commandList, context, x, y), context.setShadowBlendStyle && context.setShadowBlendStyle(graphic, graphic.attribute, themeAttributes), this.beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, themeAttributes, drawContext, fillCb, strokeCb), doStroke && (strokeCb ? strokeCb(context, graphic.attribute, themeAttributes) : sVisible && (context.setStrokeStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.stroke())), doFill && (fillCb ? fillCb(context, graphic.attribute, themeAttributes) : fVisible && (context.setCommonStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.fill())), this.afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, themeAttributes, drawContext, fillCb, strokeCb), !0;
|
|
9740
9787
|
}
|
|
9741
|
-
|
|
9788
|
+
valid(graphic, defaultAttribute, fillCb, strokeCb) {
|
|
9742
9789
|
const {
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9790
|
+
fill = defaultAttribute.fill,
|
|
9791
|
+
background: background,
|
|
9792
|
+
stroke = defaultAttribute.stroke,
|
|
9793
|
+
opacity = defaultAttribute.opacity,
|
|
9794
|
+
fillOpacity = defaultAttribute.fillOpacity,
|
|
9795
|
+
lineWidth = defaultAttribute.lineWidth,
|
|
9796
|
+
strokeOpacity = defaultAttribute.strokeOpacity,
|
|
9797
|
+
visible = defaultAttribute.visible
|
|
9798
|
+
} = graphic.attribute,
|
|
9799
|
+
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
9800
|
+
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
9801
|
+
doFill = runFill(fill, background),
|
|
9802
|
+
doStroke = runStroke(stroke, lineWidth);
|
|
9803
|
+
return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
|
|
9804
|
+
fVisible: fVisible,
|
|
9805
|
+
sVisible: sVisible,
|
|
9806
|
+
doFill: doFill,
|
|
9807
|
+
doStroke: doStroke
|
|
9757
9808
|
};
|
|
9758
9809
|
}
|
|
9759
|
-
|
|
9810
|
+
transform(graphic, graphicAttribute, context) {
|
|
9811
|
+
let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
|
|
9760
9812
|
const {
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
};
|
|
9813
|
+
x = graphicAttribute.x,
|
|
9814
|
+
y = graphicAttribute.y,
|
|
9815
|
+
z = graphicAttribute.z,
|
|
9816
|
+
scaleX = graphicAttribute.scaleX,
|
|
9817
|
+
scaleY = graphicAttribute.scaleY,
|
|
9818
|
+
angle = graphicAttribute.angle,
|
|
9819
|
+
postMatrix: postMatrix
|
|
9820
|
+
} = graphic.attribute,
|
|
9821
|
+
lastModelMatrix = context.modelMatrix,
|
|
9822
|
+
camera = context.camera;
|
|
9823
|
+
result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
|
|
9824
|
+
const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
|
|
9825
|
+
onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
|
|
9826
|
+
if (shouldTransform3d) {
|
|
9827
|
+
const nextModelMatrix = mat4Allocate.allocate(),
|
|
9828
|
+
modelMatrix = mat4Allocate.allocate();
|
|
9829
|
+
getModelMatrix(modelMatrix, graphic, graphicAttribute), multiplyMat4Mat4(nextModelMatrix, lastModelMatrix || nextModelMatrix, modelMatrix), result.x = 0, result.y = 0, result.z = 0, context.modelMatrix = nextModelMatrix, context.setTransform(1, 0, 0, 1, 0, 0, !0), mat4Allocate.free(modelMatrix);
|
|
9830
|
+
}
|
|
9831
|
+
if (onlyTranslate && !lastModelMatrix) {
|
|
9832
|
+
const point = graphic.getOffsetXY(graphicAttribute);
|
|
9833
|
+
result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
|
|
9834
|
+
} else if (shouldTransform3d) result.x = 0, result.y = 0, result.z = 0, context.setTransform(1, 0, 0, 1, 0, 0, !0);else if (camera && context.project) {
|
|
9835
|
+
const point = graphic.getOffsetXY(graphicAttribute);
|
|
9836
|
+
result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
|
|
9837
|
+
} else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
|
|
9838
|
+
return result;
|
|
9783
9839
|
}
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
scaleY = 1
|
|
9815
|
-
} = params.attribute;
|
|
9816
|
-
w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
|
|
9840
|
+
transformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
9841
|
+
const camera = context.camera;
|
|
9842
|
+
if (this.camera = camera, camera) {
|
|
9843
|
+
const bounds = graphic.AABBBounds,
|
|
9844
|
+
width = bounds.x2 - bounds.x1,
|
|
9845
|
+
height = bounds.y2 - bounds.y1,
|
|
9846
|
+
p1 = context.project(0, 0, z),
|
|
9847
|
+
p2 = context.project(width, 0, z),
|
|
9848
|
+
p3 = context.project(width, height, z),
|
|
9849
|
+
_p1 = {
|
|
9850
|
+
x: 0,
|
|
9851
|
+
y: 0
|
|
9852
|
+
},
|
|
9853
|
+
_p2 = {
|
|
9854
|
+
x: width,
|
|
9855
|
+
y: 0
|
|
9856
|
+
},
|
|
9857
|
+
_p3 = {
|
|
9858
|
+
x: width,
|
|
9859
|
+
y: height
|
|
9860
|
+
};
|
|
9861
|
+
context.camera = null;
|
|
9862
|
+
const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
|
|
9863
|
+
m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
|
|
9864
|
+
m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
|
|
9865
|
+
m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
|
|
9866
|
+
m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
|
|
9867
|
+
dx = (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) + _p1.y * (_p2.x * p3.x - _p3.x * p2.x) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) * denom,
|
|
9868
|
+
dy = (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) + _p1.y * (_p2.x * p3.y - _p3.x * p2.y) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) * denom;
|
|
9869
|
+
context.setTransform(m11, m12, m21, m22, dx, dy, !0);
|
|
9817
9870
|
}
|
|
9818
|
-
"linear" === color.gradient ? result = createLinearGradient(context, color, x, y, w, h) : "conical" === color.gradient ? result = createConicGradient(context, color, x, y, w, h) : "radial" === color.gradient && (result = createRadialGradient(context, color, x, y, w, h));
|
|
9819
9871
|
}
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9872
|
+
restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
9873
|
+
this.camera && (context.camera = this.camera);
|
|
9874
|
+
}
|
|
9875
|
+
transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
|
|
9876
|
+
const p = context.project(x, y, z);
|
|
9877
|
+
context.translate(p.x, p.y, !1), context.scale(scaleX, scaleY, !1), context.rotate(angle, !1), context.translate(-p.x, -p.y, !1), context.setTransformForCurrent();
|
|
9878
|
+
}
|
|
9879
|
+
_draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
|
|
9880
|
+
const {
|
|
9881
|
+
context: context
|
|
9882
|
+
} = drawContext;
|
|
9883
|
+
if (!context) return;
|
|
9884
|
+
const {
|
|
9885
|
+
renderable: renderable
|
|
9886
|
+
} = graphic.attribute;
|
|
9887
|
+
if (!1 === renderable) return;
|
|
9888
|
+
context.highPerformanceSave();
|
|
9889
|
+
const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
|
|
9890
|
+
{
|
|
9891
|
+
x: x,
|
|
9892
|
+
y: y,
|
|
9893
|
+
z: z,
|
|
9894
|
+
lastModelMatrix: lastModelMatrix
|
|
9895
|
+
} = data;
|
|
9896
|
+
this.z = z, this.drawPathProxy(graphic, context, x, y, drawContext, params) || (this.drawShape(graphic, context, x, y, drawContext, params), this.z = 0, context.modelMatrix !== lastModelMatrix && mat4Allocate.free(context.modelMatrix), context.modelMatrix = lastModelMatrix), context.highPerformanceRestore();
|
|
9897
|
+
}
|
|
9842
9898
|
}
|
|
9843
9899
|
|
|
9844
9900
|
var __decorate$I = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
@@ -10102,7 +10158,8 @@ class DefaultArcRenderContribution {
|
|
|
10102
10158
|
x: originX = arcAttribute.x,
|
|
10103
10159
|
y: originY = arcAttribute.y,
|
|
10104
10160
|
scaleX = arcAttribute.scaleX,
|
|
10105
|
-
scaleY = arcAttribute.scaleY
|
|
10161
|
+
scaleY = arcAttribute.scaleY,
|
|
10162
|
+
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
10106
10163
|
} = arc.attribute;
|
|
10107
10164
|
let {
|
|
10108
10165
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -10114,7 +10171,7 @@ class DefaultArcRenderContribution {
|
|
|
10114
10171
|
{
|
|
10115
10172
|
distance = arcAttribute[key].distance
|
|
10116
10173
|
} = borderStyle,
|
|
10117
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
10174
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
10118
10175
|
deltaAngle = distance / outerRadius,
|
|
10119
10176
|
sign = "outerBorder" === key ? 1 : -1;
|
|
10120
10177
|
if (arc.setAttributes({
|
|
@@ -10159,14 +10216,15 @@ class DefaultCircleRenderContribution {
|
|
|
10159
10216
|
x: originX = circleAttribute.x,
|
|
10160
10217
|
y: originY = circleAttribute.y,
|
|
10161
10218
|
scaleX = circleAttribute.scaleX,
|
|
10162
|
-
scaleY = circleAttribute.scaleY
|
|
10219
|
+
scaleY = circleAttribute.scaleY,
|
|
10220
|
+
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
10163
10221
|
} = circle.attribute,
|
|
10164
10222
|
renderBorder = (borderStyle, key) => {
|
|
10165
10223
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
10166
10224
|
{
|
|
10167
10225
|
distance = circleAttribute[key].distance
|
|
10168
10226
|
} = borderStyle,
|
|
10169
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
10227
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
10170
10228
|
sign = "outerBorder" === key ? 1 : -1;
|
|
10171
10229
|
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) {
|
|
10172
10230
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -10285,7 +10343,8 @@ class DefaultRectRenderContribution {
|
|
|
10285
10343
|
scaleX = rectAttribute.scaleX,
|
|
10286
10344
|
scaleY = rectAttribute.scaleY,
|
|
10287
10345
|
x1: x1,
|
|
10288
|
-
y1: y1
|
|
10346
|
+
y1: y1,
|
|
10347
|
+
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
10289
10348
|
} = rect.attribute;
|
|
10290
10349
|
let {
|
|
10291
10350
|
width: width,
|
|
@@ -10298,7 +10357,7 @@ class DefaultRectRenderContribution {
|
|
|
10298
10357
|
{
|
|
10299
10358
|
distance = rectAttribute[key].distance
|
|
10300
10359
|
} = borderStyle,
|
|
10301
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
10360
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
10302
10361
|
nextX = x + sign * d,
|
|
10303
10362
|
nextY = y + sign * d,
|
|
10304
10363
|
dw = 2 * d;
|
|
@@ -10455,14 +10514,15 @@ class DefaultSymbolRenderContribution {
|
|
|
10455
10514
|
x: originX = symbolAttribute.x,
|
|
10456
10515
|
y: originY = symbolAttribute.y,
|
|
10457
10516
|
scaleX = symbolAttribute.scaleX,
|
|
10458
|
-
scaleY = symbolAttribute.scaleY
|
|
10517
|
+
scaleY = symbolAttribute.scaleY,
|
|
10518
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
10459
10519
|
} = symbol.attribute,
|
|
10460
10520
|
renderBorder = (borderStyle, key) => {
|
|
10461
10521
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
10462
10522
|
{
|
|
10463
10523
|
distance = symbolAttribute[key].distance
|
|
10464
10524
|
} = borderStyle,
|
|
10465
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
10525
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
10466
10526
|
sign = "outerBorder" === key ? 1 : -1;
|
|
10467
10527
|
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) {
|
|
10468
10528
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -11746,16 +11806,8 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
11746
11806
|
verticalMode = textAttribute.verticalMode,
|
|
11747
11807
|
x: originX = textAttribute.x,
|
|
11748
11808
|
y: originY = textAttribute.y
|
|
11749
|
-
} = text.attribute
|
|
11750
|
-
|
|
11751
|
-
textAlign = textAttribute.textAlign,
|
|
11752
|
-
textBaseline = textAttribute.textBaseline
|
|
11753
|
-
} = text.attribute;
|
|
11754
|
-
if (!verticalMode && "vertical" === direction) {
|
|
11755
|
-
const t = textAlign;
|
|
11756
|
-
textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
|
|
11757
|
-
}
|
|
11758
|
-
const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
|
|
11809
|
+
} = text.attribute,
|
|
11810
|
+
lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
|
|
11759
11811
|
data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
11760
11812
|
if (!data) return;
|
|
11761
11813
|
const {
|
|
@@ -11775,79 +11827,60 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
11775
11827
|
const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
|
|
11776
11828
|
matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
|
|
11777
11829
|
}
|
|
11778
|
-
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)
|
|
11830
|
+
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());
|
|
11779
11831
|
};
|
|
11780
|
-
if (text.
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11793
|
-
|
|
11794
|
-
width: line.width
|
|
11795
|
-
});
|
|
11796
|
-
})));
|
|
11797
|
-
} else {
|
|
11798
|
-
text.tryUpdateAABBBounds();
|
|
11799
|
-
const cache = text.cache,
|
|
11800
|
-
{
|
|
11801
|
-
verticalList: verticalList
|
|
11802
|
-
} = cache;
|
|
11803
|
-
context.textAlign = "left", context.textBaseline = "top";
|
|
11804
|
-
const totalHeight = lineHeight * verticalList.length;
|
|
11805
|
-
let totalW = 0;
|
|
11806
|
-
verticalList.forEach(verticalData => {
|
|
11807
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
11808
|
-
totalW = max(_w, totalW);
|
|
11809
|
-
});
|
|
11810
|
-
let offsetY = 0,
|
|
11811
|
-
offsetX = 0;
|
|
11812
|
-
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
11813
|
-
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
11814
|
-
dw = totalW - currentW;
|
|
11815
|
-
let currentOffsetY = offsetY;
|
|
11816
|
-
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
11817
|
-
const {
|
|
11818
|
-
text: text,
|
|
11819
|
-
width: width,
|
|
11820
|
-
direction: direction
|
|
11821
|
-
} = item;
|
|
11822
|
-
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
11823
|
-
});
|
|
11832
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
11833
|
+
const {
|
|
11834
|
+
multilineLayout: multilineLayout
|
|
11835
|
+
} = text;
|
|
11836
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
11837
|
+
const {
|
|
11838
|
+
xOffset: xOffset,
|
|
11839
|
+
yOffset: yOffset
|
|
11840
|
+
} = multilineLayout.bbox;
|
|
11841
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
11842
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
11843
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
11844
|
+
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, {
|
|
11845
|
+
width: line.width
|
|
11824
11846
|
});
|
|
11825
|
-
}
|
|
11826
|
-
} else if ("horizontal" === direction) {
|
|
11827
|
-
context.setTextStyle(text.attribute, textAttribute, z);
|
|
11828
|
-
const t = text.clipedText;
|
|
11829
|
-
let dy = 0;
|
|
11830
|
-
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
|
|
11847
|
+
})));
|
|
11831
11848
|
} else {
|
|
11849
|
+
let {
|
|
11850
|
+
textAlign = textAttribute.textAlign,
|
|
11851
|
+
textBaseline = textAttribute.textBaseline
|
|
11852
|
+
} = text.attribute;
|
|
11853
|
+
if (!verticalMode) {
|
|
11854
|
+
const t = textAlign;
|
|
11855
|
+
textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
|
|
11856
|
+
}
|
|
11832
11857
|
text.tryUpdateAABBBounds();
|
|
11833
|
-
const cache = text.cache
|
|
11834
|
-
|
|
11835
|
-
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
11836
|
-
const {
|
|
11858
|
+
const cache = text.cache,
|
|
11859
|
+
{
|
|
11837
11860
|
verticalList: verticalList
|
|
11838
11861
|
} = cache;
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11862
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
11863
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
11864
|
+
let totalW = 0;
|
|
11865
|
+
verticalList.forEach(verticalData => {
|
|
11866
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
11867
|
+
totalW = max(_w, totalW);
|
|
11868
|
+
});
|
|
11869
|
+
let offsetY = 0,
|
|
11870
|
+
offsetX = 0;
|
|
11871
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
11872
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
11873
|
+
dw = totalW - currentW;
|
|
11874
|
+
let currentOffsetY = offsetY;
|
|
11875
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
11843
11876
|
const {
|
|
11844
11877
|
text: text,
|
|
11845
11878
|
width: width,
|
|
11846
11879
|
direction: direction
|
|
11847
11880
|
} = item;
|
|
11848
|
-
drawText(text, offsetX,
|
|
11881
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
11849
11882
|
});
|
|
11850
|
-
}
|
|
11883
|
+
});
|
|
11851
11884
|
}
|
|
11852
11885
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
11853
11886
|
}
|
|
@@ -11859,12 +11892,10 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
11859
11892
|
computed3dMatrix = !keepDirIn3d;
|
|
11860
11893
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
11861
11894
|
}
|
|
11862
|
-
drawUnderLine(underline, lineThrough, text,
|
|
11895
|
+
drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
|
|
11863
11896
|
if (lineThrough + underline <= 0) return;
|
|
11864
11897
|
const {
|
|
11865
11898
|
textAlign = textAttribute.textAlign,
|
|
11866
|
-
textBaseline = textAttribute.textBaseline,
|
|
11867
|
-
fontSize = textAttribute.fontSize,
|
|
11868
11899
|
fill = textAttribute.fill,
|
|
11869
11900
|
opacity = textAttribute.opacity,
|
|
11870
11901
|
underlineOffset = textAttribute.underlineOffset,
|
|
@@ -11874,23 +11905,21 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
11874
11905
|
isMulti = !isNil(multiOption),
|
|
11875
11906
|
w = isMulti ? multiOption.width : text.clipedWidth,
|
|
11876
11907
|
offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
|
|
11877
|
-
offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
|
|
11878
11908
|
attribute = {
|
|
11879
11909
|
lineWidth: 0,
|
|
11880
11910
|
stroke: fill,
|
|
11881
11911
|
opacity: opacity,
|
|
11882
11912
|
strokeOpacity: fillOpacity
|
|
11883
11913
|
};
|
|
11884
|
-
let deltaY = isMulti ? -3 : 0;
|
|
11885
11914
|
if (underline) {
|
|
11886
|
-
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute,
|
|
11887
|
-
const dy =
|
|
11888
|
-
context.moveTo(
|
|
11915
|
+
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
|
|
11916
|
+
const dy = anchorY + offsetUnderLineY + underlineOffset;
|
|
11917
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
11889
11918
|
}
|
|
11890
|
-
if (
|
|
11891
|
-
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute,
|
|
11892
|
-
const dy =
|
|
11893
|
-
context.moveTo(
|
|
11919
|
+
if (lineThrough) {
|
|
11920
|
+
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
|
|
11921
|
+
const dy = anchorY + offsetThroughLineY;
|
|
11922
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
11894
11923
|
}
|
|
11895
11924
|
}
|
|
11896
11925
|
};
|
|
@@ -12278,7 +12307,10 @@ class ShadowRootDrawItemInterceptorContribution {
|
|
|
12278
12307
|
const {
|
|
12279
12308
|
context: context
|
|
12280
12309
|
} = drawContext;
|
|
12281
|
-
|
|
12310
|
+
context.highPerformanceSave();
|
|
12311
|
+
const t1 = graphic.parent.globalTransMatrix,
|
|
12312
|
+
t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
|
|
12313
|
+
if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
|
|
12282
12314
|
tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
|
|
12283
12315
|
const m = graphic.globalTransMatrix.getInverse();
|
|
12284
12316
|
drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
|
|
@@ -13514,6 +13546,7 @@ const GROUP_ATTRIBUTES = [
|
|
|
13514
13546
|
class AbstractComponent extends Group {
|
|
13515
13547
|
constructor(attributes, options) {
|
|
13516
13548
|
super(attributes);
|
|
13549
|
+
this._skipRenderAttributes = GROUP_ATTRIBUTES;
|
|
13517
13550
|
if (options === null || options === void 0 ? void 0 : options.mode) {
|
|
13518
13551
|
this.mode = options.mode;
|
|
13519
13552
|
this.setMode(options.mode);
|
|
@@ -13542,7 +13575,7 @@ class AbstractComponent extends Group {
|
|
|
13542
13575
|
else {
|
|
13543
13576
|
this.attribute[key] = value;
|
|
13544
13577
|
}
|
|
13545
|
-
if (!
|
|
13578
|
+
if (!this._skipRenderAttributes.includes(key)) {
|
|
13546
13579
|
this.render();
|
|
13547
13580
|
}
|
|
13548
13581
|
this.valid = this.isValid();
|
|
@@ -13558,7 +13591,7 @@ class AbstractComponent extends Group {
|
|
|
13558
13591
|
setAttributes(params, forceUpdateTag) {
|
|
13559
13592
|
const keys = Object.keys(params);
|
|
13560
13593
|
this._mergeAttributes(params, keys);
|
|
13561
|
-
if (!keys.every(key =>
|
|
13594
|
+
if (!keys.every(key => this._skipRenderAttributes.includes(key))) {
|
|
13562
13595
|
this.render();
|
|
13563
13596
|
}
|
|
13564
13597
|
this.valid = this.isValid();
|
|
@@ -13645,8 +13678,9 @@ class PickerBase {
|
|
|
13645
13678
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
|
|
13646
13679
|
if (picked) return !0;
|
|
13647
13680
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13648
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13649
|
-
|
|
13681
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13682
|
+
keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13683
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13650
13684
|
}), pickContext.highPerformanceRestore(), picked;
|
|
13651
13685
|
}
|
|
13652
13686
|
}
|
|
@@ -13868,8 +13902,9 @@ class RectPickerBase {
|
|
|
13868
13902
|
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) => {
|
|
13869
13903
|
if (picked) return !0;
|
|
13870
13904
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13871
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13872
|
-
|
|
13905
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13906
|
+
keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13907
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13873
13908
|
});else {
|
|
13874
13909
|
const {
|
|
13875
13910
|
fill = rectAttribute.fill,
|
|
@@ -14048,8 +14083,9 @@ class BaseLinePicker extends BaseRender {
|
|
|
14048
14083
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
14049
14084
|
if (picked) return !0;
|
|
14050
14085
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
14051
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
14052
|
-
|
|
14086
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
14087
|
+
keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
14088
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
14053
14089
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
14054
14090
|
}
|
|
14055
14091
|
}
|
|
@@ -14184,8 +14220,9 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
|
|
|
14184
14220
|
return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
|
|
14185
14221
|
if (picked) return !0;
|
|
14186
14222
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
14187
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
14188
|
-
|
|
14223
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
14224
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
14225
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
14189
14226
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
14190
14227
|
}
|
|
14191
14228
|
};
|
|
@@ -14832,6 +14869,288 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
14832
14869
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
14833
14870
|
};
|
|
14834
14871
|
|
|
14872
|
+
var ScrollBarPlugin_1;
|
|
14873
|
+
let ScrollBarPlugin = ScrollBarPlugin_1 = class ScrollBarPlugin {
|
|
14874
|
+
constructor() {
|
|
14875
|
+
this.name = 'scrollbar';
|
|
14876
|
+
this.activeEvent = 'onRegister';
|
|
14877
|
+
this._uid = Generator.GenAutoIncrementId();
|
|
14878
|
+
this.key = this.name + this._uid;
|
|
14879
|
+
this.scroll = (e) => {
|
|
14880
|
+
var _a, _b;
|
|
14881
|
+
const graphic = e.target;
|
|
14882
|
+
const data = this.getScrollContainer(graphic);
|
|
14883
|
+
if (!data && !this.scrollContainer) {
|
|
14884
|
+
return;
|
|
14885
|
+
}
|
|
14886
|
+
if (!data && this.scrollContainer) {
|
|
14887
|
+
if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {
|
|
14888
|
+
return;
|
|
14889
|
+
}
|
|
14890
|
+
const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);
|
|
14891
|
+
if (!newScrollContainer) {
|
|
14892
|
+
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14893
|
+
return;
|
|
14894
|
+
}
|
|
14895
|
+
if (this.scrollContainer.showH && !newScrollContainer.showH) {
|
|
14896
|
+
this.clearScrollbar(this.scrollContainer.g, 'horizontal');
|
|
14897
|
+
}
|
|
14898
|
+
if (this.scrollContainer.showV && !newScrollContainer.showV) {
|
|
14899
|
+
this.clearScrollbar(this.scrollContainer.g, 'vertical');
|
|
14900
|
+
}
|
|
14901
|
+
this.scrollContainer = newScrollContainer;
|
|
14902
|
+
}
|
|
14903
|
+
else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {
|
|
14904
|
+
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14905
|
+
}
|
|
14906
|
+
this.scrollContainer = data !== null && data !== void 0 ? data : this.scrollContainer;
|
|
14907
|
+
const scrollContainer = data.g;
|
|
14908
|
+
const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;
|
|
14909
|
+
let newScrollX = scrollX;
|
|
14910
|
+
let newScrollY = scrollY;
|
|
14911
|
+
let { showH, showV } = data;
|
|
14912
|
+
this.scrollContainerBounds = new Bounds().set(0, 0, scrollContainer.attribute.width, scrollContainer.attribute.height);
|
|
14913
|
+
if (showH && showH) {
|
|
14914
|
+
if (abs(e.deltaX) > abs(e.deltaY)) {
|
|
14915
|
+
showH = showH && true;
|
|
14916
|
+
showV = showV && false;
|
|
14917
|
+
}
|
|
14918
|
+
else {
|
|
14919
|
+
showH = showH && false;
|
|
14920
|
+
showV = showV && true;
|
|
14921
|
+
}
|
|
14922
|
+
}
|
|
14923
|
+
const childrenBounds = this.childrenBounds;
|
|
14924
|
+
childrenBounds.clear();
|
|
14925
|
+
childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());
|
|
14926
|
+
const scrollWidth = childrenBounds.width();
|
|
14927
|
+
const scrollHeight = childrenBounds.height();
|
|
14928
|
+
if (showH) {
|
|
14929
|
+
newScrollX = Math.max(Math.min(((_a = e.deltaX) !== null && _a !== void 0 ? _a : 0) - scrollX, scrollWidth - width), 0);
|
|
14930
|
+
}
|
|
14931
|
+
else {
|
|
14932
|
+
newScrollX = -scrollX;
|
|
14933
|
+
}
|
|
14934
|
+
if (showV) {
|
|
14935
|
+
newScrollY = Math.max(Math.min(((_b = e.deltaY) !== null && _b !== void 0 ? _b : 0) - scrollY, scrollHeight - height), 0);
|
|
14936
|
+
}
|
|
14937
|
+
else {
|
|
14938
|
+
newScrollY = -scrollY;
|
|
14939
|
+
}
|
|
14940
|
+
childrenBounds.translate(-newScrollX, -newScrollY);
|
|
14941
|
+
this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);
|
|
14942
|
+
scrollContainer.setAttributes({
|
|
14943
|
+
scrollX: -newScrollX,
|
|
14944
|
+
scrollY: -newScrollY
|
|
14945
|
+
});
|
|
14946
|
+
};
|
|
14947
|
+
this.handleScrollBarChange = (params) => {
|
|
14948
|
+
if (!this.scrollContainer ||
|
|
14949
|
+
!this.scrollContainerBounds ||
|
|
14950
|
+
!this.childrenBounds ||
|
|
14951
|
+
!params ||
|
|
14952
|
+
!params.target ||
|
|
14953
|
+
!params.detail ||
|
|
14954
|
+
!params.detail.value) {
|
|
14955
|
+
return;
|
|
14956
|
+
}
|
|
14957
|
+
const scrollbar = params.target;
|
|
14958
|
+
const newRange = params.detail.value;
|
|
14959
|
+
if (scrollbar.attribute.direction === 'horizontal') {
|
|
14960
|
+
const scrollWidth = this.childrenBounds.width();
|
|
14961
|
+
this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });
|
|
14962
|
+
}
|
|
14963
|
+
else {
|
|
14964
|
+
const scrollHeight = this.childrenBounds.height();
|
|
14965
|
+
this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });
|
|
14966
|
+
}
|
|
14967
|
+
};
|
|
14968
|
+
}
|
|
14969
|
+
activate(context) {
|
|
14970
|
+
this.pluginService = context;
|
|
14971
|
+
const { stage } = this.pluginService;
|
|
14972
|
+
this.childrenBounds = new AABBBounds();
|
|
14973
|
+
stage.addEventListener('wheel', this.scroll);
|
|
14974
|
+
this.params = ScrollBarPlugin_1.defaultParams;
|
|
14975
|
+
}
|
|
14976
|
+
initEventOfScrollbar(scrollContainer, scrollbar, isHorozntal) {
|
|
14977
|
+
scrollContainer.addEventListener('pointerover', () => {
|
|
14978
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14979
|
+
});
|
|
14980
|
+
scrollContainer.addEventListener('pointermove', () => {
|
|
14981
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14982
|
+
});
|
|
14983
|
+
scrollContainer.addEventListener('pointerout', () => {
|
|
14984
|
+
scrollbar.setAttribute('visibleAll', false);
|
|
14985
|
+
});
|
|
14986
|
+
scrollbar.addEventListener('pointerover', () => {
|
|
14987
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14988
|
+
});
|
|
14989
|
+
scrollbar.addEventListener('pointerout', () => {
|
|
14990
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14991
|
+
});
|
|
14992
|
+
scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);
|
|
14993
|
+
scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);
|
|
14994
|
+
}
|
|
14995
|
+
addOrUpdateScroll(showH, showV, container, scrollContainer) {
|
|
14996
|
+
if (showH) {
|
|
14997
|
+
const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);
|
|
14998
|
+
if (!isUpdate) {
|
|
14999
|
+
this.initEventOfScrollbar(scrollContainer, hScrollbar, true);
|
|
15000
|
+
}
|
|
15001
|
+
}
|
|
15002
|
+
else {
|
|
15003
|
+
this.clearScrollbar(scrollContainer, 'horizontal');
|
|
15004
|
+
}
|
|
15005
|
+
if (showV) {
|
|
15006
|
+
const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);
|
|
15007
|
+
if (!isUpdate) {
|
|
15008
|
+
this.initEventOfScrollbar(scrollContainer, vScrollbar, false);
|
|
15009
|
+
}
|
|
15010
|
+
}
|
|
15011
|
+
else {
|
|
15012
|
+
this.clearScrollbar(scrollContainer, 'vertical');
|
|
15013
|
+
}
|
|
15014
|
+
}
|
|
15015
|
+
getDirection(isHorozntal) {
|
|
15016
|
+
return isHorozntal ? 'horizontal' : 'vertical';
|
|
15017
|
+
}
|
|
15018
|
+
addOrUpdateHScroll(scrollContainer, container, isHorozntal) {
|
|
15019
|
+
var _a;
|
|
15020
|
+
const direction = this.getDirection(isHorozntal);
|
|
15021
|
+
const name = `${(_a = scrollContainer.name) !== null && _a !== void 0 ? _a : scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;
|
|
15022
|
+
const scrollbars = container.children.filter((g) => g.name === name);
|
|
15023
|
+
let isUpdate = true;
|
|
15024
|
+
let scrollBar = scrollbars[0];
|
|
15025
|
+
const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;
|
|
15026
|
+
const attrs = {
|
|
15027
|
+
x: 0,
|
|
15028
|
+
y: 0,
|
|
15029
|
+
direction,
|
|
15030
|
+
zIndex: zIndex + 1,
|
|
15031
|
+
visibleAll: true,
|
|
15032
|
+
padding: [2, 0],
|
|
15033
|
+
railStyle: {
|
|
15034
|
+
fill: 'rgba(0, 0, 0, .1)'
|
|
15035
|
+
},
|
|
15036
|
+
range: [0, 0.05]
|
|
15037
|
+
};
|
|
15038
|
+
if (isHorozntal) {
|
|
15039
|
+
attrs.width = this.scrollContainerBounds.width();
|
|
15040
|
+
attrs.height = 12;
|
|
15041
|
+
}
|
|
15042
|
+
else {
|
|
15043
|
+
attrs.height = this.scrollContainerBounds.height();
|
|
15044
|
+
attrs.width = 12;
|
|
15045
|
+
}
|
|
15046
|
+
if (!scrollBar) {
|
|
15047
|
+
isUpdate = false;
|
|
15048
|
+
scrollBar = new ScrollBar(attrs);
|
|
15049
|
+
scrollBar.name = name;
|
|
15050
|
+
container.add(scrollBar);
|
|
15051
|
+
scrollBar.isScrollBar = true;
|
|
15052
|
+
}
|
|
15053
|
+
else if (scrollbars.length > 1) {
|
|
15054
|
+
scrollbars.forEach((child, index) => {
|
|
15055
|
+
var _a;
|
|
15056
|
+
if (index) {
|
|
15057
|
+
(_a = child.parent) === null || _a === void 0 ? void 0 : _a.removeChild(child);
|
|
15058
|
+
}
|
|
15059
|
+
});
|
|
15060
|
+
}
|
|
15061
|
+
const childrenBounds = this.childrenBounds;
|
|
15062
|
+
if (isHorozntal) {
|
|
15063
|
+
const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);
|
|
15064
|
+
const start = Math.max(Math.min(this.childrenBounds.x1 / this.childrenBounds.width(), 0), ratio - 1);
|
|
15065
|
+
attrs.x = x + dx;
|
|
15066
|
+
attrs.y = y + dy + height - this.scrollContainerBounds.height();
|
|
15067
|
+
attrs.range = [-start, -start + ratio];
|
|
15068
|
+
}
|
|
15069
|
+
else {
|
|
15070
|
+
const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);
|
|
15071
|
+
const start = Math.max(Math.min(this.childrenBounds.y1 / this.childrenBounds.height(), 0), ratio - 1);
|
|
15072
|
+
attrs.x = x + dx + width - this.scrollContainerBounds.width();
|
|
15073
|
+
attrs.y = y + dy;
|
|
15074
|
+
attrs.range = [-start, -start + ratio];
|
|
15075
|
+
}
|
|
15076
|
+
scrollBar.setAttributes(attrs);
|
|
15077
|
+
return {
|
|
15078
|
+
scrollBar,
|
|
15079
|
+
isUpdate
|
|
15080
|
+
};
|
|
15081
|
+
}
|
|
15082
|
+
clearScrollbar(scrollContainer, type) {
|
|
15083
|
+
if (!scrollContainer.parent) {
|
|
15084
|
+
return;
|
|
15085
|
+
}
|
|
15086
|
+
const scrollbarBars = scrollContainer.parent.children.filter((child) => {
|
|
15087
|
+
return child.isScrollBar && (type === 'all' || child.attribute.direction === type);
|
|
15088
|
+
});
|
|
15089
|
+
scrollbarBars.forEach((child) => {
|
|
15090
|
+
child.parent.removeChild(child);
|
|
15091
|
+
});
|
|
15092
|
+
}
|
|
15093
|
+
formatScrollContainer(g) {
|
|
15094
|
+
if (!g || g.type !== 'group' || !g.attribute) {
|
|
15095
|
+
return null;
|
|
15096
|
+
}
|
|
15097
|
+
const { overflow, width, height } = g.attribute;
|
|
15098
|
+
if (!overflow || overflow === 'hidden') {
|
|
15099
|
+
return null;
|
|
15100
|
+
}
|
|
15101
|
+
let showH = false;
|
|
15102
|
+
let showV = false;
|
|
15103
|
+
if (overflow === 'scroll') {
|
|
15104
|
+
showH = true;
|
|
15105
|
+
showV = true;
|
|
15106
|
+
}
|
|
15107
|
+
else {
|
|
15108
|
+
showH = overflow === 'scroll-x';
|
|
15109
|
+
showV = !showH;
|
|
15110
|
+
}
|
|
15111
|
+
if (!g.AABBBounds.empty()) {
|
|
15112
|
+
if (showH) {
|
|
15113
|
+
showH = width < g.AABBBounds.width();
|
|
15114
|
+
}
|
|
15115
|
+
if (showV) {
|
|
15116
|
+
showV = height < g.AABBBounds.height();
|
|
15117
|
+
}
|
|
15118
|
+
}
|
|
15119
|
+
return showH || showV ? { g: g, showH, showV } : null;
|
|
15120
|
+
}
|
|
15121
|
+
getScrollContainer(graphic) {
|
|
15122
|
+
let g = graphic;
|
|
15123
|
+
while (g) {
|
|
15124
|
+
const res = this.formatScrollContainer(g);
|
|
15125
|
+
if (res) {
|
|
15126
|
+
return res;
|
|
15127
|
+
}
|
|
15128
|
+
g = g.parent;
|
|
15129
|
+
}
|
|
15130
|
+
return null;
|
|
15131
|
+
}
|
|
15132
|
+
deactivate(context) {
|
|
15133
|
+
const { stage } = this.pluginService;
|
|
15134
|
+
stage.removeEventListener('wheel', this.scroll);
|
|
15135
|
+
}
|
|
15136
|
+
};
|
|
15137
|
+
ScrollBarPlugin.defaultParams = {
|
|
15138
|
+
timeout: 500
|
|
15139
|
+
};
|
|
15140
|
+
ScrollBarPlugin = ScrollBarPlugin_1 = __decorate([
|
|
15141
|
+
injectable()
|
|
15142
|
+
], ScrollBarPlugin);
|
|
15143
|
+
|
|
15144
|
+
const scrollbarModule = new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
15145
|
+
if (!isBound(ScrollBarPlugin)) {
|
|
15146
|
+
bind(ScrollBarPlugin).toSelf();
|
|
15147
|
+
bind(AutoEnablePlugins).toService(ScrollBarPlugin);
|
|
15148
|
+
}
|
|
15149
|
+
});
|
|
15150
|
+
function loadScrollbar() {
|
|
15151
|
+
container.load(scrollbarModule);
|
|
15152
|
+
}
|
|
15153
|
+
|
|
14835
15154
|
function traverseGroup(group, cb) {
|
|
14836
15155
|
group.forEachChildren(node => {
|
|
14837
15156
|
const stopped = cb(node);
|
|
@@ -16289,24 +16608,29 @@ function defaultLabelPosition(type) {
|
|
|
16289
16608
|
return DefaultPositions;
|
|
16290
16609
|
}
|
|
16291
16610
|
}
|
|
16292
|
-
function clampText(text, width, height) {
|
|
16611
|
+
function clampText(text, width, height, padding = {}) {
|
|
16293
16612
|
const { x1, x2, y1, y2 } = text.AABBBounds;
|
|
16613
|
+
const { top = 0, left = 0, right = 0, bottom = 0 } = padding;
|
|
16294
16614
|
const minX = Math.min(x1, x2);
|
|
16295
16615
|
const maxX = Math.max(x1, x2);
|
|
16296
16616
|
const minY = Math.min(y1, y2);
|
|
16297
16617
|
const maxY = Math.max(y1, y2);
|
|
16618
|
+
const minXWithPadding = 0 - left;
|
|
16619
|
+
const maxXWithPadding = width + right;
|
|
16620
|
+
const minYWithPadding = 0 - top;
|
|
16621
|
+
const maxYWithPadding = height + bottom;
|
|
16298
16622
|
let dx = 0;
|
|
16299
16623
|
let dy = 0;
|
|
16300
|
-
if (minX <
|
|
16624
|
+
if (minX < minXWithPadding && maxX - minX <= width) {
|
|
16301
16625
|
dx = -minX;
|
|
16302
16626
|
}
|
|
16303
|
-
else if (maxX >
|
|
16627
|
+
else if (maxX > maxXWithPadding && minX - (maxX - width) >= minXWithPadding) {
|
|
16304
16628
|
dx = width - maxX;
|
|
16305
16629
|
}
|
|
16306
|
-
if (minY <
|
|
16630
|
+
if (minY < minYWithPadding && maxY - minY <= height) {
|
|
16307
16631
|
dy = -minY;
|
|
16308
16632
|
}
|
|
16309
|
-
else if (maxY >
|
|
16633
|
+
else if (maxY > maxYWithPadding && minY - (maxY - height) >= minYWithPadding) {
|
|
16310
16634
|
dy = height - maxY;
|
|
16311
16635
|
}
|
|
16312
16636
|
return { dx, dy };
|
|
@@ -16606,69 +16930,177 @@ function loadLabelComponent() {
|
|
|
16606
16930
|
registerLine();
|
|
16607
16931
|
}
|
|
16608
16932
|
|
|
16609
|
-
|
|
16610
|
-
|
|
16933
|
+
const isIntersect = (top, bottom) => {
|
|
16934
|
+
return Math.ceil(top) > Math.floor(bottom);
|
|
16935
|
+
};
|
|
16936
|
+
const isXIntersect = ([a, b], [c, d]) => {
|
|
16937
|
+
return d > a && b > c;
|
|
16938
|
+
};
|
|
16939
|
+
function getIntersectionLength(range1, range2) {
|
|
16940
|
+
const [start1, end1] = range1;
|
|
16941
|
+
const [start2, end2] = range2;
|
|
16942
|
+
const start = Math.max(start1, start2);
|
|
16943
|
+
const end = Math.min(end1, end2);
|
|
16944
|
+
return Math.max(0, end - start);
|
|
16945
|
+
}
|
|
16946
|
+
function shiftY(texts, option) {
|
|
16947
|
+
const { maxY = Number.MAX_VALUE, labelling, globalShiftY = { enable: true, maxIterations: 10, maxError: 0.1, padding: 1 } } = option;
|
|
16611
16948
|
const n = texts.length;
|
|
16612
16949
|
if (n <= 1) {
|
|
16613
16950
|
return texts;
|
|
16614
16951
|
}
|
|
16615
|
-
const
|
|
16616
|
-
return d > a && b > c;
|
|
16617
|
-
};
|
|
16952
|
+
const xMap = new Map();
|
|
16618
16953
|
const textInformation = new Map();
|
|
16619
|
-
const
|
|
16620
|
-
const getY = (text) => textInformation.get(text).y;
|
|
16954
|
+
const getY1Initial = (text) => textInformation.get(text).y1Initial;
|
|
16621
16955
|
const getHeight = (text) => textInformation.get(text).height;
|
|
16956
|
+
const getY1 = (text) => textInformation.get(text).y1;
|
|
16957
|
+
const getY = (text) => textInformation.get(text).y;
|
|
16958
|
+
const getX = (text) => textInformation.get(text).x;
|
|
16622
16959
|
const getX1 = (text) => textInformation.get(text).x1;
|
|
16623
16960
|
const getX2 = (text) => textInformation.get(text).x2;
|
|
16624
|
-
const
|
|
16625
|
-
|
|
16961
|
+
const getAdjustAttempts = (text) => textInformation.get(text).attempts;
|
|
16962
|
+
const setY1 = (text, y) => {
|
|
16963
|
+
textInformation.get(text).y1 = y;
|
|
16626
16964
|
};
|
|
16965
|
+
const setAdjustAttempts = (text, attempts) => {
|
|
16966
|
+
textInformation.get(text).attempts = attempts;
|
|
16967
|
+
};
|
|
16968
|
+
function adjustPositionInOneGroup(texts) {
|
|
16969
|
+
if (texts.length === 1) {
|
|
16970
|
+
return;
|
|
16971
|
+
}
|
|
16972
|
+
for (let i = texts.length - 1; i > 0; i--) {
|
|
16973
|
+
const curText = texts[i];
|
|
16974
|
+
const upperText = texts[i - 1];
|
|
16975
|
+
const lowerText = texts[i + 1];
|
|
16976
|
+
if (isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText))) {
|
|
16977
|
+
const { y } = labelling(curText);
|
|
16978
|
+
if (!lowerText || !isIntersect(y + getHeight(curText) / 2, getY1(lowerText))) {
|
|
16979
|
+
if (y + getHeight(curText) / 2 <= maxY) {
|
|
16980
|
+
setY1(curText, getY1(curText) + y - getY(curText));
|
|
16981
|
+
}
|
|
16982
|
+
}
|
|
16983
|
+
}
|
|
16984
|
+
}
|
|
16985
|
+
}
|
|
16986
|
+
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
16627
16987
|
for (const text of texts) {
|
|
16628
16988
|
const { y1, y2, x1, x2 } = text.AABBBounds;
|
|
16629
|
-
|
|
16989
|
+
const { x, y } = text.attribute;
|
|
16990
|
+
textInformation.set(text, { y1Initial: y1, y1, y2, y, height: y2 - y1, x1, x2, x, attempts: 0 });
|
|
16991
|
+
let hasRange = false;
|
|
16992
|
+
for (const [range, xGroupTexts] of xMap) {
|
|
16993
|
+
const { start, end } = range;
|
|
16994
|
+
if (x1 >= start && x2 <= end) {
|
|
16995
|
+
xGroupTexts.push(text);
|
|
16996
|
+
hasRange = true;
|
|
16997
|
+
}
|
|
16998
|
+
else if (isNumberClose(x, getX(xGroupTexts[0]), undefined, 5)) {
|
|
16999
|
+
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
17000
|
+
xGroupTexts.push(text);
|
|
17001
|
+
xMap.set(newRange, xGroupTexts);
|
|
17002
|
+
xMap.delete(range);
|
|
17003
|
+
hasRange = true;
|
|
17004
|
+
}
|
|
17005
|
+
else if (getIntersectionLength([start, end], [x1, x2]) / (end - start) > 0.5) {
|
|
17006
|
+
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
17007
|
+
xGroupTexts.push(text);
|
|
17008
|
+
xMap.set(newRange, xGroupTexts);
|
|
17009
|
+
xMap.delete(range);
|
|
17010
|
+
hasRange = true;
|
|
17011
|
+
}
|
|
17012
|
+
if (hasRange) {
|
|
17013
|
+
break;
|
|
17014
|
+
}
|
|
17015
|
+
}
|
|
17016
|
+
if (!hasRange) {
|
|
17017
|
+
xMap.set({ start: x1, end: x2 }, [text]);
|
|
17018
|
+
}
|
|
16630
17019
|
}
|
|
16631
|
-
for (
|
|
16632
|
-
|
|
16633
|
-
|
|
16634
|
-
|
|
16635
|
-
|
|
16636
|
-
|
|
16637
|
-
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
|
|
16641
|
-
|
|
16642
|
-
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
|
|
16649
|
-
|
|
16650
|
-
|
|
16651
|
-
|
|
16652
|
-
|
|
16653
|
-
|
|
16654
|
-
|
|
16655
|
-
|
|
16656
|
-
|
|
16657
|
-
|
|
16658
|
-
|
|
17020
|
+
for (const xTexts of xMap.values()) {
|
|
17021
|
+
xTexts.sort((a, b) => getY1Initial(a) - getY1Initial(b));
|
|
17022
|
+
adjustPositionInOneGroup(xTexts);
|
|
17023
|
+
}
|
|
17024
|
+
if (globalShiftY.enable !== false) {
|
|
17025
|
+
const { maxIterations = 10, maxError = 0.1, padding = 1, maxAttempts = 1000, deltaYTolerance = Number.MAX_VALUE } = globalShiftY;
|
|
17026
|
+
for (let iter = 0; iter < maxIterations; iter++) {
|
|
17027
|
+
texts.sort((a, b) => getY1(a) - getY1(b));
|
|
17028
|
+
let error = 0;
|
|
17029
|
+
for (let i = 0; i < n - 1; i++) {
|
|
17030
|
+
const curText = texts[i];
|
|
17031
|
+
if (getAdjustAttempts(curText) >= maxAttempts) {
|
|
17032
|
+
continue;
|
|
17033
|
+
}
|
|
17034
|
+
let j = i + 1;
|
|
17035
|
+
let nextText;
|
|
17036
|
+
while ((nextText = texts[j]) &&
|
|
17037
|
+
!isXIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
|
|
17038
|
+
j += 1;
|
|
17039
|
+
}
|
|
17040
|
+
if (nextText) {
|
|
17041
|
+
const y1 = getY1(curText);
|
|
17042
|
+
const h0 = getHeight(curText);
|
|
17043
|
+
const nextY1 = getY1(nextText);
|
|
17044
|
+
const delta = nextY1 - (y1 + h0);
|
|
17045
|
+
if (delta < padding) {
|
|
17046
|
+
const newDelta = (padding - delta) / 2;
|
|
17047
|
+
error = Math.max(error, newDelta);
|
|
17048
|
+
if (y1 + newDelta + getHeight(nextText) > maxY) {
|
|
17049
|
+
const newY1 = y1 - (padding - delta);
|
|
17050
|
+
const curTextDelta = getY1Initial(curText) - newY1;
|
|
17051
|
+
if (Math.abs(curTextDelta) <= deltaYTolerance) {
|
|
17052
|
+
setY1(curText, newY1);
|
|
17053
|
+
setAdjustAttempts(curText, getAdjustAttempts(curText) + 1);
|
|
17054
|
+
}
|
|
17055
|
+
}
|
|
17056
|
+
else if (y1 - newDelta < 0) {
|
|
17057
|
+
const newY1 = nextY1 + (padding - delta);
|
|
17058
|
+
const nextTextDelta = getY1Initial(nextText) - newY1;
|
|
17059
|
+
if (Math.abs(nextTextDelta) <= deltaYTolerance) {
|
|
17060
|
+
setY1(nextText, newY1);
|
|
17061
|
+
setAdjustAttempts(nextText, getAdjustAttempts(nextText) + 1);
|
|
17062
|
+
}
|
|
17063
|
+
}
|
|
17064
|
+
else {
|
|
17065
|
+
const newCurY1 = y1 - newDelta;
|
|
17066
|
+
const curTextDelta = getY1Initial(curText) - newCurY1;
|
|
17067
|
+
const newNextY1 = nextY1 + newDelta;
|
|
17068
|
+
const nextTextDelta = getY1Initial(nextText) - newNextY1;
|
|
17069
|
+
if (Math.abs(curTextDelta) <= deltaYTolerance && Math.abs(nextTextDelta) <= deltaYTolerance) {
|
|
17070
|
+
setY1(curText, newCurY1);
|
|
17071
|
+
setY1(nextText, newNextY1);
|
|
17072
|
+
setAdjustAttempts(curText, getAdjustAttempts(curText) + 1);
|
|
17073
|
+
setAdjustAttempts(nextText, getAdjustAttempts(nextText) + 1);
|
|
17074
|
+
}
|
|
17075
|
+
}
|
|
16659
17076
|
}
|
|
16660
17077
|
}
|
|
16661
17078
|
}
|
|
16662
|
-
|
|
16663
|
-
|
|
16664
|
-
|
|
17079
|
+
if (error < maxError) {
|
|
17080
|
+
break;
|
|
17081
|
+
}
|
|
16665
17082
|
}
|
|
16666
17083
|
}
|
|
16667
17084
|
for (const text of texts) {
|
|
16668
|
-
const finalY = text.attribute.y +
|
|
17085
|
+
const finalY = text.attribute.y + getY1(text) - getY1Initial(text);
|
|
16669
17086
|
text.setAttribute('y', finalY);
|
|
16670
17087
|
}
|
|
16671
|
-
|
|
17088
|
+
const result = [];
|
|
17089
|
+
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
17090
|
+
let start = 0;
|
|
17091
|
+
let end = texts.length - 1;
|
|
17092
|
+
while (start <= end) {
|
|
17093
|
+
if (start === end) {
|
|
17094
|
+
result.push(texts[start]);
|
|
17095
|
+
}
|
|
17096
|
+
else {
|
|
17097
|
+
result.push(texts[start]);
|
|
17098
|
+
result.push(texts[end]);
|
|
17099
|
+
}
|
|
17100
|
+
start++;
|
|
17101
|
+
end--;
|
|
17102
|
+
}
|
|
17103
|
+
return result;
|
|
16672
17104
|
}
|
|
16673
17105
|
|
|
16674
17106
|
loadLabelComponent();
|
|
@@ -17014,18 +17446,25 @@ class LabelBase extends AbstractComponent {
|
|
|
17014
17446
|
if (clampForce) {
|
|
17015
17447
|
for (let i = 0; i < result.length; i++) {
|
|
17016
17448
|
const text = labels[i];
|
|
17017
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
17449
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
17018
17450
|
if (dx !== 0 || dy !== 0) {
|
|
17019
17451
|
text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
|
|
17452
|
+
text._isClamped = true;
|
|
17020
17453
|
}
|
|
17021
17454
|
}
|
|
17022
17455
|
}
|
|
17023
|
-
result = shiftY(result, Object.assign({ maxY: bmpTool.height }, strategy))
|
|
17456
|
+
result = shiftY(result, Object.assign(Object.assign({ maxY: bmpTool.height }, strategy), { labelling: (text) => {
|
|
17457
|
+
const baseMark = this.getRelatedGraphic(text.attribute);
|
|
17458
|
+
const graphicBound = this._isCollectionBase
|
|
17459
|
+
? this.getGraphicBounds(null, this._idToPoint.get(text.attribute.id))
|
|
17460
|
+
: this.getGraphicBounds(baseMark, text);
|
|
17461
|
+
return this.labeling(text.AABBBounds, graphicBound, 'bottom', this.attribute.offset);
|
|
17462
|
+
} }));
|
|
17024
17463
|
for (let i = 0; i < result.length; i++) {
|
|
17025
17464
|
const text = result[i];
|
|
17026
17465
|
const bounds = text.AABBBounds;
|
|
17027
17466
|
const range = boundToRange(bmpTool, bounds, true);
|
|
17028
|
-
if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) {
|
|
17467
|
+
if (canPlace(bmpTool, bitmap, bounds, clampForce, text._isClamped ? 0 : overlapPadding)) {
|
|
17029
17468
|
bitmap.setRange(range);
|
|
17030
17469
|
}
|
|
17031
17470
|
else {
|
|
@@ -17098,7 +17537,7 @@ class LabelBase extends AbstractComponent {
|
|
|
17098
17537
|
}
|
|
17099
17538
|
}
|
|
17100
17539
|
if (!hasPlace && clampForce) {
|
|
17101
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
17540
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
17102
17541
|
if (dx === 0 && dy === 0) {
|
|
17103
17542
|
if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
|
|
17104
17543
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
|
|
@@ -17329,7 +17768,7 @@ class LabelBase extends AbstractComponent {
|
|
|
17329
17768
|
return listener;
|
|
17330
17769
|
}
|
|
17331
17770
|
_smartInvert(labels) {
|
|
17332
|
-
var _a, _b, _c, _d, _e;
|
|
17771
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
17333
17772
|
const option = (isObject(this.attribute.smartInvert) ? this.attribute.smartInvert : {});
|
|
17334
17773
|
const { textType, contrastRatiosThreshold, alternativeColors, mode, interactInvertType } = option;
|
|
17335
17774
|
const fillStrategy = (_a = option.fillStrategy) !== null && _a !== void 0 ? _a : 'invertBase';
|
|
@@ -17346,8 +17785,15 @@ class LabelBase extends AbstractComponent {
|
|
|
17346
17785
|
continue;
|
|
17347
17786
|
}
|
|
17348
17787
|
const baseMark = this.getRelatedGraphic(label.attribute);
|
|
17349
|
-
|
|
17350
|
-
|
|
17788
|
+
let backgroundColor = baseMark.attribute.fill;
|
|
17789
|
+
let foregroundColor = label.attribute.fill;
|
|
17790
|
+
if (isObject(backgroundColor) && backgroundColor.gradient) {
|
|
17791
|
+
const firstStopColor = (_g = (_f = backgroundColor.stops) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.color;
|
|
17792
|
+
if (firstStopColor) {
|
|
17793
|
+
backgroundColor = firstStopColor;
|
|
17794
|
+
foregroundColor = firstStopColor;
|
|
17795
|
+
}
|
|
17796
|
+
}
|
|
17351
17797
|
const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode);
|
|
17352
17798
|
const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
|
|
17353
17799
|
const isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds);
|
|
@@ -17575,6 +18021,9 @@ class ArcLabel extends LabelBase {
|
|
|
17575
18021
|
this._alignOffset = 0;
|
|
17576
18022
|
}
|
|
17577
18023
|
_overlapping(labels) {
|
|
18024
|
+
if (['inside', 'inside-center'].includes(this.attribute.position)) {
|
|
18025
|
+
return super._overlapping(labels);
|
|
18026
|
+
}
|
|
17578
18027
|
return labels;
|
|
17579
18028
|
}
|
|
17580
18029
|
labeling(textBounds, graphicBounds, position = 'outside', offset = 0) {
|
|
@@ -25061,7 +25510,8 @@ class DiscreteLegend extends LegendBase {
|
|
|
25061
25510
|
items: legendItems,
|
|
25062
25511
|
isHorizontal,
|
|
25063
25512
|
totalPage: Infinity,
|
|
25064
|
-
isScrollbar: pager && pager.type === 'scrollbar'
|
|
25513
|
+
isScrollbar: pager && pager.type === 'scrollbar',
|
|
25514
|
+
clipContainer: undefined
|
|
25065
25515
|
};
|
|
25066
25516
|
this._itemContext = this._renderItems();
|
|
25067
25517
|
let pagerRendered = false;
|
|
@@ -25082,11 +25532,21 @@ class DiscreteLegend extends LegendBase {
|
|
|
25082
25532
|
}
|
|
25083
25533
|
const { hover = true, select = true } = this.attribute;
|
|
25084
25534
|
if (hover) {
|
|
25085
|
-
|
|
25086
|
-
|
|
25535
|
+
let trigger = 'pointermove';
|
|
25536
|
+
let triggerOff = 'pointerleave';
|
|
25537
|
+
if (isObject(hover)) {
|
|
25538
|
+
hover.trigger && (trigger = hover.trigger);
|
|
25539
|
+
hover.triggerOff && (triggerOff = hover.triggerOff);
|
|
25540
|
+
}
|
|
25541
|
+
this._itemsContainer.addEventListener(trigger, this._onHover);
|
|
25542
|
+
this._itemsContainer.addEventListener(triggerOff, this._onUnHover);
|
|
25087
25543
|
}
|
|
25088
25544
|
if (select) {
|
|
25089
|
-
|
|
25545
|
+
let trigger = 'pointerdown';
|
|
25546
|
+
if (isObject(select) && select.trigger) {
|
|
25547
|
+
trigger = select.trigger;
|
|
25548
|
+
}
|
|
25549
|
+
this._itemsContainer.addEventListener(trigger, this._onClick);
|
|
25090
25550
|
}
|
|
25091
25551
|
}
|
|
25092
25552
|
_autoEllipsis(autoEllipsisStrategy, layoutWidth, labelShape, valueShape) {
|
|
@@ -25291,8 +25751,8 @@ class DiscreteLegend extends LegendBase {
|
|
|
25291
25751
|
_createScrollbar(compStyle, compSize) {
|
|
25292
25752
|
const { disableTriggerEvent } = this.attribute;
|
|
25293
25753
|
return this._itemContext.isHorizontal
|
|
25294
|
-
? new ScrollBar(Object.assign(Object.assign({ direction: 'horizontal', disableTriggerEvent, range: [0, 0.5], height: 12 }, compStyle), { width: compSize }))
|
|
25295
|
-
: new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
|
|
25754
|
+
? new ScrollBar(Object.assign(Object.assign({ direction: 'horizontal', disableTriggerEvent, range: [0, 0.5], height: compStyle.visible === false ? 0 : 12 }, compStyle), { width: compSize }))
|
|
25755
|
+
: new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: compStyle.visible === false ? 0 : 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
|
|
25296
25756
|
}
|
|
25297
25757
|
_updatePositionOfPager(renderStartY, compWidth, compHeight) {
|
|
25298
25758
|
const { pager } = this.attribute;
|
|
@@ -25332,9 +25792,26 @@ class DiscreteLegend extends LegendBase {
|
|
|
25332
25792
|
});
|
|
25333
25793
|
}
|
|
25334
25794
|
}
|
|
25795
|
+
_computeScrollbarDelta() {
|
|
25796
|
+
const { isHorizontal, clipContainer } = this._itemContext;
|
|
25797
|
+
const itemContainerBounds = this._itemsContainer.AABBBounds;
|
|
25798
|
+
const clipContainerBounds = clipContainer.AABBBounds;
|
|
25799
|
+
let delta;
|
|
25800
|
+
let innerViewSize;
|
|
25801
|
+
if (isHorizontal) {
|
|
25802
|
+
innerViewSize = clipContainerBounds.width();
|
|
25803
|
+
delta = innerViewSize / itemContainerBounds.width();
|
|
25804
|
+
}
|
|
25805
|
+
else {
|
|
25806
|
+
innerViewSize = clipContainerBounds.height();
|
|
25807
|
+
delta = innerViewSize / itemContainerBounds.height();
|
|
25808
|
+
}
|
|
25809
|
+
return delta;
|
|
25810
|
+
}
|
|
25335
25811
|
_updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY) {
|
|
25336
|
-
const { currentPage, totalPage
|
|
25337
|
-
|
|
25812
|
+
const { isHorizontal, currentPage, totalPage } = this._itemContext;
|
|
25813
|
+
const start = (currentPage - 1) / totalPage;
|
|
25814
|
+
this._pagerComponent.setScrollRange([start, start + this._computeScrollbarDelta()]);
|
|
25338
25815
|
if (isHorizontal) {
|
|
25339
25816
|
this._pagerComponent.setAttributes({
|
|
25340
25817
|
x: 0,
|
|
@@ -25362,13 +25839,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
25362
25839
|
newPage = this._itemContext.totalPage;
|
|
25363
25840
|
}
|
|
25364
25841
|
else {
|
|
25365
|
-
newPage = value[0] * this._itemContext.totalPage;
|
|
25366
|
-
if (pager.scrollByPosition) {
|
|
25367
|
-
newPage = newPage + 1;
|
|
25368
|
-
}
|
|
25369
|
-
else {
|
|
25370
|
-
newPage = Math.floor(newPage) + 1;
|
|
25371
|
-
}
|
|
25842
|
+
newPage = value[0] * this._itemContext.totalPage + 1;
|
|
25372
25843
|
}
|
|
25373
25844
|
return newPage;
|
|
25374
25845
|
}
|
|
@@ -25382,6 +25853,7 @@ class DiscreteLegend extends LegendBase {
|
|
|
25382
25853
|
const { width, height } = scrollComponent.getSliderRenderBounds();
|
|
25383
25854
|
const currentScrollValue = direction === 'vertical' ? e.deltaY / height : e.deltaX / width;
|
|
25384
25855
|
scrollComponent.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);
|
|
25856
|
+
this.updateScrollMask();
|
|
25385
25857
|
};
|
|
25386
25858
|
const onPaging = (e) => {
|
|
25387
25859
|
const newPage = pageParser(e);
|
|
@@ -25393,15 +25865,39 @@ class DiscreteLegend extends LegendBase {
|
|
|
25393
25865
|
this._renderItems();
|
|
25394
25866
|
const newTotalPage = Math.ceil(this._itemContext.pages / this._itemContext.maxPages);
|
|
25395
25867
|
this._itemContext.totalPage = newTotalPage;
|
|
25396
|
-
this.
|
|
25868
|
+
if (this._itemContext.isScrollbar && this._pagerComponent) {
|
|
25869
|
+
const newDelta = this._computeScrollbarDelta();
|
|
25870
|
+
const [start] = this._pagerComponent.getScrollRange();
|
|
25871
|
+
this._pagerComponent.setScrollRange([start, start + newDelta]);
|
|
25872
|
+
}
|
|
25397
25873
|
}
|
|
25398
|
-
if (
|
|
25399
|
-
|
|
25400
|
-
.
|
|
25401
|
-
|
|
25874
|
+
if (!this._itemContext.isScrollbar) {
|
|
25875
|
+
if (animation) {
|
|
25876
|
+
this._itemsContainer
|
|
25877
|
+
.animate()
|
|
25878
|
+
.to({ [channel]: -(newPage - 1) * pageSize }, animationDuration, animationEasing);
|
|
25879
|
+
}
|
|
25880
|
+
else {
|
|
25881
|
+
this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
|
|
25882
|
+
}
|
|
25402
25883
|
}
|
|
25403
25884
|
else {
|
|
25404
|
-
this.
|
|
25885
|
+
const [start] = this._pagerComponent.getScrollRange();
|
|
25886
|
+
let containerSize;
|
|
25887
|
+
if (this._itemContext.isHorizontal) {
|
|
25888
|
+
containerSize = this._itemsContainer.AABBBounds.width();
|
|
25889
|
+
}
|
|
25890
|
+
else {
|
|
25891
|
+
containerSize = this._itemsContainer.AABBBounds.height();
|
|
25892
|
+
}
|
|
25893
|
+
const startOffset = containerSize * start;
|
|
25894
|
+
this.updateScrollMask();
|
|
25895
|
+
if (animation) {
|
|
25896
|
+
this._itemsContainer.animate().to({ [channel]: -startOffset }, animationDuration, animationEasing);
|
|
25897
|
+
}
|
|
25898
|
+
else {
|
|
25899
|
+
this._itemsContainer.setAttribute(channel, -startOffset);
|
|
25900
|
+
}
|
|
25405
25901
|
}
|
|
25406
25902
|
};
|
|
25407
25903
|
if (this._itemContext.isScrollbar) {
|
|
@@ -25516,10 +26012,12 @@ class DiscreteLegend extends LegendBase {
|
|
|
25516
26012
|
});
|
|
25517
26013
|
clipGroup.add(itemsContainer);
|
|
25518
26014
|
this._innerView.add(clipGroup);
|
|
26015
|
+
this._itemContext.clipContainer = clipGroup;
|
|
25519
26016
|
this._bindEventsOfPager(isHorizontal ? compHeight + spaceRow : compWidth + spaceCol, isHorizontal ? 'y' : 'x');
|
|
25520
26017
|
return true;
|
|
25521
26018
|
}
|
|
25522
26019
|
_renderScrollbar() {
|
|
26020
|
+
var _a;
|
|
25523
26021
|
const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, 'title.space', 8) : 0;
|
|
25524
26022
|
const { maxWidth, item = {}, pager = {} } = this.attribute;
|
|
25525
26023
|
const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = item;
|
|
@@ -25528,27 +26026,23 @@ class DiscreteLegend extends LegendBase {
|
|
|
25528
26026
|
const { isHorizontal } = this._itemContext;
|
|
25529
26027
|
const maxHeight = this._contentMaxHeight;
|
|
25530
26028
|
let comp;
|
|
25531
|
-
let compSize = 0;
|
|
25532
26029
|
let contentWidth = 0;
|
|
25533
26030
|
let contentHeight = 0;
|
|
25534
26031
|
let startY = 0;
|
|
25535
26032
|
let pages = 1;
|
|
25536
26033
|
if (isHorizontal) {
|
|
25537
|
-
compSize = maxWidth;
|
|
25538
26034
|
contentWidth = maxWidth;
|
|
25539
26035
|
contentHeight = this._itemHeight;
|
|
25540
|
-
comp = this._createScrollbar(compStyle,
|
|
26036
|
+
comp = this._createScrollbar(compStyle, contentWidth);
|
|
25541
26037
|
this._pagerComponent = comp;
|
|
25542
26038
|
this._innerView.add(comp);
|
|
25543
|
-
this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
|
|
25544
26039
|
}
|
|
25545
26040
|
else {
|
|
25546
|
-
compSize = maxHeight;
|
|
25547
|
-
comp = this._createScrollbar(compStyle, compSize);
|
|
25548
|
-
this._pagerComponent = comp;
|
|
25549
|
-
this._innerView.add(comp);
|
|
25550
26041
|
contentHeight = maxHeight - renderStartY;
|
|
25551
26042
|
contentWidth = this._itemMaxWidth;
|
|
26043
|
+
comp = this._createScrollbar(compStyle, contentHeight);
|
|
26044
|
+
this._pagerComponent = comp;
|
|
26045
|
+
this._innerView.add(comp);
|
|
25552
26046
|
if (contentHeight <= 0) {
|
|
25553
26047
|
this._innerView.removeChild(comp);
|
|
25554
26048
|
return false;
|
|
@@ -25579,14 +26073,15 @@ class DiscreteLegend extends LegendBase {
|
|
|
25579
26073
|
}
|
|
25580
26074
|
this._itemContext.totalPage = pages;
|
|
25581
26075
|
this._itemContext.pages = pages;
|
|
25582
|
-
this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
|
|
25583
26076
|
}
|
|
25584
26077
|
if (defaultCurrent > 1) {
|
|
25585
26078
|
if (isHorizontal) {
|
|
25586
|
-
|
|
26079
|
+
const maxOffset = this._itemsContainer.AABBBounds.width() - contentWidth;
|
|
26080
|
+
itemsContainer.setAttribute('x', -Math.min((defaultCurrent - 1) * (contentWidth + spaceCol), maxOffset));
|
|
25587
26081
|
}
|
|
25588
26082
|
else {
|
|
25589
|
-
|
|
26083
|
+
const maxOffset = this._itemsContainer.AABBBounds.height() - contentHeight;
|
|
26084
|
+
itemsContainer.setAttribute('y', -Math.min((defaultCurrent - 1) * (contentHeight + spaceRow), maxOffset));
|
|
25590
26085
|
}
|
|
25591
26086
|
}
|
|
25592
26087
|
const clipGroup = graphicCreator.group({
|
|
@@ -25599,9 +26094,89 @@ class DiscreteLegend extends LegendBase {
|
|
|
25599
26094
|
});
|
|
25600
26095
|
clipGroup.add(itemsContainer);
|
|
25601
26096
|
this._innerView.add(clipGroup);
|
|
26097
|
+
this._itemContext.clipContainer = clipGroup;
|
|
26098
|
+
this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
|
|
26099
|
+
if ((_a = pager.scrollMask) === null || _a === void 0 ? void 0 : _a.visible) {
|
|
26100
|
+
this.renderScrollMask(clipGroup);
|
|
26101
|
+
}
|
|
25602
26102
|
this._bindEventsOfPager(isHorizontal ? contentWidth : contentHeight, isHorizontal ? 'x' : 'y');
|
|
25603
26103
|
return true;
|
|
25604
26104
|
}
|
|
26105
|
+
renderScrollMask(clipGroup) {
|
|
26106
|
+
const { scrollMask = {} } = this.attribute
|
|
26107
|
+
.pager;
|
|
26108
|
+
const { visible = true, gradientLength = 16, gradientStops } = scrollMask;
|
|
26109
|
+
if (!visible || !gradientStops) {
|
|
26110
|
+
return;
|
|
26111
|
+
}
|
|
26112
|
+
const width = clipGroup.AABBBounds.width();
|
|
26113
|
+
const height = clipGroup.AABBBounds.height();
|
|
26114
|
+
const totalLength = this._itemContext.isHorizontal ? width : height;
|
|
26115
|
+
const startStops = gradientStops.map(stop => {
|
|
26116
|
+
return {
|
|
26117
|
+
offset: (gradientLength * stop.offset) / totalLength,
|
|
26118
|
+
color: stop.color
|
|
26119
|
+
};
|
|
26120
|
+
});
|
|
26121
|
+
const endStops = gradientStops.map(stop => {
|
|
26122
|
+
return {
|
|
26123
|
+
offset: (totalLength - gradientLength * stop.offset) / totalLength,
|
|
26124
|
+
color: stop.color
|
|
26125
|
+
};
|
|
26126
|
+
});
|
|
26127
|
+
const mask = graphicCreator.rect({
|
|
26128
|
+
x: 0,
|
|
26129
|
+
y: 0,
|
|
26130
|
+
width,
|
|
26131
|
+
height
|
|
26132
|
+
});
|
|
26133
|
+
this._scrollMask = mask;
|
|
26134
|
+
this._scrollMaskContext = { startStops, endStops };
|
|
26135
|
+
this.updateScrollMask();
|
|
26136
|
+
clipGroup.add(mask);
|
|
26137
|
+
}
|
|
26138
|
+
updateScrollMask() {
|
|
26139
|
+
if (!this._scrollMask || !this._pagerComponent) {
|
|
26140
|
+
return;
|
|
26141
|
+
}
|
|
26142
|
+
if (!this._itemContext.isScrollbar) {
|
|
26143
|
+
return;
|
|
26144
|
+
}
|
|
26145
|
+
const [start, end] = this._pagerComponent.getScrollRange();
|
|
26146
|
+
const stops = [];
|
|
26147
|
+
if (!isNumberClose(clamp(end, 0, 1), 1)) {
|
|
26148
|
+
stops.push(...this._scrollMaskContext.endStops);
|
|
26149
|
+
}
|
|
26150
|
+
if (!isNumberClose(clamp(start, 0, 1), 0)) {
|
|
26151
|
+
stops.push(...this._scrollMaskContext.startStops);
|
|
26152
|
+
}
|
|
26153
|
+
if (stops.length) {
|
|
26154
|
+
if (this._itemContext.isHorizontal) {
|
|
26155
|
+
this._scrollMask.setAttributes({
|
|
26156
|
+
fill: {
|
|
26157
|
+
gradient: 'linear',
|
|
26158
|
+
x0: 0,
|
|
26159
|
+
y0: 0,
|
|
26160
|
+
x1: 1,
|
|
26161
|
+
y1: 0,
|
|
26162
|
+
stops
|
|
26163
|
+
}
|
|
26164
|
+
});
|
|
26165
|
+
}
|
|
26166
|
+
else {
|
|
26167
|
+
this._scrollMask.setAttributes({
|
|
26168
|
+
fill: {
|
|
26169
|
+
gradient: 'linear',
|
|
26170
|
+
x0: 0,
|
|
26171
|
+
y0: 0,
|
|
26172
|
+
x1: 0,
|
|
26173
|
+
y1: 1,
|
|
26174
|
+
stops
|
|
26175
|
+
}
|
|
26176
|
+
});
|
|
26177
|
+
}
|
|
26178
|
+
}
|
|
26179
|
+
}
|
|
25605
26180
|
_renderPagerComponent() {
|
|
25606
26181
|
if (this._itemContext.isScrollbar) {
|
|
25607
26182
|
this._renderScrollbar();
|
|
@@ -29588,7 +30163,7 @@ class Radio extends AbstractComponent {
|
|
|
29588
30163
|
this.appendChild(this._circle);
|
|
29589
30164
|
}
|
|
29590
30165
|
renderText() {
|
|
29591
|
-
this._text = new
|
|
30166
|
+
this._text = new Text(merge({}, this.attribute.text));
|
|
29592
30167
|
if (this.attribute.disabled) {
|
|
29593
30168
|
this._text.setAttribute('fill', this.attribute.text.disableFill);
|
|
29594
30169
|
}
|
|
@@ -29838,6 +30413,6 @@ WeatherBox.defaultAttributes = {
|
|
|
29838
30413
|
snowRainBottomPadding: 0
|
|
29839
30414
|
};
|
|
29840
30415
|
|
|
29841
|
-
const version = "0.21.0-vstory.
|
|
30416
|
+
const version = "0.21.0-vstory.3";
|
|
29842
30417
|
|
|
29843
|
-
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, WeatherBox, 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 };
|
|
30418
|
+
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, WeatherBox, 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 };
|