Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected layoutChildView(childView: View): void {
if (RenderView.is(childView)) {
let bounds = this._bounds;
let anchor = this._anchor;
const x = bounds.x;
const y = bounds.y;
if (bounds.x !== 0 || bounds.y !== 0) {
// transform bounds into layer coordinates
const width = bounds.width;
const height = bounds.height;
bounds = new BoxR2(0, 0, width, height);
}
if (x !== 0 || y !== 0) {
// transform anchor into layer coordinates
anchor = new PointR2(anchor.x - x, anchor.y - y);
}
childView.setBounds(bounds);
childView.setAnchor(anchor);
}
}
protected layoutChildView(childView: View): void {
if (RenderView.is(childView)) {
let bounds = this._bounds;
let anchor = this._anchor;
const x = bounds.x;
const y = bounds.y;
if (bounds.x !== 0 || bounds.y !== 0) {
// transform bounds into layer coordinates
const width = bounds.width;
const height = bounds.height;
bounds = new BoxR2(0, 0, width, height);
}
if (x !== 0 || y !== 0) {
// transform anchor into layer coordinates
anchor = new PointR2(anchor.x - x, anchor.y - y);
}
childView.setBounds(bounds);
childView.setAnchor(anchor);
}
}
protected layoutTick(tick: TickView, bounds: BoxR2, anchor: PointR2): void {
const dy = this.scale.value!.scale(tick.value);
const ax = anchor.x;
const ay = anchor.y + dy;
const tickAnchor = new PointR2(ax, ay);
tick.setBounds(bounds);
tick.setAnchor(tickAnchor);
tick.setCoord(dy);
}
}
cx += point.x;
cy += point.y;
invalid = invalid || !isFinite(point.x) || !isFinite(point.y);
xMin = Math.min(xMin, point.x);
yMin = Math.min(yMin, point.y);
xMax = Math.max(point.x, xMax);
yMax = Math.max(point.y, yMax);
}
cx /= n;
cy /= n;
if (!invalid) {
hitBounds = new BoxR2(xMin, yMin, xMax, yMax);
}
}
this._hitBounds = hitBounds;
this.setAnchor(new PointR2(cx, cy));
}
protected layoutTickLabel(tickLabel: RenderView, bounds: BoxR2, anchor: PointR2): void {
const x = Math.round(anchor.x);
const y0 = Math.round(anchor.y);
const y1 = y0 + this.tickMarkLength.value!;
const y2 = y1 + this.tickLabelPadding.value!;
const tickLabelAnchor = new PointR2(x, y2);
tickLabel.setAnchor(tickLabelAnchor);
if (TypesetView.is(tickLabel)) {
tickLabel.textAlign("center");
tickLabel.textBaseline("top");
}
}
protected layoutTick(tick: TickView, bounds: BoxR2, anchor: PointR2): void {
const dy = this.scale.value!.scale(tick.value);
const ax = anchor.x;
const ay = anchor.y + dy;
const tickAnchor = new PointR2(ax, ay);
tick.setBounds(bounds);
tick.setAnchor(tickAnchor);
tick.setCoord(dy);
}
}
protected layoutTick(tick: TickView, bounds: BoxR2, anchor: PointR2): void {
const dx = this.scale.value!.scale(tick.value);
const ax = anchor.x + dx;
const ay = anchor.y;
const tickAnchor = new PointR2(ax, ay);
tick.setBounds(bounds);
tick.setAnchor(tickAnchor);
tick.setCoord(dx);
}
}
protected layoutTickLabel(tickLabel: RenderView, bounds: BoxR2, anchor: PointR2): void {
const x0 = Math.round(anchor.x);
const y = Math.round(anchor.y);
const x1 = x0 + this.tickMarkLength.value!;
const x2 = x1 + this.tickLabelPadding.value!;
const tickLabelAnchor = new PointR2(x2, y);
tickLabel.setAnchor(tickLabelAnchor);
if (TypesetView.is(tickLabel)) {
tickLabel.textAlign("left");
tickLabel.textBaseline("middle");
}
}
protected layoutTickLabel(tickLabel: RenderView, bounds: BoxR2, anchor: PointR2): void {
const x0 = Math.round(anchor.x);
const y = Math.round(anchor.y);
const x1 = x0 - this.tickMarkLength.value!;
const x2 = x1 - this.tickLabelPadding.value!;
const tickLabelAnchor = new PointR2(x2, y);
tickLabel.setAnchor(tickLabelAnchor);
if (TypesetView.is(tickLabel)) {
tickLabel.textAlign("right");
tickLabel.textBaseline("middle");
}
}
protected layoutTick(tick: TickView, bounds: BoxR2, anchor: PointR2): void {
const dx = this.scale.value!.scale(tick.value);
const ax = anchor.x + dx;
const ay = anchor.y;
const tickAnchor = new PointR2(ax, ay);
tick.setBounds(bounds);
tick.setAnchor(tickAnchor);
tick.setCoord(dx);
}
}