complete styling

This commit is contained in:
Timo Hocker 2020-04-25 17:34:05 +02:00
parent 3b67053b3e
commit cbedf36d8e
3 changed files with 13 additions and 3 deletions

View File

@ -27,10 +27,19 @@ export class Node extends Element {
// eslint-disable-next-line @typescript-eslint/naming-convention
public toString (): string {
const attributes = [];
if (this.style)
attributes.push ({ name: 'style', value: this.style.toString () });
if (this.color)
attributes.push ({ name: 'color', value: this.color.toString () });
const attrs = attributes.map ((v) => `${v.name}="${v.value}"`)
.join (',');
if (this.is_table || typeof this.label !== 'undefined') {
return `${this.full_name} [label=<${this.is_table
? this.serialized_table
: this.label}>]`;
: this.label}>${attributes.length > 0 ? `,${attrs}` : ''}]`;
}
return `${this.full_name}`;
}

View File

@ -16,7 +16,8 @@ enum NodeStyles {
diagonals='diagonals',
filled='filled',
striped='striped',
wedged='wedged'
wedged='wedged',
invisible='invis'
}
enum GraphStyles {

View File

@ -22,7 +22,7 @@ test ('serialize simple', (t) => {
test ('serialize table', (t) => {
const g = new Node ('foo', 'bar', 'baz');
g.color = Color.green;
g.style = NodeStyles.dashed;
g.style = NodeStyles.invisible;
g.table_contents = [
[