SequenceDiagramScope
Defines the DSL used to specify sequence diagrams. Receiver of the content parameter of the SequenceDiagram composable.
Samples
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import com.zachklipp.seqdiag.ArrowHeadType
import com.zachklipp.seqdiag.BasicSequenceDiagramStyle
import com.zachklipp.seqdiag.Label
import com.zachklipp.seqdiag.LineStyle
import com.zachklipp.seqdiag.Note
import com.zachklipp.seqdiag.SequenceDiagram
import com.zachklipp.seqdiag.arrowHeadType
import com.zachklipp.seqdiag.color
import com.zachklipp.seqdiag.createParticipant
import com.zachklipp.seqdiag.noteOver
fun main() {
//sampleStart
// Specifies a simple sequence diagram that consists of three participants with some lines
// between them.
SequenceDiagram {
val alice = createParticipant { Note("Alice") }
val bob = createParticipant { Note("Bob") }
val carlos = createParticipant { Note("Carlos") }
// Lines can be specified between any two participants, with their
alice.lineTo(bob)
.label { Label("Hello!") }
bob.lineTo(carlos)
.label { Label("Alice says hi") }
// Lines don't need to have labels, and they can be styled.
carlos.lineTo(bob)
.color(Color.Blue)
.arrowHeadType(ArrowHeadType.Outlined)
// Lines can span multiple participants.
carlos.lineTo(alice)
.label { Label("Hello back!") }
}
//sampleEnd
}
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import com.zachklipp.seqdiag.ArrowHeadType
import com.zachklipp.seqdiag.BasicSequenceDiagramStyle
import com.zachklipp.seqdiag.Label
import com.zachklipp.seqdiag.LineStyle
import com.zachklipp.seqdiag.Note
import com.zachklipp.seqdiag.SequenceDiagram
import com.zachklipp.seqdiag.arrowHeadType
import com.zachklipp.seqdiag.color
import com.zachklipp.seqdiag.createParticipant
import com.zachklipp.seqdiag.noteOver
fun main() {
//sampleStart
// In addition to lines, notes can also be placed around participants.
SequenceDiagram {
val alice = createParticipant { Note("Alice") }
createParticipant { Note("Bob") }
val carlos = createParticipant { Note("Carlos") }
noteToStartOf(alice) { Note("Note to the start of Alice") }
noteOver(alice) { Note("Note over Alice") }
noteToEndOf(alice) { Note("Note to the end of Alice") }
noteOver(alice, carlos) { Note("Note over multiple participants") }
}
//sampleEnd
}
Functions
Creates a Participant in the sequence. Each participant typically is typically labeled and has a vertical line drawn through the height of the diagram. The rest of the diagram is specified as lines between participants and notes anchored to them. Participants are placed horizontally from start to end in the order they're created.
Specifies a line drawn from this Participant to other. The optional properties of the line can be configured by calling methods on the returned LineBuilder.
Specifies a composable that represents a note that is placed "over", or covering, one or more participants.
Specifies a composable that represents a note that is placed on the end side of a single Participant.
Specifies a composable that represents a note that is placed on the start side of a single Participants.
Properties
The SequenceDiagramStyle passed to SequenceDiagram.
Extensions
Creates a Participant in the sequence. Each participant typically is typically labeled and has a vertical line drawn through the height of the diagram. The rest of the diagram is specified as lines between participants and notes anchored to them. Participants are placed horizontally from start to end in the order they're created.
Standard text styled by the SequenceDiagramStyle. To draw a standard background and border around a label, use the Note composable.
Standard note styled by the SequenceDiagramStyle. To just draw text without the border use the Label composable. To use your own composables with the standard note background and border, use NoteBox.
A Box that is styled according to the SequenceDiagramStyle's note properties.
Specifies a composable that represents a note that is placed "over", or covering, one or more Participants.