Interface IWorkflowBpmnLayouter
-
public interface IWorkflowBpmnLayouter
Layout helper that can be used to lay out the BPMN diagram, such as aligning the parts of a workflow node in a sequence.- Since:
- 8.4.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IWorkflowBpmnLayoutAlignAroundBuilder
alignAround()
Aligns two items, with the second item positioned relative to the first item, optionally with spacing.IWorkflowBpmnLayoutAlignAtAxisBuilder
alignAtAxis()
Aligns child items in a chosen axis-aligned direction, optionally with spacing.IWorkflowBpmnLayoutAlignAtPortsBuilder
alignAtPorts()
Creates a builder for aligning a list of items in theflow direction
.IBinarySelectionGatewayFlowLabelHelperBuilder
alignBinarySelectionGatewayFlowLabel()
Gets a builder for a flow label helper for binary selectiongateways
, i.e.IWorkflowBpmnLayoutAlignOnFlowSideBuilder
alignOnFlowSide()
Creates a builder for aligning an item on a side of the edge of a flow, such as aSequenceFlow
orMessageFlow
.List<Point2DDouble>
axisAlignedPath(Iterable<Point2DDouble> points, ECartesianAxis2D firstAxis)
Given a set of points, returns a list of points that represent the path from the first point to the last point, using only straight (axis-aligned) lines.List<Point2DDouble>
axisAlignedPath(Iterator<Point2DDouble> points, ECartesianAxis2D firstAxis)
Given a set of points, returns a list of points that represent the path from the first point to the last point, using only straight (axis-aligned) lines.Point2DDouble
cornerPoint(Point2DDouble start, Point2DDouble end, ECartesianAxis2D firstAxis)
Walks from the given start point to the given end point, by first going straight on the given axis, then making a sharp turn to the other axis.IWorkflowBpmnAlignmentItem<String,?>
flatten(IWorkflowBpmnAlignmentItem<?,?> item)
Flattens the alignment items and all its nested children and returns a new alignment item with the flattened children.IFlattenedAlignmentItemMap<String>
flattenToMap(IWorkflowBpmnAlignmentItem<?,?> item)
Flattens the alignment items and all its nested children.IWorkflowBpmnLayoutDataObjectBuilder
layoutDataObject()
Creates a builder for creating the layout of a BPMNDataObjectReference
.IWorkflowBpmnLayoutDataStoreBuilder
layoutDataStore()
Creates a builder for creating the layout of a BPMNDataStoreReference
.IWorkflowBpmnLayoutEventBuilder
layoutEvent()
Creates a builder for creating the layout of a BPMNEvent
.IWorkflowBpmnLayoutGatewayBuilder
layoutGateway()
Creates a builder for creating the layout of a BPMNGateway
.IWorkflowBpmnLayoutSubProcessBuilder
layoutSubProcess()
Creates a builder for creating the layout of a BPMNSubProcess
.IBoundedBpmnElementLayout<?>
layoutSubProcessBody(IWorkflowBpmnAlignmentItem<?,?> body, de.xima.bpmn_model.api.element.bpmn.common.FlowElementsContainer<?> container, String startEventName, String endEventName)
Adds aStartEvent
andEndEvent
to the given body alignment item.IWorkflowBpmnLayoutTaskBuilder
layoutTask()
Creates a builder for creating the layout of a BPMNTask
.IWorkflowBpmnAlignmentItem<StyledBpmnLabel,?>
layoutText(StyledBpmnLabel styledLabel, WorkflowBpmnTextLayoutSettings textSettings)
Lays out the text of a styled BPMN label.IWorkflowBpmnAlignmentItem<StyledBpmnLabel,?>
layoutText(String text, WorkflowBpmnTextLayoutSettings textSettings)
Lays out a piece of text, such as for a BPMN label.IWorkflowBpmnTwoChildAlignmentItem<String,IWorkflowBpmnAlignmentItem<de.xima.bpmn_model.api.element.bpmn.artifacts.TextAnnotation,?>,IWorkflowBpmnAlignmentItem<StyledBpmnLabel,?>>
layoutTextAnnotation(de.xima.bpmn_model.api.element.bpmn.artifacts.TextAnnotation annotation, StyledBpmnLabel styledLabel, WorkflowBpmnTextLayoutSettings settings)
Computes the layout for a BPMNTextAnnotation
with the text content of aStyledBpmnLabel
, using the given text layout settings.IWorkflowBpmnTwoChildAlignmentItem<String,IWorkflowBpmnAlignmentItem<de.xima.bpmn_model.api.element.bpmn.artifacts.TextAnnotation,?>,IWorkflowBpmnAlignmentItem<StyledBpmnLabel,?>>
layoutTextAnnotation(String text, WorkflowBpmnTextLayoutSettings settings)
Computes the layout for a BPMNTextAnnotation
with the given text and layout settings.IWorkflowBpmnLayoutPadBuilder
pad()
Adds padding to an alignment item.
-
-
-
Method Detail
-
alignAround
IWorkflowBpmnLayoutAlignAroundBuilder alignAround()
Aligns two items, with the second item positioned relative to the first item, optionally with spacing.- Returns:
- A builder for aligning a second item relative to a first item, with options for the direction and spacing.
-
alignAtAxis
IWorkflowBpmnLayoutAlignAtAxisBuilder alignAtAxis()
Aligns child items in a chosen axis-aligned direction, optionally with spacing.- Returns:
- A builder for configuring the options for the alignment and a build method to perform the alignment.
-
alignAtPorts
IWorkflowBpmnLayoutAlignAtPortsBuilder alignAtPorts()
Creates a builder for aligning a list of items in theflow direction
. The items are optionally spaced in the direction of the flow, and the out port of one item is aligned with the in port of the next item.- Returns:
- A builder for configuring the options for the alignment and a build method to perform the alignment.
-
alignBinarySelectionGatewayFlowLabel
IBinarySelectionGatewayFlowLabelHelperBuilder alignBinarySelectionGatewayFlowLabel()
Gets a builder for a flow label helper for binary selectiongateways
, i.e. gateways with two branches, usually an if and an else branch. Helps to position thelabels
for thenames
of the twoSequenceFlow
that emerge from the gateway.Assumptions:
- The two
sequence flow
lines
emanating from the gateway are perpendicular to each other, i.e. one is horizontal and the other is vertical. - Both labels for the flow lines are positioned inside the corner formed by the two lines.
- The
alignment items
for the consequent and alternate branch are placed next to each other. The alignment item for the consequent branch is at index 0, and the alignment item for the alternate branch is at index 1. - The gateway is placed next to the aligned body with the consequent and alternate branches. The alignment for the gateway is at index 0, and the alignment for the body is at index 1.
Horizontal layouts might look like this:
+----------------+ -------------------> | alternate | | +----------------+ | | | no | x yes +----------------+ x x x ---------------> | consequent | x +----------------+ gateway gateway x +----------------+ x x x ---------------> | consequent | x yes +----------------+ | | no | | | +----------------+ -------------------> | alternate | +----------------+ +----------------+ | alternate | <------------------- +----------------+ | | | no | | +----------------+ yes x | consequent | <--------------- x x x +----------------+ x gateway gateway +----------------+ x | consequent | <----------------x x x +----------------+ yes x | no | | | +----------------+ | | alternate | <------------------- +----------------+
Vertical layouts might look like this:
gateway x x x x ------------------------ x no | | | | yes | | | | | | | | | | | | | v v +----------------+ +----------------+ | consequent | | alternate | +----------------+ +----------------+ gateway x ------------------------ x x x | no x | | | yes | | | | | | | | | | | | | v v +----------------+ +----------------+ | alternate | | consequent | +----------------+ +----------------+ +----------------+ +----------------+ | consequent | | alternate | +----------------+ +----------------+ ^ ^ | | | | | | | | | | | | | yes | | | x no | x x x ------------------------ x gateway +----------------+ +----------------+ | alternate | | consequent | +----------------+ +----------------+ ^ ^ | | | | | | | | | | | | | | | yes | | no x ------------------------ x x x x gateway
To create such a layout, you should proceed as follows:- To start, use
layouter.binarySelectionGatewayFlowLabelHelper()
to obtain a builder for configuring an instance of this interface. - Somehow create the
alignment items
for theGateway
and for the consequent and alternate branches. - Use one the alignment builders provided by the
layouter
, e.g.layouter.alignAtAxis()
orlayouter.alignAtPorts
, to align the alternate with the consequent, such as on top of each other. Make sure you passlabelHelper.branchesSpacingSelector()
tobuilder.spacingSelector()
. This will create the alignment item for the body. - Use one the alignment builders provided by the
layouter
, e.g.layouter.alignAtAxis()
orlayouter.alignAtPorts
, to align the gateway with the body, e.g. the body to the right of the gateway. Make sure you passlabelHelper.gatewayBodySpacingSelector()
tobuilder.spacingSelector()
. - Keep nesting alignment items to build the layout you want, then use
layouter.flatten
. This will create the flattened map of alignment items and compute the final positions for each constituent. - Use
flattened.flow()
.name(text, configurator)
to create theSequenceFlow
connecting the gateway to the consequent branch, passinglabelHelper.consequentText()
andlabelHelper.consequentConfigurator()
as arguments. This will add the "yes" label to the correct position on the sequence flow. - In a similar fashion, use
flattened.flow()
.name(text, configurator)
to create theSequenceFlow
connecting the gateway to the alternate branch, passinglabelHelper.alternateText()
andlabelHelper.alternateConfigurator()
as arguments. This will add the "no" label to the correct position on the sequence flow.
- Returns:
- A builder for configuring the options for the binary selection gateway flow label helper.
- The two
-
alignOnFlowSide
IWorkflowBpmnLayoutAlignOnFlowSideBuilder alignOnFlowSide()
Creates a builder for aligning an item on a side of the edge of a flow, such as aSequenceFlow
orMessageFlow
. SeeIWorkflowBpmnLayoutAlignOnFlowSideConfigurator
for more details on the available layout options.(example with segment index = 1, side = RIGHT_OF_FLOW, alignment = 0.5, spacing = 3) +----------+ | | ┌──────────────────────────────────>| target | │ | | │ +----------+ │ │ +------------+ │ | item | │ +------------+ │ +----------+ │ | | │ | source |──────────────────────┘ | | +----------+
The following image illustrates the alignment for side =
RIGHT_OF_FLOW
, alignment = 1.0 spacing = 20, offset = 0; when the red flow line goes from top-left to bottom-right and the alignment item has a yellow bounding box of 50x20 pixels:- The rectangle is on the right
side
of the flow line. - The
spacing
20 is the distance between the line and the rectangle, i.e. the distance between the top-right corner of the rectangle and the line in the example image above (yellow). - An
alignment
of 1.0 means the rectangle is as close to the end of the line as possible, i.e. the bottom-right point of the rectangle touches the line that is orthogonal to the flow line and passes through the flow line's end point. - The
offset
is 0 so the rectangle is not set off. If the offset were non-zero, the rectangle would be shifted by that amount in the direction of the red flow line. A positive offset would shift the rectangle to the bottom right, a negative offset would shift it to the top left.
- Returns:
- A builder for aligning an item on a side of the edge of a flow.
- The rectangle is on the right
-
axisAlignedPath
List<Point2DDouble> axisAlignedPath(Iterator<Point2DDouble> points, ECartesianAxis2D firstAxis)
Given a set of points, returns a list of points that represent the path from the first point to the last point, using only straight (axis-aligned) lines. The path is created by first going straight on the given axis, then making a sharp turn to the other axis for the second point. Then proceeds along the same axis to the next point, and so on.To illustrate, here's an example of a path with 4 points, 1 source point (s), 3 waypoints (w1, w2, w3), and 1 target point (t). The input points are: (s, w1, w2, t). The first axis is the y-axis (vertical):
w2 o────────────┐ c3 │ │ c1 ┌───────o────────┘ c2 │ │ w1 o w3 │ │ │ │ │ first axis └────────────o │ c4 t o s
The resulting list contains 7 points, in this order: (s, c1, c2, w2, c3, c4, t). The waypoints w1 and w3 are not included in this list as they lie on the same axis as the neighbouring points.- Parameters:
points
- Points to create the path from. Must contain at least two points. If not, just returns a list with the given points.firstAxis
- The first axis to go straight on.- Returns:
- The path through the points, using only straight (axis-aligned) lines.
-
axisAlignedPath
List<Point2DDouble> axisAlignedPath(Iterable<Point2DDouble> points, ECartesianAxis2D firstAxis)
Given a set of points, returns a list of points that represent the path from the first point to the last point, using only straight (axis-aligned) lines. The path is created by first going straight on the given axis, then making a sharp turn to the other axis for the second point. Then proceeds along the same axis to the next point, and so on.To illustrate, here's an example of a path with 4 points, 1 source point (s), 3 waypoints (w1, w2, w3), and 1 target point (t). The input points are: (s, w1, w2, t). The first axis is the y-axis (vertical):
w2 o────────────┐ c3 │ │ c1 ┌───────o────────┘ c2 │ │ w1 o w3 │ │ │ │ │ first axis └────────────o │ c4 t o s
The resulting list contains 7 points, in this order: (s, c1, c2, w2, c3, c4, t). The waypoints w1 and w3 are not included in this list as they lie on the same axis as the neighbouring points.- Parameters:
points
- Points to create the path from. Must contain at least two points. If not, just returns a list with the given points.firstAxis
- The first axis to go straight on.- Returns:
- The path through the points, using only straight (axis-aligned) lines.
-
cornerPoint
Point2DDouble cornerPoint(Point2DDouble start, Point2DDouble end, ECartesianAxis2D firstAxis)
Walks from the given start point to the given end point, by first going straight on the given axis, then making a sharp turn to the other axis. Returns the corner point representing the sharp turn. If both points are axis aligned, returns the midway point between the two points.To illustrate, here are a source and target point, together with a corner point. The first axis is the y-axis (vertical):
corner ┌────────────> target │ │ │ first axis │ │ source
- Parameters:
start
- The start point.end
- The end point.firstAxis
- The first axis to go straight on.- Returns:
- The corner point representing the sharp turn.
-
flatten
IWorkflowBpmnAlignmentItem<String,?> flatten(IWorkflowBpmnAlignmentItem<?,?> item)
Flattens the alignment items and all its nested children and returns a new alignment item with the flattened children.Positions of items are relative to the top-left corner of their containing item. This method resolves all positions and makes them absolute. Usually, you would call this method once you've aligned all items, then use the final positions.
- Parameters:
item
- The item to flatten.- Returns:
- A new alignment item with the absolute positions for each nested child.
-
flattenToMap
IFlattenedAlignmentItemMap<String> flattenToMap(IWorkflowBpmnAlignmentItem<?,?> item)
Flattens the alignment items and all its nested children. Returns a map with all alignment items and thevalue
of eachalignment item
as the key.Positions of items are relative to the top-left corner of their containing item. This method resolves all positions and makes them absolute. Usually, you would call this method once you've aligned all items, then use the final positions.
- Parameters:
item
- The item to flatten.- Returns:
- A map with the absolute positions for each alignment items, indexed by the
value
of each alignment item.
-
layoutDataObject
IWorkflowBpmnLayoutDataObjectBuilder layoutDataObject()
Creates a builder for creating the layout of a BPMNDataObjectReference
.- Returns:
- A builder for the layout of a BPMN data object (reference).
-
layoutDataStore
IWorkflowBpmnLayoutDataStoreBuilder layoutDataStore()
Creates a builder for creating the layout of a BPMNDataStoreReference
.- Returns:
- A builder for the layout of a BPMN data store (reference).
-
layoutEvent
IWorkflowBpmnLayoutEventBuilder layoutEvent()
Creates a builder for creating the layout of a BPMNEvent
.- Returns:
- A builder for the layout of a BPMN event.
-
layoutGateway
IWorkflowBpmnLayoutGatewayBuilder layoutGateway()
Creates a builder for creating the layout of a BPMNGateway
.- Returns:
- A builder for the layout of a BPMN gateway.
-
layoutSubProcess
IWorkflowBpmnLayoutSubProcessBuilder layoutSubProcess()
Creates a builder for creating the layout of a BPMNSubProcess
.- Returns:
- A builder for the layout of a BPMN sub process.
-
layoutSubProcessBody
IBoundedBpmnElementLayout<?> layoutSubProcessBody(IWorkflowBpmnAlignmentItem<?,?> body, de.xima.bpmn_model.api.element.bpmn.common.FlowElementsContainer<?> container, String startEventName, String endEventName)
Adds aStartEvent
andEndEvent
to the given body alignment item. This is used e.g. by aSubProcess
, where the start event indicates where the sub process starts.Only adds a
StartEvent
if the body item has anin port
, and only adds aEndEvent
if the body item has anout port
.If the body is empty, returns an empty alignment item with an and out port.
- Parameters:
body
- The body alignment item to add the start and end events to.container
- The sub process that will contain the start event, body, and end event.startEventName
- The name of the start event to add.endEventName
- The name of the end event to add.- Returns:
- The body alignment item with the start and end events added.
-
layoutTask
IWorkflowBpmnLayoutTaskBuilder layoutTask()
Creates a builder for creating the layout of a BPMNTask
.- Returns:
- A builder for the layout of a BPMN event.
-
layoutText
IWorkflowBpmnAlignmentItem<StyledBpmnLabel,?> layoutText(String text, WorkflowBpmnTextLayoutSettings textSettings)
Lays out a piece of text, such as for a BPMN label. Wraps the text into multiple lines, according to the given text layout settings. Returns an alignment item with astyled label
as itsvalue
.- Parameters:
text
- The text to wrap.textSettings
- The settings for wrapping the text.- Returns:
- The wrapped text.
-
layoutText
IWorkflowBpmnAlignmentItem<StyledBpmnLabel,?> layoutText(StyledBpmnLabel styledLabel, WorkflowBpmnTextLayoutSettings textSettings)
Lays out the text of a styled BPMN label. Wraps the text into multiple lines, according to the given text layout settings, and returns an alignment item with the styled label as itsvalue
.- Parameters:
styledLabel
- The label with the text to wrap.textSettings
- The settings for wrapping the text.- Returns:
- The wrapped text.
-
layoutTextAnnotation
IWorkflowBpmnTwoChildAlignmentItem<String,IWorkflowBpmnAlignmentItem<de.xima.bpmn_model.api.element.bpmn.artifacts.TextAnnotation,?>,IWorkflowBpmnAlignmentItem<StyledBpmnLabel,?>> layoutTextAnnotation(String text, WorkflowBpmnTextLayoutSettings settings)
Computes the layout for a BPMNTextAnnotation
with the given text and layout settings.- Returns:
- A text annotation item with the text and layout settings applied.
-
layoutTextAnnotation
IWorkflowBpmnTwoChildAlignmentItem<String,IWorkflowBpmnAlignmentItem<de.xima.bpmn_model.api.element.bpmn.artifacts.TextAnnotation,?>,IWorkflowBpmnAlignmentItem<StyledBpmnLabel,?>> layoutTextAnnotation(de.xima.bpmn_model.api.element.bpmn.artifacts.TextAnnotation annotation, StyledBpmnLabel styledLabel, WorkflowBpmnTextLayoutSettings settings)
Computes the layout for a BPMNTextAnnotation
with the text content of aStyledBpmnLabel
, using the given text layout settings.- Returns:
- A text annotation item with the text and layout settings applied.
-
pad
IWorkflowBpmnLayoutPadBuilder pad()
Adds padding to an alignment item.- Returns:
- A builder for configuring the amount of padding.
-
-