Skip to content

Commit

Permalink
break apart LabelBackground into its own object class
Browse files Browse the repository at this point in the history
  • Loading branch information
mggower committed Nov 1, 2023
1 parent 9289549 commit d61cbd4
Show file tree
Hide file tree
Showing 5 changed files with 470 additions and 363 deletions.
30 changes: 14 additions & 16 deletions src/renderers/webgl/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ export class NodeRenderer {
}

update(node: Graph.Node) {
this.setLabel(node)
if (this.label === undefined) {
if (node.label !== undefined) {
this.label = new Label(this.renderer.labelsContainer, node.label, node.style?.label)
}
} else if (node.label === undefined || node.label.trim() === '') {
this.renderer.labelObjectManager.delete(this.label)
this.labelMounted = false
this.label = undefined
} else {
this.label.update(node.label, node.style?.label)
}

if (this.icon === undefined) {
if (node.style?.icon) {
Expand Down Expand Up @@ -491,7 +501,9 @@ export class NodeRenderer {

this.fill.update(this.x, this.y, radius, node.style)
this.strokes.update(this.x, this.y, radius, node.style)
this.setLabel(node)
if (this.label !== undefined) {
this.label.moveTo(this.x, this.y, this.strokes.radius)
}
if (this.icon && node.style?.icon) {
this.icon.update(this.x, this.y, node.style.icon)
}
Expand All @@ -507,18 +519,4 @@ export class NodeRenderer {
this.y - this.strokes.radius <= this.renderer.maxY
)
}

private setLabel(node: Graph.Node) {
if (this.label === undefined) {
if (node.label !== undefined) {
this.label = new Label(this.renderer.labelsContainer, node.label, node.style?.label)
}
} else if (node.label === undefined) {
this.renderer.labelObjectManager.delete(this.label)
this.labelMounted = false
this.label = undefined
} else {
this.label.update(node.label, { x: this.x, y: this.y, offset: this.strokes.radius }, node.style?.label)
}
}
}
291 changes: 0 additions & 291 deletions src/renderers/webgl/objects/label/Label.ts

This file was deleted.

Loading

0 comments on commit d61cbd4

Please sign in to comment.