Reduce code duplication
Signed-off-by: offtkp <parisoplop@gmail.com> Change-Id: I51e79fca321e9759aa75549e98c598e7bc150824private/offtkp/lineWidth
parent
7e5c7630f9
commit
86f22dc1f5
|
@ -98,34 +98,7 @@ export class ColumnGroup extends GroupBase {
|
|||
const endX = this.getEndPosition(group.endPos);
|
||||
|
||||
if (this.isGroupHeaderVisible(startX, group.startPos)) {
|
||||
// draw head
|
||||
this.context.beginPath();
|
||||
this.context.fillStyle = this.backgroundColor;
|
||||
this.context.fillRect(this.transformRectX(startX, this._groupHeadSize), startY, this._groupHeadSize, this._groupHeadSize);
|
||||
this.context.strokeStyle = 'black';
|
||||
this.context.lineWidth = 1.0;
|
||||
this.context.strokeRect(this.transformRectX(startX + 0.5, this._groupHeadSize), startY + 0.5, this._groupHeadSize, this._groupHeadSize);
|
||||
|
||||
if (!group.hidden) {
|
||||
// draw '-'
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(startX + 0.5 + this._groupHeadSize * 0.25, startY + 0.5 + this._groupHeadSize / 2);
|
||||
this.context.lineTo(startX + 0.5 + this._groupHeadSize * 0.75, startY + 0.5 + this._groupHeadSize / 2);
|
||||
this.context.stroke();
|
||||
}
|
||||
else {
|
||||
// draw '+'
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(startX + 0.5 + this._groupHeadSize * 0.25, startY + 0.5 + this._groupHeadSize / 2);
|
||||
this.context.lineTo(startX + 0.5 + this._groupHeadSize * 0.75, startY + 0.5 + this._groupHeadSize / 2);
|
||||
|
||||
this.context.stroke();
|
||||
|
||||
this.context.moveTo(startX + 0.5 + this._groupHeadSize / 2, startY + this._groupHeadSize * 0.25);
|
||||
this.context.lineTo(startX + 0.5 + this._groupHeadSize / 2, startY + this._groupHeadSize * 0.75 + 1.0);
|
||||
|
||||
this.context.stroke();
|
||||
}
|
||||
this.drawGroupBoxes(startX, startY, group.hidden);
|
||||
}
|
||||
|
||||
if (!group.hidden && endX > this._cornerHeaderWidth + this._groupHeadSize && endX > startX) {
|
||||
|
|
|
@ -276,6 +276,37 @@ export abstract class GroupBase extends CanvasSectionObject {
|
|||
return this.isCalcRTL() ? this.size[0] - xcoord : xcoord;
|
||||
}
|
||||
|
||||
drawGroupBoxes(startX: number, startY: number, hidden: boolean): void {
|
||||
// draw head
|
||||
this.context.beginPath();
|
||||
this.context.fillStyle = this.backgroundColor;
|
||||
this.context.fillRect(this.transformRectX(startX, this._groupHeadSize), startY, this._groupHeadSize, this._groupHeadSize);
|
||||
this.context.strokeStyle = 'black';
|
||||
this.context.lineWidth = 1.0;
|
||||
this.context.strokeRect(this.transformRectX(startX + 0.5, this._groupHeadSize), startY + 0.5, this._groupHeadSize, this._groupHeadSize);
|
||||
|
||||
if (!hidden) {
|
||||
// draw '-'
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(startX + 0.5 + this._groupHeadSize * 0.25, startY + 0.5 + this._groupHeadSize / 2);
|
||||
this.context.lineTo(startX + 0.5 + this._groupHeadSize * 0.75, startY + 0.5 + this._groupHeadSize / 2);
|
||||
this.context.stroke();
|
||||
}
|
||||
else {
|
||||
// draw '+'
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(startX + 0.5 + this._groupHeadSize * 0.25, startY + 0.5 + this._groupHeadSize / 2);
|
||||
this.context.lineTo(startX + 0.5 + this._groupHeadSize * 0.75, startY + 0.5 + this._groupHeadSize / 2);
|
||||
|
||||
this.context.stroke();
|
||||
|
||||
this.context.moveTo(startX + 0.5 + this._groupHeadSize / 2, startY + this._groupHeadSize * 0.25);
|
||||
this.context.lineTo(startX + 0.5 + this._groupHeadSize / 2, startY + this._groupHeadSize * 0.75 + 1.0);
|
||||
|
||||
this.context.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given point is within the bounds of the rectangle defined by
|
||||
* startX, startY, endX, endY. If mirrorX is true then point is horizontally
|
||||
|
|
|
@ -98,34 +98,7 @@ export class RowGroup extends GroupBase {
|
|||
const endY = this.getEndPosition(group.endPos);
|
||||
|
||||
if (this.isGroupHeaderVisible(startY, group.startPos)) {
|
||||
// draw head
|
||||
this.context.beginPath();
|
||||
this.context.fillStyle = this.backgroundColor;
|
||||
this.context.fillRect(this.transformRectX(startX, this._groupHeadSize), startY, this._groupHeadSize, this._groupHeadSize);
|
||||
this.context.strokeStyle = 'black';
|
||||
this.context.lineWidth = 1.0;
|
||||
this.context.strokeRect(this.transformRectX(startX + 0.5, this._groupHeadSize), startY + 0.5, this._groupHeadSize, this._groupHeadSize);
|
||||
|
||||
if (!group.hidden) {
|
||||
// draw '-'
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(startX + 0.5 + this._groupHeadSize * 0.25, startY + 0.5 + this._groupHeadSize / 2);
|
||||
this.context.lineTo(startX + 0.5 + this._groupHeadSize * 0.75, startY + 0.5 + this._groupHeadSize / 2);
|
||||
this.context.stroke();
|
||||
}
|
||||
else {
|
||||
// draw '+'
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(startX + 0.5 + this._groupHeadSize * 0.25, startY + 0.5 + this._groupHeadSize / 2);
|
||||
this.context.lineTo(startX + 0.5 + this._groupHeadSize * 0.75, startY + 0.5 + this._groupHeadSize / 2);
|
||||
|
||||
this.context.stroke();
|
||||
|
||||
this.context.moveTo(startX + 0.5 + this._groupHeadSize / 2, startY + this._groupHeadSize * 0.25);
|
||||
this.context.lineTo(startX + 0.5 + this._groupHeadSize / 2, startY + this._groupHeadSize * 0.75 + 1.0);
|
||||
|
||||
this.context.stroke();
|
||||
}
|
||||
this.drawGroupBoxes(startX, startY, group.hidden);
|
||||
}
|
||||
|
||||
if (!group.hidden && endY > this._cornerHeaderHeight + this._groupHeadSize && endY > startY) {
|
||||
|
|
Loading…
Reference in New Issue