diff --git a/CHANGELOG.md b/CHANGELOG.md index e29a864..ebc986c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.4.0 + +Allow specifying shapes for nodes + ## 1.3.0 Stream: diff --git a/README.md b/README.md index 7a640cf..ee0adb5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # @sapphirecode/graphviz-builder -version: 1.3.x +version: 1.4.x constructing graphviz files using an easy typescript interface diff --git a/lib/classes/Node.ts b/lib/classes/Node.ts index dfde822..a6e9163 100644 --- a/lib/classes/Node.ts +++ b/lib/classes/Node.ts @@ -6,6 +6,7 @@ */ import { NodeStyles } from '../enums/Styles'; +import { NodeShapes } from '../enums/Shapes'; import { Element } from './Element'; import { Color } from './Color'; @@ -15,6 +16,7 @@ export class Node extends Element { public table_contents?: Array>; public style?: NodeStyles; public color?: Color; + public shape?: NodeShapes; public constructor (name: string, parent: string, label?: string) { super (name, parent); @@ -47,6 +49,8 @@ export class Node extends Element { } if (this.style) attributes.push ({ name: 'style', value: this.style.toString () }); + if (this.shape) + attributes.push ({ name: 'shape', value: this.shape.toString () }); if (this.color) attributes.push ({ name: 'color', value: this.color.toString () }); diff --git a/lib/enums/Shapes.ts b/lib/enums/Shapes.ts new file mode 100644 index 0000000..1419bac --- /dev/null +++ b/lib/enums/Shapes.ts @@ -0,0 +1,63 @@ +type NodeShapes = + '' + |'box' + |'polygon' + |'ellipse' + |'oval' + |'circle' + |'point' + |'egg' + |'triangle' + |'plaintext' + |'plain' + |'diamond' + |'trapezium' + |'parallelogram' + |'house' + |'pentagon' + |'hexagon' + |'septagon' + |'octagon' + |'doublecircle' + |'doubleoctagon' + |'tripleoctagon' + |'invtriangle' + |'invtrapezium' + |'invhouse' + |'Mdiamond' + |'Msquare' + |'Mcircle' + |'rect' + |'rectangle' + |'square' + |'star' + |'none' + |'underline' + |'cylinder' + |'note' + |'tab' + |'folder' + |'box3d' + |'component' + |'promoter' + |'cds' + |'terminator' + |'utr' + |'primersite' + |'restrictionsite' + |'fivepoverhang' + |'threepoverhang' + |'noverhang' + |'assembly' + |'signature' + |'insulator' + |'ribosite' + |'rnastab' + |'proteasesite' + |'proteinstab' + |'rpromoter' + |'rarrow' + |'larrow' + |'lpromoter' + +export {NodeShapes} \ No newline at end of file diff --git a/lib/enums/Styles.ts b/lib/enums/Styles.ts index b77376b..b40191a 100644 --- a/lib/enums/Styles.ts +++ b/lib/enums/Styles.ts @@ -6,34 +6,14 @@ */ type EdgeStyles = - '' - |'solid' - |'dashed' - |'dotted' - |'bold' + '' | 'bold' | 'dashed' | 'dotted' | 'solid' type NodeStyles = - '' - |'solid' - |'dashed' - |'dotted' - |'bold' - |'rounded' - |'diagonals' - |'filled' - |'striped' - |'wedged' - |'invis' + '' | 'bold' | 'dashed' | 'diagonals' | 'dotted' | 'filled' | 'invis' | 'rounded' | 'solid' | 'striped' | 'wedged' type GraphStyles = - 'solid' - | 'dashed' - | 'dotted' - | 'bold' - | 'rounded' - | 'filled' - | 'striped' + 'bold' | 'dashed' | 'dotted' | 'filled' | 'rounded' | 'solid' | 'striped' export { EdgeStyles, NodeStyles, GraphStyles }; diff --git a/package.json b/package.json index bd12510..e395447 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@sapphirecode/graphviz-builder", "main": "dist/lib/index.js", - "version": "1.3.4", + "version": "1.4.0", "author": { "name": "Timo Hocker", "email": "timo@scode.ovh" diff --git a/test/spec/Node.ts b/test/spec/Node.ts index b53d686..f2fefbd 100644 --- a/test/spec/Node.ts +++ b/test/spec/Node.ts @@ -8,7 +8,7 @@ import { Node, Color } from '../../lib'; const serialized_simple -= 'bar_foo [label="baz", style="dashed", color="#00ff00"]'; += 'bar_foo [label="baz", style="dashed", shape="tripleoctagon", color="#00ff00"]'; const serialized_table = `bar_foo [label=< @@ -21,6 +21,7 @@ describe ('node', () => { g.color = Color.green; g.style = 'dashed'; + g.shape = 'tripleoctagon'; const serialized = g.toString ();
foobarbaz
barbazfoo