Skip to content

Commit 7afd278

Browse files
committed
change text editor bounding boxes to more reasonable (larger) sizes
1 parent 5e7f344 commit 7afd278

File tree

6 files changed

+8
-20
lines changed

6 files changed

+8
-20
lines changed

src/core/DiamondStencil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export class DiamondStencil extends RectangleTextStencil {
3535
const angle = Math.atan(this.width !== 0 ? (this.height / 2) / (this.width / 2) : 1);
3636
const side = Math.sqrt(Math.pow(this.width / 2, 2) + Math.pow(this.height / 2, 2));
3737

38-
const rectWidth = Math.cos(angle) * side;
39-
const rectHeight = Math.sin(angle) * side;
38+
const rectWidth = Math.cos(angle) * side * 1.4; // increase size to a more reasonable fit
39+
const rectHeight = Math.sin(angle) * side * 1.4;
4040

4141
this.textBoundingBox.x = (this.width - rectWidth) / 2 + this.padding;
4242
this.textBoundingBox.y = (this.height - rectHeight) / 2 + this.padding;

src/core/EllipseStencil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export class EllipseStencil extends RectangleTextStencil {
3333
protected setTextBoundingBox() {
3434
super.setTextBoundingBox();
3535

36-
const rectWidth = this.width / 2 * Math.sqrt(2);
37-
const rectHeight = this.height / 2 * Math.sqrt(2);
36+
const rectWidth = this.width / 2 * Math.sqrt(2) * 1.4;
37+
const rectHeight = this.height / 2 * Math.sqrt(2) * 1.4;
3838

3939
this.textBoundingBox.x = (this.width - rectWidth) / 2 + this.padding;
4040
this.textBoundingBox.y = (this.height - rectHeight) / 2 + this.padding;

src/core/TextStencil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class TextStencil extends StencilBase {
9393
/**
9494
* Text padding from the bounding box.
9595
*/
96-
protected padding = 5;
96+
protected padding = 2;
9797

9898
/**
9999
* Text's bounding box where text should fit and/or be anchored to.

src/stencilsets/flowchart/stencils/IOStencil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class IOStencil extends RectangleTextStencil {
3030
protected setTextBoundingBox() {
3131
super.setTextBoundingBox();
3232

33-
const rectWidth = this.width * 0.6;
33+
const rectWidth = this.width * 0.8;
3434
const rectHeight = this.height;
3535

3636
this.textBoundingBox.x = (this.width - rectWidth) / 2 + this.padding;

src/stencilsets/flowchart/stencils/TerminalStencil.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,4 @@ export class TerminalStencil extends RectangleTextStencil {
3131

3232
this.disablePorts('bottomleft', 'topleft', 'bottomright', 'topright');
3333
}
34-
35-
protected setTextBoundingBox() {
36-
super.setTextBoundingBox();
37-
38-
const rectWidth = this.width - this.height;
39-
const rectHeight = this.height;
40-
41-
this.textBoundingBox.x = (this.width - rectWidth) / 2 + this.padding;
42-
this.textBoundingBox.y = (this.height - rectHeight) / 2 + this.padding;
43-
this.textBoundingBox.width = rectWidth - this.padding * 2;
44-
this.textBoundingBox.height = rectHeight - this.padding * 2;
45-
}
4634
}

test/manual/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ export class Experiments {
174174
console.log(`editor connector enter ${(<ConnectorEditorEventData>ev.detail).connectorEditor.isSelected}`);
175175
});
176176

177-
this.editor.stencilEditorSet = orgchartStencilEditorSet;
178-
// this.editor.stencilEditorSet = basicStencilEditorSet;
177+
// this.editor.stencilEditorSet = orgchartStencilEditorSet;
178+
this.editor.stencilEditorSet = basicStencilEditorSet;
179179
// this.editor.stencilEditorSet = flowchartStencilEditorSet;
180180
// this.editor.stencilEditorSet = mindMapStencilEditorSet;
181181
// this.editor.stencilEditorSet = networkStencilEditorSet;

0 commit comments

Comments
 (0)