complete styling
This commit is contained in:
		
							
								
								
									
										11
									
								
								lib/Node.ts
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								lib/Node.ts
									
									
									
									
									
								
							@@ -27,10 +27,19 @@ export class Node extends Element {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // eslint-disable-next-line @typescript-eslint/naming-convention
 | 
					  // eslint-disable-next-line @typescript-eslint/naming-convention
 | 
				
			||||||
  public toString (): string {
 | 
					  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') {
 | 
					    if (this.is_table || typeof this.label !== 'undefined') {
 | 
				
			||||||
      return `${this.full_name} [label=<${this.is_table
 | 
					      return `${this.full_name} [label=<${this.is_table
 | 
				
			||||||
        ? this.serialized_table
 | 
					        ? this.serialized_table
 | 
				
			||||||
        : this.label}>]`;
 | 
					        : this.label}>${attributes.length > 0 ? `,${attrs}` : ''}]`;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return `${this.full_name}`;
 | 
					    return `${this.full_name}`;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,8 @@ enum NodeStyles {
 | 
				
			|||||||
  diagonals='diagonals',
 | 
					  diagonals='diagonals',
 | 
				
			||||||
  filled='filled',
 | 
					  filled='filled',
 | 
				
			||||||
  striped='striped',
 | 
					  striped='striped',
 | 
				
			||||||
  wedged='wedged'
 | 
					  wedged='wedged',
 | 
				
			||||||
 | 
					  invisible='invis'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum GraphStyles {
 | 
					enum GraphStyles {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,7 @@ test ('serialize simple', (t) => {
 | 
				
			|||||||
test ('serialize table', (t) => {
 | 
					test ('serialize table', (t) => {
 | 
				
			||||||
  const g = new Node ('foo', 'bar', 'baz');
 | 
					  const g = new Node ('foo', 'bar', 'baz');
 | 
				
			||||||
  g.color = Color.green;
 | 
					  g.color = Color.green;
 | 
				
			||||||
  g.style = NodeStyles.dashed;
 | 
					  g.style = NodeStyles.invisible;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g.table_contents = [
 | 
					  g.table_contents = [
 | 
				
			||||||
    [
 | 
					    [
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user