ag-grid-enterprise
Version:
AG Grid Enterprise Features
124 lines • 5.42 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Arc = void 0;
var shape_1 = require("./shape");
var path_1 = require("./path");
var bbox_1 = require("../bbox");
var angle_1 = require("../../util/angle");
var number_1 = require("../../util/number");
var ArcType;
(function (ArcType) {
ArcType[ArcType["Open"] = 0] = "Open";
ArcType[ArcType["Chord"] = 1] = "Chord";
ArcType[ArcType["Round"] = 2] = "Round";
})(ArcType || (ArcType = {}));
/**
* Elliptical arc node.
*/
var Arc = /** @class */ (function (_super) {
__extends(Arc, _super);
function Arc() {
var _this = _super.call(this) || this;
_this.centerX = 0;
_this.centerY = 0;
_this.radius = 10;
_this.startAngle = 0;
_this.endAngle = Math.PI * 2;
_this.counterClockwise = false;
/**
* The type of arc to render:
* - {@link ArcType.Open} - end points of the arc segment are not connected (default)
* - {@link ArcType.Chord} - end points of the arc segment are connected by a line segment
* - {@link ArcType.Round} - each of the end points of the arc segment are connected
* to the center of the arc
* Arcs with {@link ArcType.Open} do not support hit testing, even if they have their
* {@link Shape.fillStyle} set, because they are not closed paths. Hit testing support
* would require using two paths - one for rendering, another for hit testing - and there
* doesn't seem to be a compelling reason to do that, when one can just use {@link ArcType.Chord}
* to create a closed path.
*/
_this.type = ArcType.Open;
_this.restoreOwnStyles();
return _this;
}
Object.defineProperty(Arc.prototype, "fullPie", {
get: function () {
return number_1.isEqual(angle_1.normalizeAngle360(this.startAngle), angle_1.normalizeAngle360(this.endAngle));
},
enumerable: false,
configurable: true
});
Arc.prototype.updatePath = function () {
var path = this.path;
path.clear(); // No need to recreate the Path, can simply clear the existing one.
path.arc(this.centerX, this.centerY, this.radius, this.startAngle, this.endAngle, this.counterClockwise);
if (this.type === ArcType.Chord) {
path.closePath();
}
else if (this.type === ArcType.Round && !this.fullPie) {
path.lineTo(this.centerX, this.centerY);
path.closePath();
}
};
Arc.prototype.computeBBox = function () {
// Only works with full arcs (circles) and untransformed ellipses.
return new bbox_1.BBox(this.centerX - this.radius, this.centerY - this.radius, this.radius * 2, this.radius * 2);
};
Arc.prototype.isPointInPath = function (x, y) {
var point = this.transformPoint(x, y);
var bbox = this.computeBBox();
return (this.type !== ArcType.Open &&
bbox.containsPoint(point.x, point.y) &&
this.path.isPointInPath(point.x, point.y));
};
Arc.className = 'Arc';
Arc.defaultStyles = Object.assign({}, shape_1.Shape.defaultStyles, {
lineWidth: 1,
fillStyle: null,
});
__decorate([
path_1.ScenePathChangeDetection()
], Arc.prototype, "centerX", void 0);
__decorate([
path_1.ScenePathChangeDetection()
], Arc.prototype, "centerY", void 0);
__decorate([
path_1.ScenePathChangeDetection()
], Arc.prototype, "radius", void 0);
__decorate([
path_1.ScenePathChangeDetection()
], Arc.prototype, "startAngle", void 0);
__decorate([
path_1.ScenePathChangeDetection()
], Arc.prototype, "endAngle", void 0);
__decorate([
path_1.ScenePathChangeDetection()
], Arc.prototype, "counterClockwise", void 0);
__decorate([
path_1.ScenePathChangeDetection()
], Arc.prototype, "type", void 0);
return Arc;
}(path_1.Path));
exports.Arc = Arc;
//# sourceMappingURL=arc.js.map