B4J Library [ABMaterial] MashText2UML: Sequence Diagram

Finally...

Struggling with this for a couple of hours..., This is a wrap of this js snippet here, https://bramp.github.io/js-sequence-diagrams/

The UML diagrams can either be 'simple' or by 'hand'

Example 1

ex1.png


B4X:
Dim ex1 As MashText2UML
    ex1.Initialize(page,"ex1")
    ex1.AddConnection("Andrew","China","Says Hello")
    ex1.AddNote("China",ex1.EnumNotePos.right,"China thinks\nabout it")
    ex1.AddDottedConnection("China","Andrew","How are you?")
    ex1.AddConnectionOpen("Andrew","China","I am good thanks!")
    page.Cell(2,1).addcomponent(ex1.ABMComp)

Example 2

ex2.png


B4X:
Dim ex2 As MashText2UML
    ex2.Initialize(page,"ex2")
    ex2.Title = "Here is a title"
    ex2.AddNormalLine("A","B","Normal line")
    ex2.AddDashedLine("B","C","Dashed line")
    ex2.AddOpenArrow("C","D","Open arrow")
    ex2.AddDashedOpenArrow("D","A","Dashed open arrow")
    page.Cell(2,1).addcomponent(ex2.ABMComp)

Example 3

ex3.png


B4X:
Dim ex3 As MashText2UML
    ex3.Initialize(page,"ex3")
    ex3.AddNote("A",ex3.EnumNotePos.left,"Note to the\n left of A")
    ex3.AddNote("A",ex3.EnumNotePos.right,"Note to the\n right of A")
    ex3.AddNote("A",ex3.EnumNotePos.over,"Note over A")
    ex3.AddNoteOver("A","B","Note over both A and B")
    page.Cell(2,1).addcomponent(ex3.ABMComp)

Example 4

ex4.png


B4X:
Dim ex4 As MashText2UML
    ex4.Initialize(page,"ex4")
    ex4.AddParticipant("C").AddParticipant("B").AddParticipant("A")
    ex4.AddNote("A",ex4.EnumNotePos.right,"You can change the order of the\n participants")
    page.Cell(2,1).addcomponent(ex4.ABMComp)

Example 5 - A simple themed diagram

ex5.png


B4X:
Dim ex5 As MashText2UML
    ex5.Initialize(page,"ex5")
    ex5.Theme = ex5.EnumTheme.simple
    ex5.AddNote("A",ex5.EnumNotePos.left,"Note to the\n left of A")
    ex5.AddNote("A",ex5.EnumNotePos.right,"Note to the\n right of A")
    ex5.AddNote("A",ex5.EnumNotePos.over,"Note over A")
    ex5.AddNoteOver("A","B","Note over both A and B")
    page.Cell(2,1).addcomponent(ex5.ABMComp)

In BuildPage..

B4X:
pg.AddExtraCSSFile("custom/sequence-diagram-min.css")
    pg.AddExtraJavaScriptFile("custom/webfont.js")
    pg.AddExtraJavaScriptFile("custom/snap.svg-min.js")
    pg.AddExtraJavaScriptFile("custom/underscore-min.js")
    pg.AddExtraJavaScriptFile("custom/sequence-diagram-min.js")
 

Attachments

  • MashText2UML.bas
    6.7 KB · Views: 317

joulongleu

Active Member
Licensed User
Longtime User
Hi:Mashiane:I tried many times and the following error :
Error occurred on line: 161 (MashText2UML)
java.lang.RuntimeException: Object should first be initialized (Map).
 
Top