Skip to content

Commit c28f64b

Browse files
authored
feat: allow to style BPMN Elements (#247)
- New functions: `create_element_style`, `create_edge_style`, `create_shape_style`, `create_gradient_fill' - Modified the `create_stroke`, `create_font` and `create_fill` functions to accept additional style properties. - Updated the `build_bpmnContent` function to accept a `bpmnElementStyles` parameter. - Updated the `display` function to accept a `bpmnElementStyles` parameter. - Added an example of how to use `bpmnElementStyles` to define styles for BPMN elements has been added to the function documentation.
1 parent bd9b823 commit c28f64b

13 files changed

Lines changed: 1360 additions & 137 deletions

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(bpmnVisualizationROutput)
4+
export(create_edge_style)
5+
export(create_gradient_fill)
46
export(create_overlay)
57
export(create_overlay_style)
8+
export(create_shape_style)
69
export(display)
710
export(overlay_edge_position)
811
export(overlay_shape_position)

R/bpmnVisualizationR.R

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#' Use the [`create_overlay`] function to create an overlay object with content and a relative position.
2323
#' @param enableDefaultOverlayStyle If no style is set on an overlay, and this parameter is set to `TRUE`, the default style will be applied to the overlay.
2424
#' By default, `enableDefaultOverlayStyle` is set to `TRUE`.
25+
#' @param bpmnElementStyles a list of existing elements with their style to apply.
26+
#' Use the [`create_shape_style`] or [`create_edge_style`] functions to create the style of 'BPMN' elements.
2527
#' @param width A fixed width for the widget (in CSS units).
2628
#' The default value is `NULL`, which results in intelligent automatic sizing based on the widget's container.
2729
#' @param height A fixed height for the widget (in CSS units).
@@ -98,7 +100,50 @@
98100
#' height='auto'
99101
#' )
100102
#'
101-
#' @seealso [`create_overlay`] to create an overlay
103+
#' # Example 5: Display the BPMN diagram featuring styling for BPMN elements
104+
#' bpmnElementStyles <- list(
105+
#' bpmnVisualizationR::create_shape_style(
106+
#' elementIds = list("call_activity_1_1"),
107+
#' stroke_color = 'RoyalBlue',
108+
#' font_color = 'DarkOrange',
109+
#' font_family = 'Arial',
110+
#' font_size = 12,
111+
#' font_bold = TRUE,
112+
#' font_italic = TRUE,
113+
#' font_strike_through = TRUE,
114+
#' font_underline = TRUE,
115+
#' opacity = 75,
116+
#' fill_color = 'Yellow',
117+
#' fill_opacity = 50
118+
#' ),
119+
#' bpmnVisualizationR::create_edge_style(
120+
#' elementIds = list("sequence_flow_1_4"),
121+
#' stroke_color = 'DeepPink',
122+
#' stroke_width = 3,
123+
#' stroke_opacity = 70,
124+
#' font_color = 'ForestGreen',
125+
#' font_family = 'Courier New',
126+
#' font_size = 14,
127+
#' font_bold = TRUE,
128+
#' font_italic = TRUE,
129+
#' font_strike_through = FALSE,
130+
#' font_underline = FALSE,
131+
#' font_opacity = 80,
132+
#' opacity = 80
133+
#' )
134+
#' )
135+
#'
136+
#' bpmnVisualizationR::display(
137+
#' bpmn_file,
138+
#' bpmnElementStyles = bpmnElementStyles,
139+
#' width='auto',
140+
#' height='auto'
141+
#' )
142+
#'
143+
#' @seealso
144+
#' * [`create_overlay`] to create an overlay
145+
#' * [`create_shape_style`] to create the structure style for the shape
146+
#' * [`create_edge_style`] to create the structure style for the edge
102147
#'
103148
#' @import htmlwidgets
104149
#' @import xml2
@@ -108,14 +153,16 @@ display <- function(
108153
bpmnXML,
109154
overlays = NULL,
110155
enableDefaultOverlayStyle = TRUE,
156+
bpmnElementStyles = NULL,
111157
width = NULL,
112158
height = NULL,
113159
elementId = NULL
114160
) {
115161
x <- build_bpmnContent(
116162
bpmnXML,
117163
overlays = overlays,
118-
enableDefaultOverlayStyle = enableDefaultOverlayStyle
164+
enableDefaultOverlayStyle = enableDefaultOverlayStyle,
165+
bpmnElementStyles = bpmnElementStyles
119166
)
120167
# create widget
121168
htmlwidgets::createWidget(

0 commit comments

Comments
 (0)